Linux-mm Archive on lore.kernel.org
 help / color / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Oscar Salvador <osalvador@suse.de>, n-horiguchi@ah.jp.nec.com
Cc: mhocko@kernel.org, mike.kravetz@oracle.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v2 16/16] mm, soft-offline: convert parameter to pfn
Date: Fri, 18 Oct 2019 10:15:47 +0200
Message-ID: <62eb5232-1e4d-22cf-0026-3e37ac06f3a3@redhat.com> (raw)
In-Reply-To: <20191017142123.24245-17-osalvador@suse.de>

On 17.10.19 16:21, Oscar Salvador wrote:
> From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> 
> 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>
> Signed-off-by: Oscar Salvador <osalvador@suse.de>
> ---
>   drivers/base/memory.c |  7 +------
>   include/linux/mm.h    |  2 +-
>   mm/madvise.c          |  2 +-
>   mm/memory-failure.c   | 17 +++++++++--------
>   4 files changed, 12 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/base/memory.c b/drivers/base/memory.c
> index b3cae2eb1c4f..b510b4d176c9 100644
> --- a/drivers/base/memory.c
> +++ b/drivers/base/memory.c
> @@ -538,12 +538,7 @@ static ssize_t soft_offline_page_store(struct device *dev,
>   	if (kstrtoull(buf, 0, &pfn) < 0)
>   		return -EINVAL;
>   	pfn >>= PAGE_SHIFT;
> -	if (!pfn_valid(pfn))
> -		return -ENXIO;
> -	/* Only online pages can be soft-offlined (esp., not ZONE_DEVICE). */
> -	if (!pfn_to_online_page(pfn))
> -		return -EIO;
> -	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 0f80a1ce4e86..40722854d357 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -2791,7 +2791,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 9ca48345ce45..f83b7d4c68c1 100644
> --- a/mm/madvise.c
> +++ b/mm/madvise.c
> @@ -890,7 +890,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);
>   		} else {
>   			pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n",
>   				 pfn, start);
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index c038896bedf0..bfecb61fc064 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -1521,7 +1521,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);
>   	}
> @@ -1834,7 +1834,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.
>    *
> @@ -1853,16 +1853,17 @@ 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;
>   
> -	if (is_zone_device_page(page)) {
> -		pr_debug_ratelimited("soft_offline: %#lx page is device page\n",
> -				pfn);
> +	if (!pfn_valid(pfn))
> +		return -ENXIO;
> +	/* Only online pages can be soft-offlined (esp., not ZONE_DEVICE). */
> +	page = pfn_to_online_page(pfn);
> +	if (!page)
>   		return -EIO;
> -	}
>   
>   	if (PageHWPoison(page)) {
>   		pr_info("soft offline: %#lx page already poisoned\n", pfn);
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 

Thanks,

David / dhildenb


  reply index

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17 14:21 [RFC PATCH v2 00/16] Hwpoison rework {hard,soft}-offline Oscar Salvador
2019-10-17 14:21 ` [RFC PATCH v2 01/16] mm,hwpoison: cleanup unused PageHuge() check Oscar Salvador
2019-10-18 11:48   ` Michal Hocko
2019-10-21  7:00     ` Naoya Horiguchi
2019-10-21 12:16       ` Michal Hocko
2019-11-12 12:22       ` Aneesh Kumar K.V
2019-11-13  6:02         ` Naoya Horiguchi
2019-10-17 14:21 ` [RFC PATCH v2 02/16] mm,madvise: call soft_offline_page() without MF_COUNT_INCREASED Oscar Salvador
2019-10-18 11:52   ` Michal Hocko
2019-10-21  7:02     ` Naoya Horiguchi
2019-10-21 12:20       ` Michal Hocko
2019-10-17 14:21 ` [RFC PATCH v2 03/16] mm,madvise: Refactor madvise_inject_error Oscar Salvador
2019-10-21  7:03   ` Naoya Horiguchi
2019-10-17 14:21 ` [RFC PATCH v2 04/16] mm,hwpoison-inject: don't pin for hwpoison_filter Oscar Salvador
2019-10-17 14:21 ` [RFC PATCH v2 05/16] mm,hwpoison: Un-export get_hwpoison_page and make it static Oscar Salvador
2019-10-21  7:03   ` Naoya Horiguchi
2019-10-17 14:21 ` [RFC PATCH v2 06/16] mm,hwpoison: Kill put_hwpoison_page Oscar Salvador
2019-10-21  7:04   ` Naoya Horiguchi
2019-10-17 14:21 ` [RFC PATCH v2 07/16] mm,hwpoison: remove MF_COUNT_INCREASED Oscar Salvador
2019-10-17 14:21 ` [RFC PATCH v2 08/16] mm,hwpoison: remove flag argument from soft offline functions Oscar Salvador
2019-10-17 14:21 ` [RFC PATCH v2 09/16] mm,hwpoison: Unify THP handling for hard and soft offline Oscar Salvador
2019-10-21  7:04   ` Naoya Horiguchi
2019-10-21  9:51     ` [PATCH 17/16] mm,hwpoison: introduce MF_MSG_UNSPLIT_THP Naoya Horiguchi
2019-10-22  8:00       ` Oscar Salvador
2019-10-17 14:21 ` [RFC PATCH v2 10/16] mm,hwpoison: Rework soft offline for free pages Oscar Salvador
2019-10-18 12:06   ` Michal Hocko
2019-10-21 12:58     ` Oscar Salvador
2019-10-21 15:41       ` Michal Hocko
2019-10-22  7:46         ` Oscar Salvador
2019-10-22  8:26           ` Michal Hocko
2019-10-22  8:35             ` Oscar Salvador
2019-10-22  9:22               ` Michal Hocko
2019-10-22  9:58                 ` Oscar Salvador
2019-10-22 10:24                   ` Michal Hocko
2019-10-22 10:33                     ` Oscar Salvador
2019-10-23  2:15                       ` Naoya Horiguchi
2019-10-23  2:01                   ` Naoya Horiguchi
2019-10-21  7:45   ` Naoya Horiguchi
2019-10-22  8:00     ` Oscar Salvador
2019-10-17 14:21 ` [RFC PATCH v2 11/16] mm,hwpoison: Rework soft offline for in-use pages Oscar Salvador
2019-10-18 12:39   ` Michal Hocko
2019-10-21 13:48     ` Oscar Salvador
2019-10-21 14:06       ` Michal Hocko
2019-10-22  7:56         ` Oscar Salvador
2019-10-22  8:30           ` Michal Hocko
2019-10-22  9:40             ` Oscar Salvador
2019-10-17 14:21 ` [RFC PATCH v2 12/16] mm,hwpoison: Refactor soft_offline_huge_page and __soft_offline_page Oscar Salvador
2019-10-17 14:21 ` [RFC PATCH v2 13/16] mm,hwpoison: Take pages off the buddy when hard-offlining Oscar Salvador
2019-10-17 14:21 ` [RFC PATCH v2 14/16] mm,hwpoison: Return 0 if the page is already poisoned in soft-offline Oscar Salvador
2019-10-21  9:20   ` Naoya Horiguchi
2019-10-17 14:21 ` [RFC PATCH v2 15/16] mm/hwpoison-inject: Rip off duplicated checks Oscar Salvador
2019-10-21  9:40   ` David Hildenbrand
2019-10-22  7:57     ` Oscar Salvador
2019-10-17 14:21 ` [RFC PATCH v2 16/16] mm, soft-offline: convert parameter to pfn Oscar Salvador
2019-10-18  8:15   ` David Hildenbrand [this message]
2020-06-11 16:43 ` [RFC PATCH v2 00/16] Hwpoison rework {hard,soft}-offline Dmitry Yakunin
2020-06-15  6:19   ` HORIGUCHI NAOYA(堀口 直也)

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=62eb5232-1e4d-22cf-0026-3e37ac06f3a3@redhat.com \
    --to=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=mike.kravetz@oracle.com \
    --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

Linux-mm Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mm/0 linux-mm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mm linux-mm/ https://lore.kernel.org/linux-mm \
		linux-mm@kvack.org
	public-inbox-index linux-mm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kvack.linux-mm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git