linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>
Cc: Michal Hocko <mhocko@kernel.org>,
	Oscar Salvador <osalvador@suse.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] mm, soft-offline: convert parameter to pfn
Date: Wed, 16 Oct 2019 09:56:19 +0200	[thread overview]
Message-ID: <e931b14b-da27-2720-5344-b5c0b08b38ad@redhat.com> (raw)
In-Reply-To: <20191016070924.GA10178@hori.linux.bs1.fc.nec.co.jp>

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 <n-horiguchi@ah.jp.nec.com>
> 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 <n-horiguchi@ah.jp.nec.com>
> ---
>   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

  reply	other threads:[~2019-10-16  7:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-16  7:09 [PATCH] mm, soft-offline: convert parameter to pfn Naoya Horiguchi
2019-10-16  7:56 ` David Hildenbrand [this message]
2019-10-16  8:27   ` Naoya Horiguchi
2019-10-16  8:34     ` David Hildenbrand
2019-10-16  8:54       ` Naoya Horiguchi
2019-10-16  8:57         ` David Hildenbrand
2019-10-16 23:47           ` Naoya Horiguchi
2019-10-17  7:16             ` David Hildenbrand
2019-10-17  7:50               ` Naoya Horiguchi
2019-10-17  8:02                 ` David Hildenbrand
2019-10-17  8:03                 ` Oscar Salvador
2019-10-17  8:07                   ` Naoya Horiguchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e931b14b-da27-2720-5344-b5c0b08b38ad@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=n-horiguchi@ah.jp.nec.com \
    --cc=osalvador@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).