~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-only */
  2 /*
  3  *  (C) 2010,2011       Thomas Renninger <trenn@suse.de>, Novell Inc.
  4  */
  5 
  6 #ifndef __CPUIDLE_INFO_HW__
  7 #define __CPUIDLE_INFO_HW__
  8 
  9 #include <stdarg.h>
 10 #include <time.h>
 11 
 12 #include "idle_monitor/idle_monitors.h"
 13 
 14 #define MONITORS_MAX 20
 15 #define MONITOR_NAME_LEN 20
 16 
 17 /* CSTATE_NAME_LEN is limited by header field width defined
 18  * in cpupower-monitor.c. Header field width is defined to be
 19  * sum of percent width and two spaces for padding.
 20  */
 21 #ifdef __powerpc__
 22 #define CSTATE_NAME_LEN 7
 23 #else
 24 #define CSTATE_NAME_LEN 5
 25 #endif
 26 #define CSTATE_DESC_LEN 60
 27 
 28 extern int cpu_count;
 29 
 30 /* Hard to define the right names ...: */
 31 enum power_range_e {
 32         RANGE_THREAD,   /* Lowest in topology hierarcy, AMD: core, Intel: thread
 33                            kernel sysfs: cpu */
 34         RANGE_CORE,     /* AMD: unit, Intel: core, kernel_sysfs: core_id */
 35         RANGE_PACKAGE,  /* Package, processor socket */
 36         RANGE_MACHINE,  /* Machine, platform wide */
 37         RANGE_MAX };
 38 
 39 typedef struct cstate {
 40         int  id;
 41         enum power_range_e range;
 42         char name[CSTATE_NAME_LEN];
 43         char desc[CSTATE_DESC_LEN];
 44 
 45         /* either provide a percentage or a general count */
 46         int (*get_count_percent)(unsigned int self_id, double *percent,
 47                                  unsigned int cpu);
 48         int (*get_count)(unsigned int self_id, unsigned long long *count,
 49                          unsigned int cpu);
 50 } cstate_t;
 51 
 52 struct cpuidle_monitor {
 53         /* Name must not contain whitespaces */
 54         char name[MONITOR_NAME_LEN];
 55         int name_len;
 56         int hw_states_num;
 57         cstate_t *hw_states;
 58         int (*start) (void);
 59         int (*stop) (void);
 60         struct cpuidle_monitor* (*do_register) (void);
 61         void (*unregister)(void);
 62         unsigned int overflow_s;
 63         struct {
 64                 unsigned int needs_root:1;
 65                 unsigned int per_cpu_schedule:1;
 66         } flags;
 67 };
 68 
 69 extern long long timespec_diff_us(struct timespec start, struct timespec end);
 70 
 71 #define print_overflow_err(mes, ov)                                             \
 72 {                                                                               \
 73         fprintf(stderr, gettext("Measure took %u seconds, but registers could " \
 74                                 "overflow at %u seconds, results "              \
 75                                 "could be inaccurate\n"), mes, ov);             \
 76 }
 77 
 78 
 79 /* Taken over from x86info project sources  -> return 0 on success */
 80 #include <sched.h>
 81 #include <sys/types.h>
 82 #include <unistd.h>
 83 static inline int bind_cpu(int cpu)
 84 {
 85         cpu_set_t set;
 86 
 87         if (sched_getaffinity(getpid(), sizeof(set), &set) == 0) {
 88                 CPU_ZERO(&set);
 89                 CPU_SET(cpu, &set);
 90                 return sched_setaffinity(getpid(), sizeof(set), &set);
 91         }
 92         return 1;
 93 }
 94 
 95 #endif /* __CPUIDLE_INFO_HW__ */
 96 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php