Skip to contentSkip to conversation

python: xc: fix max_cpu_index sign error

PATCH In review Petre Eftime 4 participants 4 messages Apr 5, 2018 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 python: xc: fix max_cpu_index sign error

When 0-indexing, maximum index is num_entries - 1. The python xc library had a sign error where the minus was replaced by a plus, making tools that depended on it to look for CPUs that did not exist.

---
 tools/python/xen/lowlevel/xc/xc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/python/xen/lowlevel/xc/xc.c +1 -1
index f501764..694bfa0 100644
@@ -1079,7 +1079,7 @@ static PyObject *pyxc_topologyinfo(XcObject *self)
         }
     }
 
-    ret_obj = Py_BuildValue("{s:i}", "max_cpu_index", num_cpus + 1);
+    ret_obj = Py_BuildValue("{s:i}", "max_cpu_index", num_cpus - 1);
 
     PyDict_SetItemString(ret_obj, "cpu_to_core", cpu_to_core_obj);
     Py_DECREF(cpu_to_core_obj);
Signature · 12 lines
2.7.3.AMZN




Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

CC Marek

Quoted 35 lines · Petre Eftime

When 0-indexing, maximum index is num_entries - 1. The python xc library had a sign error where the minus was replaced by a plus, making tools that depended on it to look for CPUs that did not exist.

---
 tools/python/xen/lowlevel/xc/xc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/python/xen/lowlevel/xc/xc.c +1 -1
index f501764..694bfa0 100644
@@ -1079,7 +1079,7 @@ static PyObject *pyxc_topologyinfo(XcObject *self)
         }
     }
 
-    ret_obj = Py_BuildValue("{s:i}", "max_cpu_index", num_cpus + 1);
+    ret_obj = Py_BuildValue("{s:i}", "max_cpu_index", num_cpus - 1);
 
     PyDict_SetItemString(ret_obj, "cpu_to_core", cpu_to_core_obj);
     Py_DECREF(cpu_to_core_obj);
Signature · 12 lines
2.7.3.AMZN




Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 8 lines · Wei Liu

CC Marek

Quoted 5 lines · Petre Eftime

When 0-indexing, maximum index is num_entries - 1. The python xc library had a sign error where the minus was replaced by a plus, making tools that depended on it to look for CPUs that did not exist.

Quoted 30 lines
Quoted 30 lines
---
 tools/python/xen/lowlevel/xc/xc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/python/xen/lowlevel/xc/xc.c +1 -1
index f501764..694bfa0 100644
@@ -1079,7 +1079,7 @@ static PyObject *pyxc_topologyinfo(XcObject *self)
         }
     }
 
-    ret_obj = Py_BuildValue("{s:i}", "max_cpu_index", num_cpus + 1);
+    ret_obj = Py_BuildValue("{s:i}", "max_cpu_index", num_cpus - 1);
 
     PyDict_SetItemString(ret_obj, "cpu_to_core", cpu_to_core_obj);
     Py_DECREF(cpu_to_core_obj);
Signature · 12 lines
2.7.3.AMZN




Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Signature · 5 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 11 lines · Marek Marczykowski-Górecki
Quoted 8 lines · Wei Liu

CC Marek

Quoted 5 lines · Petre Eftime

When 0-indexing, maximum index is num_entries - 1. The python xc library had a sign error where the minus was replaced by a plus, making tools that depended on it to look for CPUs that did not exist.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel