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=-8.5 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 CAFA5CA9EAF for ; Mon, 21 Oct 2019 12:20:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8D251205C9 for ; Mon, 21 Oct 2019 12:20:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D251205C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 375C26B0005; Mon, 21 Oct 2019 08:20:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 325666B0006; Mon, 21 Oct 2019 08:20:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23BCE6B0007; Mon, 21 Oct 2019 08:20:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0031.hostedemail.com [216.40.44.31]) by kanga.kvack.org (Postfix) with ESMTP id F0CD06B0005 for ; Mon, 21 Oct 2019 08:20:04 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 9BDD5180AD81F for ; Mon, 21 Oct 2019 12:20:04 +0000 (UTC) X-FDA: 76067698728.28.pin75_3ad582fe31512 X-HE-Tag: pin75_3ad582fe31512 X-Filterd-Recvd-Size: 3519 Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Mon, 21 Oct 2019 12:20:04 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id D3B73B35C; Mon, 21 Oct 2019 12:20:02 +0000 (UTC) Date: Mon, 21 Oct 2019 14:20:02 +0200 From: Michal Hocko To: Naoya Horiguchi Cc: Oscar Salvador , "mike.kravetz@oracle.com" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Subject: Re: [RFC PATCH v2 02/16] mm,madvise: call soft_offline_page() without MF_COUNT_INCREASED Message-ID: <20191021122002.GM9379@dhcp22.suse.cz> References: <20191017142123.24245-1-osalvador@suse.de> <20191017142123.24245-3-osalvador@suse.de> <20191018115227.GL5017@dhcp22.suse.cz> <20191021070254.GB8782@hori.linux.bs1.fc.nec.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191021070254.GB8782@hori.linux.bs1.fc.nec.co.jp> User-Agent: Mutt/1.10.1 (2018-07-13) 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 Mon 21-10-19 07:02:55, Naoya Horiguchi wrote: > On Fri, Oct 18, 2019 at 01:52:27PM +0200, Michal Hocko wrote: > > On Thu 17-10-19 16:21:09, Oscar Salvador wrote: > > > From: Naoya Horiguchi > > > > > > The call to get_user_pages_fast is only to get the pointer to a struct > > > page of a given address, pinning it is memory-poisoning handler's job, > > > so drop the refcount grabbed by get_user_pages_fast > > > > > > Signed-off-by: Naoya Horiguchi > > > Signed-off-by: Oscar Salvador > > > --- > > > mm/madvise.c | 24 ++++++++++++------------ > > > 1 file changed, 12 insertions(+), 12 deletions(-) > > > > > > diff --git a/mm/madvise.c b/mm/madvise.c > > > index 2be9f3fdb05e..89ed9a22ff4f 100644 > > > --- a/mm/madvise.c > > > +++ b/mm/madvise.c > > > @@ -878,16 +878,24 @@ static int madvise_inject_error(int behavior, > > > */ > > > order = compound_order(compound_head(page)); > > > > > > - if (PageHWPoison(page)) { > > > - put_page(page); > > > + /* > > > + * The get_user_pages_fast() is just to get the pfn of the > > > + * given address, and the refcount has nothing to do with > > > + * what we try to test, so it should be released immediately. > > > + * This is racy but it's intended because the real hardware > > > + * errors could happen at any moment and memory error handlers > > > + * must properly handle the race. > > > + */ > > > + put_page(page); > > > + > > > + if (PageHWPoison(page)) > > > continue; > > > - } > > > > > > if (behavior == MADV_SOFT_OFFLINE) { > > > pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n", > > > pfn, start); > > > > > > - ret = soft_offline_page(page, MF_COUNT_INCREASED); > > > + ret = soft_offline_page(page, 0); > > > > What does prevent this struct page to go away completely? > > Nothing does it. Memory error handler tries to pin by itself and > then determines what state the page is in now. OK, but the page is not pinned by this context so it can go away at any time, right? Or do I miss your point? Who would be the Error handler context in this case? -- Michal Hocko SUSE Labs