File cpupower-Move-needs_root-variable-into-a-sub-struct.patch of Package cpupower.13927

From: Janakarajan Natarajan <Janakarajan.Natarajan@amd.com>
Subject: cpupower: Move needs_root variable into a sub-struct
References: bsc#1152967
Patch-Mainline: v5.5-rc1
Git-commit: d3f5d2a192a299f56579ae6e6283f9011b00208f


Move the needs_root variable into a sub-struct. This is in preparation
for adding a new flag for cpuidle_monitor.

Update all uses of the needs_root variable to reflect this change.

Signed-off-by: Janakarajan Natarajan <Janakarajan.Natarajan@amd.com>
Acked-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>


Signed-off-by:  <trenn@suse.com>
Index: cpupower-4.19/utils/idle_monitor/amd_fam14h_idle.c
===================================================================
--- cpupower-4.19.orig/utils/idle_monitor/amd_fam14h_idle.c	2018-09-30 16:15:35.000000000 +0200
+++ cpupower-4.19/utils/idle_monitor/amd_fam14h_idle.c	2020-01-14 14:39:51.708604074 +0100
@@ -329,7 +329,7 @@ struct cpuidle_monitor amd_fam14h_monito
 	.stop			= amd_fam14h_stop,
 	.do_register		= amd_fam14h_register,
 	.unregister		= amd_fam14h_unregister,
-	.needs_root		= 1,
+	.flags.needs_root	= 1,
 	.overflow_s		= OVERFLOW_MS / 1000,
 };
 #endif /* #if defined(__i386__) || defined(__x86_64__) */
Index: cpupower-4.19/utils/idle_monitor/cpuidle_sysfs.c
===================================================================
--- cpupower-4.19.orig/utils/idle_monitor/cpuidle_sysfs.c	2018-09-30 16:15:35.000000000 +0200
+++ cpupower-4.19/utils/idle_monitor/cpuidle_sysfs.c	2020-01-14 14:39:51.708604074 +0100
@@ -209,6 +209,6 @@ struct cpuidle_monitor cpuidle_sysfs_mon
 	.stop			= cpuidle_stop,
 	.do_register		= cpuidle_register,
 	.unregister		= cpuidle_unregister,
-	.needs_root		= 0,
+	.flags.needs_root	= 0,
 	.overflow_s		= UINT_MAX,
 };
Index: cpupower-4.19/utils/idle_monitor/cpupower-monitor.c
===================================================================
--- cpupower-4.19.orig/utils/idle_monitor/cpupower-monitor.c	2020-01-14 14:39:49.148603936 +0100
+++ cpupower-4.19/utils/idle_monitor/cpupower-monitor.c	2020-01-14 14:39:51.708604074 +0100
@@ -410,7 +410,7 @@ int cmd_monitor(int argc, char **argv)
 		dprint("Try to register: %s\n", all_monitors[num]->name);
 		test_mon = all_monitors[num]->do_register();
 		if (test_mon) {
-			if (test_mon->needs_root && !run_as_root) {
+			if (test_mon->flags.needs_root && !run_as_root) {
 				fprintf(stderr, _("Available monitor %s needs "
 					  "root access\n"), test_mon->name);
 				continue;
Index: cpupower-4.19/utils/idle_monitor/cpupower-monitor.h
===================================================================
--- cpupower-4.19.orig/utils/idle_monitor/cpupower-monitor.h	2018-09-30 16:15:35.000000000 +0200
+++ cpupower-4.19/utils/idle_monitor/cpupower-monitor.h	2020-01-14 14:39:51.712604074 +0100
@@ -62,7 +62,9 @@ struct cpuidle_monitor {
 	struct cpuidle_monitor* (*do_register) (void);
 	void (*unregister)(void);
 	unsigned int overflow_s;
-	int needs_root;
+	struct {
+		unsigned int needs_root:1;
+	} flags;
 };
 
 extern long long timespec_diff_us(struct timespec start, struct timespec end);
Index: cpupower-4.19/utils/idle_monitor/hsw_ext_idle.c
===================================================================
--- cpupower-4.19.orig/utils/idle_monitor/hsw_ext_idle.c	2018-09-30 16:15:35.000000000 +0200
+++ cpupower-4.19/utils/idle_monitor/hsw_ext_idle.c	2020-01-14 14:39:51.712604074 +0100
@@ -189,7 +189,7 @@ struct cpuidle_monitor intel_hsw_ext_mon
 	.stop			= hsw_ext_stop,
 	.do_register		= hsw_ext_register,
 	.unregister		= hsw_ext_unregister,
-	.needs_root		= 1,
+	.flags.needs_root	= 1,
 	.overflow_s		= 922000000 /* 922337203 seconds TSC overflow
 					       at 20GHz */
 };
Index: cpupower-4.19/utils/idle_monitor/mperf_monitor.c
===================================================================
--- cpupower-4.19.orig/utils/idle_monitor/mperf_monitor.c	2018-09-30 16:15:35.000000000 +0200
+++ cpupower-4.19/utils/idle_monitor/mperf_monitor.c	2020-01-14 14:39:51.712604074 +0100
@@ -333,7 +333,7 @@ struct cpuidle_monitor mperf_monitor = {
 	.stop			= mperf_stop,
 	.do_register		= mperf_register,
 	.unregister		= mperf_unregister,
-	.needs_root		= 1,
+	.flags.needs_root	= 1,
 	.overflow_s		= 922000000 /* 922337203 seconds TSC overflow
 					       at 20GHz */
 };
Index: cpupower-4.19/utils/idle_monitor/nhm_idle.c
===================================================================
--- cpupower-4.19.orig/utils/idle_monitor/nhm_idle.c	2018-09-30 16:15:35.000000000 +0200
+++ cpupower-4.19/utils/idle_monitor/nhm_idle.c	2020-01-14 14:39:51.712604074 +0100
@@ -209,7 +209,7 @@ struct cpuidle_monitor intel_nhm_monitor
 	.stop			= nhm_stop,
 	.do_register		= intel_nhm_register,
 	.unregister		= intel_nhm_unregister,
-	.needs_root		= 1,
+	.flags.needs_root	= 1,
 	.overflow_s		= 922000000 /* 922337203 seconds TSC overflow
 					       at 20GHz */
 };
Index: cpupower-4.19/utils/idle_monitor/snb_idle.c
===================================================================
--- cpupower-4.19.orig/utils/idle_monitor/snb_idle.c	2018-09-30 16:15:35.000000000 +0200
+++ cpupower-4.19/utils/idle_monitor/snb_idle.c	2020-01-14 14:39:51.712604074 +0100
@@ -193,7 +193,7 @@ struct cpuidle_monitor intel_snb_monitor
 	.stop			= snb_stop,
 	.do_register		= snb_register,
 	.unregister		= snb_unregister,
-	.needs_root		= 1,
+	.flags.needs_root	= 1,
 	.overflow_s		= 922000000 /* 922337203 seconds TSC overflow
 					       at 20GHz */
 };
Index: cpupower-4.19/utils/idle_monitor/rapl_monitor.c
===================================================================
--- cpupower-4.19.orig/utils/idle_monitor/rapl_monitor.c	2020-01-14 14:39:49.152603936 +0100
+++ cpupower-4.19/utils/idle_monitor/rapl_monitor.c	2020-01-14 14:44:23.640618727 +0100
@@ -134,7 +134,7 @@ struct cpuidle_monitor rapl_monitor = {
 	.start			= rapl_start,
 	.stop			= rapl_stop,
 	.do_register		= rapl_register,
-	.needs_root		= 0,
+	.flags.needs_root		= 0,
 	.overflow_s		= 60 * 60 * 24 * 100, /* To be implemented */
 };
 
openSUSE Build Service is sponsored by