From: Wei Yang <richard.weiyang@gmail.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Wei Yang <richard.weiyang@gmail.com>,
cl@linux.com, penberg@kernel.org, rientjes@google.com,
iamjoonsoo.kim@lge.com, akpm@linux-foundation.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] mm/slub: wrap cpu_slab->partial in CONFIG_SLUB_CPU_PARTIAL
Date: Mon, 1 May 2017 15:39:38 +0800 [thread overview]
Message-ID: <20170501073938.GA868@WeideMacBook-Pro.local> (raw)
In-Reply-To: <20170501024103.GI27790@bombadil.infradead.org>
[-- Attachment #1: Type: text/plain, Size: 2151 bytes --]
On Sun, Apr 30, 2017 at 07:41:03PM -0700, Matthew Wilcox wrote:
>On Sun, Apr 30, 2017 at 07:31:51PM +0800, Wei Yang wrote:
>> @@ -2302,7 +2302,11 @@ static bool has_cpu_slab(int cpu, void *info)
>> struct kmem_cache *s = info;
>> struct kmem_cache_cpu *c = per_cpu_ptr(s->cpu_slab, cpu);
>>
>> - return c->page || c->partial;
>> + return c->page
>> +#ifdef CONFIG_SLUB_CPU_PARTIAL
>> + || c->partial
>> +#endif
>> + ;
>> }
>
>No. No way. This is disgusting.
>
Thanks for your comment. I believe you are right.
>The right way to do this is to create an accessor like this:
>
>#ifdef CONFIG_SLUB_CPU_PARTIAL
>#define slub_cpu_partial(c) ((c)->partial)
>#else
>#define slub_cpu_partial(c) 0
Since partial is a pointer to a page, would this be more proper?
#define slub_cpu_partial(c) NULL
>#endif
>
>And then the above becomes:
>
>- return c->page || c->partial;
>+ return c->page || slub_cpu_partial(c);
>
>All the other ifdefs go away, apart from these two:
Looks most of the ifdefs could be replaced by this format, while not all of
them. For example, the sysfs entry.
I would form another version with your suggestion.
Welcome any other comments :-)
>
>> @@ -4980,6 +4990,7 @@ static ssize_t objects_partial_show(struct kmem_cache *s, char *buf)
>> }
>> SLAB_ATTR_RO(objects_partial);
>>
>> +#ifdef CONFIG_SLUB_CPU_PARTIAL
>> static ssize_t slabs_cpu_partial_show(struct kmem_cache *s, char *buf)
>> {
>> int objects = 0;
>> @@ -5010,6 +5021,7 @@ static ssize_t slabs_cpu_partial_show(struct kmem_cache *s, char *buf)
>> return len + sprintf(buf + len, "\n");
>> }
>> SLAB_ATTR_RO(slabs_cpu_partial);
>> +#endif
>>
>> static ssize_t reclaim_account_show(struct kmem_cache *s, char *buf)
>> {
>> @@ -5364,7 +5376,9 @@ static struct attribute *slab_attrs[] = {
>> &destroy_by_rcu_attr.attr,
>> &shrink_attr.attr,
>> &reserved_attr.attr,
>> +#ifdef CONFIG_SLUB_CPU_PARTIAL
>> &slabs_cpu_partial_attr.attr,
>> +#endif
>> #ifdef CONFIG_SLUB_DEBUG
>> &total_objects_attr.attr,
>> &slabs_attr.attr,
--
Wei Yang
Help you, Help me
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2017-05-01 7:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-30 11:31 [PATCH 0/3] try to save some memory for kmem_cache in some cases Wei Yang
2017-04-30 11:31 ` [PATCH 1/3] mm/slub: pack red_left_pad with another int to save a word Wei Yang
2017-04-30 11:31 ` [PATCH 2/3] mm/slub: wrap cpu_slab->partial in CONFIG_SLUB_CPU_PARTIAL Wei Yang
2017-05-01 2:41 ` Matthew Wilcox
2017-05-01 7:39 ` Wei Yang [this message]
2017-05-01 8:20 ` Wei Yang
2017-05-01 14:39 ` Matthew Wilcox
2017-05-01 15:15 ` Wei Yang
2017-04-30 11:31 ` [PATCH 3/3] mm/slub: wrap kmem_cache->cpu_partial in config CONFIG_SLUB_CPU_PARTIAL Wei Yang
2017-05-01 15:37 ` Wei Yang
2017-04-30 21:22 ` [PATCH 0/3] try to save some memory for kmem_cache in some cases Christoph Lameter
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=20170501073938.GA868@WeideMacBook-Pro.local \
--to=richard.weiyang@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=willy@infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).