Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7222712ybp; Wed, 16 Oct 2019 05:44:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjWVQKNQm8nYB3pvmbTurF6xWaBLAB+bt2ymhwxrNRXCKC/vRK2TB59SL6C4Wr9d5uE/0Q X-Received: by 2002:a05:6402:1511:: with SMTP id f17mr18585334edw.232.1571229850437; Wed, 16 Oct 2019 05:44:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571229850; cv=none; d=google.com; s=arc-20160816; b=m+IAo+XobZEqaKbUCHv/NuRHbv+rMvONt83TDuBO/lncxf1D21H12XnXjbcId/ku2d 7fZf6s/yyN4Rexc8pr0KNzK2UZJbin7qslRas3W43x2eiOi39h6qhLeV08rVlr4Ea3Bu gsMU3ixL0Im7dPDdBdYudiN/JmxCx3DRfLHJt6DFUMfois2asCVrtMJKn2zQzW/2e8Hf 24DnLxIB8McLi7hr6U/O0hjf2sQSBCZZEc1P4qWIOHyx/HYwE7mhDJ6MeprB17M8WStf JtA/IBjtlSqUx6UqBEhRSLXlB88t0z0rJl7s47KTAS3pM80nlW/SclqTDqfvgz0nINVC WLtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=pbiJ4J0b/mk4v3ApQI5yEI8/IqOJLo0E6s++plXA4gc=; b=PzgXaqUHOrxQLdRQnCBB8ELVQh8U1NCM5VC742e88e7VayLodR2A8PB1/5PEhTwN/n IZ1sfqap53ojVa7qhXvuH6+rYTKhWYeFYzjvym911Isn21Gu2lzAoEy+D+vY4C6rAgpX 4dH3PhLkWdTWV1RF6gThErJgaFDriAJUYor5/PmQVTwInSE1rN9b2vMlX+xB9HcdQpsC 6DvBJu+MuQ8BkZsdeIwaAMH5soKKpjBYwP2Y5OymHvFxYLwW2zFheSi9sXw7BVKubmEU MAHkTQ2d+CkUA31HVxemsCrkEEZsYS8OkPdvcNmrwo4hjGD7J+s2O7gcxSwRlvlbvXpf fH5A== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fj16si16530921ejb.385.2019.10.16.05.43.47; Wed, 16 Oct 2019 05:44:10 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391352AbfJPH4X (ORCPT + 99 others); Wed, 16 Oct 2019 03:56:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55810 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726277AbfJPH4W (ORCPT ); Wed, 16 Oct 2019 03:56:22 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 02240309DEF8; Wed, 16 Oct 2019 07:56:22 +0000 (UTC) Received: from [10.36.117.237] (ovpn-117-237.ams2.redhat.com [10.36.117.237]) by smtp.corp.redhat.com (Postfix) with ESMTP id 719A760A97; Wed, 16 Oct 2019 07:56:20 +0000 (UTC) Subject: Re: [PATCH] mm, soft-offline: convert parameter to pfn To: Naoya Horiguchi , "linux-mm@kvack.org" Cc: Michal Hocko , Oscar Salvador , "linux-kernel@vger.kernel.org" , Andrew Morton References: <20191016070924.GA10178@hori.linux.bs1.fc.nec.co.jp> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: Date: Wed, 16 Oct 2019 09:56:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 In-Reply-To: <20191016070924.GA10178@hori.linux.bs1.fc.nec.co.jp> Content-Type: text/plain; charset=iso-2022-jp; format=flowed; delsp=yes Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 16 Oct 2019 07:56:22 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16.10.19 09:09, Naoya Horiguchi wrote: > Hi, > > I wrote a simple cleanup for parameter of soft_offline_page(), > based on thread https://lkml.org/lkml/2019/10/11/57. > > I know that we need more cleanup on hwpoison-inject, but I think > that will be mentioned in re-write patchset Oscar is preparing now. > So let me shared only this part as a separate one now. > > Thanks, > Naoya Horiguchi > --- > From: Naoya Horiguchi > Date: Wed, 16 Oct 2019 15:49:00 +0900 > Subject: [PATCH] mm, soft-offline: convert parameter to pfn > > Currently soft_offline_page() receives struct page, and its sibling > memory_failure() receives pfn. This discrepancy looks weird and makes > precheck on pfn validity tricky. So let's align them. > > Signed-off-by: Naoya Horiguchi > --- > drivers/base/memory.c | 2 +- > include/linux/mm.h | 2 +- > mm/madvise.c | 2 +- > mm/memory-failure.c | 8 ++++---- > 4 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/base/memory.c b/drivers/base/memory.c > index e5485c22ef77..04e469c82852 100644 > --- a/drivers/base/memory.c > +++ b/drivers/base/memory.c > @@ -540,7 +540,7 @@ static ssize_t soft_offline_page_store(struct device *dev, > pfn >>= PAGE_SHIFT; > if (!pfn_valid(pfn)) > return -ENXIO; > - ret = soft_offline_page(pfn_to_page(pfn)); > + ret = soft_offline_page(pfn); > return ret == 0 ? count : ret; > } > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 3eba26324ff1..0a452020edf5 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -2783,7 +2783,7 @@ extern int sysctl_memory_failure_early_kill; > extern int sysctl_memory_failure_recovery; > extern void shake_page(struct page *p, int access); > extern atomic_long_t num_poisoned_pages __read_mostly; > -extern int soft_offline_page(struct page *page); > +extern int soft_offline_page(unsigned long pfn); > > > /* > diff --git a/mm/madvise.c b/mm/madvise.c > index fd221b610b52..df198d1e5e2e 100644 > --- a/mm/madvise.c > +++ b/mm/madvise.c > @@ -893,7 +893,7 @@ static int madvise_inject_error(int behavior, > if (behavior == MADV_SOFT_OFFLINE) { > pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n", > pfn, start); > - ret = soft_offline_page(page); > + ret = soft_offline_page(pfn); > if (ret) > return ret; > } else { > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 4f16e0a7e7cc..eb4fd5e8d5e1 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -1514,7 +1514,7 @@ static void memory_failure_work_func(struct work_struct *work) > if (!gotten) > break; > if (entry.flags & MF_SOFT_OFFLINE) > - soft_offline_page(pfn_to_page(entry.pfn)); > + soft_offline_page(entry.pfn); > else > memory_failure(entry.pfn, entry.flags); > } > @@ -1822,7 +1822,7 @@ static int soft_offline_free_page(struct page *page) > > /** > * soft_offline_page - Soft offline a page. > - * @page: page to offline > + * @pfn: pfn to soft-offline > * > * Returns 0 on success, otherwise negated errno. > * > @@ -1841,10 +1841,10 @@ static int soft_offline_free_page(struct page *page) > * This is not a 100% solution for all memory, but tries to be > * ``good enough'' for the majority of memory. > */ > -int soft_offline_page(struct page *page) > +int soft_offline_page(unsigned long pfn) > { > int ret; > - unsigned long pfn = page_to_pfn(page); > + struct page *page = pfn_to_page(pfn); > > if (is_zone_device_page(page)) { > pr_debug_ratelimited("soft_offline: %#lx page is device page\n", > I think you should rebase that patch on linux-next (where the pfn_to_online_page() check is in place). I assume you'll want to move the pfn_to_online_page() check into soft_offline_page() then as well? -- Thanks, David / dhildenb