[PATCH] Add bash command-line completion.
by Anthony Wong
Signed-off-by: Anthony Wong <yp(a)anthonywong.net>
---
Makefile.am | 3 +-
configure.ac | 8 ++++++
scripts/bash-completion/Makefile.am | 2 ++
scripts/bash-completion/powertop | 43 +++++++++++++++++++++++++++++
4 files changed, 55 insertions(+), 1 deletion(-)
create mode 100644 scripts/bash-completion/Makefile.am
create mode 100644 scripts/bash-completion/powertop
diff --git a/Makefile.am b/Makefile.am
index 3aabb22..ffb5e91 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,8 @@ SUBDIRS = \
traceevent \
src \
po \
- doc
+ doc \
+ scripts/bash-completion
EXTRA_DIST = \
config.rpath \
diff --git a/configure.ac b/configure.ac
index d6a15e1..ca7f1d5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,6 +17,7 @@ AC_CONFIG_FILES([
traceevent/Makefile
po/Makefile.in
doc/Makefile
+ scripts/bash-completion/Makefile
])
AC_CONFIG_SRCDIR([src/main.cpp])
AC_CONFIG_MACRO_DIR([m4])
@@ -154,4 +155,11 @@ AC_SEARCH_LIBS([inet_aton], [resolv], [], [
AC_DEFINE([PACKAGE_SHORT_VERSION], m4_esyscmd_s([cat version-short]),
[Short package version])
+AS_IF([`pkg-config --exists bash-completion`], [
+ bashcompletiondir=`pkg-config --variable=completionsdir --define-variable=prefix=${prefix} bash-completion`
+], [
+ bashcompletiondir=${datadir}/bash-completion/completions
+])
+AC_SUBST([bashcompletiondir], [$bashcompletiondir])
+
AC_OUTPUT
diff --git a/scripts/bash-completion/Makefile.am b/scripts/bash-completion/Makefile.am
new file mode 100644
index 0000000..45073bd
--- /dev/null
+++ b/scripts/bash-completion/Makefile.am
@@ -0,0 +1,2 @@
+bashcompletiondir = @bashcompletiondir@
+dist_bashcompletion_DATA = powertop
diff --git a/scripts/bash-completion/powertop b/scripts/bash-completion/powertop
new file mode 100644
index 0000000..03d238e
--- /dev/null
+++ b/scripts/bash-completion/powertop
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# Powertop tab completion for bash.
+#
+# This is part of PowerTOP
+#
+# This program file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program in a file named COPYING; if not, write to the
+# Free Software Foundation, Inc,
+# 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301 USA
+# or just google for it.
+
+_powertop()
+{
+ local cur prev words cword split
+ _init_completion -s || return
+
+ case $prev in
+ '-C'|'--csv'|'--extech'|'-r'|'--html'|'-w'|'--workload')
+ _filedir
+ return 0
+ ;;
+ esac
+
+ local all_long_options=$( _parse_help "$1" )
+
+ COMPREPLY=( $( compgen -W "${all_long_options}" -- "$cur" ) )
+
+ return 0
+}
+
+# load the completion
+complete -F _powertop powertop
--
2.20.1
2 years, 11 months
[PATCH] wakeup_xxx.h: include limits.h
by Fabrice Fontaine
limits.h must be included to define PATH_MAX otherwise build will fail
on:
In file included from wakeup/wakeup_ethernet.cpp:45:0:
wakeup/wakeup_ethernet.h:35:16: error: 'PATH_MAX' was not declared in this scope
char eth_path[PATH_MAX];
In file included from wakeup/wakeup_usb.cpp:45:0:
wakeup/wakeup_usb.h:35:16: error: 'PATH_MAX' was not declared in this scope
char usb_path[PATH_MAX];
Fixes:
- http://autobuild.buildroot.org/results/a0b3337cf4a827e6566f8b15b6bb180f0d...
Signed-off-by: Fabrice Fontaine <fontaine.fabrice(a)gmail.com>
---
src/wakeup/wakeup_ethernet.h | 1 +
src/wakeup/wakeup_usb.h | 1 +
2 files changed, 2 insertions(+)
diff --git a/src/wakeup/wakeup_ethernet.h b/src/wakeup/wakeup_ethernet.h
index 682bf95..e0fa628 100644
--- a/src/wakeup/wakeup_ethernet.h
+++ b/src/wakeup/wakeup_ethernet.h
@@ -25,6 +25,7 @@
#ifndef _INCLUDE_GUARD_ETHERNET_WAKEUP_H
#define _INCLUDE_GUARD_ETHERNET_WAKEUP_H
+#include <limits.h>
#include <vector>
#include "wakeup.h"
diff --git a/src/wakeup/wakeup_usb.h b/src/wakeup/wakeup_usb.h
index f7a1f7e..15898e3 100644
--- a/src/wakeup/wakeup_usb.h
+++ b/src/wakeup/wakeup_usb.h
@@ -25,6 +25,7 @@
#ifndef _INCLUDE_GUARD_USB_WAKEUP_H
#define _INCLUDE_GUARD_USB_WAKEUP_H
+#include <limits.h>
#include <vector>
#include "wakeup.h"
--
2.20.1
2 years, 11 months
[PATCH POWERTOP] auto tune option to set everything to bad state
by Koosha Hosseiny
Having the command `tuned-adm profile throughput-performance`, it's also
nice to tell powertop to put everything in bad state.
Also available here: https://github.com/hkoosha/powertop
diff --git a/src/main.cpp b/src/main.cpp
index cbb7a4e..6c23f58 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -75,6 +75,7 @@ void (*ui_notify_user) (const char *frmt, ...);
enum {
OPT_AUTO_TUNE = CHAR_MAX + 1,
+ OPT_AUTO_UNTUNE,
OPT_EXTECH,
OPT_DEBUG
};
@@ -83,6 +84,7 @@ static const struct option long_options[] =
{
/* These options set a flag. */
{"auto-tune", no_argument, NULL, OPT_AUTO_TUNE},
+ {"auto-untune", no_argument, NULL, OPT_AUTO_UNTUNE},
{"calibrate", no_argument, NULL, 'c'},
{"csv", optional_argument, NULL, 'C'},
{"debug", no_argument, &debug_learning, OPT_DEBUG},
@@ -454,6 +456,11 @@ int main(int argc, char **argv)
leave_powertop = 1;
ui_notify_user = ui_notify_user_console;
break;
+ case OPT_AUTO_UNTUNE:
+ auto_tune = 2;
+ leave_powertop = 1;
+ ui_notify_user = ui_notify_user_console;
+ break;
case 'c':
powertop_init(0);
calibrate();
@@ -545,7 +552,7 @@ int main(int argc, char **argv)
tuning_update_display();
show_tab(0);
} else {
- auto_toggle_tuning();
+ auto_toggle_tuning(auto_tune);
}
while (!leave_powertop) {
diff --git a/src/tuning/tuning.cpp b/src/tuning/tuning.cpp
index a54a8ca..4d23ae3 100644
--- a/src/tuning/tuning.cpp
+++ b/src/tuning/tuning.cpp
@@ -316,10 +316,11 @@ void clear_tuning()
all_untunables.clear();
}
-void auto_toggle_tuning()
+void auto_toggle_tuning(int auto_tune)
{
+ int flag = auto_tune == 1 ? TUNE_BAD : TUNE_GOOD;
for (unsigned int i = 0; i < all_tunables.size(); i++) {
- if (all_tunables[i]->good_bad() == TUNE_BAD)
+ if (all_tunables[i]->good_bad() == flag)
all_tunables[i]->toggle();
}
}
diff --git a/src/tuning/tuning.h b/src/tuning/tuning.h
index f70001b..fe3da76 100644
--- a/src/tuning/tuning.h
+++ b/src/tuning/tuning.h
@@ -29,5 +29,5 @@ extern void initialize_tuning(void);
extern void tuning_update_display(void);
extern void report_show_tunables(void);
extern void clear_tuning(void);
-extern void auto_toggle_tuning(void);
+extern void auto_toggle_tuning(int);
#endif
2 years, 12 months
[RESEND] [PATCH] Enable support for Intel ICL
by Kai-Heng Feng
This commit adds support for Intel ICL platforms
Signed-off-by: Kai-Heng Feng <kai.heng.feng(a)canonical.com>
---
src/cpu/intel_cpus.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/cpu/intel_cpus.cpp b/src/cpu/intel_cpus.cpp
index 0030dba..27c70fb 100644
--- a/src/cpu/intel_cpus.cpp
+++ b/src/cpu/intel_cpus.cpp
@@ -70,6 +70,7 @@ static int intel_cpu_models[] = {
0x5c, /* BXT-P */
0x66, /* CNL-U/Y */
0x7A, /* GLK */
+ 0x7E, /* ICL */
0x8E, /* KBL */
0x9E, /* KBL */
0 /* last entry must be zero */
@@ -171,6 +172,7 @@ nhm_core::nhm_core(int model)
case 0x5c: /* BXT-P */
case 0x66: /* CNL-U/Y */
case 0x7A: /* GLK */
+ case 0x7E: /* ICL */
case 0x8E: /* KBL */
case 0x9E: /* KBL */
has_c7_res = 1;
@@ -353,6 +355,7 @@ nhm_package::nhm_package(int model)
case 0x5c: /* BXT-P */
case 0x66: /* CNL-U/Y */
case 0x7A: /* GLK */
+ case 0x7E: /* ICL */
case 0x8E: /* KBL */
case 0x9E: /* KBL */
has_c2c6_res=1;
@@ -387,6 +390,7 @@ nhm_package::nhm_package(int model)
case 0x5c: /* BXT-P */
case 0x66: /* CNL-U/Y */
case 0x7A: /* GLK */
+ case 0x7E: /* ICL */
case 0x8E: /* KBL */
case 0x9E: /* KBL */
has_c8c9c10_res = 1;
--
2.17.1
3 years
[PATCH] event-parse: Add compatibility for non GNU strerror_r
by Rosen Penev
Needed for libraries like musl that do not implement the GNU variant.
Signed-off-by: Rosen Penev <rosenp(a)gmail.com>
---
traceevent/event-parse.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/traceevent/event-parse.c b/traceevent/event-parse.c
index 5a717a0..1f7eb80 100644
--- a/traceevent/event-parse.c
+++ b/traceevent/event-parse.c
@@ -5121,12 +5121,17 @@ int pevent_strerror(struct pevent *pevent __maybe_unused,
const char *msg;
if (errnum >= 0) {
+#if defined(__GLIBC__)
msg = strerror_r(errnum, buf, buflen);
if (msg != buf) {
size_t len = strlen(msg);
memcpy(buf, msg, min(buflen - 1, len));
*(buf + min(buflen - 1, len)) = '\0';
}
+#else
+ if (strerror_r(errnum, buf, buflen))
+ snprintf(buf, buflen, "errnum %i", errnum);
+#endif
return 0;
}
--
2.17.1
3 years
Segfault on ppc64
by Jaroslav Skarvada
PowerTOP crashes on ppc64 machine with 1 idle state, reproducer:
# powertop -t 1 --html
Parameters of the machine are attached.
It seems the problem is caused by the report_display_cpu_cstates()
function from the src/cpu/cpu.cpp file.
On https://github.com/fenrus75/powertop/blob/e8765b5475b22b7a2b6e9e8a031c68a...
it allocates table 2x1, but the table should be 2x2 (header + 1 state), so it
later crashes on
https://github.com/fenrus75/powertop/blob/e8765b5475b22b7a2b6e9e8a031c68a...
where it tries to fill the table.
Unfortunately, the whole reporting code is quite unclear, so I am not sure how
to correctly fix it and not break anything else. The attached patch fixes
the problem for me, but it can have side-effects - feel free to propose
better fix
thanks & regards
Jaroslav
Machine parameters:
# cpupower idle-info
CPUidle driver: pseries_idle
CPUidle governor: menu
analyzing CPU 0:
Number of idle states: 1
Available idle states: Shared Cede
Shared Cede:
Flags/Description: Shared Cede
Latency: 0
Usage: 1188350
Duration: 14152220333
# cat /proc/cpuinfo
processor : 0
cpu : POWER8E (raw), altivec supported
clock : 3425.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 1
cpu : POWER8E (raw), altivec supported
clock : 3425.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 2
cpu : POWER8E (raw), altivec supported
clock : 3425.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 3
cpu : POWER8E (raw), altivec supported
clock : 3425.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 4
cpu : POWER8E (raw), altivec supported
clock : 3425.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 5
cpu : POWER8E (raw), altivec supported
clock : 3425.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 6
cpu : POWER8E (raw), altivec supported
clock : 3425.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 7
cpu : POWER8E (raw), altivec supported
clock : 3425.000000MHz
revision : 2.1 (pvr 004b 0201)
timebase : 512000000
platform : pSeries
model : IBM pSeries (emulated by qemu)
machine : CHRP IBM pSeries (emulated by qemu)
3 years