Skip to contentSkip to conversation

x86: remove the useless branch in c_start()

PATCH Michael Wang 2 participants 4 messages Sep 26, 2012 – Sep 27, 2012 1 message not in the archive x86

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 7 lines · Michael Wang

Since 'cpu == -1' in cpumask_next() is legal, no need to handle '*pos == 0' specially.

About the comments:

	/* just in case, cpu 0 is not the first */

A test with a cpumask in which cpu 0 is not the first has been done, and it works well.

Could I get some comments on this patch?

Regards,
Michael Wang

Quoted 25 lines

This patch will remove that useless branch to clean the code.

---
 arch/x86/kernel/cpu/proc.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/proc.c +1 -4
index 8022c66..fbd8955 100644
@@ -140,10 +140,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 
 static void *c_start(struct seq_file *m, loff_t *pos)
 {
-	if (*pos == 0)	/* just in case, cpu 0 is not the first */
-		*pos = cpumask_first(cpu_online_mask);
-	else
-		*pos = cpumask_next(*pos - 1, cpu_online_mask);
+	*pos = cpumask_next(*pos - 1, cpu_online_mask);
 	if ((*pos) < nr_cpu_ids)
 		return &cpu_data(*pos);
 	return NULL;
#2 lore raw
Quoted 10 lines · Michael Wang
Quoted 7 lines · Michael Wang

Since 'cpu == -1' in cpumask_next() is legal, no need to handle '*pos == 0' specially.

About the comments:

	/* just in case, cpu 0 is not the first */

A test with a cpumask in which cpu 0 is not the first has been done, and it works well.

Could I get some comments on this patch?

Looks ok to me:

Thanks.

Signature · 8 lines
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551
#3 lore raw
Quoted 10 lines · Borislav Petkov
Quoted 9 lines · Michael Wang
Quoted 7 lines · Michael Wang

Since 'cpu == -1' in cpumask_next() is legal, no need to handle '*pos == 0' specially.

About the comments:

	/* just in case, cpu 0 is not the first */

A test with a cpumask in which cpu 0 is not the first has been done, and it works well.

Quoted 7 lines
Quoted 1 line

Could I get some comments on this patch?

Looks ok to me:

Thanks.

Thanks for your review.

Regards,
Michael Wang

Quoted 1 line
#4 lore raw

[tip:x86/cpu] x86: Remove the useless branch in c_start()

In reply to a message not in the archive
Commit-ID:  dec08a837fda146fee498ffc5ecd0d2eeeacd025
Gitweb:     http://git.kernel.org/tip/dec08a837fda146fee498ffc5ecd0d2eeeacd025
Author:     Michael Wang <[email protected]>
AuthorDate: Wed, 19 Sep 2012 13:42:23 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 26 Sep 2012 13:27:56 +0200

x86: Remove the useless branch in c_start()

Since 'cpu == -1' in cpumask_next() is legal, no need to handle '*pos == 0' specially.

About the comments:

	/* just in case, cpu 0 is not the first */

A test with a cpumask in which cpu 0 is not the first has been done, and it works well.

This patch will remove that useless branch to clean the code.

---
 arch/x86/kernel/cpu/proc.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/proc.c +1 -4
index 8022c66..fbd8955 100644
@@ -140,10 +140,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 
 static void *c_start(struct seq_file *m, loff_t *pos)
 {
-	if (*pos == 0)	/* just in case, cpu 0 is not the first */
-		*pos = cpumask_first(cpu_online_mask);
-	else
-		*pos = cpumask_next(*pos - 1, cpu_online_mask);
+	*pos = cpumask_next(*pos - 1, cpu_online_mask);
 	if ((*pos) < nr_cpu_ids)
 		return &cpu_data(*pos);
 	return NULL;