lkml.org 
[lkml]   [2018]   [Oct]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4] memory_hotplug: Free pages as higher order
On 2018-10-04 20:21, Michal Hocko wrote:
> On Wed 03-10-18 19:09:39, Arun KS wrote:
> [...]
>> +static int online_pages_blocks(unsigned long start, unsigned long
>> nr_pages)
>> +{
>> + unsigned long end = start + nr_pages;
>> + int order, ret, onlined_pages = 0;
>> +
>> + while (start < end) {
>> + order = min(MAX_ORDER - 1UL, __ffs(start));
>> +
>> + while (start + (1UL << order) > end)
>> + order--;
>
> this really made me scratch my head. Wouldn't it be much simpler to do
> the following?
> order = min(MAX_ORDER - 1, get_order(end - start))?

Yes. Much better. Will change to,

order = min(MAX_ORDER - 1,
get_order(PFN_PHYS(end) - PFN_PHYS(start)));

>
>> +
>> + ret = (*online_page_callback)(pfn_to_page(start), order);
>> + if (!ret)
>> + onlined_pages += (1UL << order);
>> + else if (ret > 0)
>> + onlined_pages += ret;
>> +
>> + start += (1UL << order);
>> + }
>> + return onlined_pages;
>> }
> [...]
>> -static void __init __free_pages_boot_core(struct page *page, unsigned
>> int order)
>> +void __free_pages_core(struct page *page, unsigned int order)
>> {
>> unsigned int nr_pages = 1 << order;
>> struct page *p = page;
>> unsigned int loop;
>>
>> - prefetchw(p);
>> - for (loop = 0; loop < (nr_pages - 1); loop++, p++) {
>> - prefetchw(p + 1);
>> + for (loop = 0; loop < nr_pages; loop++, p++) {
>> __ClearPageReserved(p);
>> set_page_count(p, 0);
>> }
>> - __ClearPageReserved(p);
>> - set_page_count(p, 0);
>>
>> page_zone(page)->managed_pages += nr_pages;
>> set_page_refcounted(page);
>
> I think this is wort a separate patch as it is unrelated to the patch.
Sure. Will split the patch.

Regards,
Arun

\
 
 \ /
  Last update: 2018-10-05 09:25    [W:0.083 / U:4.548 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site