Skip to contentSkip to conversation

numa_helper: don't break is_numa() with TCONF

PATCH New Jan Stancek 2 participants 4 messages Feb 19, 2016 – Feb 22, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 numa_helper: don't break is_numa() with TCONF

Li reported, that some oom tests on aarch64 exit with TCONF during is_numa() call, because get_mempolicy syscall is not implemented. And because numa_helper used ltp_syscall() it terminated the test in all instances.

Switch to syscall() and let the tests decide what should happen if system doesn't support NUMA.

---
 testcases/kernel/lib/numa_helper.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
testcases/kernel/lib/numa_helper.c +10 -2
index 0074180991ec..91214fcd85d9 100644
@@ -76,14 +76,22 @@ static int filter_nodemask_mem(nodemask_t * nodemask, unsigned long max_node)
 {
 #if MPOL_F_MEMS_ALLOWED
 	unsigned long nodemask_size = max_node / 8;
+	int ret;
+
 	memset(nodemask, 0, nodemask_size);
 	/*
 	 * avoid numa_get_mems_allowed(), because of bug in getpol()
 	 * utility function in older versions:
 	 * http://www.spinics.net/lists/linux-numa/msg00849.html
 	 */
-	if (ltp_syscall(__NR_get_mempolicy, NULL, nodemask->n,
-		    max_node, 0, MPOL_F_MEMS_ALLOWED) < 0)
+	ret = syscall(__NR_get_mempolicy, NULL, nodemask->n,
+		    max_node, 0, MPOL_F_MEMS_ALLOWED);
+	/*
+	 * If we don't have __NR_get_mempolicy assume we can use all
+	 * present nodes. It is likely this is a system, that doesn't
+	 * support NUMA and there's just 1 node.
+	 */
+	if (ret < 0 && errno != ENOSYS)
 		return -2;
 #else
 	int i;
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 numa_helper: don't break is_numa() with TCONF

Hi!

Quoted 7 lines

Li reported, that some oom tests on aarch64 exit with TCONF during is_numa() call, because get_mempolicy syscall is not implemented. And because numa_helper used ltp_syscall() it terminated the test in all instances.

Switch to syscall() and let the tests decide what should happen if system doesn't support NUMA.

Looking at the code the return value from filter_nodemask_mem() can be propagated to get_allowed_nodes() and doing git grep "get_allowed_nodes" suggets that most of the testcases does tst_brkm(TBROK | TERRNO, ...) if the call returned non-zero. Have you checked that they exit with TCONF on non-numa system before they reach the call to get_allowed_nodes()?

And the same for is_numa(), it calls tst_brkm(TBROK | TERRNO, ...) in case that get_allowed_nodes_arr() returned non-zero.

Or am I missing something?

Signature · 2 lines
Cyril Hrubis
[email protected]
#2 lore raw

PATCH 1/1 numa_helper: don't break is_numa() with TCONF

----- Original Message -----

Quoted 12 lines

From: "Cyril Hrubis" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: [email protected]
Sent: Monday, 22 February, 2016 12:36:15 PM
Subject: Re: [LTP] [PATCH] numa_helper: don't break is_numa() with TCONF

Hi!

Quoted 5 lines

Li reported, that some oom tests on aarch64 exit with TCONF during is_numa() call, because get_mempolicy syscall is not implemented. And because numa_helper used ltp_syscall() it terminated the test in all instances.

Quoted 7 lines
Quoted 2 lines

Switch to syscall() and let the tests decide what should happen if system doesn't support NUMA.

Looking at the code the return value from filter_nodemask_mem() can be propagated to get_allowed_nodes() and doing git grep "get_allowed_nodes" suggets that most of the testcases does tst_brkm(TBROK | TERRNO, ...) if the call returned non-zero.

This patch hides ENOSYS returned from get_mempolicy. So the callers won't get any more failures than before. Callers should still check how many nodes have been returned and if that numbers works for the test or not.

Quoted 2 lines

Have you checked that they exit with TCONF
on non-numa system before they reach the call to get_allowed_nodes()?

They should be free to call get_allowed_nodes(), at worst all they get back is empty set.

We could add extra call of numa_available() to setup() before call to get_allowed_nodes(), but since its implementation relies on same syscall I'm not sure it's worth it:

int numa_available(void)

{
        if (get_mempolicy(NULL, NULL, 0, 0, 0) < 0 && errno == ENOSYS)
                return -1;
        return 0;
}
Quoted 3 lines

And the same for is_numa(), it calls tst_brkm(TBROK | TERRNO, ...) in case that get_allowed_nodes_arr() returned non-zero.

If get_allowed_nodes_arr() returned non-zero because of get_mempolicy, that means get_mempolicy is implemented but failed. I think that justifies TBROK.

Regards,
Jan

#3 lore raw

PATCH 1/1 numa_helper: don't break is_numa() with TCONF

Hi!

Quoted 6 lines
Quoted 2 lines

And the same for is_numa(), it calls tst_brkm(TBROK | TERRNO, ...) in case that get_allowed_nodes_arr() returned non-zero.

If get_allowed_nodes_arr() returned non-zero because of get_mempolicy, that means get_mempolicy is implemented but failed. I think that justifies TBROK.

Now I'm confused. You said that the syscall can exit -1 and ENOSYS. In that case the filter_nodemask_mem() returns -2 which is propagated from get_allowed_nodes_arr() to is_numa() where the test ends with TBROK rather than with TCONF. Or did I miss something?

Signature · 2 lines
Cyril Hrubis
[email protected]