Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1732659ybg; Sat, 19 Oct 2019 01:18:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBRdpOqdvu5bZDQBux1TSZYXAx0uW0a1eQv2lTt/wYThjVZPaixrrCJUQB8nQ965gGkw1Y X-Received: by 2002:aa7:c44e:: with SMTP id n14mr971343edr.162.1571473116843; Sat, 19 Oct 2019 01:18:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571473116; cv=none; d=google.com; s=arc-20160816; b=rKq4wvHRsw2GnaJeaboqGusV1hlFsLGwSOtcGBfSuLMqOGG40pvtRv1EqM+zmAaFNk A+NVQG/k/kglZE/FCuSCvM00WuVA/SuKJva+XblYVfM5RjrA2CDQyWsAJQev0+no6IJP a3fYR9QLUruHxGm3O7oP3EyjBl7/0L97WOMqCh2bY6daLNCpecNid+4I9hzwHpCR/Ld6 mY6iQB4lF4klLGchWYsLFr3KF7Vg+H4ESi6bujcs87pFruRPXc2jpgPIGjieAyexc3sg Sdr7X6PxFmaXmarGaeushRqIhYblPyn3ooq+fDN4EwatWBNphlEZRheME/3oLEuQW7rf VQNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ak3tm3ZlXcbv6g7yg7SBX+0XyCu88fxKPlCsunGW/50=; b=kuKASvrBS9OkI4nYtgHqTYgqvE7hms3LyX+QnnPmDyQUogSnY4NcGdXpHR4ApvqD5/ ZPxPmRmMu667XlX/1e+4gVD3Uk1eVV1jpIIHYhBiPF0JE08stQQ/yiqxB4A6vuZlmkIk Qx5b9374ozE0Gk7Vmm3AQkFcfcukkvJHIWeMnCAMJ4zWh6riPbdyoLQjUHKbsCMQFm/+ AL+eulGAXmp9ri1awgoGWjN8MTxN0JIOgORY/HKubugzNT4MlpsP/2aEzWvHqYlej8Pv Yc/pxmf0qma/jXVVWGpZSt7xCQNGwEvWBOPTJL4ou77/sUB+RiC5GzyKw3VLoxkBlzlb aYSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v26si791358ejg.55.2019.10.19.01.18.13; Sat, 19 Oct 2019 01:18:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2633640AbfJRLwa (ORCPT + 99 others); Fri, 18 Oct 2019 07:52:30 -0400 Received: from mx2.suse.de ([195.135.220.15]:60108 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729946AbfJRLw3 (ORCPT ); Fri, 18 Oct 2019 07:52:29 -0400 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 13320ACA5; Fri, 18 Oct 2019 11:52:28 +0000 (UTC) Date: Fri, 18 Oct 2019 13:52:27 +0200 From: Michal Hocko To: Oscar Salvador Cc: n-horiguchi@ah.jp.nec.com, 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: <20191018115227.GL5017@dhcp22.suse.cz> References: <20191017142123.24245-1-osalvador@suse.de> <20191017142123.24245-3-osalvador@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191017142123.24245-3-osalvador@suse.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > if (ret) > return ret; > continue; > @@ -895,14 +903,6 @@ static int madvise_inject_error(int behavior, > > pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n", > pfn, start); > - > - /* > - * Drop the page reference taken by get_user_pages_fast(). In > - * the absence of MF_COUNT_INCREASED the memory_failure() > - * routine is responsible for pinning the page to prevent it > - * from being released back to the page allocator. > - */ > - put_page(page); > ret = memory_failure(pfn, 0); > if (ret) > return ret; > -- > 2.12.3 > -- Michal Hocko SUSE Labs