Skip to contentSkip to conversation

alloc_buffer_head() cleanup

PATCH New Coywolf Qi Hunt 2 participants 2 messages Aug 25, 2005 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 alloc_buffer_head() cleanup

Hello,

This cleanups up alloc_buffer_head(), by using a single get_cpu_var(). Boot tested.

Coywolf

---

 buffer.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
fs/buffer.c renamed from fs/buffer.c~orig +2 -3
@@ -3049,10 +3049,9 @@ struct buffer_head *alloc_buffer_head(un
 {
 	struct buffer_head *ret = kmem_cache_alloc(bh_cachep, gfp_flags);
 	if (ret) {
-		preempt_disable();
-		__get_cpu_var(bh_accounting).nr++;
+		get_cpu_var(bh_accounting).nr++;
 		recalc_bh_state();
-		preempt_enable();
+		put_cpu_var(bh_accounting);
 	}
 	return ret;
 }
#1 lore raw

PATCH 1/1 alloc_buffer_head() and free_buffer_head() cleanup

Quoted 4 lines · Coywolf Qi Hunt

Hello,

This cleanups up alloc_buffer_head(), by using a single get_cpu_var(). Boot tested.

Also cleanup free_buffer_head().

Coywolf

---

 buffer.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
fs/buffer.c renamed from fs/buffer.c~orig +4 -6
@@ -3049,10 +3049,9 @@ struct buffer_head *alloc_buffer_head(un
 {
 	struct buffer_head *ret = kmem_cache_alloc(bh_cachep, gfp_flags);
 	if (ret) {
-		preempt_disable();
-		__get_cpu_var(bh_accounting).nr++;
+		get_cpu_var(bh_accounting).nr++;
 		recalc_bh_state();
-		preempt_enable();
+		put_cpu_var(bh_accounting);
 	}
 	return ret;
 }
@@ -3062,10 +3061,9 @@ void free_buffer_head(struct buffer_head
 {
 	BUG_ON(!list_empty(&bh->b_assoc_buffers));
 	kmem_cache_free(bh_cachep, bh);
-	preempt_disable();
-	__get_cpu_var(bh_accounting).nr--;
+	get_cpu_var(bh_accounting).nr--;
 	recalc_bh_state();
-	preempt_enable();
+	put_cpu_var(bh_accounting);
 }
 EXPORT_SYMBOL(free_buffer_head);