Skip to contentSkip to conversation

sched_{g,s}etattr01: Add missing policies

PATCH In review Petr Vorel 2 participants 15 messages Jan 25, 2022 – Jan 28, 2022

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

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
author
#1 lore raw

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
index 036edd51d1..2fc32a38ca 100644
@@ -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
index 30ac3ec9db..df8633c5fc 100644
@@ -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
index 2a2c13a40f..0ffbce9c8d 100644
@@ -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
index 2d7e15a470..9f4a09f88f 100644
@@ -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
index 37ca56a0aa..82156b95cb 100644
@@ -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
#2 lore raw

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.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
index 036edd51d1..2fc32a38ca 100644
@@ -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
index 30ac3ec9db..df8633c5fc 100644
@@ -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
index 2a2c13a40f..0ffbce9c8d 100644
@@ -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
index 2d7e15a470..9f4a09f88f 100644
@@ -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
index 37ca56a0aa..82156b95cb 100644
@@ -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
Reviewed-by
#3 lore raw

Re: [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.

-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.

Also with the description fixed:

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#4 lore raw

Re: [LTP] [PATCH v2 1/4] lapi/sched.h: Add include <sched.h>

In reply to Cyril Hrubis

Hi 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
author
#5 lore raw

PATCH v2 2/4 lapi: Move SCHED_DEADLINE definition from tests

In reply to Petr Vorel

DRY

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
index 2fc32a38ca..226d3109a0 100644
@@ -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
index 0ffbce9c8d..c1715d8acf 100644
@@ -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
index 82156b95cb..d5178e0169 100644
@@ -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
author
#7 lore raw

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
index cebd08d3f9..e7ab761249 100644
@@ -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
author
#8 lore raw

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
author
#9 lore raw

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 include lapi/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
author
#11 lore raw

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
index f6fe1add9c..b9a58a46a4 100644
@@ -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
#13 lore raw
In reply to Petr Vorel

Hi!

Quoted 4 lines

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.

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
author
#14 lore raw

Hi Cyril,

Quoted 6 lines

Hi!

Quoted 4 lines

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.

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