---
 Makefile        |    4 ++++
 test/tshared2.c |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)

Index: numactl-dev/test/tshared2.c
===================================================================
--- /dev/null
+++ numactl-dev/test/tshared2.c
@@ -0,0 +1,51 @@
+#include <numa.h>
+#include <numaif.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#define err(x) perror(x),exit(1)
+
+enum SZ {
+	MEMSZ = 100<<20,
+	NTHR = 10,
+};
+
+/* test if shared interleaving state works. */
+int main(void)
+{
+	int i, k;
+	char *mem;
+	int pagesz = getpagesize();
+	int max_node;
+	int errs = 0;
+
+	if (numa_available() < 0) {
+		printf("no NUMA API available\n");
+		exit(1);
+	}
+	max_node = numa_max_node();
+	mem = numa_alloc_interleaved(MEMSZ);
+	for (i = 0; i < MEMSZ; i += pagesz) {
+		*(mem+i) = 1;
+	}
+	k = 1;
+	for (i = 0; i < MEMSZ; i += pagesz) {
+		int nd;
+		if (get_mempolicy(&nd, NULL, 0, mem + i,
+						MPOL_F_NODE|MPOL_F_ADDR) < 0) {
+			err("get_mempolicy");
+		}
+		if (nd != k) {
+			printf("%p offset %d node %d expected %d\n",
+							mem+i, i, nd, k);
+			errs++;
+		}
+		k = (k+1)%(max_node+1);
+	}
+	if (errs == 0)
+		printf("Success\n");
+
+	return 0;
+}
Index: numactl-dev/Makefile
===================================================================
--- numactl-dev.orig/Makefile
+++ numactl-dev/Makefile
@@ -26,6 +26,7 @@ CLEANFILES := numactl.o libnuma.o numact
 	      memhog libnuma.so libnuma.so.1 numamon numamon.o syscall.o bitops.o \
 	      memhog.o util.o stream_main.o stream_lib.o shm.o stream clearcache.o \
 	      test/pagesize test/tshared test/mynode.o test/tshared.o mt.o empty.o empty.c \
+	      test/tshared2 \
 	      test/mynode test/ftok test/prefered test/randmap \
 	      .depend .depend.X test/nodemap test/distance test/tbitmap \
 	      test/after test/before threadtest test_move_pages \
@@ -43,6 +44,7 @@ docdir := ${prefix}/share/doc
 
 all: numactl migratepages migspeed libnuma.so numademo numamon memhog \
      test/tshared stream test/mynode test/pagesize test/ftok test/prefered \
+     test/tshared2 \
      test/randmap test/nodemap test/distance test/tbitmap test/move_pages \
      test/mbind_mig_pages test/migrate_pages test/realloc_test libnuma.a \
      test/node-parse
@@ -109,6 +111,8 @@ rtnetlink.o : CFLAGS += -fPIC
 
 test/tshared: test/tshared.o libnuma.so
 
+test/tshared2: test/tshared2.o libnuma.so
+
 test/mynode: test/mynode.o libnuma.so
 
 test/pagesize: test/pagesize.c libnuma.so
