Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1483466

Re: [PATCH] memory-hotplug: Fix bad area access on dissolve_free_huge_pages()

From Rui Teng <rui.teng@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject Re: [PATCH] memory-hotplug: Fix bad area access on dissolve_free_huge_pages()
Date 2016-09-14 18:40 +0200
Message-ID <shlo5-3d7-19@gated-at.bofh.it> (permalink)
References <sgRq1-7PG-13@gated-at.bofh.it> <sgZQC-4ZB-39@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 9/14/16 1:32 AM, Dave Hansen wrote:
> On 09/13/2016 01:39 AM, Rui Teng wrote:
>> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
>> index 87e11d8..64b5f81 100644
>> --- a/mm/hugetlb.c
>> +++ b/mm/hugetlb.c
>> @@ -1442,7 +1442,7 @@ static int free_pool_huge_page(struct hstate *h, nodemask_t *nodes_allowed,
>>  static void dissolve_free_huge_page(struct page *page)
>>  {
>>  	spin_lock(&hugetlb_lock);
>> -	if (PageHuge(page) && !page_count(page)) {
>> +	if (PageHuge(page) && !page_count(page) && PageHead(page)) {
>>  		struct hstate *h = page_hstate(page);
>>  		int nid = page_to_nid(page);
>>  		list_del(&page->lru);
>
> This is goofy.  What is calling dissolve_free_huge_page() on a tail page?
>
> Hmm:
>
>>         for (pfn = start_pfn; pfn < end_pfn; pfn += 1 << minimum_order)
>>                 dissolve_free_huge_page(pfn_to_page(pfn));
>
> So, skip through the area being offlined at the smallest huge page size,
> and try to dissolve a huge page in each place one might appear.  But,
> after we dissolve a 16GB huge page, we continue looking through the
> remaining 15.98GB tail area for huge pages in the area we just
> dissolved.  The tail pages are still PageHuge() (how??), and we call
> page_hstate() on the tail page whose head was just dissolved.
>
> Note, even with the fix, this taking a (global) spinlock 1023 more times
> that it doesn't have to.
>
> This seems inefficient, and fails to fully explain what is going on, and
> how tail pages still _look_ like PageHuge(), which seems pretty wrong.
>
> I guess the patch _works_.  But, sheesh, it leaves a lot of room for
> improvement.
>
Thanks for your suggestion!
How about return the size of page freed from dissolve_free_huge_page(), 
and jump such step on pfn?

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] memory-hotplug: Fix bad area access on dissolve_free_huge_pages() Rui Teng <rui.teng@linux.vnet.ibm.com> - 2016-09-13 10:40 +0200
  Re: [PATCH] memory-hotplug: Fix bad area access on  dissolve_free_huge_pages() Dave Hansen <dave.hansen@linux.intel.com> - 2016-09-13 19:40 +0200
    Re: [PATCH] memory-hotplug: Fix bad area access on  dissolve_free_huge_pages() Dave Hansen <dave.hansen@linux.intel.com> - 2016-09-14 18:40 +0200
      Re: [PATCH] memory-hotplug: Fix bad area access on  dissolve_free_huge_pages() Rui Teng <rui.teng@linux.vnet.ibm.com> - 2016-09-16 16:00 +0200
        Re: [PATCH] memory-hotplug: Fix bad area access on  dissolve_free_huge_pages() Dave Hansen <dave.hansen@linux.intel.com> - 2016-09-16 18:30 +0200
          Re: [PATCH] memory-hotplug: Fix bad area access on  dissolve_free_huge_pages() Rui Teng <rui.teng@linux.vnet.ibm.com> - 2016-09-20 16:50 +0200
            Re: [PATCH] memory-hotplug: Fix bad area access on  dissolve_free_huge_pages() Dave Hansen <dave.hansen@linux.intel.com> - 2016-09-20 17:00 +0200
              Re: [PATCH] memory-hotplug: Fix bad area access on  dissolve_free_huge_pages() Rui Teng <rui.teng@linux.vnet.ibm.com> - 2016-09-20 18:00 +0200
                Re: [PATCH] memory-hotplug: Fix bad area access on  dissolve_free_huge_pages() Dave Hansen <dave.hansen@linux.intel.com> - 2016-09-20 19:50 +0200
                Re: [PATCH] memory-hotplug: Fix bad area access on  dissolve_free_huge_pages() Michal Hocko <mhocko@kernel.org> - 2016-09-21 14:10 +0200
                Re: [PATCH] memory-hotplug: Fix bad area access on  dissolve_free_huge_pages() Dave Hansen <dave.hansen@linux.intel.com> - 2016-09-21 18:10 +0200
                Re: [PATCH] memory-hotplug: Fix bad area access on  dissolve_free_huge_pages() Michal Hocko <mhocko@kernel.org> - 2016-09-21 18:30 +0200
                Re: [PATCH] memory-hotplug: Fix bad area access on  dissolve_free_huge_pages() Dave Hansen <dave.hansen@linux.intel.com> - 2016-09-21 18:40 +0200
                Re: [PATCH] memory-hotplug: Fix bad area access on  dissolve_free_huge_pages() Michal Hocko <mhocko@kernel.org> - 2016-09-21 19:00 +0200
    Re: [PATCH] memory-hotplug: Fix bad area access on  dissolve_free_huge_pages() Rui Teng <rui.teng@linux.vnet.ibm.com> - 2016-09-14 18:40 +0200

csiph-web