2012-05-03 05:16:13

by Nitin Gupta

[permalink] [raw]
Subject: Re: [PATCH 2/6] zsmalloc: remove unnecessary alignment

Hi Minchan,

Sorry for late reply.

On 4/25/12 9:42 PM, Minchan Kim wrote:
> On 04/25/2012 09:53 PM, Nitin Gupta wrote:
>
>> On 04/25/2012 02:23 AM, Minchan Kim wrote:
>>
>>> It isn't necessary to align pool size with PAGE_SIZE.
>>> If I missed something, please let me know it.
>>>
>>> Signed-off-by: Minchan Kim<[email protected]>
>>> ---
>>> drivers/staging/zsmalloc/zsmalloc-main.c | 5 ++---
>>> 1 file changed, 2 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c b/drivers/staging/zsmalloc/zsmalloc-main.c
>>> index 504b6c2..b99ad9e 100644
>>> --- a/drivers/staging/zsmalloc/zsmalloc-main.c
>>> +++ b/drivers/staging/zsmalloc/zsmalloc-main.c
>>> @@ -489,14 +489,13 @@ fail:
>>>
>>> struct zs_pool *zs_create_pool(const char *name, gfp_t flags)
>>> {
>>> - int i, error, ovhd_size;
>>> + int i, error;
>>> struct zs_pool *pool;
>>>
>>> if (!name)
>>> return NULL;
>>>
>>> - ovhd_size = roundup(sizeof(*pool), PAGE_SIZE);
>>> - pool = kzalloc(ovhd_size, GFP_KERNEL);
>>> + pool = kzalloc(sizeof(*pool), GFP_KERNEL);
>>> if (!pool)
>>> return NULL;
>>>
>>
>>
>> pool metadata is rounded-up to avoid potential false-sharing problem
>> (though we could just roundup to cache_line_size()).
>
>
> Do you really have any hurt by false-sharing problem?
> If so, we can change it with
>

I've never been hit by this false-sharing in any testing but this is
really just a random chance. Apart from aligning to cache-line size,
there is no way to ensure some unfortunate read-mostly object never
falls in the same line.

> kzalloc(ALIGN(sizeof(*pool), cache_line_size()), GFP_KERNEL);
>

Yes, looks better than aligning to PAGE_SIZE.


Thanks,
Nitin