PECI patchset tweaks
Subsystems (2)
cover PECI patchset tweaks
[Re-sending as I clumsily typoed the mailing list's address on the first attempt; apologies for the duplication.]
Hello,
These patches address a few small things I noticed with the PECI patch set currently in the OpenBMC kernel tree. Assuming they're deemed acceptable, I'd of course hope they get folded in to the version of the PECI code that gets upstreamed into the mainline kernel.
(Please let me know if there's some other way I should send this -- I looked for but couldn't find a gerrit repo for the obmc kernel or any kernel-specific patch submission instructions in openbmc/docs/CONTRIBUTING.md, so 'git send-email' is my best guess.)
Thanks,
Zev
PATCH 1/2 peci: fix error-handling in peci_dev_ioctl()
peci_get_xfer_msg() returns NULL on failure, not an ERR_PTR. Also avoid calling kfree() on an ERR_PTR.
--- drivers/peci/peci-dev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/peci/peci-dev.c +4 -3
@@ -122,8 +122,8 @@ static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg) } xmsg =peci_get_xfer_msg (uxmsg.tx_len, uxmsg.rx_len); -if (IS_ERR (xmsg)) { - ret =PTR_ERR (xmsg); +if (!xmsg) { + ret = -ENOMEM ;break ; }
@@ -162,7 +162,8 @@ static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg) }peci_put_xfer_msg (xmsg); -kfree (msg); +if (!IS_ERR (msg)) +kfree (msg);return (long )ret; }
Signature · 1 line
2.28.0
Re: [PATCH 1/2] peci: fix error-handling in peci_dev_ioctl()
Hello Zev,
Quoted 13 lines · Zev Weiss
peci_get_xfer_msg()returns NULL on failure, not anERR_PTR. Also avoid callingkfree()on anERR_PTR.Signed-off-by Zev Weiss <[email protected]>--- drivers/peci/peci-dev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/peci/peci-dev.c +0
-0
drivers/peci/peci-dev.c static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg) · line 126
Quoted 7 lines
drivers/peci/peci-dev.c +2
-2@@ -122,8 +122,8 @@ static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg) } xmsg =peci_get_xfer_msg (uxmsg.tx_len, uxmsg.rx_len); -if (IS_ERR (xmsg)) { - ret =PTR_ERR (xmsg); +if (!xmsg) { + ret = -ENOMEM ;
Yes, it's a right fix. Thanks!
drivers/peci/peci-dev.c static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg) · line 166
Quoted 10 lines
drivers/peci/peci-dev.c +2
-1break ; }@@ -162,7 +162,8 @@ static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg) }peci_put_xfer_msg (xmsg); -kfree (msg); +if (!IS_ERR (msg)) +kfree (msg);
Not needed. kfree itself has null pointer checking inside.
Quoted 4 lines
drivers/peci/peci-dev.c +0
-0return (long )ret; }
Re: [PATCH 1/2] peci: fix error-handling in peci_dev_ioctl()
Quoted 25 lines · Jae Hyun Yoo
Hello Zev,
Quoted 13 lines · Zev Weiss
peci_get_xfer_msg()returns NULL on failure, not anERR_PTR. Also avoid callingkfree()on anERR_PTR.Signed-off-by Zev Weiss <[email protected]>--- drivers/peci/peci-dev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/peci/peci-dev.c +0
-0drivers/peci/peci-dev.c static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg) · line 125
Quoted 6 lines
drivers/peci/peci-dev.c +2
-2@@ -122,8 +122,8 @@ static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg) } xmsg =peci_get_xfer_msg (uxmsg.tx_len, uxmsg.rx_len); -if (IS_ERR (xmsg)) { - ret =PTR_ERR (xmsg); +if (!xmsg) { + ret = -ENOMEM ;Yes, it's a right fix. Thanks!
Quoted 11 lines
drivers/peci/peci-dev.c static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg) · line 165
Quoted 8 lines
drivers/peci/peci-dev.c +2
-1break ; }@@ -162,7 +162,8 @@ static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg) }peci_put_xfer_msg (xmsg); -kfree (msg); +if (!IS_ERR (msg)) +kfree (msg);Not needed. kfree itself has null pointer checking inside.
Certainly, but the condition in question here isn't whether it's NULL, but whether it's an ERR_PTR (which as far as I can tell kfree() does not check for). As is, there's an error path that leads to passing a non-NULL but also non-kfree-safe ERR_PTR (the memdup_user() return value).
Zev
Jae Hyun Yoo
Reviewed-byRe: [PATCH 1/2] peci: fix error-handling in peci_dev_ioctl()
Quoted 40 lines · Zev Weiss
Quoted 26 lines · Jae Hyun Yoo
Hello Zev,
Quoted 13 lines · Zev Weiss
peci_get_xfer_msg()returns NULL on failure, not an ERR_PTR. Also avoid callingkfree()on anERR_PTR.Signed-off-by Zev Weiss <[email protected]>---
drivers/peci/peci-dev.c | 7 ++++---1 file changed, 4 insertions(+), 3 deletions(-)drivers/peci/peci-dev.c +0
-0drivers/peci/peci-dev.c static long peci_dev_ioctl(struct file *file, · line 126
Quoted 7 lines
drivers/peci/peci-dev.c +2
-2@@ -122,8 +122,8 @@ static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg) } xmsg = peci_get_xfer_msg(uxmsg.tx_len, uxmsg.rx_len); - if (IS_ERR(xmsg)) { - ret = PTR_ERR(xmsg); + if (!xmsg) { + ret = -ENOMEM;Yes, it's a right fix. Thanks!
Quoted 12 lines
drivers/peci/peci-dev.c static long peci_dev_ioctl(struct file *file, · line 166
Quoted 9 lines
drivers/peci/peci-dev.c +2
-1break; }@@ -162,7 +162,8 @@ static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg) } peci_put_xfer_msg(xmsg); - kfree(msg); + if (!IS_ERR(msg)) + kfree(msg);Not needed. kfree itself has null pointer checking inside.
Quoted 1 line
Certainly, but the condition in question here isn't whether it's NULL, but whether it's an
ERR_PTR(which as far as I can tellkfree()does not check for). As is, there's an error path that leads to passing a non-NULL but also non-kfree-safeERR_PTR(thememdup_user()return value).
Yeah, checked that memdup_user can also return ERR_PTR(-ENOMEM) or ERR_PTR(-EFAULT) in error cases so null checking isn't enough for calling free(). I'll add this change into PECI patch set. Thanks!
Quoted 4 lines
Zev
Re: [PATCH 1/2] peci: fix error-handling in peci_dev_ioctl()
In reply to Zev WeissQuoted 5 lines · Zev Weiss
peci_get_xfer_msg()returns NULL on failure, not anERR_PTR. Also avoid callingkfree()on anERR_PTR.Signed-off-by Zev Weiss <[email protected]>
Applied to dev-5.8.
Cheers,
Joel
Quoted 32 lines
--- drivers/peci/peci-dev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/peci/peci-dev.c +4
-4@@ -122,8 +122,8 @@ static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg) } xmsg =peci_get_xfer_msg (uxmsg.tx_len, uxmsg.rx_len); -if (IS_ERR (xmsg)) { - ret =PTR_ERR (xmsg); +if (!xmsg) { + ret = -ENOMEM ;break ; }@@ -162,7 +162,8 @@ static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg) }peci_put_xfer_msg (xmsg); -kfree (msg); +if (!IS_ERR (msg)) +kfree (msg);return (long )ret; } --2.28.0
PATCH 2/2 peci-cputemp: label CPU cores from zero instead of one
In reply to Zev WeissZero-based numbering is more consistent with all other cpu/core numbering I'm aware of (including the PECI spec).
--- drivers/hwmon/peci-cputemp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/peci-cputemp.c +1 -1
@@ -363,7 +363,7 @@ static int create_core_temp_label(struct peci_cputemp *priv, int idx)if (!priv->coretemp_label[idx])return -ENOMEM ; -sprintf (priv->coretemp_label[idx],"Core %d" , idx +1 ); +sprintf (priv->coretemp_label[idx],"Core %d" , idx);return 0 ; }
Signature · 1 line
2.28.0
Re: [PATCH 2/2] peci-cputemp: label CPU cores from zero instead of one
Quoted 13 lines · Zev Weiss
Zero-based numbering is more consistent with all other cpu/core numbering I'm aware of (including the PECI spec).
Signed-off-by Zev Weiss <[email protected]>--- drivers/hwmon/peci-cputemp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hwmon/peci-cputemp.c +0
-0
drivers/hwmon/peci-cputemp.c static int create_core_temp_label(struct peci_cputemp *priv, int idx) · line 366
Quoted 5 lines
drivers/hwmon/peci-cputemp.c +1
-1@@ -363,7 +363,7 @@ static int create_core_temp_label(struct peci_cputemp *priv, int idx)if (!priv->coretemp_label[idx])return -ENOMEM ; -sprintf (priv->coretemp_label[idx],"Core %d" , idx +1 ); +sprintf (priv->coretemp_label[idx],"Core %d" , idx);
Differently from low level indexing, it's labeling for users and it should be synced with other temp or ADC sensors such as
PVCCIN CPU1
PVDQ ABC CPU1
CPU1 P12V PVCCIN
CPU1 VR Mem ABCD
CPU1 VR P1V8
These are using indexes starting from '1'.
Thanks,
Jae
Quoted 3 lines
drivers/hwmon/peci-cputemp.c +0
-0return 0 ; }
Re: [PATCH 2/2] peci-cputemp: label CPU cores from zero instead of one
Quoted 24 lines · Jae Hyun Yoo
Quoted 13 lines · Zev Weiss
Zero-based numbering is more consistent with all other cpu/core numbering I'm aware of (including the PECI spec).
Signed-off-by Zev Weiss <[email protected]>--- drivers/hwmon/peci-cputemp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hwmon/peci-cputemp.c +0
-0drivers/hwmon/peci-cputemp.c static int create_core_temp_label(struct peci_cputemp *priv, int idx) · line 365
Quoted 4 lines
drivers/hwmon/peci-cputemp.c +1
-1@@ -363,7 +363,7 @@ static int create_core_temp_label(struct peci_cputemp *priv, int idx)if (!priv->coretemp_label[idx])return -ENOMEM ; -sprintf (priv->coretemp_label[idx],"Core %d" , idx +1 ); +sprintf (priv->coretemp_label[idx],"Core %d" , idx);Differently from low level indexing, it's labeling for users and it should be synced with other temp or ADC sensors such as
Quoted 8 lines
PVCCIN CPU1
PVDQ ABC CPU1
CPU1 P12V PVCCIN
CPU1 VR Mem ABCD
CPU1 VR P1V8These are using indexes starting from '1'.
OK, if it's for consistency with other existing drivers I suppose that's reasonable, though for my own reference, could you point me to where those are implemented? Some rough grepping around the source tree didn't appear to turn up anything relevant.
Thanks,
Zev
Re: [PATCH 2/2] peci-cputemp: label CPU cores from zero instead of one
Quoted 32 lines · Zev Weiss
Quoted 31 lines · Jae Hyun Yoo
Quoted 13 lines · Zev Weiss
Zero-based numbering is more consistent with all other cpu/core numbering I'm aware of (including the PECI spec).
Signed-off-by Zev Weiss <[email protected]>---
drivers/hwmon/peci-cputemp.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/hwmon/peci-cputemp.c +0
-0drivers/hwmon/peci-cputemp.c static int create_core_temp_label(struct · line 366
Quoted 5 lines
drivers/hwmon/peci-cputemp.c +1
-1@@ -363,7 +363,7 @@ static int create_core_temp_label(struct peci_cputemp *priv, int idx) if (!priv->coretemp_label[idx]) return -ENOMEM; - sprintf(priv->coretemp_label[idx], "Core %d", idx + 1); + sprintf(priv->coretemp_label[idx], "Core %d", idx);Differently from low level indexing, it's labeling for users and it should be synced with other temp or ADC sensors such as
PVCCIN CPU1
PVDQ ABC CPU1
CPU1 P12V PVCCIN
CPU1 VR Mem ABCD
CPU1 VR P1V8
Quoted 4 lines
Quoted 2 lines
These are using indexes starting from '1'.
OK, if it's for consistency with other existing drivers I suppose that's reasonable, though for my own reference, could you point me to where those are implemented? Some rough grepping around the source tree didn't appear to turn up anything relevant.
Sensor names get assigned through these services
https://github.com/openbmc/entity-manager
https://github.com/openbmc/dbus-sensors
and it depends on board configuration of each machine.
Quoted 3 lines
Thanks,
Zev
Re: [PATCH 2/2] peci-cputemp: label CPU cores from zero instead of one
Quoted 36 lines · Jae Hyun Yoo
Quoted 35 lines · Zev Weiss
Quoted 33 lines · Jae Hyun Yoo
Quoted 13 lines · Zev Weiss
Zero-based numbering is more consistent with all other cpu/core numbering I'm aware of (including the PECI spec).
Signed-off-by Zev Weiss <[email protected]>---
drivers/hwmon/peci-cputemp.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/hwmon/peci-cputemp.c +0
-0drivers/hwmon/peci-cputemp.c static int create_core_temp_label(struct · line 366
Quoted 5 lines
drivers/hwmon/peci-cputemp.c +1
-1@@ -363,7 +363,7 @@ static int create_core_temp_label(struct peci_cputemp *priv, int idx) if (!priv->coretemp_label[idx]) return -ENOMEM; - sprintf(priv->coretemp_label[idx], "Core %d", idx + 1); + sprintf(priv->coretemp_label[idx], "Core %d", idx);Differently from low level indexing, it's labeling for users and it should be synced with other temp or ADC sensors such as
PVCCIN CPU1
PVDQ ABC CPU1
CPU1 P12V PVCCIN
CPU1 VR Mem ABCD
CPU1 VR P1V8These are using indexes starting from '1'.
Quoted 8 lines
Quoted 1 line
OK, if it's for consistency with other existing drivers I suppose that's reasonable, though for my own reference, could you point me to where those are implemented? Some rough grepping around the source tree didn't appear to turn up anything relevant.
Sensor names get assigned through these services
https://github.com/openbmc/entity-manager
https://github.com/openbmc/dbus-sensorsand it depends on board configuration of each machine.
Oh I see -- I had thought you were referring to other existing hwmon drivers in the kernel.
As far as I can tell, all those instances appear to be numbering CPU *sockets* though -- which as Jason mentioned in a call earlier today I gather is done to line up with motherboard silkscreen labeling. But in the code in question here we're labeling *cores* within a given socket, which I don't see arising anywhere in any existing entity-manager configs. So I'm still unclear on why we want to use one-based indexing here instead of zero-based -- I'd think we'd want the PECI driver to match the PECI spec?
Thanks,
Zev
Re: [PATCH 2/2] peci-cputemp: label CPU cores from zero instead of one
Quoted 43 lines · Zev Weiss
Quoted 42 lines · Jae Hyun Yoo
Quoted 32 lines · Zev Weiss
Quoted 31 lines · Jae Hyun Yoo
Quoted 13 lines · Zev Weiss
Zero-based numbering is more consistent with all other cpu/core numbering I'm aware of (including the PECI spec).
Signed-off-by Zev Weiss <[email protected]>---
drivers/hwmon/peci-cputemp.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/hwmon/peci-cputemp.c +0
-0drivers/hwmon/peci-cputemp.c static int create_core_temp_label(struct · line 366
Quoted 5 lines
drivers/hwmon/peci-cputemp.c +1
-1@@ -363,7 +363,7 @@ static int create_core_temp_label(struct peci_cputemp *priv, int idx) if (!priv->coretemp_label[idx]) return -ENOMEM; - sprintf(priv->coretemp_label[idx], "Core %d", idx + 1); + sprintf(priv->coretemp_label[idx], "Core %d", idx);Differently from low level indexing, it's labeling for users and it should be synced with other temp or ADC sensors such as
PVCCIN CPU1
PVDQ ABC CPU1
CPU1 P12V PVCCIN
CPU1 VR Mem ABCD
CPU1 VR P1V8Quoted 4 lines
Quoted 2 lines
These are using indexes starting from '1'.
OK, if it's for consistency with other existing drivers I suppose that's reasonable, though for my own reference, could you point me to where those are implemented? Some rough grepping around the source tree didn't appear to turn up anything relevant.
Sensor names get assigned through these services
https://github.com/openbmc/entity-manager
https://github.com/openbmc/dbus-sensors
Quoted 6 lines
Quoted 2 lines
and it depends on board configuration of each machine.
Oh I see -- I had thought you were referring to other existing hwmon drivers in the kernel.
As far as I can tell, all those instances appear to be numbering CPU *sockets* though -- which as Jason mentioned in a call earlier today I gather is done to line up with motherboard silkscreen labeling. But in the code in question here we're labeling *cores* within a given socket, which I don't see arising anywhere in any existing entity-manager configs. So I'm still unclear on why we want to use one-based indexing here instead of zero-based -- I'd think we'd want the PECI driver to match the PECI spec?
PECI driver uses zero-based index for PECI command handling but label is user facing stuff which shouldn't make confusion to users. We can modify driver like you did in this patch and previous driver also used zero-based indexing but I changed it to natural number based indexing to avoid confusion between driver labels and dbus-sensors names. Any specific reason for the zero-based indexing? Any benefit?
Thanks,
Jae
Re: [PATCH 2/2] peci-cputemp: label CPU cores from zero instead of one
Quoted 11 lines · Jae Hyun Yoo
Quoted 3 lines
Oh I see -- I had thought you were referring to other existing hwmon drivers in the kernel.
As far as I can tell, all those instances appear to be numbering CPU *sockets* though -- which as Jason mentioned in a call earlier today I gather is done to line up with motherboard silkscreen labeling. But in the code in question here we're labeling *cores* within a given socket, which I don't see arising anywhere in any existing entity-manager configs. So I'm still unclear on why we want to use one-based indexing here instead of zero-based -- I'd think we'd want the PECI driver to match the PECI spec?
PECI driver uses zero-based index for PECI command handling but label is user facing stuff which shouldn't make confusion to users. We can modify driver like you did in this patch and previous driver also used zero-based indexing but I changed it to natural number based indexing to avoid confusion between driver labels and dbus-sensors names. Any specific reason for the zero-based indexing? Any benefit?
[Re-adding CCs...]
Well, as I see it basically just consistency with a larger set of things. Most other related numbering schemes I'm aware of are zero-based -- userspace tools like 'taskset' and 'lscpu', system APIs like the <sched.h> CPU_SET() routines, and the kernel's own numbering (e.g. what's shown in /proc/cpuinfo) all number processors starting from zero, so dbus-sensors seems kind of like the odd one out there. (Personally I'd be fully in support of changing it to be zero-based as well, though I have no idea offhand about how distruptive a change that would be.)
It also seems pretty OpenBMC-specific, whereas I'd expect we want to aim for greater generality in things going into mainline.
Thanks,
Zev
Re: [PATCH 2/2] peci-cputemp: label CPU cores from zero instead of one
Quoted 13 lines · Zev Weiss
Quoted 11 lines · Jae Hyun Yoo
Quoted 3 lines
Oh I see -- I had thought you were referring to other existing hwmon drivers in the kernel.
As far as I can tell, all those instances appear to be numbering CPU *sockets* though -- which as Jason mentioned in a call earlier today I gather is done to line up with motherboard silkscreen labeling. But in the code in question here we're labeling *cores* within a given socket, which I don't see arising anywhere in any existing entity-manager configs. So I'm still unclear on why we want to use one-based indexing here instead of zero-based -- I'd think we'd want the PECI driver to match the PECI spec?
PECI driver uses zero-based index for PECI command handling but label is user facing stuff which shouldn't make confusion to users. We can modify driver like you did in this patch and previous driver also used zero-based indexing but I changed it to natural number based indexing to avoid confusion between driver labels and dbus-sensors names. Any specific reason for the zero-based indexing? Any benefit?
Quoted 5 lines
[Re-adding CCs...]
Well, as I see it basically just consistency with a larger set of things. Most other related numbering schemes I'm aware of are zero-based -- userspace tools like 'taskset' and 'lscpu', system APIs like the <
sched.h>CPU_SET()routines, and the kernel's own numbering (e.g. what's shown in/proc/cpuinfo) all number processors starting from zero, so dbus-sensors seems kind of like the odd one out there. (Personally I'd be fully in support of changing it to be zero-based as well, though I have no idea offhand about how distruptive a change that would be.)It also seems pretty OpenBMC-specific, whereas I'd expect we want to aim for greater generality in things going into mainline.
First of all, it's for labeling of sysfs interfaces in hwmon subsystem which monitors target CPUs, not for local CPUs you mentioned. As you can see in hwmon subsystem, property indexing starts from 1. Also, we have used this natural number indexing traditionally for all Intel BMCs we made so far, and it's also for keeping product value against misreading of actual core numbers. If you don't have any critical or blocking issue, I need to keep the current indexing as is.
Thanks,
Jae
Re: [PATCH 2/2] peci-cputemp: label CPU cores from zero instead of one
In reply to Zev WeissQuoted 22 lines · Zev Weiss
Quoted 12 lines · Jae Hyun Yoo
Quoted 11 lines
Oh I see -- I had thought you were referring to other existing hwmon drivers in the kernel.
As far as I can tell, all those instances appear to be numbering CPU *sockets* though -- which as Jason mentioned in a call earlier today I gather is done to line up with motherboard silkscreen labeling. But in the code in question here we're labeling *cores* within a given socket, which I don't see arising anywhere in any existing entity-manager configs. So I'm still unclear on why we want to use one-based indexing here instead of zero-based -- I'd think we'd want the PECI driver to match the PECI spec?
Quoted 7 lines
PECI driver uses zero-based index for PECI command handling but label is user facing stuff which shouldn't make confusion to users. We can modify driver like you did in this patch and previous driver also used zero-based indexing but I changed it to natural number based indexing to avoid confusion between driver labels and dbus-sensors names. Any specific reason for the zero-based indexing? Any benefit?
Quoted 1 line
[Re-adding CCs...]
Thanks. Please keep the discussion on the list.
Quoted 11 lines
Well, as I see it basically just consistency with a larger set of things. Most other related numbering schemes I'm aware of are zero-based -- userspace tools like 'taskset' and 'lscpu', system APIs like the <
sched.h>CPU_SET()routines, and the kernel's own numbering (e.g. what's shown in/proc/cpuinfo) all number processors starting from zero, so dbus-sensors seems kind of like the odd one out there. (Personally I'd be fully in support of changing it to be zero-based as well, though I have no idea offhand about how distruptive a change that would be.)
Quoted 2 lines
It also seems pretty OpenBMC-specific, whereas I'd expect we want to aim for greater generality in things going into mainline.
Agreed. The hwmon numbering varies; some attributes are zero indexed and some start at 1. More commonly we start counting from zero in the kernel, so I would expect PECI to do the same.
If there's some userspace that depends on the behaviour of these out of tree PECI patches, then that userspace will need to change. This reminds us why the project prefers patches exposing userspace ABI are merged to mainline first.
Cheers,
Joel
Jae Hyun Yoo
Reviewed-byRe: [PATCH 2/2] peci-cputemp: label CPU cores from zero instead of one
Hi Zev,
Quoted 41 lines · Joel Stanley
Quoted 22 lines · Zev Weiss
Quoted 12 lines · Jae Hyun Yoo
Quoted 11 lines
Oh I see -- I had thought you were referring to other existing hwmon drivers in the kernel.
As far as I can tell, all those instances appear to be numbering CPU *sockets* though -- which as Jason mentioned in a call earlier today I gather is done to line up with motherboard silkscreen labeling. But in the code in question here we're labeling *cores* within a given socket, which I don't see arising anywhere in any existing entity-manager configs. So I'm still unclear on why we want to use one-based indexing here instead of zero-based -- I'd think we'd want the PECI driver to match the PECI spec?
Quoted 7 lines
PECI driver uses zero-based index for PECI command handling but label is user facing stuff which shouldn't make confusion to users. We can modify driver like you did in this patch and previous driver also used zero-based indexing but I changed it to natural number based indexing to avoid confusion between driver labels and dbus-sensors names. Any specific reason for the zero-based indexing? Any benefit?
Quoted 1 line
[Re-adding CCs...]
Thanks. Please keep the discussion on the list.
Quoted 11 lines
Well, as I see it basically just consistency with a larger set of things. Most other related numbering schemes I'm aware of are zero-based -- userspace tools like 'taskset' and 'lscpu', system APIs like the <
sched.h>CPU_SET()routines, and the kernel's own numbering (e.g. what's shown in/proc/cpuinfo) all number processors starting from zero, so dbus-sensors seems kind of like the odd one out there. (Personally I'd be fully in support of changing it to be zero-based as well, though I have no idea offhand about how distruptive a change that would be.)Quoted 2 lines
It also seems pretty OpenBMC-specific, whereas I'd expect we want to aim for greater generality in things going into mainline.
Quoted 8 lines
Agreed. The hwmon numbering varies; some attributes are zero indexed and some start at 1. More commonly we start counting from zero in the kernel, so I would expect PECI to do the same.
If there's some userspace that depends on the behaviour of these out of tree PECI patches, then that userspace will need to change. This reminds us why the project prefers patches exposing userspace ABI are merged to mainline first.
Okay. Not a big deal. The coretemp module for local CPU also uses zero starting label index for core numbers so better match up. Thanks for your patch.
Joel Stanley
AppliedRe: [PATCH 2/2] peci-cputemp: label CPU cores from zero instead of one
Quoted 54 lines · Jae Hyun Yoo
Hi Zev,
Quoted 41 lines · Joel Stanley
Quoted 22 lines · Zev Weiss
Quoted 12 lines · Jae Hyun Yoo
Quoted 11 lines
Oh I see -- I had thought you were referring to other existing hwmon drivers in the kernel.
As far as I can tell, all those instances appear to be numbering CPU *sockets* though -- which as Jason mentioned in a call earlier today I gather is done to line up with motherboard silkscreen labeling. But in the code in question here we're labeling *cores* within a given socket, which I don't see arising anywhere in any existing entity-manager configs. So I'm still unclear on why we want to use one-based indexing here instead of zero-based -- I'd think we'd want the PECI driver to match the PECI spec?
Quoted 7 lines
PECI driver uses zero-based index for PECI command handling but label is user facing stuff which shouldn't make confusion to users. We can modify driver like you did in this patch and previous driver also used zero-based indexing but I changed it to natural number based indexing to avoid confusion between driver labels and dbus-sensors names. Any specific reason for the zero-based indexing? Any benefit?
Quoted 1 line
[Re-adding CCs...]
Thanks. Please keep the discussion on the list.
Quoted 11 lines
Well, as I see it basically just consistency with a larger set of things. Most other related numbering schemes I'm aware of are zero-based -- userspace tools like 'taskset' and 'lscpu', system APIs like the <
sched.h>CPU_SET()routines, and the kernel's own numbering (e.g. what's shown in/proc/cpuinfo) all number processors starting from zero, so dbus-sensors seems kind of like the odd one out there. (Personally I'd be fully in support of changing it to be zero-based as well, though I have no idea offhand about how distruptive a change that would be.)Quoted 2 lines
It also seems pretty OpenBMC-specific, whereas I'd expect we want to aim for greater generality in things going into mainline.
Quoted 8 lines
Agreed. The hwmon numbering varies; some attributes are zero indexed and some start at 1. More commonly we start counting from zero in the kernel, so I would expect PECI to do the same.
If there's some userspace that depends on the behaviour of these out of tree PECI patches, then that userspace will need to change. This reminds us why the project prefers patches exposing userspace ABI are merged to mainline first.
Quoted 5 lines
Okay. Not a big deal. The coretemp module for local CPU also uses zero starting label index for core numbers so better match up. Thanks for your patch.
Reviewed-by Jae Hyun Yoo <[email protected]>
Applied to dev-5.8.
Cheers,
Joel
Hello Zev,
Quoted 10 lines · Zev Weiss
[Re-sending as I clumsily typoed the mailing list's address on the first attempt; apologies for the duplication.]
Hello,
These patches address a few small things I noticed with the PECI patch set currently in the OpenBMC kernel tree. Assuming they're deemed acceptable, I'd of course hope they get folded in to the version of the PECI code that gets upstreamed into the mainline kernel.
Quoted 4 lines
(Please let me know if there's some other way I should send this -- I looked for but couldn't find a gerrit repo for the obmc kernel or any kernel-specific patch submission instructions in
openbmc/docs/CONTRIBUTING.md, so 'git send-email' is my best guess.)
This mailing list would be a right place as long as the PECI patch set is in OpenBMC kernel tree but in case if it is removed from the tree later (probably from the 5.9 kernel), you may need to use pull request through https://github.com/Intel-BMC/openbmc when it replaces the kernel repo with forked kernel.
Thanks,
Jae
Quoted 5 lines
Thanks,
Zev