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, chris.hyser@oracle.com
Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] selftests: sched: skip cs_prctl_test for systems with core scheduling disabled
Date: Wed, 26 Feb 2025 18:35:52 +0530	[thread overview]
Message-ID: <93e10bcf-3537-45f0-b282-ae4fd4573c6e@linux.ibm.com> (raw)
In-Reply-To: <20250225200910.260569-3-sinadin.shan@oracle.com>



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@oracle.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 */


This works for me in my workflow. I don't know full selftest framework 
or how to trigger it.

When CONFIG_SCHED_CORE=n
-----------------------------
./cs_prctl_test
prctl failed: Invalid argument
Core sched not supported, hence skipping tests


When CONFIG_SCHED_CORE=y
-----------------------------
./cs_prctl_test
(369) PASSED: _prctl(PR_SCHED_CORE, PR_SCHED_CORE_MAX, 0, PIDTYPE_PGID, 
0) < 0 && errno == EINVAL
-1 = prctl(62, 2, 0, 2, 1)
(372) PASSED: _prctl(PR_SCHED_CORE, PR_SCHED_CORE_SHARE_TO, 0, 
PIDTYPE_PGID, 1) < 0 && errno == EINVAL
SUCCESS !!!


So for this patch,
Tested-by: Shrikanth Hegde <sshegde@linux.ibm.com>


  reply	other threads:[~2025-02-26 13:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25 20:09 [PATCH v3 0/2] selftests: sched: Add default target support for sched Sinadin Shan
2025-02-25 20:09 ` [PATCH v3 1/2] selftests: sched: add sched as a default selftest target Sinadin Shan
2025-02-25 20:09 ` [PATCH v3 2/2] selftests: sched: skip cs_prctl_test for systems with core scheduling disabled Sinadin Shan
2025-02-26 13:05   ` Shrikanth Hegde [this message]
2025-02-26 17:01     ` Chris Hyser

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=93e10bcf-3537-45f0-b282-ae4fd4573c6e@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