Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4382373pxu; Tue, 1 Dec 2020 03:40:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJy1NAGoLOkHBjp51nwxa8bAbz6Sp2ifXRu5GGYyTHTUiFTEGviDaRMN2l+Wl3ESJyuURJMV X-Received: by 2002:a05:6402:22ab:: with SMTP id cx11mr2563222edb.98.1606822848464; Tue, 01 Dec 2020 03:40:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606822848; cv=none; d=google.com; s=arc-20160816; b=BsrueqKGd1nMOV+hrKWUst2barsoQu6j+bTLAmbTsFXgCaMFStS2xn7fvA1ZNrbCHS 8d78ouMvWFy/GLscrVYGI4GsQcRuR70LMRWzrfRGeCBH0NVB4I/mNvLWX6/BJpsEHVVC aTM2uCm6JbATvjH8ZYBFbnENInJCyOz7aC2N9+q22WSgcNvuhofipCc2YszMjeeVD0Hv Yp4L+Z4TpcO3ffXD9mYh5HiTQhGJufzkNCX7LY4jW8x5KkD+AR8k/X85MzS+FqeLPoiO jhxuaW36Vu9NFh/QIi8ut2YgHAZRmPXyqXcWObFYEm/hrrP3O82iJ+Gpc4MWly/Csnct R6sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=H9NPEHbRsAjEB02942eugWvUtppWHg/GwnyTdoEPk3Q=; b=V1m1/uEbam9JU/EhNzBHN2BLwfbMOdD2Fy42BNeAvyWGoJ72KSKsI3DfOMgco+b43Y /pX69wHMle/z7XD4TqiziAVHBH+tgo3k+wHA+V6mVRi45ADrhPS9qZXjKXqWIvLyO6cF 4u8ZAGX1C4egSLDMMFhoDOefFex43tj/N1LBaQZ9Q8R3qjLEzFemFCKntOgN+a5AjXzG 99Lb0HNtbhZZ99mWLY3w6KxCO2a+YED4S1ys2yGBFR8u27tw7Xcr3GxisbyEjdjwJaZq 8YYmJaZsdPCso3qsYK6OEJvTeXPP7MrdRwKH0vuDHHp6JCQp/TF45lAv229pm9uBVbgj PkRw== 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 fy24si675943ejb.348.2020.12.01.03.40.24; Tue, 01 Dec 2020 03:40:48 -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 S1730659AbgLALgB (ORCPT + 99 others); Tue, 1 Dec 2020 06:36:01 -0500 Received: from mx2.suse.de ([195.135.220.15]:60986 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730635AbgLALgA (ORCPT ); Tue, 1 Dec 2020 06:36:00 -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 3D819ADCF; Tue, 1 Dec 2020 11:35:19 +0000 (UTC) Date: Tue, 1 Dec 2020 12:35:16 +0100 From: Oscar Salvador To: Vlastimil Babka Cc: akpm@linux-foundation.org, n-horiguchi@ah.jp.nec.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Naoya Horiguchi Subject: Re: [PATCH 3/7] mm,madvise: call soft_offline_page() without MF_COUNT_INCREASED Message-ID: <20201201113511.GA22242@linux> References: <20201119105716.5962-1-osalvador@suse.de> <20201119105716.5962-4-osalvador@suse.de> <2aa4bf71-443b-9b9b-b761-12761263dfec@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2aa4bf71-443b-9b9b-b761-12761263dfec@suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. I will remove those patches from the patchset and re-submit with only the refactoring and pcp-disabling. Thanks Vlastimil -- Oscar Salvador SUSE L3