From patchwork Tue Jun 26 17:01:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10489961 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DB2516023A for ; Tue, 26 Jun 2018 18:06:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE6B827FB0 for ; Tue, 26 Jun 2018 18:06:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C22FC286E1; Tue, 26 Jun 2018 18:06:27 +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,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3DDD127FB0 for ; Tue, 26 Jun 2018 18:06:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=z3auZOqNqSg0NYr2wF0Zj5e1XSrrl7V5L7CsF926MTo=; b=tR69GoPMpTj0tv9XeGsdcKDIwO VhmPfSEKz+tqmxOBW3hy084hjEDAa7/eitE2r3TzVgXubXRVmNOs7pth/gieAL3tac9QH/QDmfBxI Djx0aJruhQPexVWtOpMsON08iqH/AvHm1Kcjwi0XTuFYEYB8aR6G5pMmg/VqMoU+R2lZZafz9hsyw j9yZk+e4LO09Xgg4OW35WGfuC+1lMhZgwgV7j3pZ9mAlHvnCL9lYNGa3vv8XK4oKHOjn6HMZsId5a C9MfyygTZTdgsRIhLdadgnAGtMl3/Zg0APwPhL9/Te5rcGWflA7e2NI6mUjzJQ7hwnnINDRwzwfFO oGqOkaUQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fXsM0-0006S1-Tb; Tue, 26 Jun 2018 18:06:12 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fXsLK-0005zW-Al for linux-arm-kernel@bombadil.infradead.org; Tue, 26 Jun 2018 18:05:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=2mgiRVa8jhCDbzlECBdkSJM/Tifyaig9Ocone3zuhc0=; b=V6a5nyt2dYVwsiyKFpiTDj1uu fSvQXv/5Hn6oDbmLN/xZE4c+kjhHfEFQgFp5Qi2ncgKvEA/eqjdIQcqp1penhwWJYIB5VjbL+V8CM 1iHO4I4Ypgn+GZhiKUEqNL1VNKPPTIiIXl75Z/gOu4ooSeXSwGtkRjbQ4EXlFiRSUXz0L0aL1sdR6 vCdy9eUTd1yQYprn/QN7sv9BU1mn0M1S7BMsW8aBG+99jzIpUtUHohHLTzFDg3/fLUMnfsUyXFXW0 6P8oHkSwkW7rwctDgpRKXJNDZfmLL+6KnYNI9sDIw5kEGQwbxagUMwIf9nmkNdaFh/GpC2m29Kuub UnmC4HbqQ==; Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fXrMz-0003dz-Ue for linux-arm-kernel@lists.infradead.org; Tue, 26 Jun 2018 17:03:11 +0000 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 57E947A9; Tue, 26 Jun 2018 10:03:09 -0700 (PDT) Received: from melchizedek.cambridge.arm.com (melchizedek.cambridge.arm.com [10.1.206.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DF7183F318; Tue, 26 Jun 2018 10:03:05 -0700 (PDT) From: James Morse To: linux-acpi@vger.kernel.org Subject: [PATCH v5 19/20] mm/memory-failure: increase queued recovery work's priority Date: Tue, 26 Jun 2018 18:01:15 +0100 Message-Id: <20180626170116.25825-20-james.morse@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626170116.25825-1-james.morse@arm.com> References: <20180626170116.25825-1-james.morse@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180626_130310_064798_1AE92048 X-CRM114-Status: GOOD ( 15.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jonathan.zhang@cavium.com, Rafael Wysocki , Tony Luck , Punit Agrawal , Xie XiuQi , Marc Zyngier , Catalin Marinas , Tyler Baicar , Will Deacon , Christoffer Dall , Dongjiu Geng , linux-mm@kvack.org, Borislav Petkov , James Morse , Naoya Horiguchi , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Len Brown MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 9d142b9b86dc..f0e69d7ac406 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include "internal.h" @@ -1333,6 +1334,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 = { @@ -1342,11 +1344,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); }