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] [day] [month] [year] [list]
Message-ID: <527705F3.50407@cn.fujitsu.com>
Date:	Mon, 04 Nov 2013 10:26:59 +0800
From:	Gu Zheng <guz.fnst@...fujitsu.com>
To:	Dave Chinner <david@...morbit.com>
CC:	bpm@....com, elder@...nel.org,
	linux-kernel <linux-kernel@...r.kernel.org>, xfs@....sgi.com
Subject: Re: [PATCH] xfs: simplify kmem_{zone_}zalloc

Hi Dave,
On 11/02/2013 04:58 AM, Dave Chinner wrote:

> On Fri, Nov 01, 2013 at 06:25:11PM +0800, Gu Zheng wrote:
>> Introduce flag KM_ZERO which is used to alloc zeroed entry, and convert
>> kmem_{zone_}zalloc to call kmem_{zone_}alloc() with KM_ZERO directly,
>> in order to avoid the setting to zero step.
>>
>>
>> Signed-off-by: Gu Zheng <guz.fnst@...fujitsu.com>
>> ---
>>  fs/xfs/kmem.c |   14 ++------------
>>  fs/xfs/kmem.h |    7 ++++++-
>>  2 files changed, 8 insertions(+), 13 deletions(-)
>>
>> diff --git a/fs/xfs/kmem.c b/fs/xfs/kmem.c
>> index a02cfb9..d56fcc9 100644
>> --- a/fs/xfs/kmem.c
>> +++ b/fs/xfs/kmem.c
>> @@ -65,12 +65,7 @@ kmem_alloc(size_t size, xfs_km_flags_t flags)
>>  void *
>>  kmem_zalloc(size_t size, xfs_km_flags_t flags)
>>  {
>> -	void	*ptr;
>> -
>> -	ptr = kmem_alloc(size, flags);
>> -	if (ptr)
>> -		memset((char *)ptr, 0, (int)size);
>> -	return ptr;
>> +	return kmem_alloc(size, flags | KM_ZERO);
>>  }
>>  
>>  void *
>> @@ -132,10 +127,5 @@ kmem_zone_alloc(kmem_zone_t *zone, xfs_km_flags_t flags)
>>  void *
>>  kmem_zone_zalloc(kmem_zone_t *zone, xfs_km_flags_t flags)
>>  {
>> -	void	*ptr;
>> -
>> -	ptr = kmem_zone_alloc(zone, flags);
>> -	if (ptr)
>> -		memset((char *)ptr, 0, kmem_cache_size(zone));
>> -	return ptr;
>> +	return kmem_zone_alloc(zone, flags | KM_ZERO);
>>  }
> 
> These functions should be made static inline functions in kmem.h
> seeing as they are now just a simple wrapper.

Agree. Thanks for your suggestion, I'll follow it.

> 
> Otherwise it's a nice cleanup.

Thanks:)

Regards,
Gu

> 
> Cheers,
> 
> Dave.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ