linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Oscar Salvador <osalvador@suse.de>
To: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@redhat.com>,
	Michal Hocko <mhocko@kernel.org>,
	Muchun Song <songmuchun@bytedance.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] mm: Make alloc_contig_range handle free hugetlb pages
Date: Fri, 19 Feb 2021 07:08:06 +0100	[thread overview]
Message-ID: <73df96ab131fb1587c3527a5ca151c08@suse.de> (raw)
In-Reply-To: <9a902aae-7478-4287-ad5c-f6b0b7fdf2ad@oracle.com>

On 2021-02-19 03:10, Mike Kravetz wrote:
> Those counts will be wrong as there are no huge pages on the node.
> 
> I'll think about this more tomorrow.
> Pretty sure this is an issue, but I could be wrong.  Just wanted to 
> give
> a heads up.

Yes, this is a problem, although the fixup would be to check whether we 
have any hugepages.

Nevertheless, I think we should not be touching surplus at all but 
rather make the page temporary.
I am exploring making migrate_pages() handle free hugepages as Michal 
suggested, so the approach is cleaner and we do not need extra 
functions. I yet have to see if that is feasible, as some issues come to 
my mind like the page needs to be in a list to go to migrate_pages, but 
if it is in that list, it is not in hugepages_freelist, and that could 
disrupt userspace as it could not dequeue hugepages if it demands it.
I have to check. Shoult not be possible, we can always make the page 
temporary here.

> --
> Mike Kravetz
> 
>> +		}
>> +	}
>> +
>> +	return ret;
>> +}
>> +
>> +bool isolate_or_dissolve_huge_page(struct page *page)
>> +{
>> +	struct hstate *h = NULL;
>> +	struct page *head;
>> +	bool ret = false;
>> +
>> +	spin_lock(&hugetlb_lock);
>> +	if (PageHuge(page)) {
>> +		head = compound_head(page);
>> +		h = page_hstate(head);
>> +	}
>> +	spin_unlock(&hugetlb_lock);
>> +
>> +	/*
>> +	 * The page might have been dissolved from under our feet.
>> +	 * If that is the case, return success as if we dissolved it 
>> ourselves.
>> +	 */
>> +	if (!h)
>> +		return true;
>> +
>> +	/*
>> +	 * Fence off gigantic pages as there is a cyclic dependency
>> +	 * between alloc_contig_range and them.
>> +	 */
>> +	if (hstate_is_gigantic(h))
>> +		return ret;
>> +
>> +	if(!page_count(head) && alloc_and_dissolve_huge_page(h, head))
>> +		ret = true;
>> +
>> +	return ret;
>> +}
>> +
>>  struct page *alloc_huge_page(struct vm_area_struct *vma,
>>  				    unsigned long addr, int avoid_reserve)
>>  {
>> 

-- 
Oscar Salvador
SUSE L3


  reply	other threads:[~2021-02-19  6:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-18 12:00 [PATCH v2 0/2] Make alloc_contig_range handle Hugetlb pages Oscar Salvador
2021-02-18 12:00 ` [PATCH v2 1/2] mm: Make alloc_contig_range handle free hugetlb pages Oscar Salvador
2021-02-19  2:10   ` Mike Kravetz
2021-02-19  6:08     ` Oscar Salvador [this message]
2021-02-18 12:00 ` [PATCH v2 2/2] mm: Make alloc_contig_range handle in-use " Oscar Salvador

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=73df96ab131fb1587c3527a5ca151c08@suse.de \
    --to=osalvador@suse.de \
    --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=mike.kravetz@oracle.com \
    --cc=songmuchun@bytedance.com \
    /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).