Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp552698pxu; Fri, 4 Dec 2020 09:31:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxX2mk5f2/Wy6CiJe81GWqkzx4j3MeJF29nYWn8rM2YJp1Gg1TqIfGOMSw1HqRLmL1UsHwf X-Received: by 2002:a17:907:36a:: with SMTP id rs10mr7815524ejb.411.1607103061298; Fri, 04 Dec 2020 09:31:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607103061; cv=none; d=google.com; s=arc-20160816; b=Vofx65ftSu0la4u/fX2aOTHPhBcbGj9xgLQNthKSZrMZVCZFrfzM5KjmDXF8wGnVEY 6ZtCPX3RgGH2IIAQsfZOYjluN+5JwD93RtdUtLv/l9aMgppbKKFZ98qIfam8bzAzlCBj oD41PceWsiwZYQ0TbhPZJR2SdtouYBYRtocSaXPrZOX3qYpUpu17U7uY9Fvl0GfAgIeY ubckClSN/ZpsvnsY7jw86HUI5lc3IhYntOFMEfjMqNXZWKhnKvDEocWqguEqIXOHZJoT Qf7SiRIBrh7Ta6zyIO7m6lRlh+rQ6b3dsQn2N1xiuGcLgKrqOX+ysJr1Bv9Qn4Aonsrl 61Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=M3/GFBSznyt5QOUCy0Qu0xaEyQlkMTYuymVZ880O5I8=; b=pWONStBRNc0bximNJ37WX8oBLq4pNC24U/sf2mDKLtbJM0h9S/d0G2K6ERpmwGQ4sI HD0WEfzTrFj378CG3Z4VM4qrU2KaV43c9id7FrdSZ/TGh0yFXD11x9u9xltDR5QrDAAv XMpsPD+d5upQ5v/9F8nhnkOiDkPQvALABStSYlSJ+Id4vw14V01j0t3r96X7GtBsQq6M q/xOC6TU43F7Tjr+6juMXRYZ9CGXKr/0gyKz8bOOtalvBvdlXSOOFfK9LQJ7RhDuQhco 7lLJrRHA4o++WNiWAnvrukcJXYB/w47L4OGQARX+Ai496GOBpI/47V1qBViFNkh6/4ZK n4Gg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si1682892ejx.39.2020.12.04.09.30.36; Fri, 04 Dec 2020 09:31:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731219AbgLDR0O (ORCPT + 99 others); Fri, 4 Dec 2020 12:26:14 -0500 Received: from mx2.suse.de ([195.135.220.15]:60776 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731043AbgLDR0N (ORCPT ); Fri, 4 Dec 2020 12:26:13 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 316DFAD20; Fri, 4 Dec 2020 17:25:32 +0000 (UTC) Subject: Re: [PATCH 3/7] mm,madvise: call soft_offline_page() without MF_COUNT_INCREASED To: Oscar Salvador Cc: akpm@linux-foundation.org, n-horiguchi@ah.jp.nec.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Naoya Horiguchi , Dan Williams References: <20201119105716.5962-1-osalvador@suse.de> <20201119105716.5962-4-osalvador@suse.de> <2aa4bf71-443b-9b9b-b761-12761263dfec@suse.cz> <20201201113511.GA22242@linux> From: Vlastimil Babka Message-ID: <840d4669-ae3f-b7c4-6132-e20d1bf9e952@suse.cz> Date: Fri, 4 Dec 2020 18:25:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20201201113511.GA22242@linux> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/1/20 12:35 PM, Oscar Salvador wrote: > On Wed, Nov 25, 2020 at 07:20:33PM +0100, Vlastimil Babka wrote: >> On 11/19/20 11:57 AM, 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(). >> > >> > Note that the target page is still pinned after this put_page() because >> > the current process should have refcount from mapping. >> >> Well, but can't it go away due to reclaim, migration or whatever? > > Yes, it can. > >> > @@ -900,20 +900,23 @@ static int madvise_inject_error(int behavior, >> > */ >> > size = page_size(compound_head(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. >> >> Sure they have to. We might just be unexpectedly messing with other process' >> memory. Or does anything else prevent that? > > No, nothing does, and I have to confess that I managed to confuse myself here. > If we release such page and that page ends up in buddy, nothing prevents someone > else to get that page, and then we would be messing with other process memory. > > I guess the right thing to do is just to make sure we got that page and that > that page remains pinned as long as the memory failure handling goes. OK, so that means we don't introduce this race for MADV_SOFT_OFFLINE, but it's already (and still) there for MADV_HWPOISON since Dan's 23e7b5c2e271 ("mm, madvise_inject_error: Let memory_failure() optionally take a page reference") no? > I will remove those patches from the patchset and re-submit with only the > refactoring and pcp-disabling. > > Thanks Vlastimil >