Skip to contentSkip to conversation

x86/AMD: remove an unneeded condition in srat_detect_node()

PATCH In review Dan Carpenter 3 participants 3 messages Jan 13, 2016 – Jan 14, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/AMD: remove an unneeded condition in srat_detect_node()

Originally we calculated ht_nodeid as "ht_nodeid = apicid - boot_cpu_id;" so presumably it could be negative. But after commit 01aaea1afbcd ('x86: introduce initial apicid') we use c->initial_apicid which is an unsigned short and thus always >= 0.

It causes a static checker warning to test for impossible conditions so let's remove it.

arch/x86/kernel/cpu/amd.c +1 -2
index e678dde..a07956a 100644
@@ -434,8 +434,7 @@ static void srat_detect_node(struct cpuinfo_x86 *c)
 		 */
 		int ht_nodeid = c->initial_apicid;
 
-		if (ht_nodeid >= 0 &&
-		    __apicid_to_node[ht_nodeid] != NUMA_NO_NODE)
+		if (__apicid_to_node[ht_nodeid] != NUMA_NO_NODE)
 			node = __apicid_to_node[ht_nodeid];
 		/* Pick a nearby node */
 		if (!node_online(node))
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Dan Carpenter

Originally we calculated ht_nodeid as "ht_nodeid = apicid - boot_cpu_id;" so presumably it could be negative. But after commit 01aaea1afbcd ('x86: introduce initial apicid') we use c->initial_apicid which is an unsigned short and thus always >= 0.

It causes a static checker warning to test for impossible conditions so let's remove it.

Looks OK for me.

Quoted 14 lines
arch/x86/kernel/cpu/amd.c +1 -2
index e678dde..a07956a 100644
@@ -434,8 +434,7 @@ static void srat_detect_node(struct cpuinfo_x86 *c)
 		 */
 		int ht_nodeid = c->initial_apicid;
 
-		if (ht_nodeid >= 0 &&
-		    __apicid_to_node[ht_nodeid] != NUMA_NO_NODE)
+		if (__apicid_to_node[ht_nodeid] != NUMA_NO_NODE)
 			node = __apicid_to_node[ht_nodeid];
 		/* Pick a nearby node */
 		if (!node_online(node))
#2 lore raw

[tip:x86/urgent] x86/cpu/amd: Remove an unneeded condition in srat_detect_node()

In reply to Dan Carpenter
x86/cpu/amd: Remove an unneeded condition in srat_detect_node()
Commit-ID:  7030a7e9321166eef44c811fe4af4d460360d424
Gitweb:     http://git.kernel.org/tip/7030a7e9321166eef44c811fe4af4d460360d424
Author:     Dan Carpenter <[email protected]>
AuthorDate: Wed, 13 Jan 2016 15:39:40 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 14 Jan 2016 09:46:00 +0100

x86/cpu/amd: Remove an unneeded condition in srat_detect_node()

Originally we calculated ht_nodeid as "ht_nodeid = apicid - boot_cpu_id;" so presumably it could be negative.

But after commit:

01aaea1afbcd ('x86: introduce initial apicid')

we use c->initial_apicid which is an unsigned short and thus always >= 0.

It causes a static checker warning to test for impossible conditions so let's remove it.

Cc Andy Lutomirski <[email protected]>
Cc Aravind Gopalakrishnan <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Hector Marco-Gisbert <[email protected]>
Cc Huang Rui <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Yinghai Lu <[email protected]>
---
 arch/x86/kernel/cpu/amd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/cpu/amd.c +1 -2
index e678dde..a07956a 100644
@@ -434,8 +434,7 @@ static void srat_detect_node(struct cpuinfo_x86 *c)
 		 */
 		int ht_nodeid = c->initial_apicid;
 
-		if (ht_nodeid >= 0 &&
-		    __apicid_to_node[ht_nodeid] != NUMA_NO_NODE)
+		if (__apicid_to_node[ht_nodeid] != NUMA_NO_NODE)
 			node = __apicid_to_node[ht_nodeid];
 		/* Pick a nearby node */
 		if (!node_online(node))