<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 29, 2021 at 10:20 PM Jan Stancek <<a href="mailto:jstancek@redhat.com" target="_blank">jstancek@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div style="font-family:monospace"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 29, 2021 at 3:25 PM Li Wang <<a href="mailto:liwang@redhat.com" target="_blank">liwang@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Signed-off-by: Li Wang <<a href="mailto:liwang@redhat.com" target="_blank">liwang@redhat.com</a>><br>
---<br>
 testcases/kernel/syscalls/mbind/mbind01.c | 25 ++++++++++++++++++++---<br>
 1 file changed, 22 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/testcases/kernel/syscalls/mbind/mbind01.c b/testcases/kernel/syscalls/mbind/mbind01.c<br>
index d2cf13c8f..b5c1e948d 100644<br>
--- a/testcases/kernel/syscalls/mbind/mbind01.c<br>
+++ b/testcases/kernel/syscalls/mbind/mbind01.c<br>
@@ -34,7 +34,7 @@ static struct bitmask *nodemask, *getnodemask, *empty_nodemask;<br>
 static void test_default(unsigned int i, char *p);<br>
 static void test_none(unsigned int i, char *p);<br>
 static void test_invalid_nodemask(unsigned int i, char *p);<br>
-static void check_policy_pref_no_target(int);<br>
+static void check_policy_pref_or_local(int);<br>
<br>
 struct test_case {<br>
        int policy;<br>
@@ -92,7 +92,7 @@ static struct test_case tcase[] = {<br>
                .ret = 0,<br>
                .err = 0,<br>
                .test = test_none,<br>
-               .check_policy = check_policy_pref_no_target,<br>
+               .check_policy = check_policy_pref_or_local,<br>
        },<br>
        {<br>
                POLICY_DESC(MPOL_PREFERRED),<br>
@@ -101,6 +101,20 @@ static struct test_case tcase[] = {<br>
                .test = test_default,<br>
                .exp_nodemask = &nodemask,<br>
        },<br>
+       {<br>
+               POLICY_DESC(MPOL_LOCAL),<br>
+               .ret = 0,<br>
+               .err = 0,<br>
+               .test = test_none,<br>
+               .exp_nodemask = &empty_nodemask,<br>
+               .check_policy = check_policy_pref_or_local,<br></blockquote><div><br></div><div><div style="font-family:monospace">This is a bit more permissive, it allows for MPOL_LOCAL to return also MPOL_PREFERRED.</div><div style="font-family:monospace">

</div><div style="font-family:monospace">Shouldn't that still be treated as error?</div></div></div></div></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">To strictly this should be an error.</div><div class="gmail_default" style="font-size:small"><br></div></div><span class="gmail_default" style="font-size:small">But </span>I <span class="gmail_default" style="font-size:small">slightly think</span> that<span class="gmail_default" style="font-size:small"> it's</span> acceptable <span class="gmail_default" style="font-size:small">to</span> get 'MPOL_PREFERRED'<span class="gmail_default" style="font-size:small"> </span>on<span class="gmail_default" style="font-size:small"> the old</span></div><div class="gmail_quote"><span class="gmail_default" style="font-size:small">kernel (i.e. 4.18</span><span class="gmail_default" style="font-size:small">.0, v5.13) </span><span class="gmail_default">because</span> 'MPOL_LOCAL' is not treated as a real policy.</div><div class="gmail_quote"><div class="gmail_default" style="font-size:small">And the situation exists for quite a long time.</div></div><div class="gmail_quote"><br></div><div class="gmail_quote"><div class="gmail_default" style="font-size:small">  7858d7bca7fb ("mm/mempolicy: don't handle MPOL_LOCAL like a fake</div><div class="gmail_default" style="font-size:small">  MPOL_PREFERRED policy")<br class="gmail-Apple-interchange-newline"></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Without this kernel commit, looks like the MPOL_LOCAL will convert to</div><div class="gmail_default" style="font-size:small">MPOL_PREFERRED in mpol_new.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><div class="gmail_default">SYSCAL_DEFINE6(mbind, ...)</div><div class="gmail_default"> kernel_mbind</div><div class="gmail_default">  do_mbind</div><div class="gmail_default">   mpol_new</div><div class="gmail_default">     ....</div><div class="gmail_default"><br></div></div></div><div class="gmail_quote"><div class="gmail_default" style="font-size:small"># cat mempolicy.c -n</div><br></div><div class="gmail_quote"><div class="gmail_default" style="font-size:small">   287          /*</div>   288           * MPOL_PREFERRED cannot be used with MPOL_F_STATIC_NODES or<br>   289           * MPOL_F_RELATIVE_NODES if the nodemask is empty (local allocation).<br>   290           * All other modes require a valid pointer to a non-empty nodemask.<br>   291           */<br>   292          if (mode == MPOL_PREFERRED) {<br>   293                  if (nodes_empty(*nodes)) {<br>   294                          if (((flags & MPOL_F_STATIC_NODES) ||<br>   295                               (flags & MPOL_F_RELATIVE_NODES)))<br>   296                                  return ERR_PTR(-EINVAL);<br>   297                  }<br>   298          } else if (mode == MPOL_LOCAL) {<br>   299                  if (!nodes_empty(*nodes) ||<br>   300                      (flags & MPOL_F_STATIC_NODES) ||<br>   301                      (flags & MPOL_F_RELATIVE_NODES))<br>   302                          return ERR_PTR(-EINVAL);<br>   303                  mode = MPOL_PREFERRED;<span class="gmail_default" style="font-size:small">    <--------- this line has been removed after the commit</span><br>   304          } else if (nodes_empty(*nodes))<br>   305                  return ERR_PTR(-EINVAL);<br></div><div class="gmail_quote"><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">But maybe I was wrong here, CC FengTang in case he has suggestions on this.</div><div class="gmail_default" style="font-size:small"> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
+       if ((tst_kvercmp(3, 8, 0)) < 0 && (tc->policy == MPOL_LOCAL)) {<br>
+               tst_res(TCONF, "%s is not supported", tst_mempolicy_mode_name(tc->policy));<br>
+               return;<br>
+       }<br></blockquote><div><br></div><div><div style="font-family:monospace">I was thinking of runtime check (to support also downstream kernels that backported it),</div><div style="font-family:monospace">but I don't have strong opinion.<br></div></div></div></div></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Thanks, I assume there is little probability to backport it.</div></div></div><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>