From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B3B5C433E0 for ; Mon, 18 May 2020 12:45:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 50C4620674 for ; Mon, 18 May 2020 12:45:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 50C4620674 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CFA63900003; Mon, 18 May 2020 08:45:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CAB15900002; Mon, 18 May 2020 08:45:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE8F1900003; Mon, 18 May 2020 08:45:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0196.hostedemail.com [216.40.44.196]) by kanga.kvack.org (Postfix) with ESMTP id A7BEC900002 for ; Mon, 18 May 2020 08:45:11 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 693E63ABC for ; Mon, 18 May 2020 12:45:11 +0000 (UTC) X-FDA: 76829810022.14.waves72_8484346a0bb4f X-HE-Tag: waves72_8484346a0bb4f X-Filterd-Recvd-Size: 4149 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Mon, 18 May 2020 12:45:10 +0000 (UTC) Received: from 89-64-86-21.dynamic.chello.pl (89.64.86.21) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.415) id 49b173e4072387ec; Mon, 18 May 2020 14:45:07 +0200 From: "Rafael J. Wysocki" To: James Morse Cc: linux-mm@kvack.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Naoya Horiguchi , Andrew Morton , Len Brown , Tony Luck , Borislav Petkov , Catalin Marinas , Will Deacon , Mark Rutland , Tyler Baicar , Xie XiuQi Subject: Re: [PATCH v2 1/3] mm/memory-failure: Add memory_failure_queue_kick() Date: Mon, 18 May 2020 14:45:05 +0200 Message-ID: <49686237.p6yG9EJavU@kreacher> In-Reply-To: <20200501164543.24423-2-james.morse@arm.com> References: <20200501164543.24423-1-james.morse@arm.com> <20200501164543.24423-2-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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: On Friday, May 1, 2020 6:45:41 PM CEST James Morse wrote: > The GHES code calls memory_failure_queue() from IRQ context to schedule > work on the current CPU so that memory_failure() can sleep. > > For synchronous memory errors the arch code needs to know any signals > that memory_failure() will trigger are pending before it returns to > user-space, possibly when exiting from the IRQ. > > Add a helper to kick the memory failure queue, to ensure the scheduled > work has happened. This has to be called from process context, so may > have been migrated from the original cpu. Pass the cpu the work was > queued on. > > Change memory_failure_work_func() to permit being called on the 'wrong' > cpu. > > Signed-off-by: James Morse > Tested-by: Tyler Baicar > --- > include/linux/mm.h | 1 + > mm/memory-failure.c | 15 ++++++++++++++- > 2 files changed, 15 insertions(+), 1 deletion(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 5a323422d783..c606dbbfa5e1 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -3012,6 +3012,7 @@ enum mf_flags { > }; > extern int memory_failure(unsigned long pfn, int flags); > extern void memory_failure_queue(unsigned long pfn, int flags); > +extern void memory_failure_queue_kick(int cpu); > extern int unpoison_memory(unsigned long pfn); > extern int get_hwpoison_page(struct page *page); > #define put_hwpoison_page(page) put_page(page) > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index a96364be8ab4..c4afb407bf0f 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -1493,7 +1493,7 @@ static void memory_failure_work_func(struct work_struct *work) > unsigned long proc_flags; > int gotten; > > - mf_cpu = this_cpu_ptr(&memory_failure_cpu); > + mf_cpu = container_of(work, struct memory_failure_cpu, work); > for (;;) { > spin_lock_irqsave(&mf_cpu->lock, proc_flags); > gotten = kfifo_get(&mf_cpu->fifo, &entry); > @@ -1507,6 +1507,19 @@ static void memory_failure_work_func(struct work_struct *work) > } > } > > +/* > + * Process memory_failure work queued on the specified CPU. > + * Used to avoid return-to-userspace racing with the memory_failure workqueue. > + */ > +void memory_failure_queue_kick(int cpu) > +{ > + struct memory_failure_cpu *mf_cpu; > + > + mf_cpu = &per_cpu(memory_failure_cpu, cpu); > + cancel_work_sync(&mf_cpu->work); > + memory_failure_work_func(&mf_cpu->work); > +} > + > static int __init memory_failure_init(void) > { > struct memory_failure_cpu *mf_cpu; > I could apply this provided an ACK from the mm people. Thanks!