lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170501082005.GA2006@WeideMacBook-Pro.local>
Date:   Mon, 1 May 2017 16:20:05 +0800
From:   Wei Yang <richard.weiyang@...il.com>
To:     Matthew Wilcox <willy@...radead.org>
Cc:     Wei Yang <richard.weiyang@...il.com>, cl@...ux.com,
        penberg@...nel.org, rientjes@...gle.com, iamjoonsoo.kim@....com,
        akpm@...ux-foundation.org, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/3] mm/slub: wrap cpu_slab->partial in
 CONFIG_SLUB_CPU_PARTIAL

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.
>
>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
>#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:
>

Matthew

I have tried to replace the code with slub_cpu_partial(), it works fine on
most of cases except two:

1. slub_cpu_partial(c) = page->next;
2. page = READ_ONCE(slub_cpu_partial(c));

The sysfs part works fine.

So if you agree, I would leave these two parts as v1.

>> @@ -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

Download attachment "signature.asc" of type "application/pgp-signature" (820 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ