Re: [RFC][PATCH 1/2] memcg: avoiding unnecessary get_page at move_charge

From: Hiroyuki Kamezawa
Date: Fri Oct 15 2010 - 18:36:14 EST


2010/10/16 Christoph Lameter <cl@xxxxxxxxx>:
> On Fri, 15 Oct 2010, KAMEZAWA Hiroyuki wrote:
>
>> But above is called all under pte_offset_map_lock().
>> get_page_unless_zero() #1 is not necessary because we do all under a
>> pte_offset_map_lock().
>
> The two (ptl and refcount) are entirely different. The ptl is for
> protecting the page table. The refcount handles only the page.
>
> However, if the entry in the page table is pointing to the page then there
> must have been a refcount taken on the page. So if you know that the page
> is in the page table and you took the ptl then you can be sure that the
> page refcount will not become zero. Therefore get_page_unless_zero() will
> never fail and there is no need to take additional refcounts as long as
> the page table lock is held and the page is not removed from the page
> table.
>

Ok, thank you for explanation. I can make this function faster.

>> Index: mmotm-1013/mm/vmscan.c
>> ===================================================================
>> --- mmotm-1013.orig/mm/vmscan.c
>> +++ mmotm-1013/mm/vmscan.c
>> @@ -1166,7 +1166,8 @@ static unsigned long clear_active_flags(
>>   * found will be decremented.
>>   *
>>   * Restrictions:
>> - * (1) Must be called with an elevated refcount on the page. This is a
>> + * (1) Must be called with an elevated refcount on the page, IOW, the
>> + *     caller must guarantee that there is a stable reference. This is a
>>   *     fundamentnal difference from isolate_lru_pages (which is called
>>   *     without a stable reference).
>>   * (2) the lru_lock must not be held.
>
> There is no need for this change since you have an elevated refcount.
> IMH The words "stable reference" may be confusing since the refcount may
> change. The elevated refcount protects against the freeing of the page.
>

Sure, drop change this in v2. I misunderstand "elevated refcount"
means "extra get_page()".

Thanks,
-Kame
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/