2010/3/26, Aneesh Kumar K. V <aneesh.kumar@linux.vnet.ibm.com>:
cool idea, Aneesh, and I got it.
---
--- old-linux-2.6.32/fs/ext4/mballoc.c 2009-12-03 11:51:22.000000000 +0800
+++ ext4_mm_leak/mballoc3-2.c 2010-03-28 16:13:20.000000000 +0800
@@ -2397,11 +2397,27 @@ int ext4_mb_init(struct super_block *sb,
i++;
} while (i <= sb->s_blocksize_bits + 1);
+ sbi->s_locality_groups = alloc_percpu(struct ext4_locality_group);
+ if (sbi->s_locality_groups == NULL) {
+ kfree(sbi->s_mb_offsets);
+ kfree(sbi->s_mb_maxs);
+ return -ENOMEM;
+ }
+ for_each_possible_cpu(i) {
+ struct ext4_locality_group *lg;
+ lg = per_cpu_ptr(sbi->s_locality_groups, i);
+ mutex_init(&lg->lg_mutex);
+ for (j = 0; j < PREALLOC_TB_SIZE; j++)
+ INIT_LIST_HEAD(&lg->lg_prealloc_list[j]);
+ spin_lock_init(&lg->lg_prealloc_lock);
+ }
+
/* init file for buddy data */
ret = ext4_mb_init_backend(sb);
if (ret != 0) {
kfree(sbi->s_mb_offsets);
kfree(sbi->s_mb_maxs);
+ free_percpu(sbi->s_locality_groups);
return ret;
}
@@ -2415,20 +2431,6 @@ int ext4_mb_init(struct super_block *sb,
sbi->s_mb_order2_reqs = MB_DEFAULT_ORDER2_REQS;
sbi->s_mb_group_prealloc = MB_DEFAULT_GROUP_PREALLOC;
- sbi->s_locality_groups = alloc_percpu(struct ext4_locality_group);
- if (sbi->s_locality_groups == NULL) {
- kfree(sbi->s_mb_offsets);
- kfree(sbi->s_mb_maxs);
- return -ENOMEM;
- }
- for_each_possible_cpu(i) {
- struct ext4_locality_group *lg;
- lg = per_cpu_ptr(sbi->s_locality_groups, i);
- mutex_init(&lg->lg_mutex);
- for (j = 0; j < PREALLOC_TB_SIZE; j++)
- INIT_LIST_HEAD(&lg->lg_prealloc_list[j]);
- spin_lock_init(&lg->lg_prealloc_lock);
- }
if (sbi->s_proc)
proc_create_data("mb_groups", S_IRUGO, sbi->s_proc,
--
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