V2: Fix C states and P states presentation issue.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Austin Zhang
PATCH 1/1 V2: Fix C states and P states presentation issue.
If using '10' in this 'for' loop, for P states, once the processor provides more than 10 P states, those additional ones cannot been presented; and for C states, once the processor provides maximize C states level more than 9, for example, it only has POLL, C1, C3, C6, C10, the additional one like C10 also cannot be presented.
Now we get the loop numbers from the system information we had got before.
Changes from V1:
Using std:max to simplify codes
--- src/cpu/cpu.cpp | 36 +++++++++++++++++++++++++++++------- 1 files changed, 29 insertions(+), 7 deletions(-)
src/cpu/cpu.cpp +29 -7
@@ -402,8 +402,16 @@ void report_display_cpu_cstates(void) { char buffer[512], buffer2[512]; unsigned int package, core, cpu; - int line; + int line, cstates_num; class abstract_cpu *_package, * _core, * _cpu; + unsigned int i, j; + + for (i = 0, cstates_num = 0; i < all_cpus.size(); i++) { + if (all_cpus[i]) + for (j = 0; j < all_cpus[i]->cstates.size(); j++) + cstates_num = std::max(cstates_num, + (all_cpus[i]->cstates[j])->line_level); + } report.begin_section(SECTION_CPUIDLE); report.add_header("Processor Idle state report");
@@ -421,7 +429,7 @@ void report_display_cpu_cstates(void) if (!_core) continue; - for (line = LEVEL_HEADER; line < 10; line++) { + for (line = LEVEL_HEADER; line <= cstates_num; line++) { bool first_cpu = true; if (!_package->has_cstate_level(line))
@@ -628,14 +636,29 @@ void impl_w_display_cpu_states(int state) char buffer[128]; char linebuf[1024]; unsigned int package, core, cpu; - int line; + int line, loop, cstates_num, pstates_num; class abstract_cpu *_package, * _core, * _cpu; int ctr = 0; + unsigned int i, j; + + for (i = 0, cstates_num = 0, pstates_num = 0; i < all_cpus.size(); i++) { + if (!all_cpus[i]) + continue; - if (state == PSTATE) + pstates_num = std::max<int>(pstates_num, all_cpus[i]->pstates.size()); + + for (j = 0; j < all_cpus[i]->cstates.size(); j++) + cstates_num = std::max(cstates_num, + (all_cpus[i]->cstates[j])->line_level); + } + + if (state == PSTATE) { win = get_ncurses_win("Frequency stats"); - else + loop = pstates_num; + } else { win = get_ncurses_win("Idle stats"); + loop = cstates_num; + } if (!win) return;
@@ -656,8 +679,7 @@ void impl_w_display_cpu_states(int state) if (!_core->has_pstates() && state == PSTATE) continue; - - for (line = LEVEL_HEADER; line < 10; line++) { + for (line = LEVEL_HEADER; line <= loop; line++) { int first = 1; ctr = 0; linebuf[0] = 0;
Signature · 1 line
1.7.5.4
Sergey Senozhatsky
Quoted 6 lines · Austin Zhang
If using '10' in this 'for' loop, for P states, once the processor provides more than 10 P states, those additional ones cannot been presented; and for C states, once the processor provides maximize C states level more than 9, for example, it only has POLL, C1, C3, C6, C10, the additional one like C10 also cannot be presented.
Quoted 8 lines
Now we get the loop numbers from the system information we had got before.
Changes from V1:
Using std:max to simplify codesSigned-off-by Austin Zhang <zhang.austin(a)gmail.com>---
looks good to me.
-ss
Quoted 85 lines
src/cpu/cpu.cpp | 36 +++++++++++++++++++++++++++++------- 1 files changed, 29 insertions(+), 7 deletions(-)src/cpu/cpu.cpp +29
-7@@ -402,8 +402,16 @@ void report_display_cpu_cstates(void) { char buffer[512], buffer2[512]; unsigned int package, core, cpu; - int line; + int line, cstates_num; class abstract_cpu *_package, * _core, * _cpu; + unsigned int i, j; + + for (i = 0, cstates_num = 0; i < all_cpus.size(); i++) { + if (all_cpus[i]) + for (j = 0; j < all_cpus[i]->cstates.size(); j++) + cstates_num = std::max(cstates_num, + (all_cpus[i]->cstates[j])->line_level); + } report.begin_section(SECTION_CPUIDLE); report.add_header("Processor Idle state report");@@ -421,7 +429,7 @@ void report_display_cpu_cstates(void) if (!_core) continue; - for (line = LEVEL_HEADER; line < 10; line++) { + for (line = LEVEL_HEADER; line <= cstates_num; line++) { bool first_cpu = true; if (!_package->has_cstate_level(line))@@ -628,14 +636,29 @@ void impl_w_display_cpu_states(int state) char buffer[128]; char linebuf[1024]; unsigned int package, core, cpu; - int line; + int line, loop, cstates_num, pstates_num; class abstract_cpu *_package, * _core, * _cpu; int ctr = 0; + unsigned int i, j; + + for (i = 0, cstates_num = 0, pstates_num = 0; i < all_cpus.size(); i++) { + if (!all_cpus[i]) + continue; - if (state == PSTATE) + pstates_num = std::max<int>(pstates_num, all_cpus[i]->pstates.size()); + + for (j = 0; j < all_cpus[i]->cstates.size(); j++) + cstates_num = std::max(cstates_num, + (all_cpus[i]->cstates[j])->line_level); + } + + if (state == PSTATE) { win = get_ncurses_win("Frequency stats"); - else + loop = pstates_num; + } else { win = get_ncurses_win("Idle stats"); + loop = cstates_num; + } if (!win) return;@@ -656,8 +679,7 @@ void impl_w_display_cpu_states(int state) if (!_core->has_pstates() && state == PSTATE) continue; - - for (line = LEVEL_HEADER; line < 10; line++) { + for (line = LEVEL_HEADER; line <= loop; line++) { int first = 1; ctr = 0; linebuf[0] = 0;Signature · 6 lines
1.7.5.4 _______________________________________________ PowerTop mailing list PowerTop(a)lists.01.org https://lists.01.org/mailman/listinfo/powertop
Sergey Senozhatsky
Quoted 62 lines · Austin Zhang
Date: Tue, 22 Jan 2013 19:43:32 +0800
From: Austin Zhang <zhang.austin(a)gmail.com>
To: powertop(a)lists.01.org
Subject: [Powertop] [PATCH] V2: Fix C states and P states presentation
issue.
X-Mailer: git-send-email 1.7.5.4If using '10' in this 'for' loop, for P states, once the processor provides more than 10 P states, those additional ones cannot been presented; and for C states, once the processor provides maximize C states level more than 9, for example, it only has POLL, C1, C3, C6, C10, the additional one like C10 also cannot be presented.
Now we get the loop numbers from the system information we had got before.
Changes from V1:
Using std:max to simplify codesSigned-off-by Austin Zhang <zhang.austin(a)gmail.com>--- src/cpu/cpu.cpp | 36 +++++++++++++++++++++++++++++------- 1 files changed, 29 insertions(+), 7 deletions(-)src/cpu/cpu.cpp +11
-3@@ -402,8 +402,16 @@ void report_display_cpu_cstates(void) { char buffer[512], buffer2[512]; unsigned int package, core, cpu; - int line; + int line, cstates_num; class abstract_cpu *_package, * _core, * _cpu; + unsigned int i, j; + + for (i = 0, cstates_num = 0; i < all_cpus.size(); i++) { + if (all_cpus[i]) + for (j = 0; j < all_cpus[i]->cstates.size(); j++) + cstates_num = std::max(cstates_num, + (all_cpus[i]->cstates[j])->line_level); + } report.begin_section(SECTION_CPUIDLE); report.add_header("Processor Idle state report");@@ -421,7 +429,7 @@ void report_display_cpu_cstates(void) if (!_core) continue; - for (line = LEVEL_HEADER; line < 10; line++) { + for (line = LEVEL_HEADER; line <= cstates_num; line++) { bool first_cpu = true; if (!_package->has_cstate_level(line))@@ -628,14 +636,29 @@ void impl_w_display_cpu_states(int state) char buffer[128]; char linebuf[1024]; unsigned int package, core, cpu; - int line; + int line, loop, cstates_num, pstates_num; class abstract_cpu *_package, * _core, * _cpu;
src/cpu/cpu.cpp void impl_w_display_cpu_states(int state) · line 649
Quoted 10 lines
src/cpu/cpu.cpp +7
-1int ctr = 0; + unsigned int i, j; + + for (i = 0, cstates_num = 0, pstates_num = 0; i < all_cpus.size(); i++) { + if (!all_cpus[i]) + continue; - if (state == PSTATE) + pstates_num = std::max<int>(pstates_num, all_cpus[i]->pstates.size()); +
just for note, perhaps we can do the same for pstates_num in report_display_cpu_pstates(), to keep it similar.
-ss
Quoted 34 lines
src/cpu/cpu.cpp +11
-3+ for (j = 0; j < all_cpus[i]->cstates.size(); j++) + cstates_num = std::max(cstates_num, + (all_cpus[i]->cstates[j])->line_level); + } + + if (state == PSTATE) { win = get_ncurses_win("Frequency stats"); - else + loop = pstates_num; + } else { win = get_ncurses_win("Idle stats"); + loop = cstates_num; + } if (!win) return;@@ -656,8 +679,7 @@ void impl_w_display_cpu_states(int state) if (!_core->has_pstates() && state == PSTATE) continue; - - for (line = LEVEL_HEADER; line < 10; line++) { + for (line = LEVEL_HEADER; line <= loop; line++) { int first = 1; ctr = 0; linebuf[0] = 0;Signature · 6 lines
1.7.5.4 _______________________________________________ PowerTop mailing list PowerTop(a)lists.01.org https://lists.01.org/mailman/listinfo/powertop
Austin Zhang
PATCH 1/1 Using std::max to handle all such kind of logic
--- src/cpu/cpu.cpp | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
src/cpu/cpu.cpp +3 -2
@@ -525,8 +525,9 @@ void report_display_cpu_pstates(void) unsigned int i, pstates_num; for (i = 0, pstates_num = 0; i < all_cpus.size(); i++) - if (all_cpus[i] && all_cpus[i]->pstates.size() > pstates_num) - pstates_num = all_cpus[i]->pstates.size(); + if (all_cpus[i]) + pstates_num = std::max<unsigned int>(pstates_num, + all_cpus[i]->pstates.size()); report.begin_section(SECTION_CPUFREQ); report.add_header("Processor Frequency Report");
Signature · 1 line
1.7.5.4
Sergey Senozhatsky
Re: [Powertop] [PATCH] Using std::max to handle all such kind of logic
Quoted 8 lines · Austin Zhang
Date: Wed, 23 Jan 2013 11:54:47 +0800
From: Austin Zhang <zhang.austin(a)gmail.com>
To: powertop(a)lists.01.org
Cc: sergey.senozhatsky(a)gmail.com, i.zhbanov(a)samsung.com, Austin Zhang
<zhang.austin(a)gmail.com>
Subject: [PATCH] Usingstd::maxto handle all such kind of logic
X-Mailer: git-send-email 1.7.5.4
Quoted 5 lines
Signed-off-by Austin Zhang <zhang.austin(a)gmail.com>--- src/cpu/cpu.cpp | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
looks good to me.
-ss
Quoted 19 lines
src/cpu/cpu.cpp +3
-2@@ -525,8 +525,9 @@ void report_display_cpu_pstates(void) unsigned int i, pstates_num; for (i = 0, pstates_num = 0; i < all_cpus.size(); i++) - if (all_cpus[i] && all_cpus[i]->pstates.size() > pstates_num) - pstates_num = all_cpus[i]->pstates.size(); + if (all_cpus[i]) + pstates_num = std::max<unsigned int>(pstates_num, + all_cpus[i]->pstates.size()); report.begin_section(SECTION_CPUFREQ); report.add_header("Processor Frequency Report");Signature · 1 line
1.7.5.4
Magnus Fromreide
Re: [Powertop] [PATCH] Using std::max to handle all such kind of logic
In reply to Austin ZhangQuoted 10 lines · Austin Zhang
Signed-off-by Austin Zhang <zhang.austin(a)gmail.com>--- src/cpu/cpu.cpp | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)src/cpu/cpu.cpp +0
-0
src/cpu/cpu.cpp void report_display_cpu_pstates(void) · line 530
Quoted 8 lines
src/cpu/cpu.cpp +3
-2@@ -525,8 +525,9 @@ void report_display_cpu_pstates(void) unsigned int i, pstates_num; for (i = 0, pstates_num = 0; i < all_cpus.size(); i++) - if (all_cpus[i] && all_cpus[i]->pstates.size() > pstates_num) - pstates_num = all_cpus[i]->pstates.size(); + if (all_cpus[i]) + pstates_num = std::max<unsigned int>(pstates_num, + all_cpus[i]->pstates.size());
There should be no need to specify the template argument if pstates_num is declared to the right type.
The return type of vector<T>::size() is vector<T>::size_type. Thus I think this is a nicer version:
vector<frequency*>::size_type pstates_num;
for (i = 0, pstates_num = 0; i < all_cpus.size(); ++i)
if (all_cpus[i]) pstates_num = max(pstates_num, all_cpus[i]->pstates.size());
What do you think?
/MF
Austin Zhang
Re: [Powertop] [PATCH] Using std::max to handle all such kind of logic
Magnus,
Thanks for your comments. In fact, as to this, I don't have much points because from my limited knowledge, there was not too much difference/benefit just from logic.
Maybe others can give some brilliant points.
Thanks.
2013/1/23 Magnus Fromreide <magfr(a)lysator.liu.se>
Quoted 39 lines · Austin Zhang
Quoted 10 lines
Signed-off-by Austin Zhang <zhang.austin(a)gmail.com>--- src/cpu/cpu.cpp | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)src/cpu/cpu.cpp +0
-0src/cpu/cpu.cpp void report_display_cpu_pstates(void) · line 528
Quoted 4 lines
src/cpu/cpu.cpp +0
-1@@ -525,8 +525,9 @@ void report_display_cpu_pstates(void) unsigned int i, pstates_num; for (i = 0, pstates_num = 0; i < all_cpus.size(); i++) - if (all_cpus[i] && all_cpus[i]->pstates.size() >
pstates_num)src/cpu/cpu.cpp void report_display_cpu_pstates(void)
Quoted 4 lines
src/cpu/cpu.cpp +3
-1- pstates_num = all_cpus[i]->pstates.size(); + if (all_cpus[i]) + pstates_num = std::max<unsigned int>(pstates_num, +all_cpus[i]->pstates.size());
There should be no need to specify the template argument if
pstates_numis declared to the right type.
The return type of vector<T>::size() is vector<T>::size_type. Thus I think this is a nicer version:vector<frequency*>::size_type
pstates_num;for (i = 0,
pstates_num= 0; i <all_cpus.size(); ++i)
if (all_cpus[i])
pstates_num= max(pstates_num,
all_cpus[i]->pstates.size());What do you think?
/MF
Sergey Senozhatsky
Re: [Powertop] [PATCH] Using std::max to handle all such kind of logic
In reply to Magnus FromreideQuoted 21 lines · Magnus Fromreide
Date: Wed, 23 Jan 2013 08:53:12 +0100
From: Magnus Fromreide <magfr(a)lysator.liu.se>
To: Austin Zhang <zhang.austin(a)gmail.com>
Cc: powertop(a)lists.01.org
Subject: Re: [Powertop] [PATCH] Usingstd::maxto handle all such kind of
logic
X-Mailer: Evolution 3.4.4-1Quoted 12 lines · Austin Zhang
Signed-off-by Austin Zhang <zhang.austin(a)gmail.com>--- src/cpu/cpu.cpp | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)src/cpu/cpu.cpp +0
-0@@ -525,8 +525,9 @@ void report_display_cpu_pstates(void) unsigned int i, pstates_num;
Quoted 9 lines
src/cpu/cpu.cpp void report_display_cpu_pstates(void) · line 530
Quoted 6 lines
src/cpu/cpu.cpp +3
-2for (i = 0, pstates_num = 0; i < all_cpus.size(); i++) - if (all_cpus[i] && all_cpus[i]->pstates.size() > pstates_num) - pstates_num = all_cpus[i]->pstates.size(); + if (all_cpus[i]) + pstates_num = std::max<unsigned int>(pstates_num, + all_cpus[i]->pstates.size());There should be no need to specify the template argument if
pstates_numis declared to the right type.
I personally don't have any objections to specify template arguments (and may be find it even more verbal), it never bothered me.
-ss
Quoted 18 lines
The return type of vector<T>::size() is vector<T>::size_type. Thus I think this is a nicer version:
vector<frequency*>::size_type
pstates_num;for (i = 0,
pstates_num= 0; i <all_cpus.size(); ++i)if (all_cpus[i]) pstates_num = max(pstates_num, all_cpus[i]->pstates.size());What do you think?
/MF
_______________________________________________
PowerTop mailing list
PowerTop(a)lists.01.org
https://lists.01.org/mailman/listinfo/powertop
Kristen Carlson Accardi
AppliedRe: [Powertop] [PATCH] Using std::max to handle all such kind of logic
In reply to Austin ZhangQuoted 21 lines · On Wed, 23 Jan 2013 11:54:47 +0800 Austin Zhang <zhang.austin(a)gmail.com>…
Signed-off-by Austin Zhang <zhang.austin(a)gmail.com>--- src/cpu/cpu.cpp | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)src/cpu/cpu.cpp +3
-2@@ -525,8 +525,9 @@ void report_display_cpu_pstates(void) unsigned int i, pstates_num; for (i = 0, pstates_num = 0; i < all_cpus.size(); i++) - if (all_cpus[i] && all_cpus[i]->pstates.size() > pstates_num) - pstates_num = all_cpus[i]->pstates.size(); + if (all_cpus[i]) + pstates_num = std::max<unsigned int>(pstates_num, + all_cpus[i]->pstates.size());
src/cpu/cpu.cpp void report_display_cpu_pstates(void) · line 533
Quoted 2 lines
src/cpu/cpu.cpp +0
-0report.begin_section(SECTION_CPUFREQ); report.add_header("Processor Frequency Report");
Applied, thanks.
Kristen
Igor Zhbanov
Quoted 2 lines · Sergey Senozhatsky
just for note, perhaps we can do the same for
pstates_numinreport_display_cpu_pstates(), to keep it similar.
I don't have any objection. It could be the same for pstates. I didn't send the patch for cstates because was not sure that there are architectures with more than 10 cstates. Austin pointed that IA is. So both pstates and cstates handling could be fixed in the same way.
Signature · 9 lines
Best regards, Igor Zhbanov, Technical Leader, phone: +7 (495) 797 25 00 ext 3806 e-mail: i.zhbanov(a)samsung.com Mobile group, Moscow R&D center, Samsung Electronics 12 Dvintsev street, building 1 127018, Moscow, Russian Federation
Kristen Carlson Accardi
AppliedQuoted 96 lines · On Tue, 22 Jan 2013 19:43:32 +0800 Austin Zhang <zhang.austin(a)gmail.com>…
If using '10' in this 'for' loop, for P states, once the processor provides more than 10 P states, those additional ones cannot been presented; and for C states, once the processor provides maximize C states level more than 9, for example, it only has POLL, C1, C3, C6, C10, the additional one like C10 also cannot be presented.
Now we get the loop numbers from the system information we had got before.
Changes from V1:
Using std:max to simplify codesSigned-off-by Austin Zhang <zhang.austin(a)gmail.com>--- src/cpu/cpu.cpp | 36 +++++++++++++++++++++++++++++------- 1 files changed, 29 insertions(+), 7 deletions(-)src/cpu/cpu.cpp +9
-1@@ -402,8 +402,16 @@ void report_display_cpu_cstates(void) { char buffer[512], buffer2[512]; unsigned int package, core, cpu; - int line; + int line, cstates_num; class abstract_cpu *_package, * _core, * _cpu; + unsigned int i, j; + + for (i = 0, cstates_num = 0; i < all_cpus.size(); i++) { + if (all_cpus[i]) + for (j = 0; j < all_cpus[i]->cstates.size(); j++) + cstates_num = std::max(cstates_num, + (all_cpus[i]->cstates[j])->line_level); + }src/cpu/cpu.cpp +1
-1report.begin_section(SECTION_CPUIDLE); report.add_header("Processor Idle state report");@@ -421,7 +429,7 @@ void report_display_cpu_cstates(void) if (!_core) continue; - for (line = LEVEL_HEADER; line < 10; line++) { + for (line = LEVEL_HEADER; line <= cstates_num; line++) { bool first_cpu = true;if
(!_package->has_cstate_level(line)) @@ -628,14 +636,29 @@ voidimpl_w_display_cpu_states(int state)char buffer[128];src/cpu/cpu.cpp +4
-1char linebuf[1024]; unsigned int package, core, cpu; - int line; + int line, loop, cstates_num, pstates_num; class abstract_cpu *_package, * _core, * _cpu; int ctr = 0; + unsigned int i, j; + + for (i = 0, cstates_num = 0, pstates_num = 0; i <
all_cpus.size(); i++) {src/cpu/cpu.cpp +3
-1+ if (!all_cpus[i]) + continue; - if (state == PSTATE) + pstates_num = std::max<int>(pstates_num,all_cpus[i]->pstates.size()); +
src/cpu/cpu.cpp +3
-0+ for (j = 0; j < all_cpus[i]->cstates.size(); j++) + cstates_num = std::max(cstates_num, +(all_cpus[i]->cstates[j])->line_level);
src/cpu/cpu.cpp +8
-3+ } + + if (state == PSTATE) { win = get_ncurses_win("Frequency stats"); - else + loop = pstates_num; + } else { win = get_ncurses_win("Idle stats"); + loop = cstates_num; + } if (!win) return;@@ -656,8 +679,7 @@ void impl_w_display_cpu_states(int state) if (!_core->has_pstates() && state == PSTATE) continue; - - for (line = LEVEL_HEADER; line < 10; line++) { + for (line = LEVEL_HEADER; line <= loop; line++) { int first = 1; ctr = 0;
Quoted 1 line
linebuf[0] = 0;
Applied, thanks.
Kristen
Paul Menzel
Dear Kristen, dear Austin,
Austin, thank you for the patch and Kristen, thank you for committing it.
Am Donnerstag, den 31.01.2013, 15:39 -0800 schrieb Kristen Carlson Accardi:
Quoted 2 lines
On Tue, 22 Jan 2013 19:43:32 +0800
Austin Zhang <zhang.austin(a)gmail.com> wrote:
Austin, when sending patch iterations, please make sure to include the version into the brackets: [PATCH v2]. Otherwise git am will not remove it.
[…]
Quoted 11 lines
Quoted 11 lines
src/cpu/cpu.cpp +1
-2@@ -656,8 +679,7 @@ void impl_w_display_cpu_states(int state) if (!_core->has_pstates() && state == PSTATE) continue; - - for (line = LEVEL_HEADER; line < 10; line++) { + for (line = LEVEL_HEADER; line <= loop; line++) { int first = 1; ctr = 0;linebuf[0] = 0;
Kristen, please do not line wrap replies (at least code pastes) for better legibility.
Quoted 1 line
Applied, thanks.
Kristen, please double check when applying a patch. As know the commit history contains that »V2:« confusing people looking at the commit log. That would be great.
Thanks,
Paul
Austin Zhang
Re: [Powertop] [PATCH] Fix C states and P states presentation issue.
In reply to a message not in the archiveHi, list,
Just find I just click 'reply-to' to ss, and doesn't cc/to powertop(a)lists.01.org in this thread for those before feedback, sorry for this.
Copy to here so that maybe Igor has comments also:
Quoted 1 line
Hm, I'm sure I've seen this before. Was it the same patch from you?
No, I didn't watch those patches from mailling list, just found this issue in my daily working and then work out this patch. And I also didn't send it before.
Quoted 1 line
Ok, I found it: "Display all P-states in HTML-report"
(http://lists.01.org/pipermail/powertop/2012-July/000161.html).
Thanks, just read it, it is only for pstates and this patch is learning the same way from the mentioned codes. Seemed Igor and I encounter the same situation for ARM and IA respectively :-)
Is the 2 patches conflict? I use the latest codes base from github. Or the same fixing from igor is pending in the pool?
Quoted 1 line
but I'm not sure that CPUs with more than 10 C-states exists.
Yes, I am not sure the ARM case like igor is facing, for IA, yes.
2013/1/22 Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com>
Quoted 170 lines · Austin Zhang
Quoted 9 lines
Date: Tue, 22 Jan 2013 18:40:03 +0800
From: Austin Zhang <zhang.austin(a)gmail.com>
To: Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com>
Subject: Re: [Powertop] [PATCH] Fix C states and P states presentation
issue.Sergey,
Thanks for your review and comments, I will send out V2 by this. �thank you,
-ssQuoted 52 lines
2013/1/22 Sergey Senozhatsky <[1]sergey.senozhatsky(a)gmail.com> On (01/15/13 19:05), Austin Zhang wrote: > Date: Tue, 15 Jan 2013 19:05:18 +0800 > From: Austin Zhang <[2]zhang.austin(a)gmail.com> > To: [3]powertop(a)lists.01.org > Subject: [Powertop] [PATCH] Fix C states and P states presentation issue. > X-Mailer: git-send-email 1.7.5.4 > > If using '10' in this 'for' loop, for P states, once the processor > provides more than 10 P states, those additional ones cannot been > presented; and for C states, once the processor provides maximize > C states level more than 9, for example, it only has POLL, C1, C3, > C6, C10, the additional one like C10 also cannot be presented. > > Now we get the loop numbers from the system information we had got > before. > > Signed-off-by: Austin Zhang <[4]zhang.austin(a)gmail.com> > --- > �src/cpu/cpu.cpp | � 35 +++++++++++++++++++++++++++++------ > �1 files changed, 29 insertions(+), 6 deletions(-) > > diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp > index 7f3af69..28f77b7 100644 > --- a/src/cpu/cpu.cpp > +++ b/src/cpu/cpu.cpp > @@ -404,6 +404,15 @@ void report_display_cpu_cstates(void) > � � � unsigned int package, core, cpu; > � � � int line; > � � � class abstract_cpu *_package, * _core, * _cpu; > + � � unsigned int i, j, cstates_num; > + > + � � for (i = 0, cstates_num = 0; i < all_cpus.size(); i++) { > + � � � � � � if (all_cpus[i]) > + � � � � � � � � � � for (j = 0; j < all_cpus[i]->cstates.size(); j++) > + � � � � � � � � � � � � � � if ((all_cpus[i]->cstates[j])->line_level >= 0 && > + � � � � � � � � � � � � � � � � (all_cpus[i]->cstates[j])->line_level > cstates_num) > + � � � � � � � � � � � � � � � � � � cstates_num = (all_cpus[i]->cstates[j])->line_level; > + � � } > how about removing this `if' condition? � � � � for (j = 0; j < all_cpus[i]->cstates.size(); j++) � � � � � � � � cstates_num = std::max(cstates_num, (all_cpus[i]->cstates[j])->line_level);Quoted 7 lines
> � � � report.begin_section(SECTION_CPUIDLE); > � � � report.add_header("Processor Idle state report"); > @@ -421,7 +430,7 @@ void report_display_cpu_cstates(void) > � � � � � � � � � � � if (!_core) > � � � � � � � � � � � � � � � continue; > > - � � � � � � � � � � for (line = LEVEL_HEADER; line < 10;line++) {
Quoted 5 lines
> + � � � � � � � � � � for (line = LEVEL_HEADER; line <= (int)cstates_num; line++) { > � � � � � � � � � � � � � � � bool first_cpu = true; > > � � � � � � � � � � � � � � � if(!_package->has_cstate_level(line))
Quoted 6 lines
> @@ -628,14 +637,29 @@ void impl_w_display_cpu_states(int state) > � � � char buffer[128]; > � � � char linebuf[1024]; > � � � unsigned int package, core, cpu; > - � � int line; > + � � int line, loop;Quoted 8 lines
> � � � class abstract_cpu *_package, * _core, * _cpu; > � � � int ctr = 0; > + � � unsigned int i, j, cstates_num, pstates_num; > + > + � � for (i = 0, cstates_num = 0, pstates_num = 0; i < all_cpus.size(); i++) { we have two all_cpus[i] checks in one for loop, let's change tosingle
Quoted 8 lines
`if (!all_cpus[i]) continue;' > + � � � � � � if (all_cpus[i] && all_cpus[i]->pstates.size() > pstates_num) > + � � � � � � � � � � pstates_num = all_cpus[i]->pstates.size(); > � � � � pstates_num = std::max(pstates_num,all_cpus[i]->pstates.size())
Quoted 25 lines
> - � � if (state == PSTATE) > + � � � � � � if (all_cpus[i]) > + � � � � � � � � � � for (j = 0; j < all_cpus[i]->cstates.size(); j++) > + � � � � � � � � � � � � � � if ((all_cpus[i]->cstates[j])->line_level >= 0 && > + � � � � � � � � � � � � � � � � (all_cpus[i]->cstates[j])->line_level > cstates_num) > + � � � � � � � � � � � � � � � � � � cstates_num = (all_cpus[i]->cstates[j])->line_level; � � � � for (j = 0; j < all_cpus[i]->cstates.size(); j++) � � � � � � � � cstates_num = std::max(cstates_num, (all_cpus[i]->cstates[j])->line_level) � � � � -ss > + � � } > + > + � � if (state == PSTATE) { > � � � � � � � win = get_ncurses_win("Frequency stats"); > - � � else > + � � � � � � loop = (int)pstates_num; > + � � } else {Quoted 8 lines
> � � � � � � � win = get_ncurses_win("Idle stats"); > + � � � � � � loop = (int)cstates_num; > + � � } > > � � � if (!win) > � � � � � � � return; > @@ -656,8 +680,7 @@ void impl_w_display_cpu_states(int state) > � � � � � � � � � � � if (!_core->has_pstates() && state ==PSTATE)
Quoted 4 lines
> � � � � � � � � � � � � � � � continue; > > - > - � � � � � � � � � � for (line = LEVEL_HEADER; line < 10;line++) {
Quoted 1 line
> + � � � � � � � � � � for (line = LEVEL_HEADER; line <= loop;line++)
Quoted 22 lines
{ > � � � � � � � � � � � � � � � int first = 1; > � � � � � � � � � � � � � � � ctr = 0; > � � � � � � � � � � � � � � � linebuf[0] = 0; > -- > 1.7.5.4 > > _______________________________________________ > PowerTop mailing list > [5]PowerTop(a)lists.01.org > [6]https://lists.01.org/mailman/listinfo/powertop >References
Visible links
1. mailto:sergey.senozhatsky(a)gmail.com
2. mailto:zhang.austin(a)gmail.com
3. mailto:powertop(a)lists.01.org
4. mailto:zhang.austin(a)gmail.com
5. mailto:PowerTop(a)lists.01.org
6. https://lists.01.org/mailman/listinfo/powertop