Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1633568

Re: [PATCH 2/3] mm/slub: wrap cpu_slab->partial in CONFIG_SLUB_CPU_PARTIAL

From Wei Yang <richard.weiyang@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH 2/3] mm/slub: wrap cpu_slab->partial in CONFIG_SLUB_CPU_PARTIAL
Date 2017-05-01 09:50 +0200
Message-ID <tCefL-6cu-7@gated-at.bofh.it> (permalink)
References <tBVmO-2D4-1@gated-at.bofh.it> <tBVmP-2D4-39@gated-at.bofh.it> <tC9zs-3ad-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/3] try to save some memory for kmem_cache in some cases Wei Yang <richard.weiyang@gmail.com> - 2017-04-30 13:40 +0200
  [PATCH 3/3] mm/slub: wrap kmem_cache->cpu_partial in config CONFIG_SLUB_CPU_PARTIAL Wei Yang <richard.weiyang@gmail.com> - 2017-04-30 13:40 +0200
    Re: [PATCH 3/3] mm/slub: wrap kmem_cache->cpu_partial in config  CONFIG_SLUB_CPU_PARTIAL Wei Yang <richard.weiyang@gmail.com> - 2017-05-01 17:50 +0200
  [PATCH 1/3] mm/slub: pack red_left_pad with another int to save a word Wei Yang <richard.weiyang@gmail.com> - 2017-04-30 13:40 +0200
  [PATCH 2/3] mm/slub: wrap cpu_slab->partial in CONFIG_SLUB_CPU_PARTIAL Wei Yang <richard.weiyang@gmail.com> - 2017-04-30 13:40 +0200
    Re: [PATCH 2/3] mm/slub: wrap cpu_slab->partial in  CONFIG_SLUB_CPU_PARTIAL Matthew Wilcox <willy@infradead.org> - 2017-05-01 04:50 +0200
      Re: [PATCH 2/3] mm/slub: wrap cpu_slab->partial in  CONFIG_SLUB_CPU_PARTIAL Wei Yang <richard.weiyang@gmail.com> - 2017-05-01 09:50 +0200
      Re: [PATCH 2/3] mm/slub: wrap cpu_slab->partial in  CONFIG_SLUB_CPU_PARTIAL Wei Yang <richard.weiyang@gmail.com> - 2017-05-01 10:30 +0200
        Re: [PATCH 2/3] mm/slub: wrap cpu_slab->partial in  CONFIG_SLUB_CPU_PARTIAL Matthew Wilcox <willy@infradead.org> - 2017-05-01 16:40 +0200
          Re: [PATCH 2/3] mm/slub: wrap cpu_slab->partial in  CONFIG_SLUB_CPU_PARTIAL Wei Yang <richard.weiyang@gmail.com> - 2017-05-01 17:50 +0200
  Re: [PATCH 0/3] try to save some memory for kmem_cache in some  cases Christoph Lameter <cl@linux.com> - 2017-04-30 23:30 +0200

csiph-web