From patchwork Fri Sep 21 22:17:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10611073 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C06C614BD for ; Fri, 21 Sep 2018 22:19:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2F6B2DDC8 for ; Fri, 21 Sep 2018 22:19:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A73E12DDD4; Fri, 21 Sep 2018 22:19:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 469622DDC8 for ; Fri, 21 Sep 2018 22:19:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B22748E0022; Fri, 21 Sep 2018 18:19:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AD2CE8E0001; Fri, 21 Sep 2018 18:19:06 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E89E8E0022; Fri, 21 Sep 2018 18:19:06 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) by kanga.kvack.org (Postfix) with ESMTP id 73E728E0001 for ; Fri, 21 Sep 2018 18:19:06 -0400 (EDT) Received: by mail-ot1-f71.google.com with SMTP id h9-v6so13793650otj.10 for ; Fri, 21 Sep 2018 15:19:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=MRWCM2674PLZLao8XX6YSk3/LTKlQlpF1gW9UIEfsUY=; b=bxdet9RgOSwPgNAJUrO/Z5PL36lSrD6oqHsVoCcGDI5xyamzEiroqed02787aJIokk 0pBl3j9FH1NPYtbn/FD01GYkwAa4gDzNunUCQNs/+iMQzccJPIErB7n3DIDQRQBR9zbf m7OR/aI1KdH5iKMFfXnxzuvrYhoX5nIdv0uxNcw4pXhEKl1PHjkUNm3RfPDN6tYcgl09 lHYf2ofl+kVaRM5iCj26boviDKJXOIB5FtJqpoUKMQ2Z59rOsJi2OOYvxeq5G/y3c7KB mtspRP8Z7Vk2hbWjaajUjGXmqpWGWeR2vWCMseDUurV1IG4m/TAXav5XO49oYsc0maYS sbLw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com X-Gm-Message-State: ABuFfog+eI6y1ylCl+/PqzR7ifHlvGy4EtnVJhjuGwJYEcr2LMtz0Ipm i2l4iDnFyFZ3YMSMC/eAuIzmd6ouiYitCAzOKBNQ7sIHkOoca0WudlDdVkyjrttTH1s627rvCfe ZycDvvUJdOapHfe8IqHVYRaKt8eEu4yBhoNHuQiVVyq5OuwT0ou23bYSJhuKsSkM0mQ== X-Received: by 2002:a9d:6082:: with SMTP id m2-v6mr1063965otj.177.1537568346242; Fri, 21 Sep 2018 15:19:06 -0700 (PDT) X-Google-Smtp-Source: ACcGV606L+XG2E/bGKGv1Qdkf5uWLHls1V62Z031u/Zg3z91X5c2CWE99NaoVQAjas/RWLkjMOjk X-Received: by 2002:a9d:6082:: with SMTP id m2-v6mr1063932otj.177.1537568345004; Fri, 21 Sep 2018 15:19:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537568344; cv=none; d=google.com; s=arc-20160816; b=IRSo9Tdg1QC0013qPKp1pom57CwrkcU+ty4JG44aIe/ttuzP/s7NSGjPd7wa+0m2ip cljr9uymKBEGckIMmk+k4jVGojbtCCMe31l9Eo2TmePY6F6YFNlqwX1XfFVe6LTR0cDO kxlVZ+G12H6Q4DBdxRrlGaGCfU/NXekGlDyLj6pLoFKatO2My/GhZnOeQgJmvRlo1Kn/ kPk4Iu58XJFtqVOyprksaJ0zC7ecQ0f1L1LpSYAxw6adWqA2+TiLAdxNbdpgve+WsyU4 9QCpfsWtPZNNhjJ/I8q+pG/Ec9xbFO9FREnqK6ToUUuN4l7U4wsNpH66wtk/yJb39yBA hTDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=MRWCM2674PLZLao8XX6YSk3/LTKlQlpF1gW9UIEfsUY=; b=QM+uBFhJO0hqMWeCXjKpkQUSbc0YRzWioP19jtUmd6hojBklXWExN5wR9wACz3mhEW 0DO8iguWhbQ5kABHcImbPiqjVmHcUHKjIa/qN6EWcwRXR5HRxKgvrCM19Z9t+njAmtrH LJdVnDtQNkWgMxTUOOmpPyMssJPlksrHeQiABQd9Kgp93YZixMtZnkkyNw9bTudBaw9N 4WGuze0IGsdttXLsVw66eXMggOX6HqVLCu4qiGKdfvmA8t1824soBVzuK1qt2QCA6b5K PHshKUMe3/isxTEmML+HXjqYb5B+FC+2tmPaguQw5aB85vXhZGtYWJLmEllZGfsdlqp6 PM3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id x64-v6si10328466otb.272.2018.09.21.15.19.04 for ; Fri, 21 Sep 2018 15:19:04 -0700 (PDT) Received-SPF: pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8754318A; Fri, 21 Sep 2018 15:19:04 -0700 (PDT) Received: from melchizedek.Emea.Arm.com (melchizedek.emea.arm.com [10.4.12.81]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 727973F557; Fri, 21 Sep 2018 15:19:01 -0700 (PDT) From: James Morse To: linux-acpi@vger.kernel.org Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, Borislav Petkov , Marc Zyngier , Christoffer Dall , Will Deacon , Catalin Marinas , Naoya Horiguchi , Rafael Wysocki , Len Brown , Tony Luck , Tyler Baicar , Dongjiu Geng , Xie XiuQi , Punit Agrawal , jonathan.zhang@cavium.com, James Morse Subject: [PATCH v6 17/18] mm/memory-failure: increase queued recovery work's priority Date: Fri, 21 Sep 2018 23:17:04 +0100 Message-Id: <20180921221705.6478-18-james.morse@arm.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180921221705.6478-1-james.morse@arm.com> References: <20180921221705.6478-1-james.morse@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP arm64 can take an NMI-like error notification when user-space steps in some corrupt memory. APEI's GHES code will call memory_failure_queue() to schedule the recovery work. We then return to user-space, possibly taking the fault again. Currently the arch code unconditionally signals user-space from this path, so we don't get stuck in this loop, but the affected process never benefits from memory_failure()s recovery work. To fix this we need to know the recovery work will run before we get back to user-space. Increase the priority of the recovery work by scheduling it on the system_highpri_wq, then try to bump the current task off this CPU so that the recovery work starts immediately. Reported-by: Xie XiuQi Signed-off-by: James Morse Reviewed-by: Punit Agrawal Tested-by: Tyler Baicar Tested-by: gengdongjiu CC: Xie XiuQi CC: gengdongjiu --- mm/memory-failure.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 0cd3de3550f0..4e7b115cea5a 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -1454,6 +1455,7 @@ static DEFINE_PER_CPU(struct memory_failure_cpu, memory_failure_cpu); */ void memory_failure_queue(unsigned long pfn, int flags) { + int cpu = smp_processor_id(); struct memory_failure_cpu *mf_cpu; unsigned long proc_flags; struct memory_failure_entry entry = { @@ -1463,11 +1465,14 @@ void memory_failure_queue(unsigned long pfn, int flags) mf_cpu = &get_cpu_var(memory_failure_cpu); spin_lock_irqsave(&mf_cpu->lock, proc_flags); - if (kfifo_put(&mf_cpu->fifo, entry)) - schedule_work_on(smp_processor_id(), &mf_cpu->work); - else + if (kfifo_put(&mf_cpu->fifo, entry)) { + queue_work_on(cpu, system_highpri_wq, &mf_cpu->work); + set_tsk_need_resched(current); + preempt_set_need_resched(); + } else { pr_err("Memory failure: buffer overflow when queuing memory failure at %#lx\n", pfn); + } spin_unlock_irqrestore(&mf_cpu->lock, proc_flags); put_cpu_var(memory_failure_cpu); }