linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
To: David Hildenbrand <david@redhat.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
	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 08:27:36 +0000	[thread overview]
Message-ID: <20191016082735.GB13770@hori.linux.bs1.fc.nec.co.jp> (raw)
In-Reply-To: <e931b14b-da27-2720-5344-b5c0b08b38ad@redhat.com>

On Wed, Oct 16, 2019 at 09:56:19AM +0200, David Hildenbrand wrote:
> 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.
...
> 
> 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?

I rebased to next-20191016. And yes, we will move pfn_to_online_page()
into soft offline code.  It seems that we can also move pfn_valid(),
but is simply moving like below good enough for you?

  @@ -1877,11 +1877,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 flags)
  +int soft_offline_page(unsigned long pfn, int flags)
   {
   	int ret;
  -	unsigned long pfn = page_to_pfn(page);
  +	struct page *page;
   
  +	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;
  +	page = pfn_to_page(pfn);
   	if (is_zone_device_page(page)) {
   		pr_debug_ratelimited("soft_offline: %#lx page is device page\n",
   				pfn);
  -- 

Or we might have an option to do as memory_failure() does like below:

  int memory_failure(unsigned long pfn, int flags)
  {
          ....
          p = pfn_to_online_page(pfn);
          if (!p) {
                  if (pfn_valid(pfn)) {
                          pgmap = get_dev_pagemap(pfn, NULL);
                          if (pgmap)
                                  return memory_failure_dev_pagemap(pfn, flags,
                                                                    pgmap);
                  }
                  pr_err("Memory failure: %#lx: memory outside kernel control\n",
                          pfn);
                  return -ENXIO;
          }

Thanks,
Naoya Horiguchi

  reply	other threads:[~2019-10-16  8:28 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
2019-10-16  8:27   ` Naoya Horiguchi [this message]
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=20191016082735.GB13770@hori.linux.bs1.fc.nec.co.jp \
    --to=n-horiguchi@ah.jp.nec.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --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).