Home » Mailing lists » Devel » [PATCH v5 00/14] kmem controller for memcg.
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure [message #48461 is a reply to message #48440] |
Thu, 18 October 2012 09:16 |
Glauber Costa
Messages: 916 Registered: October 2011
|
Senior Member |
|
|
On 10/18/2012 02:12 AM, Andrew Morton wrote:
> On Tue, 16 Oct 2012 14:16:43 +0400
> Glauber Costa <glommer@parallels.com> wrote:
>
>> This patch introduces infrastructure for tracking kernel memory pages to
>> a given memcg. This will happen whenever the caller includes the flag
>> __GFP_KMEMCG flag, and the task belong to a memcg other than the root.
>>
>> In memcontrol.h those functions are wrapped in inline acessors. The
>> idea is to later on, patch those with static branches, so we don't incur
>> any overhead when no mem cgroups with limited kmem are being used.
>>
>> Users of this functionality shall interact with the memcg core code
>> through the following functions:
>>
>> memcg_kmem_newpage_charge: will return true if the group can handle the
>> allocation. At this point, struct page is not
>> yet allocated.
>>
>> memcg_kmem_commit_charge: will either revert the charge, if struct page
>> allocation failed, or embed memcg information
>> into page_cgroup.
>>
>> memcg_kmem_uncharge_page: called at free time, will revert the charge.
>>
>> ...
>>
>> +static __always_inline bool
>> +memcg_kmem_newpage_charge(gfp_t gfp, struct mem_cgroup **memcg, int order)
>> +{
>> + if (!memcg_kmem_enabled())
>> + return true;
>> +
>> + /*
>> + * __GFP_NOFAIL allocations will move on even if charging is not
>> + * possible. Therefore we don't even try, and have this allocation
>> + * unaccounted. We could in theory charge it with
>> + * res_counter_charge_nofail, but we hope those allocations are rare,
>> + * and won't be worth the trouble.
>> + */
>> + if (!(gfp & __GFP_KMEMCG) || (gfp & __GFP_NOFAIL))
>> + return true;
>> + if (in_interrupt() || (!current->mm) || (current->flags & PF_KTHREAD))
>> + return true;
>> +
>> + /* If the test is dying, just let it go. */
>> + if (unlikely(test_thread_flag(TIF_MEMDIE)
>> + || fatal_signal_pending(current)))
>> + return true;
>> +
>> + return __memcg_kmem_newpage_charge(gfp, memcg, order);
>> +}
>
> That's a big function! Why was it __always_inline? I'd have thought
> it would be better to move the code after memcg_kmem_enabled() out of
> line.
>
it is big, but it is mostly bit testing. So the goal here is to avoid a
function call at all costs, this being a fast path.
> Do we actually need to test PF_KTHREAD when current->mm == NULL?
> Perhaps because of aio threads whcih temporarily adopt a userspace mm?
I believe so. I remember I discussed this in the past with David
Rientjes and he advised me to test for both.
>
>> +/**
>> + * memcg_kmem_uncharge_page: uncharge pages from memcg
>> + * @page: pointer to struct page being freed
>> + * @order: allocation order.
>> + *
>> + * there is no need to specify memcg here, since it is embedded in page_cgroup
>> + */
>> +static __always_inline void
>> +memcg_kmem_uncharge_page(struct page *page, int order)
>> +{
>> + if (memcg_kmem_enabled())
>> + __memcg_kmem_uncharge_page(page, order);
>> +}
>> +
>> +/**
>> + * memcg_kmem_commit_charge: embeds correct memcg in a page
>> + * @page: pointer to struct page recently allocated
>> + * @memcg: the memcg structure we charged against
>> + * @order: allocation order.
>> + *
>> + * Needs to be called after memcg_kmem_newpage_charge, regardless of success or
>> + * failure of the allocation. if @page is NULL, this function will revert the
>> + * charges. Otherwise, it will commit the memcg given by @memcg to the
>> + * corresponding page_cgroup.
>> + */
>> +static __always_inline void
>> +memcg_kmem_commit_charge(struct page *page, struct mem_cgroup *memcg, int order)
>> +{
>> + if (memcg_kmem_enabled() && memcg)
>> + __memcg_kmem_commit_charge(page, memcg, order);
>> +}
>
> I suspect the __always_inline's here are to do with static branch
> trickery. A code comment is warranted if so?
>
Not necessarily. Same thing as above. We want to avoid function calls in
those sites.
|
|
|
|
|
[PATCH v5 00/14] kmem controller for memcg.
|
|
|
[PATCH v5 03/14] memcg: change defines to an enum
|
|
|
Re: [PATCH v5 03/14] memcg: change defines to an enum
|
|
|
[PATCH v5 01/14] memcg: Make it possible to use the stock for more than one page.
|
|
|
Re: [PATCH v5 01/14] memcg: Make it possible to use the stock for more than one page.
By: akpm on Wed, 17 October 2012 22:11
|
|
|
Re: [PATCH v5 01/14] memcg: Make it possible to use the stock for more than one page.
|
|
|
[PATCH v5 04/14] kmem accounting basic infrastructure
|
|
|
Re: [PATCH v5 04/14] kmem accounting basic infrastructure
|
|
|
Re: [PATCH v5 04/14] kmem accounting basic infrastructure
|
|
|
Re: [PATCH v5 04/14] kmem accounting basic infrastructure
|
|
|
Re: [PATCH v5 04/14] kmem accounting basic infrastructure
|
|
|
Re: [PATCH v5 04/14] kmem accounting basic infrastructure
|
|
|
Re: [PATCH v5 04/14] kmem accounting basic infrastructure
By: akpm on Wed, 17 October 2012 22:12
|
|
|
Re: [PATCH v5 04/14] kmem accounting basic infrastructure
|
|
|
[PATCH v5 11/14] memcg: allow a memcg with kmem charges to be destructed.
|
|
|
Re: [PATCH v5 11/14] memcg: allow a memcg with kmem charges to be destructed.
By: akpm on Wed, 17 October 2012 22:12
|
|
|
Re: [PATCH v5 11/14] memcg: allow a memcg with kmem charges to be destructed.
|
|
|
[PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
By: akpm on Wed, 17 October 2012 22:12
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
[PATCH v5 05/14] Add a __GFP_KMEMCG flag
|
|
|
Re: [PATCH v5 05/14] Add a __GFP_KMEMCG flag
|
|
|
Re: [PATCH v5 05/14] Add a __GFP_KMEMCG flag
|
|
|
[PATCH v5 09/14] memcg: kmem accounting lifecycle management
|
|
|
Re: [PATCH v5 09/14] memcg: kmem accounting lifecycle management
|
|
|
Re: [PATCH v5 09/14] memcg: kmem accounting lifecycle management
|
|
|
Re: [PATCH v5 09/14] memcg: kmem accounting lifecycle management
|
|
|
[PATCH v5 10/14] memcg: use static branches when code not in use
|
|
|
[PATCH v5 14/14] Add documentation about the kmem controller
|
|
|
Re: [PATCH v5 14/14] Add documentation about the kmem controller
|
|
|
Re: [PATCH v5 14/14] Add documentation about the kmem controller
|
|
|
Re: [PATCH v5 14/14] Add documentation about the kmem controller
|
|
|
Re: [PATCH v5 14/14] Add documentation about the kmem controller
|
|
|
Re: [PATCH v5 14/14] Add documentation about the kmem controller
By: akpm on Wed, 17 October 2012 22:12
|
|
|
Re: [PATCH v5 14/14] Add documentation about the kmem controller
|
|
|
[PATCH v5 13/14] protect architectures where THREAD_SIZE >= PAGE_SIZE against fork bombs
|
|
|
Re: [PATCH v5 13/14] protect architectures where THREAD_SIZE >= PAGE_SIZE against fork bombs
By: akpm on Wed, 17 October 2012 22:12
|
|
|
Re: [PATCH v5 13/14] protect architectures where THREAD_SIZE >= PAGE_SIZE against fork bombs
|
|
|
[PATCH v5 07/14] mm: Allocate kernel pages to the right memcg
|
|
|
Re: [PATCH v5 07/14] mm: Allocate kernel pages to the right memcg
|
|
|
Re: [PATCH v5 07/14] mm: Allocate kernel pages to the right memcg
|
|
|
Re: [PATCH v5 07/14] mm: Allocate kernel pages to the right memcg
By: akpm on Wed, 17 October 2012 22:12
|
|
|
Re: [PATCH v5 07/14] mm: Allocate kernel pages to the right memcg
|
|
|
Re: [PATCH v5 07/14] mm: Allocate kernel pages to the right memcg
By: akpm on Thu, 18 October 2012 20:44
|
|
|
Re: [PATCH v5 07/14] mm: Allocate kernel pages to the right memcg
|
|
|
Re: [PATCH v5 07/14] mm: Allocate kernel pages to the right memcg
|
|
|
Re: [PATCH v5 00/14] kmem controller for memcg.
By: akpm on Wed, 17 October 2012 22:11
|
|
|
Re: [PATCH v5 00/14] kmem controller for memcg.
|
|
|
Re: [PATCH v5 00/14] kmem controller for memcg.
By: akpm on Thu, 18 October 2012 19:21
|
|
|
Re: [PATCH v5 00/14] kmem controller for memcg.
|
Goto Forum:
Current Time: Mon Oct 14 20:43:28 GMT 2024
Total time taken to generate the page: 0.06022 seconds
|