lkml.org 
[lkml]   [2017]   [Mar]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH -mm -v7 2/9] mm, memcg: Support to charge/uncharge multiple swap entries
Date
Johannes Weiner <hannes@cmpxchg.org> writes:

> On Tue, Mar 28, 2017 at 01:32:02PM +0800, Huang, Ying wrote:
>> @@ -5908,16 +5907,19 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t entry)
>> css_put(&memcg->css);
>> }
>>
>> -/*
>> - * mem_cgroup_try_charge_swap - try charging a swap entry
>> +/**
>> + * mem_cgroup_try_charge_swap - try charging a set of swap entries
>> * @page: page being added to swap
>> - * @entry: swap entry to charge
>> + * @entry: the first swap entry to charge
>> + * @nr_entries: the number of swap entries to charge
>> *
>> - * Try to charge @entry to the memcg that @page belongs to.
>> + * Try to charge @nr_entries swap entries starting from @entry to the
>> + * memcg that @page belongs to.
>> *
>> * Returns 0 on success, -ENOMEM on failure.
>> */
>> -int mem_cgroup_try_charge_swap(struct page *page, swp_entry_t entry)
>> +int mem_cgroup_try_charge_swap(struct page *page, swp_entry_t entry,
>> + unsigned int nr_entries)
>
> I've pointed this out before,

Yes. And I have replied to your original comments too :-)

> but there doesn't seem to be a reason to
> pass @nr_entries when we have the struct page. Why can't this function
> just check PageTransHuge() by itself?

Because sometimes we need to charge one swap entry for a THP. Please
take a look at the original add_to_swap() implementation. For a THP,
one swap entry will be allocated and charged to the mem cgroup before
the THP is split. And I think it is not easy to change this, because we
don't want to split THP if the mem cgroup for swap exceeds its limit.

Best Regards,
Huang, Ying

\
 
 \ /
  Last update: 2017-03-30 02:54    [W:0.048 / U:1.696 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site