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] [day] [month] [year] [list]
Message-ID:
 <CO1PR10MB47054DBFCB3BCF4D43AC19AA9BC22@CO1PR10MB4705.namprd10.prod.outlook.com>
Date: Wed, 26 Feb 2025 17:01:21 +0000
From: Chris Hyser <chris.hyser@...cle.com>
To: Shrikanth Hegde <sshegde@...ux.ibm.com>,
        Sinadin Shan
	<sinadin.shan@...cle.com>,
        "shuah@...nel.org" <shuah@...nel.org>
CC: "linux-kselftest@...r.kernel.org" <linux-kselftest@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3 2/2] selftests: sched: skip cs_prctl_test for systems
 with core scheduling disabled

On 2/26/25 01:39, Sinadin Shan wrote:
> For kernels with CONFIG_SCHED_CORE=n, the sched selftest cs_prctl_test
> fails with "Not a core sched system" error. Change this to gracefully
> skip the test for systems with core scheduling disabled. Exiting early
> would also ensure failures reported in obtaining cookie are valid
> failures and not because core scheduling isn't supported.
> 
> Skip cs_prctl_test for systems with CONFIG_SCHED_CORE=n
> 
> Signed-off-by: Sinadin Shan <sinadin.shan@...cle.com>
> ---
>  tools/testing/selftests/sched/cs_prctl_test.c | 34 ++++++++++++++++++-
>  1 file changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/sched/cs_prctl_test.c b/tools/testing/selftests/sched/cs_prctl_test.c
> index 52d97fae4dbd8..5b0047b50e640 100644
> --- a/tools/testing/selftests/sched/cs_prctl_test.c
> +++ b/tools/testing/selftests/sched/cs_prctl_test.c
> @@ -109,6 +109,36 @@ static void handle_usage(int rc, char *msg)
>          exit(rc);
>  }
>  
> +static void check_core_sched(void)
> +{
> +       unsigned long long cookie;
> +       int ret, num_max_process;
> +       char buffer[32];
> +
> +       FILE *fp = fopen("/proc/sys/kernel/pid_max", "r");
> +
> +       if (fp == NULL) {
> +               perror("Failed to obtain max process number");
> +               exit(EXIT_FAILURE);
> +       }
> +
> +       if (fgets(buffer, sizeof(buffer), fp) == NULL) {
> +               fclose(fp);
> +               exit(EXIT_FAILURE);
> +       }
> +
> +       num_max_process = atoi(buffer);
> +       fclose(fp);
> +
> +       ret = prctl(PR_SCHED_CORE, PR_SCHED_CORE_GET, num_max_process+1, PIDTYPE_PID,
> +                       (unsigned long)&cookie);
> +       if (ret == -1 && errno != ESRCH) {
> +               perror("prctl failed");
> +               printf("Core sched not supported, hence skipping tests\n");
> +               exit(4);
> +       }
> +}
> +
>  static unsigned long get_cs_cookie(int pid)
>  {
>          unsigned long long cookie;
> @@ -117,7 +147,7 @@ static unsigned long get_cs_cookie(int pid)
>          ret = prctl(PR_SCHED_CORE, PR_SCHED_CORE_GET, pid, PIDTYPE_PID,
>                      (unsigned long)&cookie);
>          if (ret) {
> -               printf("Not a core sched system\n");
> +               printf("Failed to get cookie\n");
>                  return -1UL;
>          }
>  
> @@ -270,6 +300,8 @@ int main(int argc, char *argv[])
>          if (keypress)
>                  delay = -1;
>  
> +       check_core_sched();
> +
>          srand(time(NULL));
>  
>          /* put into separate process group */
> --
> 2.43.5

So assuming a return code of 4 means skip (and I believe you stated that affirmatively before), then this
should solve the problem. Thanks for fixing this.

Reviewed-by: Chris Hyser <chris.hyser@...cle.com>

-chrish

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ