public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] percpu in linux-2.6.35-rc3
@ 2010-06-16 11:44 Пантелеев Павел
  0 siblings, 0 replies; 3+ messages in thread
From: Пантелеев Павел @ 2010-06-16 11:44 UTC (permalink / raw)
  To: andi, linux-mm, linux-kernel

Hello! My name is Pavel V. Panteleev. 

While working with percpu on linux-2.6.35-rc3 I have found trivial bugs in pcpu_build_alloc_info() function:
- we should memset group_cnt to 0 by size of group_cnt, not size of group_map;
- we can delete useless variable group_cnt_max.

Best regards,
Pavel V. Panteleev

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

* Re: [patch] percpu in linux-2.6.35-rc3
       [not found] <E1OOr6Q-0005Zi-00.pp_84-mail-ru@f57.mail.ru>
@ 2010-06-16 14:56 ` Andi Kleen
  2010-06-17  8:14   ` Tejun Heo
  0 siblings, 1 reply; 3+ messages in thread
From: Andi Kleen @ 2010-06-16 14:56 UTC (permalink / raw)
  To: Pavel V. Panteleev; +Cc: linux-mm, linux-kernel, andi, tj

On Wed, Jun 16, 2010 at 03:48:18PM +0400, Pavel V. Panteleev wrote:
> Hello! My name is Pavel V. Panteleev.
> 
> While working with percpu on linux-2.6.35-rc3 I have found trivial bugs in pcpu_build_alloc_info() function:
> - we should memset group_cnt to 0 by size of group_cnt, not size of group_map;
> - we can delete useless variable group_cnt_max.

Thanks for the patch. Tejun maintains percpu code these days,
putting him into cc.

-Andi

Pavel's patch:

--- percpu_old.c	2010-06-12 06:14:04.000000000 +0400
+++ percpu_new.c	2010-06-16 15:05:16.280214868 +0400
@@ -1086,7 +1086,7 @@
 	static int group_map[NR_CPUS] __initdata;
 	static int group_cnt[NR_CPUS] __initdata;
 	const size_t static_size = __per_cpu_end - __per_cpu_start;
-	int group_cnt_max = 0, nr_groups = 1, nr_units = 0;
+	int nr_groups = 1, nr_units = 0;
 	size_t size_sum, min_unit_size, alloc_size;
 	int upa, max_upa, uninitialized_var(best_upa);	/* units_per_alloc */
 	int last_allocs, group, unit;
@@ -1096,7 +1096,7 @@
 
 	/* this function may be called multiple times */
 	memset(group_map, 0, sizeof(group_map));
-	memset(group_cnt, 0, sizeof(group_map));
+	memset(group_cnt, 0, sizeof(group_cnt));
 
 	/*
 	 * Determine min_unit_size, alloc_size and max_upa such that
@@ -1130,7 +1130,6 @@
 		}
 		group_map[cpu] = group;
 		group_cnt[group]++;
-		group_cnt_max = max(group_cnt_max, group_cnt[group]);
 	}
 
 	/*

-- 
ak@linux.intel.com -- Speaking for myself only.

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

* Re: [patch] percpu in linux-2.6.35-rc3
  2010-06-16 14:56 ` [patch] percpu in linux-2.6.35-rc3 Andi Kleen
@ 2010-06-17  8:14   ` Tejun Heo
  0 siblings, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2010-06-17  8:14 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Pavel V. Panteleev, linux-mm, linux-kernel

Andi, thanks for forwarding.

Pavel, I wrote up the patch description, added SOBs and committed it to
percpu#for-linus.  Will push it to mainline later.

  git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu.git for-linus

Thanks.

>From a92d3ff9e5dbd958d8008a3e7a573e988e370ca3 Mon Sep 17 00:00:00 2001
From: Pavel V. Panteleev <pp_84@mail.ru>
Date: Thu, 17 Jun 2010 10:07:25 +0200
Subject: [PATCH] percpu: fix trivial bugs in pcpu_build_alloc_info()

Fix the following two trivial bugs in pcpu_build_alloc_info()

* we should memset group_cnt to 0 by size of group_cnt, not size of
  group_map (both are of the same size, so the bug isn't dangerous)

* we can delete useless variable group_cnt_max.

Signed-off-by: Pavel V. Panteleev <pp_84@mail.ru>
Signed-off-by: Tejun Heo <tj@kernel.org>
---
 mm/percpu.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/mm/percpu.c b/mm/percpu.c
index 39f7dfd..46485e1 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1086,7 +1086,7 @@ struct pcpu_alloc_info * __init pcpu_build_alloc_info(
 	static int group_map[NR_CPUS] __initdata;
 	static int group_cnt[NR_CPUS] __initdata;
 	const size_t static_size = __per_cpu_end - __per_cpu_start;
-	int group_cnt_max = 0, nr_groups = 1, nr_units = 0;
+	int nr_groups = 1, nr_units = 0;
 	size_t size_sum, min_unit_size, alloc_size;
 	int upa, max_upa, uninitialized_var(best_upa);	/* units_per_alloc */
 	int last_allocs, group, unit;
@@ -1096,7 +1096,7 @@ struct pcpu_alloc_info * __init pcpu_build_alloc_info(

 	/* this function may be called multiple times */
 	memset(group_map, 0, sizeof(group_map));
-	memset(group_cnt, 0, sizeof(group_map));
+	memset(group_cnt, 0, sizeof(group_cnt));

 	/*
 	 * Determine min_unit_size, alloc_size and max_upa such that
@@ -1130,7 +1130,6 @@ struct pcpu_alloc_info * __init pcpu_build_alloc_info(
 		}
 		group_map[cpu] = group;
 		group_cnt[group]++;
-		group_cnt_max = max(group_cnt_max, group_cnt[group]);
 	}

 	/*
-- 
1.6.4.2


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

end of thread, other threads:[~2010-06-17  8:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <E1OOr6Q-0005Zi-00.pp_84-mail-ru@f57.mail.ru>
2010-06-16 14:56 ` [patch] percpu in linux-2.6.35-rc3 Andi Kleen
2010-06-17  8:14   ` Tejun Heo
2010-06-16 11:44 Пантелеев Павел

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