+ percpu-counter-data-type-changes-to-suppport.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     percpu counter data type changes to suppport more than 2**31 ext3 free blocks counter

has been added to the -mm tree.  Its filename is

     percpu-counter-data-type-changes-to-suppport.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this


From: Mingming Cao <cmm@xxxxxxxxxx>

The percpu counter data type are changed in this set of patches to support
more users like ext3 who need more than 32 bit to store the free blocks
total in the filesystem.

- Generic perpcu counters data type changes.  The size of the global counter
  and local counter were explictly specified using s64 and s32.  The global
  counter is changed from long to s64, while the local counter is changed from
  long to s32, so we could avoid doing 64 bit update in most cases.

- Users of the percpu counters are updated to make use of the new
  percpu_counter_init() routine now taking an additional parameter to allow
  users to pass the initial value of the global counter.

Signed-off-by: Mingming Cao <cmm@xxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 fs/ext2/super.c                |    9 +----
 fs/ext3/super.c                |    9 +----
 fs/file_table.c                |    2 -
 include/linux/percpu_counter.h |   47 ++++++++++++++++---------------
 lib/percpu_counter.c           |   18 +++++------
 net/core/sock.c                |    2 -
 net/decnet/af_decnet.c         |    2 -
 net/ipv4/proc.c                |    2 -
 net/ipv4/tcp.c                 |    2 -
 9 files changed, 45 insertions(+), 48 deletions(-)

diff -puN include/linux/percpu_counter.h~percpu-counter-data-type-changes-to-suppport include/linux/percpu_counter.h
--- devel/include/linux/percpu_counter.h~percpu-counter-data-type-changes-to-suppport	2006-04-24 19:09:26.000000000 -0700
+++ devel-akpm/include/linux/percpu_counter.h	2006-04-24 19:09:26.000000000 -0700
@@ -17,8 +17,8 @@
 
 struct percpu_counter {
 	spinlock_t lock;
-	long count;
-	long *counters;
+	s64 count;
+	s32 *counters;
 };
 
 #if NR_CPUS >= 16
@@ -27,11 +27,11 @@ struct percpu_counter {
 #define FBC_BATCH	(NR_CPUS*4)
 #endif
 
-static inline void percpu_counter_init(struct percpu_counter *fbc)
+static inline void percpu_counter_init(struct percpu_counter *fbc, s64 amount)
 {
 	spin_lock_init(&fbc->lock);
-	fbc->count = 0;
-	fbc->counters = alloc_percpu(long);
+	fbc->count = amount;
+	fbc->counters = alloc_percpu(s32);
 }
 
 static inline void percpu_counter_destroy(struct percpu_counter *fbc)
@@ -39,12 +39,12 @@ static inline void percpu_counter_destro
 	free_percpu(fbc->counters);
 }
 
-void percpu_counter_mod(struct percpu_counter *fbc, long amount);
-long percpu_counter_sum(struct percpu_counter *fbc);
-void percpu_counter_mod_bh(struct percpu_counter *fbc, long amount);
-int percpu_counter_exceeds(struct percpu_counter *fbc, long limit);
+void percpu_counter_mod(struct percpu_counter *fbc, s32 amount);
+s64 percpu_counter_sum(struct percpu_counter *fbc);
+void percpu_counter_mod_bh(struct percpu_counter *fbc, s32 amount);
+int percpu_counter_exceeds(struct percpu_counter *fbc, s64 limit);
 
-static inline long percpu_counter_read(struct percpu_counter *fbc)
+static inline s64 percpu_counter_read(struct percpu_counter *fbc)
 {
 	return fbc->count;
 }
@@ -52,13 +52,14 @@ static inline long percpu_counter_read(s
 /*
  * It is possible for the percpu_counter_read() to return a small negative
  * number for some counter which should never be negative.
+ *
  */
-static inline long percpu_counter_read_positive(struct percpu_counter *fbc)
+static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc)
 {
-	long ret = fbc->count;
+	s64 ret = fbc->count;
 
 	barrier();		/* Prevent reloads of fbc->count */
-	if (ret > 0)
+	if (ret >= 0)
 		return ret;
 	return 1;
 }
@@ -66,12 +67,12 @@ static inline long percpu_counter_read_p
 #else
 
 struct percpu_counter {
-	long count;
+	s64 count;
 };
 
-static inline void percpu_counter_init(struct percpu_counter *fbc)
+static inline void percpu_counter_init(struct percpu_counter *fbc, s64 amount)
 {
-	fbc->count = 0;
+	fbc->count = amount;
 }
 
 static inline void percpu_counter_destroy(struct percpu_counter *fbc)
@@ -79,36 +80,38 @@ static inline void percpu_counter_destro
 }
 
 static inline void
-percpu_counter_mod(struct percpu_counter *fbc, long amount)
+percpu_counter_mod(struct percpu_counter *fbc, s32 amount)
 {
 	preempt_disable();
 	fbc->count += amount;
 	preempt_enable();
 }
 
-static inline long percpu_counter_read(struct percpu_counter *fbc)
+static inline s64 percpu_counter_read(struct percpu_counter *fbc)
 {
 	return fbc->count;
 }
 
-static inline long percpu_counter_read_positive(struct percpu_counter *fbc)
+static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc)
 {
 	return fbc->count;
 }
 
-static inline long percpu_counter_sum(struct percpu_counter *fbc)
+static inline
+unsigned s64 percpu_counter_sum(struct percpu_counter *fbc)
 {
 	return percpu_counter_read_positive(fbc);
 }
 
-static inline void percpu_counter_mod_bh(struct percpu_counter *fbc, long amount)
+static inline void percpu_counter_mod_bh(struct percpu_counter *fbc, s32 amount)
 {
 	local_bh_disable();
 	fbc->count += amount;
 	local_bh_enable();
 }
 
-static inline int percpu_counter_exceeds(struct percpu_counter *fbc, long limit)
+static inline int
+percpu_counter_exceeds(struct percpu_counter *fbc, s64 limit)
 {
 	return percpu_counter_read(fbc) > limit;
 }
diff -puN lib/percpu_counter.c~percpu-counter-data-type-changes-to-suppport lib/percpu_counter.c
--- devel/lib/percpu_counter.c~percpu-counter-data-type-changes-to-suppport	2006-04-24 19:09:26.000000000 -0700
+++ devel-akpm/lib/percpu_counter.c	2006-04-24 19:09:26.000000000 -0700
@@ -5,10 +5,10 @@
 #include <linux/percpu_counter.h>
 #include <linux/module.h>
 
-static void __percpu_counter_mod(struct percpu_counter *fbc, long amount)
+static void __percpu_counter_mod(struct percpu_counter *fbc, s32 amount)
 {
-	long count;
-	long *pcount;
+	s64 count;
+	s32 *pcount;
 	int cpu = smp_processor_id();
 
 	pcount = per_cpu_ptr(fbc->counters, cpu);
@@ -23,7 +23,7 @@ static void __percpu_counter_mod(struct 
 	}
 }
 
-void percpu_counter_mod(struct percpu_counter *fbc, long amount)
+void percpu_counter_mod(struct percpu_counter *fbc, s32 amount)
 {
 	preempt_disable();
 	__percpu_counter_mod(fbc, amount);
@@ -31,7 +31,7 @@ void percpu_counter_mod(struct percpu_co
 }
 EXPORT_SYMBOL(percpu_counter_mod);
 
-void percpu_counter_mod_bh(struct percpu_counter *fbc, long amount)
+void percpu_counter_mod_bh(struct percpu_counter *fbc, s32 amount)
 {
 	local_bh_disable();
 	__percpu_counter_mod(fbc, amount);
@@ -43,15 +43,15 @@ EXPORT_SYMBOL(percpu_counter_mod_bh);
  * Add up all the per-cpu counts, return the result.  This is a more accurate
  * but much slower version of percpu_counter_read_positive()
  */
-long percpu_counter_sum(struct percpu_counter *fbc)
+s64 percpu_counter_sum(struct percpu_counter *fbc)
 {
-	long ret;
+	s64 ret;
 	int cpu;
 
 	spin_lock(&fbc->lock);
 	ret = fbc->count;
 	for_each_possible_cpu(cpu) {
-		long *pcount = per_cpu_ptr(fbc->counters, cpu);
+		s32 *pcount = per_cpu_ptr(fbc->counters, cpu);
 		ret += *pcount;
 	}
 	spin_unlock(&fbc->lock);
@@ -69,7 +69,7 @@ EXPORT_SYMBOL(percpu_counter_sum);
  * it turns out that the limit wasn't exceeded, there will be no more calls to
  * percpu_counter_sum() until significant counter skew has reoccurred.
  */
-int percpu_counter_exceeds(struct percpu_counter *fbc, long limit)
+int percpu_counter_exceeds(struct percpu_counter *fbc, s64 limit)
 {
 	if (percpu_counter_read(fbc) > limit)
 		if (percpu_counter_sum(fbc) > limit)
diff -puN fs/ext2/super.c~percpu-counter-data-type-changes-to-suppport fs/ext2/super.c
--- devel/fs/ext2/super.c~percpu-counter-data-type-changes-to-suppport	2006-04-24 19:10:33.000000000 -0700
+++ devel-akpm/fs/ext2/super.c	2006-04-24 19:10:33.000000000 -0700
@@ -834,9 +834,6 @@ static int ext2_fill_super(struct super_
 		printk ("EXT2-fs: not enough memory\n");
 		goto failed_mount;
 	}
-	percpu_counter_init(&sbi->s_freeblocks_counter);
-	percpu_counter_init(&sbi->s_freeinodes_counter);
-	percpu_counter_init(&sbi->s_dirs_counter);
 	bgl_lock_init(&sbi->s_blockgroup_lock);
 	sbi->s_debts = kmalloc(sbi->s_groups_count * sizeof(*sbi->s_debts),
 			       GFP_KERNEL);
@@ -886,11 +883,11 @@ static int ext2_fill_super(struct super_
 		ext2_warning(sb, __FUNCTION__,
 			"mounting ext3 filesystem as ext2");
 	ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY);
-	percpu_counter_mod(&sbi->s_freeblocks_counter,
+	percpu_counter_init(&sbi->s_freeblocks_counter,
 				ext2_count_free_blocks(sb));
-	percpu_counter_mod(&sbi->s_freeinodes_counter,
+	percpu_counter_init(&sbi->s_freeinodes_counter,
 				ext2_count_free_inodes(sb));
-	percpu_counter_mod(&sbi->s_dirs_counter,
+	percpu_counter_init(&sbi->s_dirs_counter,
 				ext2_count_dirs(sb));
 	return 0;
 
diff -puN fs/ext3/super.c~percpu-counter-data-type-changes-to-suppport fs/ext3/super.c
--- devel/fs/ext3/super.c~percpu-counter-data-type-changes-to-suppport	2006-04-24 19:10:33.000000000 -0700
+++ devel-akpm/fs/ext3/super.c	2006-04-24 19:10:33.000000000 -0700
@@ -1580,9 +1580,6 @@ static int ext3_fill_super (struct super
 		goto failed_mount;
 	}
 
-	percpu_counter_init(&sbi->s_freeblocks_counter);
-	percpu_counter_init(&sbi->s_freeinodes_counter);
-	percpu_counter_init(&sbi->s_dirs_counter);
 	bgl_lock_init(&sbi->s_blockgroup_lock);
 
 	for (i = 0; i < db_count; i++) {
@@ -1724,11 +1721,11 @@ static int ext3_fill_super (struct super
 		test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered":
 		"writeback");
 
-	percpu_counter_mod(&sbi->s_freeblocks_counter,
+	percpu_counter_init(&sbi->s_freeblocks_counter,
 		ext3_count_free_blocks(sb));
-	percpu_counter_mod(&sbi->s_freeinodes_counter,
+	percpu_counter_init(&sbi->s_freeinodes_counter,
 		ext3_count_free_inodes(sb));
-	percpu_counter_mod(&sbi->s_dirs_counter,
+	percpu_counter_init(&sbi->s_dirs_counter,
 		ext3_count_dirs(sb));
 
 	lock_kernel();
diff -puN fs/file_table.c~percpu-counter-data-type-changes-to-suppport fs/file_table.c
--- devel/fs/file_table.c~percpu-counter-data-type-changes-to-suppport	2006-04-24 19:10:33.000000000 -0700
+++ devel-akpm/fs/file_table.c	2006-04-24 19:10:33.000000000 -0700
@@ -300,5 +300,5 @@ void __init files_init(unsigned long mem
 	if (files_stat.max_files < NR_FILE)
 		files_stat.max_files = NR_FILE;
 	files_defer_init();
-	percpu_counter_init(&nr_files);
+	percpu_counter_init(&nr_files, 0);
 } 
diff -puN net/core/sock.c~percpu-counter-data-type-changes-to-suppport net/core/sock.c
--- devel/net/core/sock.c~percpu-counter-data-type-changes-to-suppport	2006-04-24 19:10:33.000000000 -0700
+++ devel-akpm/net/core/sock.c	2006-04-24 19:10:33.000000000 -0700
@@ -1783,7 +1783,7 @@ static char proto_method_implemented(con
 
 static void proto_seq_printf(struct seq_file *seq, struct proto *proto)
 {
-	seq_printf(seq, "%-9s %4u %6d  %6lu   %-3s %6u   %-3s  %-10s "
+	seq_printf(seq, "%-9s %4u %6d  %6llu   %-3s %6u   %-3s  %-10s "
 			"%2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c\n",
 		   proto->name,
 		   proto->obj_size,
diff -puN net/decnet/af_decnet.c~percpu-counter-data-type-changes-to-suppport net/decnet/af_decnet.c
--- devel/net/decnet/af_decnet.c~percpu-counter-data-type-changes-to-suppport	2006-04-24 19:10:33.000000000 -0700
+++ devel-akpm/net/decnet/af_decnet.c	2006-04-24 19:10:33.000000000 -0700
@@ -2384,7 +2384,7 @@ static int __init decnet_init(void)
 	if (rc != 0)
 		goto out;
 
-	percpu_counter_init(&decnet_memory_allocated);
+	percpu_counter_init(&decnet_memory_allocated, 0);
 	dn_neigh_init();
 	dn_dev_init();
 	dn_route_init();
diff -puN net/ipv4/proc.c~percpu-counter-data-type-changes-to-suppport net/ipv4/proc.c
--- devel/net/ipv4/proc.c~percpu-counter-data-type-changes-to-suppport	2006-04-24 19:10:33.000000000 -0700
+++ devel-akpm/net/ipv4/proc.c	2006-04-24 19:10:33.000000000 -0700
@@ -61,7 +61,7 @@ static int fold_prot_inuse(struct proto 
 static int sockstat_seq_show(struct seq_file *seq, void *v)
 {
 	socket_seq_show(seq);
-	seq_printf(seq, "TCP: inuse %d orphan %d tw %d alloc %d mem %lu\n",
+	seq_printf(seq, "TCP: inuse %d orphan %d tw %d alloc %d mem %llu\n",
 		   fold_prot_inuse(&tcp_prot), atomic_read(&tcp_orphan_count),
 		   tcp_death_row.tw_count, read_sockets_allocated(&tcp_prot),
 		   percpu_counter_read_positive(&tcp_memory_allocated));
diff -puN net/ipv4/tcp.c~percpu-counter-data-type-changes-to-suppport net/ipv4/tcp.c
--- devel/net/ipv4/tcp.c~percpu-counter-data-type-changes-to-suppport	2006-04-24 19:10:33.000000000 -0700
+++ devel-akpm/net/ipv4/tcp.c	2006-04-24 19:10:33.000000000 -0700
@@ -2178,7 +2178,7 @@ void __init tcp_init(void)
 	       "(established %d bind %d)\n",
 	       tcp_hashinfo.ehash_size << 1, tcp_hashinfo.bhash_size);
 
-	percpu_counter_init(&tcp_memory_allocated);
+	percpu_counter_init(&tcp_memory_allocated, 0);
 
 	tcp_register_congestion_control(&tcp_reno);
 }
_

Patches currently in -mm which might be from cmm@xxxxxxxxxx are

percpu-counter-data-type-changes-to-suppport.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux