From: Vlastimil Babka <vbabka@suse.cz>
To: David Rientjes <rientjes@google.com>
Cc: linux-mm@kvack.org, Christoph Lameter <cl@linux.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Pekka Enberg <penberg@kernel.org>, Jann Horn <jannh@google.com>,
linux-kernel@vger.kernel.org, Roman Gushchin <guro@fb.com>
Subject: Re: [RFC PATCH] mm, slub: change percpu partial accounting from objects to pages
Date: Wed, 15 Sep 2021 10:42:06 +0200 [thread overview]
Message-ID: <ba5b7957-52fc-d8be-ed51-a2d21a233b4b@suse.cz> (raw)
In-Reply-To: <c167ab10-f970-15c-b0e-fd4484ddc637@google.com>
On 9/15/21 07:32, David Rientjes wrote:
> On Mon, 13 Sep 2021, Vlastimil Babka wrote:
>
>> While this is no longer a problem in kmemcg context thanks to the accounting
>> rewrite in 5.9, the memory waste is still not ideal and it's questionable
>> whether it makes sense to perform free object count based control when object
>> counts can easily become so much inaccurate. So this patch converts the
>> accounting to be based on number of pages only (which is precise) and removes
>> the page->pobjects field completely. This is also ultimately simpler.
>>
>
> Thanks for the very detailed explanation, this is very timely for us.
>
> I'm wondering if we should be concerned about the memory waste even being
> possible, though, now that we have the kmemcg accounting change?
>
> IIUC, because we're accounting objects and not pages, then it *seems* like
> we could have a high number of pages but very few objects charged per
> page so this memory waste could go unconstrained from any kmemcg
> limitation.
So the main problem before 5.9 was that there were separate kmem caches per
memcg with their own percpu partial lists, so the memory used was determined
by caches x cpus x memcgs, now they are shared so it's just caches x cpus.
What you're saying would be also true, but relatively much smaller issue
than what it was before 5.9.
>> To retain the existing set_cpu_partial() heuristic, first calculate the target
>> number of objects as previously, but then convert it to target number of pages
>> by assuming the pages will be half-filled on average. This assumption might
>> obviously also be inaccurate in practice, but cannot degrade to actual number of
>> pages being equal to the target number of objects.
>>
>
> I think that's a fair heuristic.
>
>> We could also skip the intermediate step with target number of objects and
>> rewrite the heuristic in terms of pages. However we still have the sysfs file
>> cpu_partial which uses number of objects and could break existing users if it
>> suddenly becomes number of pages, so this patch doesn't do that.
>>
>> In practice, after this patch the heuristics limit the size of percpu partial
>> list up to 2 pages. In case of a reported regression (which would mean some
>> workload has benefited from the previous imprecise object based counting), we
>> can tune the heuristics to get a better compromise within the new scheme, while
>> still avoid the unexpectedly long percpu partial lists.
>>
>
> Curious if you've tried netperf TCP_RR with this change? This benchmark
> was the most significantly improved benchmark that I recall with the
> introduction of per-cpu partial slabs for SLUB. If there are any
> regressions to be introduced by such an approach, I'm willing to bet that
> it would be surfaced with that benchmark.
I'll try, thanks for the tip.
next prev parent reply other threads:[~2021-09-15 8:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-13 17:01 Vlastimil Babka
2021-09-15 5:32 ` David Rientjes
2021-09-15 8:42 ` Vlastimil Babka [this message]
2021-10-01 12:35 ` Vlastimil Babka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ba5b7957-52fc-d8be-ed51-a2d21a233b4b@suse.cz \
--to=vbabka@suse.cz \
--cc=cl@linux.com \
--cc=guro@fb.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox