public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: Sinadin Shan <sinadin.shan@oracle.com>, shuah@kernel.org
Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	chris.hyser@oracle.com
Subject: Re: [PATCH v2 2/2] selftests: sched: skip cs_prctl_test for systems with core scheduling disabled
Date: Mon, 24 Feb 2025 13:49:58 +0530	[thread overview]
Message-ID: <ed7386c2-50f9-4fa0-8a94-fd67ae2bba4f@linux.ibm.com> (raw)
In-Reply-To: <20250221115750.631990-3-sinadin.shan@oracle.com>



On 2/21/25 17:27, 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 due to the config.
> 
> Skip cs_prctl_test for systems with CONFIG_SCHED_CORE=n

I tried this on kernel built with CONFIG_SCHED_CORE=y.
I did make, make modules_install and make install and reboot.

./cs_prctl_test
## Checking for CONFIG_SCHED_CORE support
Cannot find kernel config in /proc or /boot

This happens because, make install wouldnt copy the .config to 
/boot/config-<kernel-release>.

If the self-tests are to be used in development flow, these checks may 
not be sufficient.

Not sure if i have missed any steps in building process.


> 
> Signed-off-by: Sinadin Shan <sinadin.shan@oracle.com>
> ---
>   tools/testing/selftests/sched/cs_prctl_test.c | 29 ++++++++++++++++++-
>   1 file changed, 28 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..60fd657b56c84 100644
> --- a/tools/testing/selftests/sched/cs_prctl_test.c
> +++ b/tools/testing/selftests/sched/cs_prctl_test.c
> @@ -23,6 +23,7 @@
>   #include <sys/eventfd.h>
>   #include <sys/wait.h>
>   #include <sys/types.h>
> +#include <sys/utsname.h>
>   #include <sched.h>
>   #include <sys/prctl.h>
>   #include <unistd.h>
> @@ -109,6 +110,30 @@ static void handle_usage(int rc, char *msg)
>   	exit(rc);
>   }
>   
> +static void check_core_sched_support(void)
> +{
> +	char config[128] = "/proc/config.gz";
> +	char cmd[128];
> +	struct utsname kernel;
> +
> +	printf("## Checking for CONFIG_SCHED_CORE support\n");
> +
> +	if (access(config, F_OK) != 0)
> +		if (uname(&kernel) == 0)
> +			snprintf(config, sizeof(config), "/boot/config-%s", kernel.release);
> +
> +	if (access(config, F_OK) != 0) {
> +		printf("Cannot find kernel config in /proc or /boot\n");
> +		exit(EXIT_FAILURE);
> +	}
> +
> +	snprintf(cmd, sizeof(cmd), "zgrep CONFIG_SCHED_CORE=[ym] %s", config);
> +	if (system(cmd)) {
> +		printf("Core scheduling not enabled in kernel, hence skipping tests\n");
> +		exit(4);
> +	}
> +}
> +
>   static unsigned long get_cs_cookie(int pid)
>   {
>   	unsigned long long cookie;
> @@ -117,7 +142,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 +295,8 @@ int main(int argc, char *argv[])
>   	if (keypress)
>   		delay = -1;
>   
> +	check_core_sched_support();
> +
>   	srand(time(NULL));
>   
>   	/* put into separate process group */


  reply	other threads:[~2025-02-24  8:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-21 11:57 [PATCH v2 0/2] selftests: sched: Add default target support for sched Sinadin Shan
2025-02-21 11:57 ` [PATCH v2 1/2] selftests: sched: add sched as a default selftest target Sinadin Shan
2025-02-21 11:57 ` [PATCH v2 2/2] selftests: sched: skip cs_prctl_test for systems with core scheduling disabled Sinadin Shan
2025-02-24  8:19   ` Shrikanth Hegde [this message]
2025-02-24 12:10     ` Sinadin Shan
2025-02-24 23:02       ` Chris Hyser
2025-02-25  8:54         ` Sinadin Shan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ed7386c2-50f9-4fa0-8a94-fd67ae2bba4f@linux.ibm.com \
    --to=sshegde@linux.ibm.com \
    --cc=chris.hyser@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=sinadin.shan@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox