public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] use percpu data for lg_prealloc_list
@ 2008-08-13 19:11 Eric Sandeen
  2008-08-18 15:47 ` Eric Sandeen
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Sandeen @ 2008-08-13 19:11 UTC (permalink / raw)
  To: ext4 development; +Cc: Aneesh Kumar K.V

lg_prealloc_list seems to cry out for a per-cpu data structure; on a large
smp system I think this should be better.  I've lightly tested this change
on a 4-cpu system.  Comments welcome...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

ndex: linux-2.6/fs/ext4/mballoc.c
===================================================================
--- linux-2.6.orig/fs/ext4/mballoc.c	2008-08-04 15:30:30.000000000 -0500
+++ linux-2.6/fs/ext4/mballoc.c	2008-08-13 13:48:33.224165751 -0500
@@ -2540,17 +2540,16 @@ int ext4_mb_init(struct super_block *sb,
 	sbi->s_mb_history_filter = EXT4_MB_HISTORY_DEFAULT;
 	sbi->s_mb_group_prealloc = MB_DEFAULT_GROUP_PREALLOC;
 
-	i = sizeof(struct ext4_locality_group) * nr_cpu_ids;
-	sbi->s_locality_groups = kmalloc(i, GFP_KERNEL);
+	sbi->s_locality_groups = alloc_percpu(struct ext4_locality_group);
 	if (sbi->s_locality_groups == NULL) {
 		clear_opt(sbi->s_mount_opt, MBALLOC);
 		kfree(sbi->s_mb_offsets);
 		kfree(sbi->s_mb_maxs);
 		return -ENOMEM;
 	}
-	for (i = 0; i < nr_cpu_ids; i++) {
+	for_each_possible_cpu(i) {
 		struct ext4_locality_group *lg;
-		lg = &sbi->s_locality_groups[i];
+		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]);
@@ -2647,8 +2646,7 @@ int ext4_mb_release(struct super_block *
 				atomic_read(&sbi->s_mb_discarded));
 	}
 
-	kfree(sbi->s_locality_groups);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] use percpu data for lg_prealloc_list
  2008-08-13 19:11 [PATCH] use percpu data for lg_prealloc_list Eric Sandeen
@ 2008-08-18 15:47 ` Eric Sandeen
  2008-08-18 15:56   ` Aneesh Kumar K.V
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Sandeen @ 2008-08-18 15:47 UTC (permalink / raw)
  To: ext4 development; +Cc: Aneesh Kumar K.V

Eric Sandeen wrote:
> lg_prealloc_list seems to cry out for a per-cpu data structure; on a large
> smp system I think this should be better.  I've lightly tested this change
> on a 4-cpu system.  Comments welcome...

Any thoughts on this?  Does this seem to be the right way to go?

Thanks,
-Eric

> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> ndex: linux-2.6/fs/ext4/mballoc.c
> ===================================================================
> --- linux-2.6.orig/fs/ext4/mballoc.c	2008-08-04 15:30:30.000000000 -0500
> +++ linux-2.6/fs/ext4/mballoc.c	2008-08-13 13:48:33.224165751 -0500
> @@ -2540,17 +2540,16 @@ int ext4_mb_init(struct super_block *sb,
>  	sbi->s_mb_history_filter = EXT4_MB_HISTORY_DEFAULT;
>  	sbi->s_mb_group_prealloc = MB_DEFAULT_GROUP_PREALLOC;
>  
> -	i = sizeof(struct ext4_locality_group) * nr_cpu_ids;
> -	sbi->s_locality_groups = kmalloc(i, GFP_KERNEL);
> +	sbi->s_locality_groups = alloc_percpu(struct ext4_locality_group);
>  	if (sbi->s_locality_groups == NULL) {
>  		clear_opt(sbi->s_mount_opt, MBALLOC);
>  		kfree(sbi->s_mb_offsets);
>  		kfree(sbi->s_mb_maxs);
>  		return -ENOMEM;
>  	}
> -	for (i = 0; i < nr_cpu_ids; i++) {
> +	for_each_possible_cpu(i) {
>  		struct ext4_locality_group *lg;
> -		lg = &sbi->s_locality_groups[i];
> +		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]);
> @@ -2647,8 +2646,7 @@ int ext4_mb_release(struct super_block *
>  				atomic_read(&sbi->s_mb_discarded));
>  	}
>  
> -	kfree(sbi->s_locality_groups);
> -
> +	free_percpu(sbi->s_locality_groups);
>  	ext4_mb_history_release(sb);
>  	ext4_mb_destroy_per_dev_proc(sb);
>  
> @@ -4055,8 +4053,7 @@ static void ext4_mb_group_or_file(struct
>  	 * per cpu locality group is to reduce the contention between block
>  	 * request from multiple CPUs.
>  	 */
> -	ac->ac_lg = &sbi->s_locality_groups[get_cpu()];
> -	put_cpu();
> +	ac->ac_lg = per_cpu_ptr(sbi->s_locality_groups, smp_processor_id());
>  
>  	/* we're going to use group allocation */
>  	ac->ac_flags |= EXT4_MB_HINT_GROUP_ALLOC;
> 
> --
> 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] 4+ messages in thread

* Re: [PATCH] use percpu data for lg_prealloc_list
  2008-08-18 15:47 ` Eric Sandeen
@ 2008-08-18 15:56   ` Aneesh Kumar K.V
  2008-08-18 16:07     ` Eric Sandeen
  0 siblings, 1 reply; 4+ messages in thread
From: Aneesh Kumar K.V @ 2008-08-18 15:56 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: ext4 development

On Mon, Aug 18, 2008 at 10:47:40AM -0500, Eric Sandeen wrote:
> Eric Sandeen wrote:
> > lg_prealloc_list seems to cry out for a per-cpu data structure; on a large
> > smp system I think this should be better.  I've lightly tested this change
> > on a 4-cpu system.  Comments welcome...
> 
> Any thoughts on this?  Does this seem to be the right way to go?
> 

Acked-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] use percpu data for lg_prealloc_list
  2008-08-18 15:56   ` Aneesh Kumar K.V
@ 2008-08-18 16:07     ` Eric Sandeen
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Sandeen @ 2008-08-18 16:07 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: ext4 development

Aneesh Kumar K.V wrote:
> On Mon, Aug 18, 2008 at 10:47:40AM -0500, Eric Sandeen wrote:
>> Eric Sandeen wrote:
>>> lg_prealloc_list seems to cry out for a per-cpu data structure; on a large
>>> smp system I think this should be better.  I've lightly tested this change
>>> on a 4-cpu system.  Comments welcome...
>> Any thoughts on this?  Does this seem to be the right way to go?
>>
> 
> Acked-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

Thanks :)  I'll toss it in the patch queue.

-Eric

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-08-18 16:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-13 19:11 [PATCH] use percpu data for lg_prealloc_list Eric Sandeen
2008-08-18 15:47 ` Eric Sandeen
2008-08-18 15:56   ` Aneesh Kumar K.V
2008-08-18 16:07     ` Eric Sandeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox