* [LTP] [PATCH 2/2] get_mempolicy: enable libnuma API == 2
@ 2012-03-09 8:46 Caspar Zhang
2012-03-09 8:47 ` [LTP] [PATCH] " Caspar Zhang
2012-03-09 17:40 ` [LTP] [PATCH 2/2] " Caspar Zhang
0 siblings, 2 replies; 3+ messages in thread
From: Caspar Zhang @ 2012-03-09 8:46 UTC (permalink / raw)
To: LTP List
[-- Attachment #1: Type: text/plain, Size: 263 bytes --]
This patch enables get_mempolicy01 test when libnuma API version is 2.
Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
---
.../syscalls/get_mempolicy/get_mempolicy01.c | 73 +++++++++++++-------
1 files changed, 47 insertions(+), 26 deletions(-)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-get_mempolicy-enable-libnuma-API-2.patch --]
[-- Type: text/x-patch; name="0002-get_mempolicy-enable-libnuma-API-2.patch", Size: 4448 bytes --]
diff --git a/testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c b/testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c
index bea681b..75164d0 100644
--- a/testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c
+++ b/testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c
@@ -70,14 +70,8 @@ int TST_TOTAL = 1; /* total number of tests in this file. */
#if HAVE_NUMA_H && HAVE_NUMAIF_H && HAVE_MPOL_CONSTANTS
-#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
-
#define MEM_LENGTH (4 * 1024 * 1024)
-static int do_test(struct test_case *tc);
-static void setup(void);
-static void cleanup(void);
-
static int testno;
enum test_type {
@@ -198,6 +192,10 @@ static struct test_case tcase[] = {
},
};
+static int do_test(struct test_case *tc);
+static void setup(void);
+static void cleanup(void);
+
int main(int argc, char **argv)
{
int i, ret, lc;
@@ -225,16 +223,23 @@ static int do_test(struct test_case *tc)
{
int ret, err, result, cmp_ok;
int policy, flags;
- nodemask_t nodemask, getnodemask;
+#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
+ nodemask_t *nodemask, *getnodemask;
unsigned long maxnode = NUMA_NUM_NODES;
+#else
+ struct bitmask *nodemask = numa_allocate_nodemask();
+ struct bitmask *getnodemask = numa_allocate_nodemask();
+#endif
char *p = NULL;
unsigned long len = MEM_LENGTH;
- /* We assume that there is only one node(node0). */
- nodemask_zero(&nodemask); /* Segfaults here with libnuma v2. */
- nodemask_set(&nodemask, 0);
- nodemask_zero(&getnodemask);
-
+#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
+ nodemask_zero(nodemask);
+ nodemask_set(nodemask, 0);
+ nodemask_zero(getnodemask);
+#else
+ numa_bitmask_setbit(nodemask, 0);
+#endif
switch (tc->ttype) {
case DEFAULT:
flags = 0;
@@ -243,12 +248,18 @@ static int do_test(struct test_case *tc)
TEST(syscall(__NR_set_mempolicy, tc->policy,
NULL, 0));
else
+#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
+ TEST(syscall(__NR_set_mempolicy, tc->policy,
+ nodemask, maxnode));
+#else
TEST(syscall(__NR_set_mempolicy, tc->policy,
- &nodemask, maxnode));
- if (TESET_RETURN < 0) {
+ nodemask->maskp, nodemask->size));
+#endif
+ if (TEST_RETURN < 0) {
tst_resm(TBROK|TERRNO, "set_mempolicy");
return -1;
}
+
break;
default:
flags = MPOL_F_ADDR;
@@ -260,32 +271,49 @@ static int do_test(struct test_case *tc)
TEST(syscall(__NR_mbind, p, len, tc->policy,
NULL, 0, 0));
else
+#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
+ TEST(syscall(__NR_mbind, p, len, tc->policy,
+ nodemask, maxnode, 0));
+#else
TEST(syscall(__NR_mbind, p, len, tc->policy,
- &nodemask, maxnode, 0));
+ nodemask->maskp, nodemask->size,
+ 0));
+#endif
if (TEST_RETURN < 0) {
tst_brkm(TBROK|TERRNO, cleanup, "mbind");
return -1;
}
if (tc->ttype == INVALID_POINTER)
- p = NULL;
+ p = 0;
if (tc->ttype == INVALID_FLAGS)
flags = -1;
}
errno = 0;
cmp_ok = 1;
- TEST(ret = syscall(__NR_get_mempolicy, &policy, &getnodemask,
+#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
+ TEST(ret = syscall(__NR_get_mempolicy, &policy, getnodemask,
maxnode, p, flags));
+#else
+ TEST(ret = syscall(__NR_get_mempolicy, &policy, getnodemask->maskp,
+ getnodemask->size, p, flags));
+#endif
err = errno;
if (ret < 0)
goto TEST_END;
/* if policy == MPOL_DEFAULT, get_mempolicy doesn't return nodemask */
if (tc->policy == MPOL_DEFAULT)
- nodemask_zero(&nodemask);
+#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
+ nodemask_zero(nodemask);
+ cmp_ok = (tc->policy == policy && (tc->from_node == NONE ||
+ nodemask_equal(nodemask, getnodemask)));
+#else
+ numa_bitmask_clearall(nodemask);
cmp_ok = (tc->policy == policy && (tc->from_node == NONE ||
- nodemask_equal(&nodemask, &getnodemask)));
+ numa_bitmask_equal(nodemask, getnodemask)));
+#endif
TEST_END:
result = (err != tc->err) || !cmp_ok;
PRINT_RESULT_CMP(0, tc->ret, tc->err, ret, err, cmp_ok);
@@ -307,13 +335,6 @@ static void setup(void)
#else
int main(void)
{
- tst_brkm(TCONF, NULL, "XXX: test is broken on libnuma v2 "
- "(read numa_helpers.h for more details).");
-}
-#endif
-#else
-int main(void)
-{
tst_brkm(TCONF, NULL, "System doesn't have required numa support");
}
#endif
[-- Attachment #3: Type: text/plain, Size: 317 bytes --]
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
[-- Attachment #4: Type: text/plain, Size: 155 bytes --]
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH] get_mempolicy: enable libnuma API == 2
2012-03-09 8:46 [LTP] [PATCH 2/2] get_mempolicy: enable libnuma API == 2 Caspar Zhang
@ 2012-03-09 8:47 ` Caspar Zhang
2012-03-09 17:40 ` [LTP] [PATCH 2/2] " Caspar Zhang
1 sibling, 0 replies; 3+ messages in thread
From: Caspar Zhang @ 2012-03-09 8:47 UTC (permalink / raw)
To: LTP List
On 03/09/2012 04:46 PM, Caspar Zhang wrote:
>
> This patch enables get_mempolicy01 test when libnuma API version is 2.
>
> Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
> ---
> .../syscalls/get_mempolicy/get_mempolicy01.c | 73 +++++++++++++-------
> 1 files changed, 47 insertions(+), 26 deletions(-)
>
sorry, wrong title, should be PATCH 1/1 ...
Thanks,
Caspar
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH 2/2] get_mempolicy: enable libnuma API == 2
2012-03-09 8:46 [LTP] [PATCH 2/2] get_mempolicy: enable libnuma API == 2 Caspar Zhang
2012-03-09 8:47 ` [LTP] [PATCH] " Caspar Zhang
@ 2012-03-09 17:40 ` Caspar Zhang
1 sibling, 0 replies; 3+ messages in thread
From: Caspar Zhang @ 2012-03-09 17:40 UTC (permalink / raw)
To: LTP List
On 03/09/2012 04:46 PM, Caspar Zhang wrote:
>
> This patch enables get_mempolicy01 test when libnuma API version is 2.
>
> Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
> ---
> .../syscalls/get_mempolicy/get_mempolicy01.c | 73 +++++++++++++-------
> 1 files changed, 47 insertions(+), 26 deletions(-)
>
FYI, updated the patch and tested in RHEL5 and RHEL6, both libnuma v1
and v2 work well. Also fixed mbind01, both patches committed.
Thanks,
Caspar
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-03-09 17:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-09 8:46 [LTP] [PATCH 2/2] get_mempolicy: enable libnuma API == 2 Caspar Zhang
2012-03-09 8:47 ` [LTP] [PATCH] " Caspar Zhang
2012-03-09 17:40 ` [LTP] [PATCH 2/2] " Caspar Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox