mbind01: make use of tst_numa_mode_name
PATCH 1/3 mbind01: make use of tst_numa_mode_name
Add MPOL_LOCAL and adjust some mempolicy mode modes order. To prettify the error log of mbind01.
--- libs/libltpnuma/tst_numa.c | 7 +++++-- testcases/kernel/syscalls/mbind/mbind01.c | 10 ++++++---- 2 files changed, 11 insertions(+), 6 deletions(-)
libs/libltpnuma/tst_numa.c +5 -2
@@ -16,6 +16,7 @@#define TST_NO_DEFAULT_MAIN #include "tst_test.h" #include "tst_numa.h" +#include "lapi/numaif.h" void tst_nodemap_print_counters (struct tst_nodemap *nodes) {
@@ -50,12 +51,14 @@ const char *tst_numa_mode_name(int mode)switch (mode) {case MPOL_DEFAULT :return "MPOL_DEFAULT" ; -case MPOL_BIND : -return "MPOL_BIND" ;case MPOL_PREFERRED :return "MPOL_PREFERRED" ; +case MPOL_BIND : +return "MPOL_BIND" ;case MPOL_INTERLEAVE :return "MPOL_INTERLEAVE" ; +case MPOL_LOCAL : +return "MPOL_LOCAL" ;default :return "???" ; }
testcases/kernel/syscalls/mbind/mbind01.c +6 -4
@@ -17,6 +17,7 @@#include "config.h" #include "numa_helper.h" #include "tst_test.h" +#include "tst_numa.h" #include "lapi/numaif.h" #ifdef HAVE_NUMA_V2
@@ -124,9 +125,9 @@ static struct test_case tcase[] = {static void check_policy_pref_no_target (int policy) {if (policy !=MPOL_PREFERRED && policy !=MPOL_LOCAL ) { -tst_res (TFAIL ,"Wrong policy: %d, " +tst_res (TFAIL ,"Wrong policy: %s(%d), " "expected MPOL_PREFERRED or MPOL_LOCAL" , - policy); +tst_numa_mode_name (policy), policy); } }
@@ -200,8 +201,9 @@ static void do_test(unsigned int i)if (tc->check_policy) tc->check_policy (policy);else if (tc->policy != policy) { -tst_res (TFAIL ,"Wrong policy: %d, expected: %d" , - policy, tc->policy); +tst_res (TFAIL ,"Wrong policy: %s(%d), expected: %s(%d)" , +tst_numa_mode_name (policy), policy, +tst_numa_mode_name (tc->policy), tc->policy); fail =1 ; }if (tc->exp_nodemask) {
Signature · 1 line
2.31.1
PATCH 2/3 libs: rename tst_numa_mode_name to tst_mempolicy_mode_name
To be precise describe the MPOL_* mempolicy mode and be consistent with kernel's consuetude.
--- include/tst_numa.h | 2 +- libs/libltpnuma/tst_numa.c | 2 +- testcases/kernel/syscalls/mbind/mbind01.c | 6 +++--- testcases/kernel/syscalls/mbind/mbind02.c | 6 +++--- testcases/kernel/syscalls/mbind/mbind03.c | 4 ++-- testcases/kernel/syscalls/mbind/mbind04.c | 4 ++-- testcases/kernel/syscalls/set_mempolicy/set_mempolicy01.c | 4 ++-- testcases/kernel/syscalls/set_mempolicy/set_mempolicy03.c | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-)
include/tst_numa.h +1 -1
@@ -38,7 +38,7 @@ void tst_nodemap_print_counters(struct tst_nodemap *nodes);* * @mode Numa mempolicy mode. */ -const char *tst_numa_mode_name (int mode); +const char *tst_mempolicy_mode_name (int mode);/** * Maps pages into memory, if path is NULL the mapping is anonymous otherwise is backed by the file.
libs/libltpnuma/tst_numa.c +1 -1
@@ -46,7 +46,7 @@ void tst_nodemap_free(struct tst_nodemap *nodes)#ifdef HAVE_NUMA_V2 -const char *tst_numa_mode_name (int mode) +const char *tst_mempolicy_mode_name (int mode) {switch (mode) {case MPOL_DEFAULT :
testcases/kernel/syscalls/mbind/mbind01.c +3 -3
@@ -127,7 +127,7 @@ static void check_policy_pref_no_target(int policy)if (policy !=MPOL_PREFERRED && policy !=MPOL_LOCAL ) {tst_res (TFAIL ,"Wrong policy: %s(%d), " "expected MPOL_PREFERRED or MPOL_LOCAL" , -tst_numa_mode_name (policy), policy); +tst_mempolicy_mode_name (policy), policy); } }
@@ -202,8 +202,8 @@ static void do_test(unsigned int i) tc->check_policy (policy); else if (tc->policy != policy) {tst_res (TFAIL ,"Wrong policy: %s(%d), expected: %s(%d)" , -tst_numa_mode_name (policy), policy, -tst_numa_mode_name (tc->policy), tc->policy); +tst_mempolicy_mode_name (policy), policy, +tst_mempolicy_mode_name (tc->policy), tc->policy); fail =1 ; }if (tc->exp_nodemask) {
testcases/kernel/syscalls/mbind/mbind02.c +3 -3
@@ -74,18 +74,18 @@ static void verify_policy(int mode)if (TST_RET !=-1 ) {tst_res (TFAIL ,"mbind(%s, MPOL_MF_STRICT) node %u returned %li, expected -1" , -tst_numa_mode_name (mode), node,TST_RET ); +tst_mempolicy_mode_name (mode), node,TST_RET );return ; }if (TST_ERR ==EIO ) {tst_res (TPASS |TTERRNO ,"mbind(%s, MPOL_MF_STRICT) node %u" , -tst_numa_mode_name (mode), node); +tst_mempolicy_mode_name (mode), node); }else {tst_res (TFAIL |TTERRNO ,"mbind(%s, MPOL_MF_STRICT) node %u expected EIO" , -tst_numa_mode_name (mode), node); +tst_mempolicy_mode_name (mode), node); } }
testcases/kernel/syscalls/mbind/mbind03.c +2 -2
@@ -68,11 +68,11 @@ static void verify_policy(int mode, unsigned flag)if (TST_RET ) {tst_res (TFAIL |TTERRNO ,"mbind(%s, %s) node %u" , -tst_numa_mode_name (mode),mbind_flag_name (flag), node); +tst_mempolicy_mode_name (mode),mbind_flag_name (flag), node); goto exit; }else {tst_res (TPASS ,"mbind(%s, %s) node %u succeded" , -tst_numa_mode_name (mode),mbind_flag_name (flag), node); +tst_mempolicy_mode_name (mode),mbind_flag_name (flag), node); }tst_nodemap_reset_counters (nodes);
testcases/kernel/syscalls/mbind/mbind04.c +2 -2
@@ -61,12 +61,12 @@ static void verify_policy(unsigned int node, int mode, unsigned flag)if (TST_RET ) {tst_res (TFAIL |TTERRNO ,"mbind(%s, %s) node %u" , -tst_numa_mode_name (mode),mbind_flag_name (flag), node); +tst_mempolicy_mode_name (mode),mbind_flag_name (flag), node);return ; }tst_res (TPASS ,"mbind(%s, %s) node %u" , -tst_numa_mode_name (mode),mbind_flag_name (flag), node); +tst_mempolicy_mode_name (mode),mbind_flag_name (flag), node);const char *prefix ="child: " ;
testcases/kernel/syscalls/set_mempolicy/set_mempolicy01.c +2 -2
@@ -55,12 +55,12 @@ static void verify_mempolicy(unsigned int node, int mode)if (TST_RET ) {tst_res (TFAIL |TTERRNO ,"set_mempolicy(%s) node %u" , -tst_numa_mode_name (mode), node); +tst_mempolicy_mode_name (mode), node);return ; }tst_res (TPASS ,"set_mempolicy(%s) node %u" , -tst_numa_mode_name (mode), node); +tst_mempolicy_mode_name (mode), node);numa_free_nodemask (bm);
testcases/kernel/syscalls/set_mempolicy/set_mempolicy03.c +2 -2
@@ -54,12 +54,12 @@ static void verify_mempolicy(unsigned int node, int mode)if (TST_RET ) {tst_res (TFAIL |TTERRNO ,"set_mempolicy(%s) node %u" , -tst_numa_mode_name (mode), node); +tst_mempolicy_mode_name (mode), node);return ; }tst_res (TPASS ,"set_mempolicy(%s) node %u" , -tst_numa_mode_name (mode), node); +tst_mempolicy_mode_name (mode), node);numa_free_nodemask (bm);
Signature · 1 line
2.31.1
PATCH 3/3 mbind01: add more tests for MPOL_LOCAL
In reply to Li Wang--- testcases/kernel/syscalls/mbind/mbind01.c | 25 ++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
testcases/kernel/syscalls/mbind/mbind01.c +22 -3
@@ -34,7 +34,7 @@ static struct bitmask *nodemask, *getnodemask, *empty_nodemask;static void test_default (unsigned int i,char *p);static void test_none (unsigned int i,char *p);static void test_invalid_nodemask (unsigned int i,char *p); -static void check_policy_pref_no_target (int ); +static void check_policy_pref_or_local (int );struct test_case {int policy;
@@ -92,7 +92,7 @@ static struct test_case tcase[] = { .ret = 0, .err = 0, .test = test_none, - .check_policy = check_policy_pref_no_target, + .check_policy = check_policy_pref_or_local, }, { POLICY_DESC(MPOL_PREFERRED),
@@ -101,6 +101,20 @@ static struct test_case tcase[] = { .test = test_default, .exp_nodemask = &nodemask, }, + { + POLICY_DESC(MPOL_LOCAL), + .ret = 0, + .err = 0, + .test = test_none, + .exp_nodemask = &empty_nodemask, + .check_policy = check_policy_pref_or_local, + }, + { +POLICY_DESC_TEXT (MPOL_LOCAL ,"target exists" ), + .ret = -1, + .err = EINVAL, + .test = test_default, + }, {POLICY_DESC (UNKNOWN_POLICY ), .ret = -1,
@@ -122,7 +136,7 @@ static struct test_case tcase[] = { }, }; -static void check_policy_pref_no_target (int policy) +static void check_policy_pref_or_local (int policy) {if (policy !=MPOL_PREFERRED && policy !=MPOL_LOCAL ) { tst_res(TFAIL, "Wrong policy: %s(%d), "
@@ -182,6 +196,11 @@ static void do_test(unsigned int i)tst_res (TINFO ,"case %s" , tc->desc); +if ((tst_kvercmp (3 ,8 ,0 )) <0 && (tc->policy ==MPOL_LOCAL )) { +tst_res (TCONF ,"%s is not supported" ,tst_mempolicy_mode_name (tc->policy)); +return ; + } +setup_node (); p = SAFE_MMAP(NULL, MEM_LENGTH, PROT_READ | PROT_WRITE, MAP_PRIVATE |
Signature · 1 line
2.31.1
PATCH 3/3 mbind01: add more tests for MPOL_LOCAL
Quoted 31 lines · Li Wang
Signed-off-by Li Wang <[email protected]>--- testcases/kernel/syscalls/mbind/mbind01.c | 25 ++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)testcases/kernel/syscalls/mbind/mbind01.c +1
-1@@ -34,7 +34,7 @@ static struct bitmask *nodemask, *getnodemask, *empty_nodemask;static void test_default (unsigned int i,char *p);static void test_none (unsigned int i,char *p);static void test_invalid_nodemask (unsigned int i,char *p); -static void check_policy_pref_no_target (int ); +static void check_policy_pref_or_local (int );struct test_case {int policy;testcases/kernel/syscalls/mbind/mbind01.c +1
-1@@ -92,7 +92,7 @@ static struct test_case tcase[] = { .ret = 0, .err = 0, .test = test_none, - .check_policy = check_policy_pref_no_target, + .check_policy = check_policy_pref_or_local, }, { POLICY_DESC(MPOL_PREFERRED),@@ -101,6 +101,20 @@ static struct test_case tcase[] = { .test = test_default,
testcases/kernel/syscalls/mbind/mbind01.c static struct test_case tcase[] = { · line 111
Quoted 10 lines
testcases/kernel/syscalls/mbind/mbind01.c +7
-0.exp_nodemask = &nodemask, }, + { + POLICY_DESC(MPOL_LOCAL), + .ret = 0, + .err = 0, + .test = test_none, + .exp_nodemask = &empty_nodemask, + .check_policy = check_policy_pref_or_local,
This is a bit more permissive, it allows for MPOL_LOCAL to return also MPOL_PREFERRED.
Shouldn't that still be treated as error?
Quoted 20 lines
testcases/kernel/syscalls/mbind/mbind01.c +7
-0+ }, + { + POLICY_DESC_TEXT(MPOL_LOCAL, "target exists"), + .ret = -1, + .err = EINVAL, + .test = test_default, + }, { POLICY_DESC(UNKNOWN_POLICY),.ret = -1,testcases/kernel/syscalls/mbind/mbind01.c +1
-1@@ -122,7 +136,7 @@ static struct test_case tcase[] = { }, }; -static void check_policy_pref_no_target (int policy) +static void check_policy_pref_or_local (int policy) {if (policy !=MPOL_PREFERRED && policy !=MPOL_LOCAL ) { tst_res(TFAIL, "Wrong policy: %s(%d), "
testcases/kernel/syscalls/mbind/mbind01.c static void do_test(unsigned int i) · line 204
Quoted 9 lines
testcases/kernel/syscalls/mbind/mbind01.c +4
-0@@ -182,6 +196,11 @@ static void do_test(unsigned int i)tst_res (TINFO ,"case %s" , tc->desc); +if ((tst_kvercmp (3 ,8 ,0 )) <0 && (tc->policy ==MPOL_LOCAL )) { +tst_res (TCONF ,"%s is not supported" ,tst_mempolicy_mode_name (tc->policy)); +return ; + }
I was thinking of runtime check (to support also downstream kernels that backported it),
but I don't have strong opinion.
Quoted 9 lines
testcases/kernel/syscalls/mbind/mbind01.c +1
-0+setup_node ();p = SAFE_MMAP(NULL,
MEM_LENGTH,PROT_READ|PROT_WRITE,MAP_PRIVATE|
--
2.31.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210729/7098a98b/attachment.htm>
PATCH 3/3 mbind01: add more tests for MPOL_LOCAL
Quoted 41 lines · Jan Stancek
Quoted 37 lines · Li Wang
Signed-off-by Li Wang <[email protected]>--- testcases/kernel/syscalls/mbind/mbind01.c | 25 ++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)testcases/kernel/syscalls/mbind/mbind01.c +1
-1@@ -34,7 +34,7 @@ static struct bitmask *nodemask, *getnodemask, *empty_nodemask;static void test_default (unsigned int i,char *p);static void test_none (unsigned int i,char *p);static void test_invalid_nodemask (unsigned int i,char *p); -static void check_policy_pref_no_target (int ); +static void check_policy_pref_or_local (int );struct test_case {int policy;testcases/kernel/syscalls/mbind/mbind01.c +5
-1@@ -92,7 +92,7 @@ static struct test_case tcase[] = { .ret = 0, .err = 0, .test = test_none, - .check_policy = check_policy_pref_no_target, + .check_policy = check_policy_pref_or_local, }, { POLICY_DESC(MPOL_PREFERRED),@@ -101,6 +101,20 @@ static struct test_case tcase[] = { .test = test_default, .exp_nodemask = &nodemask, }, + { + POLICY_DESC(MPOL_LOCAL), + .ret = 0, + .err = 0,
Quoted 9 lines
testcases/kernel/syscalls/mbind/mbind01.c static struct test_case tcase[] = {
Quoted 4 lines
testcases/kernel/syscalls/mbind/mbind01.c +3
-0+ .test = test_none, + .exp_nodemask = &empty_nodemask, + .check_policy = check_policy_pref_or_local,This is a bit more permissive, it allows for
MPOL_LOCALto return alsoMPOL_PREFERRED.
Shouldn't that still be treated as error?
To strictly this should be an error.
But I slightly think that it's acceptable to get 'MPOL_PREFERRED' on the old kernel (i.e. 4.18.0, v5.13) because 'MPOL_LOCAL' is not treated as a real policy.
And the situation exists for quite a long time.
7858d7bca7fb ("mm/mempolicy: don't handle MPOL_LOCAL like a fake MPOL_PREFERRED policy")
Without this kernel commit, looks like the MPOL_LOCAL will convert to MPOL_PREFERRED in mpol_new.
SYSCAL_DEFINE6(mbind, ...)
kernel_mbind
do_mbind
mpol_new
....
# cat mempolicy.c -n
287 /*
288 * MPOL_PREFERRED cannot be used with MPOL_F_STATIC_NODES or
289 * MPOL_F_RELATIVE_NODES if the nodemask is empty (local
allocation).
290 * All other modes require a valid pointer to a non-empty
nodemask.
291 */
292 if (mode == MPOL_PREFERRED) {
293 if (nodes_empty(*nodes)) {
294 if (((flags & MPOL_F_STATIC_NODES) ||
295 (flags & MPOL_F_RELATIVE_NODES)))
296 return ERR_PTR(-EINVAL);
297 }
298 } else if (mode == MPOL_LOCAL) {
299 if (!nodes_empty(*nodes) ||
300 (flags & MPOL_F_STATIC_NODES) ||
301 (flags & MPOL_F_RELATIVE_NODES))
302 return ERR_PTR(-EINVAL);
303 mode = MPOL_PREFERRED; <--------- this line has
been removed after the commit
304 } else if (nodes_empty(*nodes))
305 return ERR_PTR(-EINVAL);
But maybe I was wrong here, CC FengTang in case he has suggestions on this.
Quoted 8 lines
testcases/kernel/syscalls/mbind/mbind01.c static void do_test(unsigned int i) · line 205
Quoted 7 lines
testcases/kernel/syscalls/mbind/mbind01.c +4
-0+if ((tst_kvercmp (3 ,8 ,0 )) <0 && (tc->policy ==MPOL_LOCAL )) { +tst_res (TCONF ,"%s is not supported" ,tst_mempolicy_mode_name (tc->policy)); +return ; + }
Quoted 4 lines
I was thinking of runtime check (to support also downstream kernels that backported it),
but I don't have strong opinion.
Thanks, I assume there is little probability to backport it.
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20210730/782d0cdb/attachment.htm>
PATCH 3/3 mbind01: add more tests for MPOL_LOCAL
Quoted 55 lines · Li Wang
Quoted 41 lines · Jan Stancek
Quoted 37 lines · Li Wang
Signed-off-by Li Wang <[email protected]>--- testcases/kernel/syscalls/mbind/mbind01.c | 25 ++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)testcases/kernel/syscalls/mbind/mbind01.c +1
-1@@ -34,7 +34,7 @@ static struct bitmask *nodemask, *getnodemask, *empty_nodemask;static void test_default (unsigned int i,char *p);static void test_none (unsigned int i,char *p);static void test_invalid_nodemask (unsigned int i,char *p); -static void check_policy_pref_no_target (int ); +static void check_policy_pref_or_local (int );struct test_case {int policy;testcases/kernel/syscalls/mbind/mbind01.c +5
-1@@ -92,7 +92,7 @@ static struct test_case tcase[] = { .ret = 0, .err = 0, .test = test_none, - .check_policy = check_policy_pref_no_target, + .check_policy = check_policy_pref_or_local, }, { POLICY_DESC(MPOL_PREFERRED),@@ -101,6 +101,20 @@ static struct test_case tcase[] = { .test = test_default, .exp_nodemask = &nodemask, }, + { + POLICY_DESC(MPOL_LOCAL), + .ret = 0, + .err = 0,Quoted 9 lines
testcases/kernel/syscalls/mbind/mbind01.c static struct test_case tcase[] = {
Quoted 4 lines
testcases/kernel/syscalls/mbind/mbind01.c +3
-0+ .test = test_none, + .exp_nodemask = &empty_nodemask, + .check_policy = check_policy_pref_or_local,This is a bit more permissive, it allows for
MPOL_LOCALto return alsoMPOL_PREFERRED.
Shouldn't that still be treated as error?
Quoted 8 lines
To strictly this should be an error.
But I slightly think that it's acceptable to get '
MPOL_PREFERRED' on the old
kernel (i.e. 4.18.0, v5.13) because 'MPOL_LOCAL' is not treated as a real policy.
And the situation exists for quite a long time.
You're right, on older kernel it failed in similar way for MPOL_LOCAL as it failed for MPOL_PREFERRED on latest one.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210730/18bd325e/attachment.htm>
PATCH 3/3 mbind01: add more tests for MPOL_LOCAL
Quoted 68 lines · Jan Stancek
Quoted 55 lines · Li Wang
Quoted 41 lines · Jan Stancek
Quoted 37 lines · Li Wang
Signed-off-by Li Wang <[email protected]>--- testcases/kernel/syscalls/mbind/mbind01.c | 25 ++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)testcases/kernel/syscalls/mbind/mbind01.c +1
-1@@ -34,7 +34,7 @@ static struct bitmask *nodemask, *getnodemask, *empty_nodemask;static void test_default (unsigned int i,char *p);static void test_none (unsigned int i,char *p);static void test_invalid_nodemask (unsigned int i,char *p); -static void check_policy_pref_no_target (int ); +static void check_policy_pref_or_local (int );struct test_case {int policy;testcases/kernel/syscalls/mbind/mbind01.c +5
-1@@ -92,7 +92,7 @@ static struct test_case tcase[] = { .ret = 0, .err = 0, .test = test_none, - .check_policy = check_policy_pref_no_target, + .check_policy = check_policy_pref_or_local, }, { POLICY_DESC(MPOL_PREFERRED),@@ -101,6 +101,20 @@ static struct test_case tcase[] = { .test = test_default, .exp_nodemask = &nodemask, }, + { + POLICY_DESC(MPOL_LOCAL), + .ret = 0, + .err = 0,Quoted 9 lines
testcases/kernel/syscalls/mbind/mbind01.c static struct test_case tcase[] = {
Quoted 4 lines
testcases/kernel/syscalls/mbind/mbind01.c +3
-0+ .test = test_none, + .exp_nodemask = &empty_nodemask, + .check_policy = check_policy_pref_or_local,This is a bit more permissive, it allows for
MPOL_LOCALto return alsoMPOL_PREFERRED.
Shouldn't that still be treated as error?Quoted 8 lines
To strictly this should be an error.
But I slightly think that it's acceptable to get '
MPOL_PREFERRED' on the old
kernel (i.e. 4.18.0, v5.13) because 'MPOL_LOCAL' is not treated as a real policy.
And the situation exists for quite a long time.
Quoted 3 lines
You're right, on older kernel it failed in similar way for
MPOL_LOCALas it failed forMPOL_PREFERREDon latest one.
Or, If we want something more precise, just cancel the check_policy_pref_or_local on kernel >= 5.14.
Is this sound better?
- if ((tst_kvercmp(3, 8, 0)) < 0 && (tc->policy == MPOL_LOCAL)) {
- tst_res(TCONF, "%s is not supported",tst_mempolicy_mode_name(tc->policy));
- return;
+ if (tc->policy == MPOL_LOCAL) {
+ if ((tst_kvercmp(3, 8, 0)) < 0) {
+ tst_res(TCONF, "%s is not supported",tst_mempolicy_mode_name(tc->policy));
+ return;
+ }
+
+ if ((tst_kvercmp(5, 14, 0)) >= 0)
+ tc->check_policy = NULL;
Quoted 4 lines
Acked-by Jan Stancek <[email protected]>
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20210730/aa0582ad/attachment-0001.htm>
PATCH 3/3 mbind01: add more tests for MPOL_LOCAL
Quoted 17 lines
Or, If we want something more precise, just cancel the
check_policy_pref_or_localon kernel >= 5.14.Is this sound better?
(quoted diff) +0
-2- if ((tst_kvercmp(3, 8, 0)) < 0 && (tc->policy == MPOL_LOCAL)) { - tst_res(TCONF, "%s is not supported",
tst_mempolicy_mode_name(tc->policy));(quoted diff) +3
-1- return; + if (tc->policy == MPOL_LOCAL) { + if ((tst_kvercmp(3, 8, 0)) < 0) { + tst_res(TCONF, "%s is not supported",
tst_mempolicy_mode_name(tc->policy));
testcases/kernel/syscalls/mbind/mbind01.c static void do_test(unsigned int i)
Quoted 5 lines
testcases/kernel/syscalls/mbind/mbind01.c +5
-0+return ; + } + +if ((tst_kvercmp (5 ,14 ,0 )) >=0 ) + tc->check_policy =NULL ;
Yes, that works too.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210730/78002607/attachment.htm>
PATCH 3/3 mbind01: add more tests for MPOL_LOCAL
In reply to Li WangHi Li,
On Fri, Jul 30, 2021 at 04:03:28PM +0800, Li Wang wrote:
[....]
Quoted 59 lines · Jan Stancek
Quoted 8 lines
Quoted 8 lines
testcases/kernel/syscalls/mbind/mbind01.c +4
-0@@ -101,6 +101,20 @@ static struct test_case tcase[] = { .test = test_default, .exp_nodemask = &nodemask, }, + { + POLICY_DESC(MPOL_LOCAL), + .ret = 0, + .err = 0,Quoted 9 lines
testcases/kernel/syscalls/mbind/mbind01.c static struct test_case tcase[] = {
Quoted 4 lines
testcases/kernel/syscalls/mbind/mbind01.c +3
-0+ .test = test_none, + .exp_nodemask = &empty_nodemask, + .check_policy = check_policy_pref_or_local,This is a bit more permissive, it allows for
MPOL_LOCALto return alsoMPOL_PREFERRED.
Shouldn't that still be treated as error?To strictly this should be an error.
But I slightly think that it's acceptable to get '
MPOL_PREFERRED' on the old kernel (i.e. 4.18.0, v5.13) because 'MPOL_LOCAL' is not treated as a real policy.
And the situation exists for quite a long time.
7858d7bca7fb("mm/mempolicy: don't handleMPOL_LOCALlike a fakeMPOL_PREFERREDpolicy")Without this kernel commit, looks like the
MPOL_LOCALwill convert toMPOL_PREFERREDinmpol_new.
SYSCAL_DEFINE6(mbind, ...)
kernel_mbind
do_mbind
mpol_new....# cat mempolicy.c -n287 /*
288 *MPOL_PREFERREDcannot be used withMPOL_F_STATIC_NODESor
289 *MPOL_F_RELATIVE_NODESif the nodemask is empty (local
allocation).
290 * All other modes require a valid pointer to a non-empty
nodemask.
291 */292 if (mode == MPOL_PREFERRED) { 293 if (nodes_empty(*nodes)) { 294 if (((flags & MPOL_F_STATIC_NODES) || 295 (flags & MPOL_F_RELATIVE_NODES))) 296 return ERR_PTR(-EINVAL); 297 } 298 } else if (mode == MPOL_LOCAL) { 299 if (!nodes_empty(*nodes) || 300 (flags & MPOL_F_STATIC_NODES) || 301 (flags & MPOL_F_RELATIVE_NODES)) 302 return ERR_PTR(-EINVAL); 303 mode = MPOL_PREFERRED; <--------- this line has
Quoted 5 lines
been removed after the commit
304 } else if (nodes_empty(*nodes))
305 returnERR_PTR(-EINVAL);But maybe I was wrong here, CC FengTang in case he has suggestions on this.
Yes, you are right. With the commit MPOL_LOCAL will be taken as a real policy, be MPOL_LOCAL itself, and not a fake MPOL_PREFERRED.
Faking MPOL_LOCAL as a MPOL_PREFERRED makes the semantic very confusing, and the kenrel code is also very confusing and difficult to be maintained, as there are many ambiguous logic to check this faking and transform the policy back and forth. So we chosed to clean it up.
Thanks,
Feng
Quoted 19 lines
Quoted 9 lines
testcases/kernel/syscalls/mbind/mbind01.c static void do_test(unsigned int i) · line 205
Quoted 8 lines
testcases/kernel/syscalls/mbind/mbind01.c +4
-0+if ((tst_kvercmp (3 ,8 ,0 )) <0 && (tc->policy ==MPOL_LOCAL )) { +tst_res (TCONF ,"%s is not supported" ,tst_mempolicy_mode_name (tc->policy)); +return ; + }Quoted 4 lines
I was thinking of runtime check (to support also downstream kernels that backported it),
but I don't have strong opinion.Thanks, I assume there is little probability to backport it.
Signature · 2 lines
Regards, Li Wang
PATCH 3/3 mbind01: add more tests for MPOL_LOCAL
Hi Jan, Feng,
Thanks for your confirmation, the patch was applied.
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20210802/bfe4861b/attachment.htm>