* [PATCH] ext4: use kmem_cache_zalloc instead of kmem_cache_alloc/memset
@ 2012-08-27 4:40 Wei Yongjun
2012-08-28 12:34 ` Ashish Sangwan
0 siblings, 1 reply; 3+ messages in thread
From: Wei Yongjun @ 2012-08-27 4:40 UTC (permalink / raw)
To: tytso, adilger.kernel; +Cc: yongjun_wei, linux-ext4
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Using kmem_cache_zalloc() instead of kmem_cache_alloc() and memset().
spatch with a semantic match is used to found this problem.
(http://coccinelle.lip6.fr/)
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
fs/ext4/mballoc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 8eae947..6bc21a2 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2195,12 +2195,11 @@ int ext4_mb_add_groupinfo(struct super_block *sb, ext4_group_t group,
sbi->s_group_info[group >> EXT4_DESC_PER_BLOCK_BITS(sb)];
i = group & (EXT4_DESC_PER_BLOCK(sb) - 1);
- meta_group_info[i] = kmem_cache_alloc(cachep, GFP_KERNEL);
+ meta_group_info[i] = kmem_cache_zalloc(cachep, GFP_KERNEL);
if (meta_group_info[i] == NULL) {
ext4_msg(sb, KERN_ERR, "can't allocate buddy mem");
goto exit_group_info;
}
- memset(meta_group_info[i], 0, kmem_cache_size(cachep));
set_bit(EXT4_GROUP_INFO_NEED_INIT_BIT,
&(meta_group_info[i]->bb_state));
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4: use kmem_cache_zalloc instead of kmem_cache_alloc/memset
2012-08-27 4:40 [PATCH] ext4: use kmem_cache_zalloc instead of kmem_cache_alloc/memset Wei Yongjun
@ 2012-08-28 12:34 ` Ashish Sangwan
0 siblings, 0 replies; 3+ messages in thread
From: Ashish Sangwan @ 2012-08-28 12:34 UTC (permalink / raw)
To: Wei Yongjun; +Cc: tytso, adilger.kernel, yongjun_wei, linux-ext4
you can add 1 more.
In function ext4_mb_new_blocks(), change:
ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS);
to
ac = kmem_cache_zalloc(ext4_ac_cachep, GFP_NOFS); and remove
memset(ac, 0, sizeof(struct ext4_allocation_context)); from
ext4_mb_initialize_context().
On Mon, Aug 27, 2012 at 10:10 AM, Wei Yongjun <weiyj.lk@gmail.com> wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>
> Using kmem_cache_zalloc() instead of kmem_cache_alloc() and memset().
>
> spatch with a semantic match is used to found this problem.
> (http://coccinelle.lip6.fr/)
>
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> ---
> fs/ext4/mballoc.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 8eae947..6bc21a2 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -2195,12 +2195,11 @@ int ext4_mb_add_groupinfo(struct super_block *sb, ext4_group_t group,
> sbi->s_group_info[group >> EXT4_DESC_PER_BLOCK_BITS(sb)];
> i = group & (EXT4_DESC_PER_BLOCK(sb) - 1);
>
> - meta_group_info[i] = kmem_cache_alloc(cachep, GFP_KERNEL);
> + meta_group_info[i] = kmem_cache_zalloc(cachep, GFP_KERNEL);
> if (meta_group_info[i] == NULL) {
> ext4_msg(sb, KERN_ERR, "can't allocate buddy mem");
> goto exit_group_info;
> }
> - memset(meta_group_info[i], 0, kmem_cache_size(cachep));
> set_bit(EXT4_GROUP_INFO_NEED_INIT_BIT,
> &(meta_group_info[i]->bb_state));
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4: use kmem_cache_zalloc instead of kmem_cache_alloc/memset
@ 2012-08-28 13:38 Wei Yongjun
0 siblings, 0 replies; 3+ messages in thread
From: Wei Yongjun @ 2012-08-28 13:38 UTC (permalink / raw)
To: ashishsangwan2; +Cc: tytso, adilger.kernel, yongjun_wei, linux-ext4
On 08/28/2012 08:34 PM, Ashish Sangwan wrote:
> you can add 1 more.
> In function ext4_mb_new_blocks(), change:
> ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS);
> to
> ac = kmem_cache_zalloc(ext4_ac_cachep, GFP_NOFS); and remove
> memset(ac, 0, sizeof(struct ext4_allocation_context)); from
> ext4_mb_initialize_context().
got it, thanks, will include in the update version patch.
>
> On Mon, Aug 27, 2012 at 10:10 AM, Wei Yongjun <weiyj.lk@gmail.com> wrote:
>> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>>
>> Using kmem_cache_zalloc() instead of kmem_cache_alloc() and memset().
>>
>> spatch with a semantic match is used to found this problem.
>> (http://coccinelle.lip6.fr/)
>>
>> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>> ---
>> fs/ext4/mballoc.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-08-28 13:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-27 4:40 [PATCH] ext4: use kmem_cache_zalloc instead of kmem_cache_alloc/memset Wei Yongjun
2012-08-28 12:34 ` Ashish Sangwan
2012-08-28 13:38 Wei Yongjun
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.