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: 10489659 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 BD70E60532 for ; Tue, 26 Jun 2018 17:04:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9D542864E for ; Tue, 26 Jun 2018 17:04:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D92C285AF; Tue, 26 Jun 2018 17:04:05 +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 6A3B8288DA for ; Tue, 26 Jun 2018 17:03:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E24766B028F; Tue, 26 Jun 2018 13:03:10 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DFCA06B0290; Tue, 26 Jun 2018 13:03:10 -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 D13166B0291; Tue, 26 Jun 2018 13:03:10 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot0-f197.google.com (mail-ot0-f197.google.com [74.125.82.197]) by kanga.kvack.org (Postfix) with ESMTP id A2B236B028F for ; Tue, 26 Jun 2018 13:03:10 -0400 (EDT) Received: by mail-ot0-f197.google.com with SMTP id h38-v6so12409471otb.4 for ; Tue, 26 Jun 2018 10:03:10 -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; bh=2mgiRVa8jhCDbzlECBdkSJM/Tifyaig9Ocone3zuhc0=; b=BcdHIW3uoquurl8cn2RRaUD+Iw80ix0KYWA661fzhd11tQFyzVmv68P+11Lo0ZwMcA IHhW+1YEhk7eDCwVFq+4CgvZsEg98SqX2d06JICpu/tyN+OHQm+FGIEk2K9PwWAz5lQL 4ROJSbeL2k67Apm/rBxx5sdILssjUak4G5iMKACKSh+7V3Kj7nfSqG2Gi1gdWlfVXpoM ktkiMifvF6/HYaYFJ9k8IUgGYuGccKauFqJiUMPNqCiekNQQPK8gxmoEs/XXwk3e6zwH zcuIEVhnW9gd0f0FMiYTho/YB/tDTmG8Zbikb/zjMK113+he5NmpPvdcWwrqorVhCqv4 OqLQ== 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: APt69E1zcr6XZPKW1z3x+28mSSQdqcAeLkl1HAIavCucdijbv3gUL+DK 9QleD5+R8ihFiEt0Fa68gmDFKSvt2KwOaJLLWZ5+S93OsOqpIKT8Nf/5SyKT5JTPCJcS1vbnZp1 NjW142Ykxqve0NS9m2xCunnMsO9bpc1EvVRB90M+SPoPT3aWeMQFYQXePoVTL88bqlw== X-Received: by 2002:a9d:5d18:: with SMTP id b24-v6mr1378812oti.227.1530032590454; Tue, 26 Jun 2018 10:03:10 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcohRTTu7fJhnsvmRkeTjeC/KAGatNwVbDJg8h05PcoTA4ZeF25YyFvfoLxAIlIQVEfYQET X-Received: by 2002:a9d:5d18:: with SMTP id b24-v6mr1378770oti.227.1530032589670; Tue, 26 Jun 2018 10:03:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530032589; cv=none; d=google.com; s=arc-20160816; b=pyVnzKVOPZW6rAbYbZZefR5SQOGVKWbGo/SR5ypt5ofxsJjQD7zS0nvC6xtHhXLim/ t2fKQWFXQCt4emWABtGxS3Tbe8BZP9/fqkf/bmbCv32pCGkmqu7mHljIG1ZWHAXwxubF KXRfH9o6ao0UCq8ridhF/wxhflOyjJUWl+QMMSP/xNqtUESEBcyOqLAnRCtuAs8ms/Hw ZGzzWEyTCkzbTv4srpV7k7pQSXIKK+pL3NqljNFpejpJnoFTIUQTHUBDLDTSbsty0vzf fByhHEIJSk5+UlooG8WO+cw1bzOYb8e3I3nUdbTTBQ4Q9Rn6tP/DDE4JWoQKXoKZbHLw jfjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=2mgiRVa8jhCDbzlECBdkSJM/Tifyaig9Ocone3zuhc0=; b=t2CX1ziBY5SGYMyHUO7SRYa3KsjAQRV/rqwsfA0wTW2j5S3UW8GMCwbiww7ZO6QBq6 DXcqF2W36Tsl6XWMopY2I1W7JF8XSIwyYIutpqE+j4vAihTs/WCNZ6edTZEuSFxm5D6Q fSfXLF6wCKdAkgK8oKNWyzTkAtxm/zEFTt1fYI9H4TZgI2TPjIK+Z90xiBN6CV93rniK wCyx41dsRd2lOVgPPlVJ37VSFPHXtViM83N2RsyWl6A3K6W/gh7Ju85XG3e//QpIp22o 77vWWGz0WxQf3Ux/wZyDKISFgyeCeYLEJX85EWsFvfRuNvSQ8C9+o7tQI5IBVUNORsFC bsUw== 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 (foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id 13-v6si623348ois.101.2018.06.26.10.03.09 for ; Tue, 26 Jun 2018 10:03:09 -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 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 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 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-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 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); }