lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <09c7ad5e-4061-4c0b-b097-fa575c12a244@linuxfoundation.org>
Date: Tue, 13 May 2025 16:03:55 -0600
From: Shuah Khan <skhan@...uxfoundation.org>
To: Suchit Karunakaran <suchitkarunakaran@...il.com>, trenn@...e.com,
 shuah@...nel.org, jwyatt@...hat.com, jkacur@...hat.com,
 linux-pm@...r.kernel.org
Cc: linux-kernel-mentees@...ts.linux.dev, linux-kernel@...r.kernel.org,
 Shuah Khan <skhan@...uxfoundation.org>
Subject: Re: [PATCH] tools/powercap: Implement powercap_set_enabled()

On 5/10/25 12:47, Suchit Karunakaran wrote:
> The powercap_set_enabled() function previously returned a dummy value
> and was marked with a TODO comment. This patch implements the function
> by writing the desired mode (0 or 1) to /sys/class/powercap/intel-rapl/enabled

The short summary should say cpupower: Implement powercap_set_enabled()
> 
> Signed-off-by: Suchit Karunakaran <suchitkarunakaran@...il.com>
> ---
>   tools/power/cpupower/lib/powercap.c | 22 ++++++++++++++++++----
>   1 file changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/power/cpupower/lib/powercap.c b/tools/power/cpupower/lib/powercap.c
> index 94a0c69e55ef..7947b9809239 100644
> --- a/tools/power/cpupower/lib/powercap.c
> +++ b/tools/power/cpupower/lib/powercap.c
> @@ -70,6 +70,22 @@ static int sysfs_get_enabled(char *path, int *mode)
>   	return ret;
>   }
>   
> +static int sysfs_set_enabled(const char *path, int mode)
> +{
> +	int fd;
> +	char buf[2] = { mode ? '1' : '0', '\n' };
> +	ssize_t ret;
> +
> +	fd = open(path, O_WRONLY);
> +	if (fd == -1)
> +		return -1;
> +
> +	ret = write(fd, buf, sizeof(buf));
> +	close(fd);
> +
> +	return ret == sizeof(buf) ? 0 : -1;
> +}
> +
>   int powercap_get_enabled(int *mode)
>   {
>   	char path[SYSFS_PATH_MAX] = PATH_TO_POWERCAP "/intel-rapl/enabled";
> @@ -77,12 +93,10 @@ int powercap_get_enabled(int *mode)
>   	return sysfs_get_enabled(path, mode);
>   }
>   
> -/*
> - * TODO: implement function. Returns dummy 0 for now.
> - */
>   int powercap_set_enabled(int mode)
>   {
> -	return 0;
> +	char path[SYSFS_PATH_MAX] = PATH_TO_POWERCAP "/intel-rapl/enabled";
> +	return sysfs_set_enabled(path, mode);

Did you compile this?

thanks,
-- Shuah

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ