mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-09 06:43:09 +00:00
c2294c1496
Read out powercap zone information via: cpupower powercap-info and show the zone hierarchy to the user: ./cpupower powercap-info Driver: intel-rapl Powercap domain hierarchy: Zone: package-0 (enabled) Power consumption can be monitored in micro Watts Zone: core (disabled) Power consumption can be monitored in micro Watts Zone: uncore (disabled) Power consumption can be monitored in micro Watts Zone: dram (disabled) Power consumption can be monitored in micro Watts There is a dummy -a option for powercap-info which can/should be used to show more detailed info later. Like that other args can be added easily later as well. A enable/disable option via powercap-set subcommand is also an enhancement for later. Also not all RAPL domains are shown. The func walking through RAPL subdomains is restricted and hardcoded to: "intel-rapl/intel-rapl:0" On my system above powercap domains map to: intel-rapl/intel-rapl:0 -> pack (age-0) intel-rapl/intel-rapl:0/intel-rapl:0:0 -> core intel-rapl/intel-rapl:0/intel-rapl:0:1 -> uncore Missing ones on my system are: intel-rapl-mmio/intel-rapl-mmio:0 -> pack (age-0) intel-rapl/intel-rapl:1 -> psys This could get enhanced in: struct powercap_zone *powercap_init_zones() and adopted to walk through all intel-rapl zones, but also to other powercap drivers like dtpm (Dynamic Thermal Power Management framework), cmp with: drivers/powercap/dtpm_* Signed-off-by: Thomas Renninger <trenn@suse.de> CC: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
55 lines
1.6 KiB
C
55 lines
1.6 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* (C) 2016 SUSE Software Solutions GmbH
|
|
* Thomas Renninger <trenn@suse.de>
|
|
*/
|
|
|
|
#ifndef __CPUPOWER_RAPL_H__
|
|
#define __CPUPOWER_RAPL_H__
|
|
|
|
#define PATH_TO_POWERCAP "/sys/devices/virtual/powercap"
|
|
#define PATH_TO_RAPL "/sys/devices/virtual/powercap/intel-rapl"
|
|
#define PATH_TO_RAPL_CLASS "/sys/devices/virtual/powercap/intel-rapl"
|
|
|
|
#define POWERCAP_MAX_CHILD_ZONES 10
|
|
#define POWERCAP_MAX_TREE_DEPTH 10
|
|
|
|
#define MAX_LINE_LEN 4096
|
|
#define SYSFS_PATH_MAX 255
|
|
|
|
#include <stdint.h>
|
|
|
|
struct powercap_zone {
|
|
char name[MAX_LINE_LEN];
|
|
/*
|
|
* sys_name relative to PATH_TO_POWERCAP,
|
|
* do not forget the / in between
|
|
*/
|
|
char sys_name[SYSFS_PATH_MAX];
|
|
int tree_depth;
|
|
struct powercap_zone *parent;
|
|
struct powercap_zone *children[POWERCAP_MAX_CHILD_ZONES];
|
|
/* More possible caps or attributes to be added? */
|
|
uint32_t has_power_uw:1,
|
|
has_energy_uj:1;
|
|
|
|
};
|
|
|
|
int powercap_walk_zones(struct powercap_zone *zone,
|
|
int (*f)(struct powercap_zone *zone));
|
|
|
|
struct powercap_zone *powercap_init_zones(void);
|
|
int powercap_get_enabled(int *mode);
|
|
int powercap_set_enabled(int mode);
|
|
int powercap_get_driver(char *driver, int buflen);
|
|
|
|
int powercap_get_max_energy_range_uj(struct powercap_zone *zone, uint64_t *val);
|
|
int powercap_get_energy_uj(struct powercap_zone *zone, uint64_t *val);
|
|
int powercap_get_max_power_range_uw(struct powercap_zone *zone, uint64_t *val);
|
|
int powercap_get_power_uw(struct powercap_zone *zone, uint64_t *val);
|
|
int powercap_zone_get_enabled(struct powercap_zone *zone, int *mode);
|
|
int powercap_zone_set_enabled(struct powercap_zone *zone, int mode);
|
|
|
|
|
|
#endif /* __CPUPOWER_RAPL_H__ */
|