sched_{g,s}etattr01: Add missing policies
v2 cover sched_{g,s}etattr01: Add missing policies
Hi,
changes v1->v2:
3 new commits
sched_getattr and sched_setattr are 99% identical (2 values are different). I was thinking to use the same approach from e197796f22 ("sethostname: Convert to new API"), but not sure if it's a good approach.
Do we want to reduce files needed to be updated after new policy is added? If yes, shouldn't there be just a single directory? (what name should be using to show 2 syscalls are in sources in this directory?)
Also docparse expect source file to be just for one binary, thus not sure whether it should just document both binaries (and thus also rename source file to show 2 syscalls are for this source?)
Kind regards,
Petr
Petr Vorel (4):
lapi/sched.h: Add include <sched.h>
lapi: Move SCHED_DEADLINE definition from tests
sched_get_priority_min01: Add missing policies
sched_get_priority_max01: Add missing policies
include/lapi/sched.h | 16 +++++++++++----- testcases/kernel/syscalls/kcmp/kcmp03.c | 1 - .../sched_get_priority_max01.c | 13 +++++++++---- .../sched_get_priority_min01.c | 13 +++++++++---- .../syscalls/sched_getattr/sched_getattr01.c | 3 --- .../syscalls/sched_getattr/sched_getattr02.c | 2 -- .../syscalls/sched_setattr/sched_setattr01.c | 2 -- 7 files changed, 29 insertions(+), 21 deletions(-)
Signature · 5 lines
2.34.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/4 lapi/sched.h: Add include <sched.h>
We including headers in lapi headers instead of depending headers are included in tests which use lapi headers.
Also remove redundant include lapi/syscalls.h from tests which use lapi/sched.h (included in lapi/sched.h).
---
New in v2
include/lapi/sched.h | 3 ++- testcases/kernel/syscalls/kcmp/kcmp03.c | 1 - testcases/kernel/syscalls/sched_getattr/sched_getattr01.c | 2 -- testcases/kernel/syscalls/sched_getattr/sched_getattr02.c | 2 -- testcases/kernel/syscalls/sched_setattr/sched_setattr01.c | 1 - 5 files changed, 2 insertions(+), 7 deletions(-)
include/lapi/sched.h +2 -1
@@ -6,9 +6,10 @@ #ifndef LAPI_SCHED_H__ #define LAPI_SCHED_H__ -#include "lapi/syscalls.h" +#include <sched.h> #include <stdint.h> #include <inttypes.h> +#include "lapi/syscalls.h" struct sched_attr { uint32_t size;
testcases/kernel/syscalls/kcmp/kcmp03.c +0 -1
@@ -18,7 +18,6 @@#include <errno.h> #include <stdlib.h> -#include <sched.h> #include <sys/wait.h> #include "tst_test.h" #include "kcmp.h"
testcases/kernel/syscalls/sched_getattr/sched_getattr01.c +0 -2
@@ -22,11 +22,9 @@#include <linux/types.h> #include <sys/syscall.h> #include <pthread.h> -#include <sched.h> #include <errno.h> #include "test.h" -#include "lapi/syscalls.h" #include "lapi/sched.h" char *TCID ="sched_getattr01" ;
testcases/kernel/syscalls/sched_getattr/sched_getattr02.c +0 -2
@@ -31,11 +31,9 @@#include <linux/types.h> #include <sys/syscall.h> #include <pthread.h> -#include <sched.h> #include <errno.h> #include "test.h" -#include "lapi/syscalls.h" #include "lapi/sched.h" char *TCID ="sched_getattr02" ;
testcases/kernel/syscalls/sched_setattr/sched_setattr01.c +0 -1
@@ -29,7 +29,6 @@#include <linux/types.h> #include <sys/syscall.h> #include <pthread.h> -#include <sched.h> #include <errno.h> #include "test.h"
Signature · 5 lines
2.34.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 1/4] lapi/sched.h: Add include <sched.h>
Hi!
Quoted 2 lines
We including headers in lapi headers instead of depending headers are included in tests which use lapi headers.
-ENOPARSE
The patch itself looks good though.
So maybe this should be something as:
Include <sched.h> and "lapi/syscalls.h" in "lapi/sched.h" instead of the tests.
Quoted 89 lines
Also remove redundant include
lapi/syscalls.hfrom tests which uselapi/sched.h(included inlapi/sched.h).Signed-off-by Petr Vorel <[email protected]>---
New in v2include/lapi/sched.h | 3 ++- testcases/kernel/syscalls/kcmp/kcmp03.c | 1 - testcases/kernel/syscalls/sched_getattr/sched_getattr01.c | 2 -- testcases/kernel/syscalls/sched_getattr/sched_getattr02.c | 2 -- testcases/kernel/syscalls/sched_setattr/sched_setattr01.c | 1 - 5 files changed, 2 insertions(+), 7 deletions(-)include/lapi/sched.h +2
-1@@ -6,9 +6,10 @@ #ifndef LAPI_SCHED_H__ #define LAPI_SCHED_H__ -#include "lapi/syscalls.h" +#include <sched.h> #include <stdint.h> #include <inttypes.h> +#include "lapi/syscalls.h" struct sched_attr { uint32_t size;testcases/kernel/syscalls/kcmp/kcmp03.c +0
-1@@ -18,7 +18,6 @@#include <errno.h> #include <stdlib.h> -#include <sched.h> #include <sys/wait.h> #include "tst_test.h" #include "kcmp.h" testcases/kernel/syscalls/sched_getattr/sched_getattr01.c +0
-2@@ -22,11 +22,9 @@#include <linux/types.h> #include <sys/syscall.h> #include <pthread.h> -#include <sched.h> #include <errno.h> #include "test.h" -#include "lapi/syscalls.h" #include "lapi/sched.h" char *TCID ="sched_getattr01" ;testcases/kernel/syscalls/sched_getattr/sched_getattr02.c +0
-2@@ -31,11 +31,9 @@#include <linux/types.h> #include <sys/syscall.h> #include <pthread.h> -#include <sched.h> #include <errno.h> #include "test.h" -#include "lapi/syscalls.h" #include "lapi/sched.h" char *TCID ="sched_getattr02" ;testcases/kernel/syscalls/sched_setattr/sched_setattr01.c +0
-1@@ -29,7 +29,6 @@#include <linux/types.h> #include <sys/syscall.h> #include <pthread.h> -#include <sched.h> #include <errno.h> #include "test.h" Signature · 1 line
2.34.1
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Cyril Hrubis
Reviewed-byRe: [LTP] [PATCH v2 1/4] lapi/sched.h: Add include <sched.h>
Hi!
Quoted 11 lines
Quoted 2 lines
We including headers in lapi headers instead of depending headers are included in tests which use lapi headers.
-ENOPARSEThe patch itself looks good though.
So maybe this should be something as:
Include <
sched.h> and "lapi/syscalls.h" in "lapi/sched.h" instead of the tests.
Also with the description fixed:
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 1/4] lapi/sched.h: Add include <sched.h>
In reply to Cyril HrubisHi Cyril,
Quoted 5 lines
Hi!
Quoted 2 lines
We including headers in lapi headers instead of depending headers are included in tests which use lapi headers.
-ENOPARSE
:)
Quoted 6 lines
The patch itself looks good though.
So maybe this should be something as:
Include <
sched.h> and "lapi/syscalls.h" in "lapi/sched.h" instead of the tests.
Thanks! Fixed and merged.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 2/4 lapi: Move SCHED_DEADLINE definition from tests
In reply to Petr VorelDRY
SCHED_DEADLINE is currently missing on uclibc-ng (v1.0.40).
+ add indent for definitions (formatting).
---
New in v2
include/lapi/sched.h | 13 +++++++++---- .../kernel/syscalls/sched_getattr/sched_getattr01.c | 1 - .../kernel/syscalls/sched_setattr/sched_setattr01.c | 1 - 3 files changed, 9 insertions(+), 6 deletions(-)
include/lapi/sched.h +9 -4
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) 2015 Cui Bixuan <[email protected]> +* Copyright (c) Linux Test Project, 2016-2022 */ #ifndef LAPI_SCHED_H__
@@ -41,20 +42,24 @@ static inline int sched_getattr(pid_t pid, struct sched_attr *attr, return syscall(__NR_sched_getattr, pid, attr, size, flags); } +#ifndef SCHED_DEADLINE +# define SCHED_DEADLINE 6 +#endif +#ifndef CLONE_VM -#define CLONE_VM 0x00000100 +# define CLONE_VM 0x00000100#endif #ifndef CLONE_FS -#define CLONE_FS 0x00000200 +# define CLONE_FS 0x00000200#endif #ifndef CLONE_SYSVSEM -#define CLONE_SYSVSEM 0x00040000 +# define CLONE_SYSVSEM 0x00040000#endif #ifndef CLONE_IO -#define CLONE_IO 0x80000000 +# define CLONE_IO 0x80000000#endif #endif /* LAPI_SCHED_H__ */
testcases/kernel/syscalls/sched_getattr/sched_getattr01.c +0 -1
@@ -30,7 +30,6 @@char *TCID ="sched_getattr01" ;int TST_TOTAL =1 ; -#define SCHED_DEADLINE 6#define RUNTIME_VAL 10000000#define PERIOD_VAL 30000000#define DEADLINE_VAL 30000000
testcases/kernel/syscalls/sched_setattr/sched_setattr01.c +0 -1
@@ -36,7 +36,6 @@char *TCID ="sched_setattr01" ; -#define SCHED_DEADLINE 6#define RUNTIME_VAL 10000000#define PERIOD_VAL 30000000#define DEADLINE_VAL 30000000
Signature · 5 lines
2.34.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 2/4] lapi: Move SCHED_DEADLINE definition from tests
Hi!
Looks obviously fine.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 3/4 sched_get_priority_min01: Add missing policies
In reply to Petr Vorel+ improve doc wording and update copyright.
---
New in v2
.../sched_get_priority_min01.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
testcases/kernel/syscalls/sched_get_priority_min/sched_get_priority_min01.c +9 -4
@@ -2,6 +2,7 @@/* * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved. * Copyright (c) 2021 sujiaxun <[email protected]> +* Copyright (c) Linux Test Project, 2009-2022 */ /*\
@@ -9,11 +10,12 @@* * Basic test for the sched_get_priority_min(2) system call. * -* Obtain different minimum priority scheduling strategies and +* Obtain different minimum priority for different schedulling policies and * compare them with the expected value. */ -#include <errno.h> +#define _GNU_SOURCE +#include <sched.h> #include "tst_test.h" #include "lapi/syscalls.h"
@@ -25,9 +27,12 @@ static struct test_case {int policy;int retval; } tcases[] = { - {POLICY_DESC(SCHED_OTHER), 0}, + {POLICY_DESC(SCHED_BATCH), 0}, + {POLICY_DESC(SCHED_DEADLINE), 0}, {POLICY_DESC(SCHED_FIFO), 1}, - {POLICY_DESC(SCHED_RR), 1} + {POLICY_DESC(SCHED_IDLE), 0}, + {POLICY_DESC(SCHED_OTHER), 0}, + {POLICY_DESC(SCHED_RR), 1}, }; static void run_test(unsigned int nr)
Signature · 5 lines
2.34.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 3/4] sched_get_priority_min01: Add missing policies
Hi,
this test and sched_get_priority_max01 (latest commit) need to include lapi/sched.h. I'll fix it before merge.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 3/4] sched_get_priority_min01: Add missing policies
Quoted 2 lines
this test and
sched_get_priority_max01(latest commit) need to includelapi/sched.h. I'll fix it before merge.
For a record: on traditional distros with glibc it's required only on CentOS 7 and Ubuntu Xenial (very old distros, but Centos 7 EOL in 2024).
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 3/4] sched_get_priority_min01: Add missing policies
In reply to Petr VorelHi!
Looks good.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 4/4 sched_get_priority_max01: Add missing policies
In reply to Petr Vorel+ improve doc wording and update copyright.
---
changes v1->v2:
* code is the same, only copyright and doc updated
.../sched_get_priority_max01.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
testcases/kernel/syscalls/sched_get_priority_max/sched_get_priority_max01.c +9 -4
@@ -2,6 +2,7 @@/* * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved. * Copyright (c) 2021 sujiaxun <[email protected]> +* Copyright (c) Linux Test Project, 2009-2022 */ /*\
@@ -10,9 +11,11 @@* Basic test for the sched_get_priority_max(2) system call. * * Obtain different maximum priority for different schedulling policies and -* compare them with expected value. +* compare them with the expected value. */ +#define _GNU_SOURCE +#include <sched.h> #include "tst_test.h" #include "lapi/syscalls.h"
@@ -24,14 +27,16 @@ static struct test_case {int policy;int retval; } tcases[] = { - {POLICY_DESC(SCHED_OTHER), 0}, + {POLICY_DESC(SCHED_BATCH), 0}, + {POLICY_DESC(SCHED_DEADLINE), 0}, {POLICY_DESC(SCHED_FIFO), 99}, - {POLICY_DESC(SCHED_RR), 99} + {POLICY_DESC(SCHED_IDLE), 0}, + {POLICY_DESC(SCHED_OTHER), 0}, + {POLICY_DESC(SCHED_RR), 99}, }; static void run_test(unsigned int nr) { - struct test_case *tc = &tcases[nr]; TST_EXP_VAL(tst_syscall(__NR_sched_get_priority_max, tc->policy),
Signature · 5 lines
2.34.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 4/4] sched_get_priority_max01: Add missing policies
Hi!
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 4 lines
sched_getattrandsched_setattrare 99% identical (2 values are different). I was thinking to use the same approach frome197796f22("sethostname: Convert to new API"), but not sure if it's a good approach.
Actually I do not think that the approach in sethostname is good. There should be a C file for each test. If they share code that should be put into headers or libraries.
We used to have more tests like that that build binaries in different directories from a single source with different macros and I find it utterly confusing.
Quoted 4 lines
Do we want to reduce files needed to be updated after new policy is added? If yes, shouldn't there be just a single directory? (what name should be using to show 2 syscalls are in sources in this directory?)
I would vote against this.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Cyril,
Quoted 6 lines
Hi!
Quoted 4 lines
sched_getattrandsched_setattrare 99% identical (2 values are different). I was thinking to use the same approach frome197796f22("sethostname: Convert to new API"), but not sure if it's a good approach.
Quoted 7 lines
Actually I do not think that the approach in sethostname is good. There should be a C file for each test. If they share code that should be put into headers or libraries.
We used to have more tests like that that build binaries in different directories from a single source with different macros and I find it utterly confusing.
Thanks for info. Agree, it's confusing.
I guess in tests which are very simple like sethostname or even these sched_getattr we'll just endup with duplicity, right?
Because putting one function into header which is shared with tests in different directory is just confusing and not worth of doing.
So I can recreate sethostname01.c.
And for these tests I can make a note just to remember update struct for the other test.
Quoted 6 lines
Quoted 4 lines
Do we want to reduce files needed to be updated after new policy is added? If yes, shouldn't there be just a single directory? (what name should be using to show 2 syscalls are in sources in this directory?)
I would vote against this.
Understand now.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp