* [PATCH]lscpu: Read available CPUs max and min frequencies
@ 2017-04-17 8:30 Mamatha Inamdar
2017-04-17 9:00 ` Rüdiger Meier
0 siblings, 1 reply; 5+ messages in thread
From: Mamatha Inamdar @ 2017-04-17 8:30 UTC (permalink / raw)
To: util-linux
Problem: On power syatems "lscpu frequency-info" command was always
reading CPU0 max and min frequencies. If CPU0 is guarded or offline
then it used to display max and min frequencies as NULL.
Solution: This patch will check for the available/online CPUs
and read the max/min frequencies of that CPU
Test Results:
Before Patch:
#lscpu (CPU0 is guarded/offline)
Architecture: ppc64le
Byte Order: Little Endian
CPU(s): 120
On-line CPU(s) list: 8-127
Thread(s) per core: 8
Core(s) per socket: 3
Socket(s): 4
NUMA node(s): 4
Model: 2.1 (pvr 004b 0201)
Model name: POWER8E (raw), altivec supported
CPU max MHz: (null)
CPU min MHz: (null)
L1d cache: 64K
L1i cache: 32K
L2 cache: 512K
L3 cache: 8192K
NUMA node0 CPU(s): 8-31
NUMA node1 CPU(s): 32-63
NUMA node16 CPU(s): 64-95
NUMA node17 CPU(s): 96-127
With Patch:
# ./lscpu
Architecture: ppc64le
Byte Order: Little Endian
CPU(s): 120
On-line CPU(s) list: 8-127
Thread(s) per core: 8
Core(s) per socket: 3
Socket(s): 4
NUMA node(s): 4
Model: 2.1 (pvr 004b 0201)
Model name: POWER8E (raw), altivec supported
CPU max MHz: 4322.0000
CPU min MHz: 2061.0000
L1d cache: 64K
L1i cache: 32K
L2 cache: 512K
L3 cache: 8192K
NUMA node0 CPU(s): 8-31
NUMA node1 CPU(s): 32-63
NUMA node16 CPU(s): 64-95
NUMA node17 CPU(s): 96-127
Signed-off-by: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
---
sys-utils/lscpu.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 683fd66..7f92b20 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -1775,7 +1775,7 @@ static void
print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
{
char buf[512];
- int i;
+ int i = 0;
size_t setsize = CPU_ALLOC_SIZE(maxcpus);
print_s(_("Architecture:"), desc->arch);
@@ -1898,9 +1898,21 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
if (desc->static_mhz)
print_s(_("CPU static MHz:"), desc->static_mhz);
if (desc->maxmhz)
- print_s(_("CPU max MHz:"), desc->maxmhz[0]);
+ for (i = 0; i < desc->ncpuspos; i++) {
+ /*Check for the first online CPU */
+ if (desc->present &&
+ CPU_ISSET(real_cpu_num(desc, i), desc->present))
+ break;
+ }
+ print_s(_("CPU max MHz:"), desc->maxmhz[i]);
if (desc->minmhz)
- print_s(_("CPU min MHz:"), desc->minmhz[0]);
+ for (i = 0; i < desc->ncpuspos; i++) {
+ /*Check for the first online CPU */
+ if (desc->present &&
+ CPU_ISSET(real_cpu_num(desc, i), desc->present))
+ break;
+ }
+ print_s(_("CPU min MHz:"), desc->minmhz[i]);
if (desc->bogomips)
print_s(_("BogoMIPS:"), desc->bogomips);
if (desc->virtflag) {
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH]lscpu: Read available CPUs max and min frequencies
2017-04-17 8:30 [PATCH]lscpu: Read available CPUs max and min frequencies Mamatha Inamdar
@ 2017-04-17 9:00 ` Rüdiger Meier
2017-04-17 9:56 ` Mamatha Inamdar
2017-04-18 10:31 ` Karel Zak
0 siblings, 2 replies; 5+ messages in thread
From: Rüdiger Meier @ 2017-04-17 9:00 UTC (permalink / raw)
To: mamatha4, util-linux
On 04/17/2017 10:30 AM, Mamatha Inamdar wrote:
> Problem: On power syatems "lscpu frequency-info" command was always
> reading CPU0 max and min frequencies. If CPU0 is guarded or offline
> then it used to display max and min frequencies as NULL.
>
> Solution: This patch will check for the available/online CPUs
> and read the max/min frequencies of that CPU
Maybe we could do it even more generically, not letting the first lookup
win but really using the minimum/maximum over *all* CPUs. Who knows,
maybe different cores could have different min/max.
cu,
Rudi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH]lscpu: Read available CPUs max and min frequencies
2017-04-17 9:00 ` Rüdiger Meier
@ 2017-04-17 9:56 ` Mamatha Inamdar
2017-04-18 10:31 ` Karel Zak
1 sibling, 0 replies; 5+ messages in thread
From: Mamatha Inamdar @ 2017-04-17 9:56 UTC (permalink / raw)
To: Rüdiger Meier, util-linux
Thanks for reviewing,
On 04/17/2017 02:30 PM, Rüdiger Meier wrote:
> On 04/17/2017 10:30 AM, Mamatha Inamdar wrote:
>> Problem: On power syatems "lscpu frequency-info" command was always
>> reading CPU0 max and min frequencies. If CPU0 is guarded or offline
>> then it used to display max and min frequencies as NULL.
>>
>> Solution: This patch will check for the available/online CPUs
>> and read the max/min frequencies of that CPU
>
> Maybe we could do it even more generically, not letting the first
> lookup win but really using the minimum/maximum over *all* CPUs. Who
> knows, maybe different cores could have different min/max.
ok..sure..let me check on this.
>
> cu,
> Rudi
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH]lscpu: Read available CPUs max and min frequencies
2017-04-17 9:00 ` Rüdiger Meier
2017-04-17 9:56 ` Mamatha Inamdar
@ 2017-04-18 10:31 ` Karel Zak
2017-04-27 10:47 ` Mamatha Inamdar
1 sibling, 1 reply; 5+ messages in thread
From: Karel Zak @ 2017-04-18 10:31 UTC (permalink / raw)
To: Rüdiger Meier; +Cc: mamatha4, util-linux
On Mon, Apr 17, 2017 at 11:00:50AM +0200, Rüdiger Meier wrote:
> On 04/17/2017 10:30 AM, Mamatha Inamdar wrote:
> > Problem: On power syatems "lscpu frequency-info" command was always
> > reading CPU0 max and min frequencies. If CPU0 is guarded or offline
> > then it used to display max and min frequencies as NULL.
> >
> > Solution: This patch will check for the available/online CPUs
> > and read the max/min frequencies of that CPU
>
> Maybe we could do it even more generically, not letting the first lookup win
> but really using the minimum/maximum over *all* CPUs. Who knows, maybe
> different cores could have different min/max.
Good point.
We already have this information for all CPUs in the desc->maxmhz[]
and desc->minmhz[]. So all we need is function that will return
max/min from the arrays.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH]lscpu: Read available CPUs max and min frequencies
2017-04-18 10:31 ` Karel Zak
@ 2017-04-27 10:47 ` Mamatha Inamdar
0 siblings, 0 replies; 5+ messages in thread
From: Mamatha Inamdar @ 2017-04-27 10:47 UTC (permalink / raw)
To: Karel Zak, Rüdiger Meier; +Cc: util-linux
Thanks for your review comments...
On 04/18/2017 04:01 PM, Karel Zak wrote:
> On Mon, Apr 17, 2017 at 11:00:50AM +0200, Rüdiger Meier wrote:
>> On 04/17/2017 10:30 AM, Mamatha Inamdar wrote:
>>> Problem: On power syatems "lscpu frequency-info" command was always
>>> reading CPU0 max and min frequencies. If CPU0 is guarded or offline
>>> then it used to display max and min frequencies as NULL.
>>>
>>> Solution: This patch will check for the available/online CPUs
>>> and read the max/min frequencies of that CPU
>> Maybe we could do it even more generically, not letting the first lookup win
>> but really using the minimum/maximum over *all* CPUs. Who knows, maybe
>> different cores could have different min/max.
> Good point.
>
> We already have this information for all CPUs in the desc->maxmhz[]
> and desc->minmhz[]. So all we need is function that will return
> max/min from the arrays.
>
> Karel
I have worked on your comments and sent new version of patch, please
review and let me
know your comments.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-04-27 10:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-17 8:30 [PATCH]lscpu: Read available CPUs max and min frequencies Mamatha Inamdar
2017-04-17 9:00 ` Rüdiger Meier
2017-04-17 9:56 ` Mamatha Inamdar
2017-04-18 10:31 ` Karel Zak
2017-04-27 10:47 ` Mamatha Inamdar
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.