1*49cdfc7eSAndroid Build Coastguard Worker /*
2*49cdfc7eSAndroid Build Coastguard Worker * Copyright (C) 2012 Linux Test Project
3*49cdfc7eSAndroid Build Coastguard Worker *
4*49cdfc7eSAndroid Build Coastguard Worker * This program is free software; you can redistribute it and/or
5*49cdfc7eSAndroid Build Coastguard Worker * modify it under the terms of version 2 of the GNU General Public
6*49cdfc7eSAndroid Build Coastguard Worker * License as published by the Free Software Foundation.
7*49cdfc7eSAndroid Build Coastguard Worker *
8*49cdfc7eSAndroid Build Coastguard Worker * This program is distributed in the hope that it would be useful,
9*49cdfc7eSAndroid Build Coastguard Worker * but WITHOUT ANY WARRANTY; without even the implied warranty of
10*49cdfc7eSAndroid Build Coastguard Worker * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11*49cdfc7eSAndroid Build Coastguard Worker *
12*49cdfc7eSAndroid Build Coastguard Worker * Further, this software is distributed without any warranty that it
13*49cdfc7eSAndroid Build Coastguard Worker * is free of the rightful claim of any third person regarding
14*49cdfc7eSAndroid Build Coastguard Worker * infringement or the like. Any license provided herein, whether
15*49cdfc7eSAndroid Build Coastguard Worker * implied or otherwise, applies only to this software file. Patent
16*49cdfc7eSAndroid Build Coastguard Worker * licenses, if any, provided herein do not apply to combinations of
17*49cdfc7eSAndroid Build Coastguard Worker * this program with other software, or any other product whatsoever.
18*49cdfc7eSAndroid Build Coastguard Worker *
19*49cdfc7eSAndroid Build Coastguard Worker * You should have received a copy of the GNU General Public License
20*49cdfc7eSAndroid Build Coastguard Worker * along with this program; if not, write the Free Software
21*49cdfc7eSAndroid Build Coastguard Worker * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22*49cdfc7eSAndroid Build Coastguard Worker * 02110-1301, USA.
23*49cdfc7eSAndroid Build Coastguard Worker */
24*49cdfc7eSAndroid Build Coastguard Worker /*
25*49cdfc7eSAndroid Build Coastguard Worker * There are several corner cases (documented in mm/mmap.c) for mbind
26*49cdfc7eSAndroid Build Coastguard Worker * vma merge issue, which makes commit 8aacc9f550 slightly incorrect.
27*49cdfc7eSAndroid Build Coastguard Worker * KOSAKI Motohiro made a patch for it (commit e26a511) and composed
28*49cdfc7eSAndroid Build Coastguard Worker * a reproducer containing these corner cases. Now I port it to LTP.
29*49cdfc7eSAndroid Build Coastguard Worker *
30*49cdfc7eSAndroid Build Coastguard Worker * Author: KOSAKI Motohiro <[email protected]>
31*49cdfc7eSAndroid Build Coastguard Worker * Ported-to-LTP-by: Caspar Zhang <[email protected]>
32*49cdfc7eSAndroid Build Coastguard Worker */
33*49cdfc7eSAndroid Build Coastguard Worker
34*49cdfc7eSAndroid Build Coastguard Worker #include "config.h"
35*49cdfc7eSAndroid Build Coastguard Worker #include <sys/types.h>
36*49cdfc7eSAndroid Build Coastguard Worker #include <sys/mman.h>
37*49cdfc7eSAndroid Build Coastguard Worker #include <errno.h>
38*49cdfc7eSAndroid Build Coastguard Worker #if HAVE_NUMA_H
39*49cdfc7eSAndroid Build Coastguard Worker #include <numa.h>
40*49cdfc7eSAndroid Build Coastguard Worker #endif
41*49cdfc7eSAndroid Build Coastguard Worker #if HAVE_NUMAIF_H
42*49cdfc7eSAndroid Build Coastguard Worker #include <numaif.h>
43*49cdfc7eSAndroid Build Coastguard Worker #endif
44*49cdfc7eSAndroid Build Coastguard Worker #include <stdio.h>
45*49cdfc7eSAndroid Build Coastguard Worker #include <stdlib.h>
46*49cdfc7eSAndroid Build Coastguard Worker #include <string.h>
47*49cdfc7eSAndroid Build Coastguard Worker #include <unistd.h>
48*49cdfc7eSAndroid Build Coastguard Worker #include <limits.h>
49*49cdfc7eSAndroid Build Coastguard Worker #include "test.h"
50*49cdfc7eSAndroid Build Coastguard Worker #include "safe_macros.h"
51*49cdfc7eSAndroid Build Coastguard Worker #include "numa_helper.h"
52*49cdfc7eSAndroid Build Coastguard Worker
53*49cdfc7eSAndroid Build Coastguard Worker char *TCID = "vma04";
54*49cdfc7eSAndroid Build Coastguard Worker int TST_TOTAL = 5;
55*49cdfc7eSAndroid Build Coastguard Worker
56*49cdfc7eSAndroid Build Coastguard Worker #ifdef HAVE_NUMA_V2
57*49cdfc7eSAndroid Build Coastguard Worker
58*49cdfc7eSAndroid Build Coastguard Worker static unsigned long pagesize;
59*49cdfc7eSAndroid Build Coastguard Worker static int opt_node;
60*49cdfc7eSAndroid Build Coastguard Worker static char *opt_nodestr;
61*49cdfc7eSAndroid Build Coastguard Worker static char retbuf[BUFSIZ];
62*49cdfc7eSAndroid Build Coastguard Worker static void *mmap_addr;
63*49cdfc7eSAndroid Build Coastguard Worker static struct bitmask *nmask;
64*49cdfc7eSAndroid Build Coastguard Worker
65*49cdfc7eSAndroid Build Coastguard Worker static option_t options[] = {
66*49cdfc7eSAndroid Build Coastguard Worker {"n:", &opt_node, &opt_nodestr},
67*49cdfc7eSAndroid Build Coastguard Worker {NULL, NULL, NULL}
68*49cdfc7eSAndroid Build Coastguard Worker };
69*49cdfc7eSAndroid Build Coastguard Worker
70*49cdfc7eSAndroid Build Coastguard Worker static void init(void);
71*49cdfc7eSAndroid Build Coastguard Worker static void fin(void);
72*49cdfc7eSAndroid Build Coastguard Worker static void mem_bind(int index, int len);
73*49cdfc7eSAndroid Build Coastguard Worker static void mem_interleave(int index, int len);
74*49cdfc7eSAndroid Build Coastguard Worker static void mem_unbind(int index, int len);
75*49cdfc7eSAndroid Build Coastguard Worker static void assertion(char *expected, char *value, char *name);
76*49cdfc7eSAndroid Build Coastguard Worker static void get_vmas(char *retbuf, void *addr_s, void *addr_e);
77*49cdfc7eSAndroid Build Coastguard Worker static void case4(void);
78*49cdfc7eSAndroid Build Coastguard Worker static void case5(void);
79*49cdfc7eSAndroid Build Coastguard Worker static void case6(void);
80*49cdfc7eSAndroid Build Coastguard Worker static void case7(void);
81*49cdfc7eSAndroid Build Coastguard Worker static void case8(void);
82*49cdfc7eSAndroid Build Coastguard Worker static void setup(void);
83*49cdfc7eSAndroid Build Coastguard Worker static void cleanup(void);
84*49cdfc7eSAndroid Build Coastguard Worker static void usage(void);
85*49cdfc7eSAndroid Build Coastguard Worker
main(int argc,char ** argv)86*49cdfc7eSAndroid Build Coastguard Worker int main(int argc, char **argv)
87*49cdfc7eSAndroid Build Coastguard Worker {
88*49cdfc7eSAndroid Build Coastguard Worker int lc, node, err;
89*49cdfc7eSAndroid Build Coastguard Worker
90*49cdfc7eSAndroid Build Coastguard Worker tst_parse_opts(argc, argv, options, usage);
91*49cdfc7eSAndroid Build Coastguard Worker
92*49cdfc7eSAndroid Build Coastguard Worker nmask = numa_allocate_nodemask();
93*49cdfc7eSAndroid Build Coastguard Worker if (opt_node) {
94*49cdfc7eSAndroid Build Coastguard Worker node = SAFE_STRTOL(NULL, opt_nodestr, 1, LONG_MAX);
95*49cdfc7eSAndroid Build Coastguard Worker } else {
96*49cdfc7eSAndroid Build Coastguard Worker err = get_allowed_nodes(NH_MEMS | NH_MEMS, 1, &node);
97*49cdfc7eSAndroid Build Coastguard Worker if (err == -3)
98*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TCONF, NULL, "requires at least one node.");
99*49cdfc7eSAndroid Build Coastguard Worker else if (err < 0)
100*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TBROK | TERRNO, NULL, "get_allowed_nodes");
101*49cdfc7eSAndroid Build Coastguard Worker }
102*49cdfc7eSAndroid Build Coastguard Worker numa_bitmask_setbit(nmask, node);
103*49cdfc7eSAndroid Build Coastguard Worker
104*49cdfc7eSAndroid Build Coastguard Worker setup();
105*49cdfc7eSAndroid Build Coastguard Worker
106*49cdfc7eSAndroid Build Coastguard Worker for (lc = 0; TEST_LOOPING(lc); lc++) {
107*49cdfc7eSAndroid Build Coastguard Worker tst_count = 0;
108*49cdfc7eSAndroid Build Coastguard Worker
109*49cdfc7eSAndroid Build Coastguard Worker case4();
110*49cdfc7eSAndroid Build Coastguard Worker case5();
111*49cdfc7eSAndroid Build Coastguard Worker case6();
112*49cdfc7eSAndroid Build Coastguard Worker case7();
113*49cdfc7eSAndroid Build Coastguard Worker case8();
114*49cdfc7eSAndroid Build Coastguard Worker }
115*49cdfc7eSAndroid Build Coastguard Worker
116*49cdfc7eSAndroid Build Coastguard Worker cleanup();
117*49cdfc7eSAndroid Build Coastguard Worker tst_exit();
118*49cdfc7eSAndroid Build Coastguard Worker }
119*49cdfc7eSAndroid Build Coastguard Worker
120*49cdfc7eSAndroid Build Coastguard Worker /*
121*49cdfc7eSAndroid Build Coastguard Worker * BBBBBB
122*49cdfc7eSAndroid Build Coastguard Worker * AAAAAAAA
123*49cdfc7eSAndroid Build Coastguard Worker */
init(void)124*49cdfc7eSAndroid Build Coastguard Worker static void init(void)
125*49cdfc7eSAndroid Build Coastguard Worker {
126*49cdfc7eSAndroid Build Coastguard Worker void *addr;
127*49cdfc7eSAndroid Build Coastguard Worker
128*49cdfc7eSAndroid Build Coastguard Worker addr = SAFE_MMAP(cleanup, NULL, pagesize * 8, PROT_NONE,
129*49cdfc7eSAndroid Build Coastguard Worker MAP_ANON | MAP_PRIVATE, 0, 0);
130*49cdfc7eSAndroid Build Coastguard Worker SAFE_MMAP(cleanup, addr + pagesize, pagesize * 6,
131*49cdfc7eSAndroid Build Coastguard Worker PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, 0,
132*49cdfc7eSAndroid Build Coastguard Worker 0);
133*49cdfc7eSAndroid Build Coastguard Worker
134*49cdfc7eSAndroid Build Coastguard Worker mmap_addr = addr + pagesize;
135*49cdfc7eSAndroid Build Coastguard Worker memset(mmap_addr, 0, pagesize * 6);
136*49cdfc7eSAndroid Build Coastguard Worker }
137*49cdfc7eSAndroid Build Coastguard Worker
fin(void)138*49cdfc7eSAndroid Build Coastguard Worker static void fin(void)
139*49cdfc7eSAndroid Build Coastguard Worker {
140*49cdfc7eSAndroid Build Coastguard Worker void *addr;
141*49cdfc7eSAndroid Build Coastguard Worker
142*49cdfc7eSAndroid Build Coastguard Worker addr = mmap_addr - pagesize;
143*49cdfc7eSAndroid Build Coastguard Worker SAFE_MUNMAP(cleanup, addr, pagesize * 8);
144*49cdfc7eSAndroid Build Coastguard Worker
145*49cdfc7eSAndroid Build Coastguard Worker memset(retbuf, 0, sizeof(retbuf));
146*49cdfc7eSAndroid Build Coastguard Worker }
147*49cdfc7eSAndroid Build Coastguard Worker
mem_bind(int index,int len)148*49cdfc7eSAndroid Build Coastguard Worker static void mem_bind(int index, int len)
149*49cdfc7eSAndroid Build Coastguard Worker {
150*49cdfc7eSAndroid Build Coastguard Worker if (mbind(mmap_addr + pagesize * index, pagesize * len,
151*49cdfc7eSAndroid Build Coastguard Worker MPOL_BIND, nmask->maskp, nmask->size, 0) != 0) {
152*49cdfc7eSAndroid Build Coastguard Worker if (errno != ENOSYS)
153*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TBROK | TERRNO, cleanup, "mbind: bind");
154*49cdfc7eSAndroid Build Coastguard Worker else
155*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TCONF, cleanup,
156*49cdfc7eSAndroid Build Coastguard Worker "mbind syscall not implemented "
157*49cdfc7eSAndroid Build Coastguard Worker "on this system.");
158*49cdfc7eSAndroid Build Coastguard Worker }
159*49cdfc7eSAndroid Build Coastguard Worker }
160*49cdfc7eSAndroid Build Coastguard Worker
mem_interleave(int index,int len)161*49cdfc7eSAndroid Build Coastguard Worker static void mem_interleave(int index, int len)
162*49cdfc7eSAndroid Build Coastguard Worker {
163*49cdfc7eSAndroid Build Coastguard Worker if (mbind(mmap_addr + pagesize * index, pagesize * len,
164*49cdfc7eSAndroid Build Coastguard Worker MPOL_INTERLEAVE, nmask->maskp, nmask->size, 0) != 0) {
165*49cdfc7eSAndroid Build Coastguard Worker if (errno != ENOSYS)
166*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TBROK | TERRNO, cleanup, "mbind: interleave");
167*49cdfc7eSAndroid Build Coastguard Worker else
168*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TCONF, cleanup,
169*49cdfc7eSAndroid Build Coastguard Worker "mbind syscall not implemented "
170*49cdfc7eSAndroid Build Coastguard Worker "on this system.");
171*49cdfc7eSAndroid Build Coastguard Worker }
172*49cdfc7eSAndroid Build Coastguard Worker }
173*49cdfc7eSAndroid Build Coastguard Worker
mem_unbind(int index,int len)174*49cdfc7eSAndroid Build Coastguard Worker static void mem_unbind(int index, int len)
175*49cdfc7eSAndroid Build Coastguard Worker {
176*49cdfc7eSAndroid Build Coastguard Worker if (mbind(mmap_addr + pagesize * index, pagesize * len,
177*49cdfc7eSAndroid Build Coastguard Worker MPOL_DEFAULT, NULL, 0, 0) != 0) {
178*49cdfc7eSAndroid Build Coastguard Worker if (errno != ENOSYS)
179*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TBROK | TERRNO, cleanup, "mbind: unbind");
180*49cdfc7eSAndroid Build Coastguard Worker else
181*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TCONF, cleanup,
182*49cdfc7eSAndroid Build Coastguard Worker "mbind syscall not implemented "
183*49cdfc7eSAndroid Build Coastguard Worker "on this system.");
184*49cdfc7eSAndroid Build Coastguard Worker }
185*49cdfc7eSAndroid Build Coastguard Worker }
186*49cdfc7eSAndroid Build Coastguard Worker
assertion(char * expected,char * value,char * name)187*49cdfc7eSAndroid Build Coastguard Worker static void assertion(char *expected, char *value, char *name)
188*49cdfc7eSAndroid Build Coastguard Worker {
189*49cdfc7eSAndroid Build Coastguard Worker if (strcmp(expected, value) == 0)
190*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TPASS, "%s: passed.", name);
191*49cdfc7eSAndroid Build Coastguard Worker else
192*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TFAIL, "%s: failed. expect '%s', actual '%s'",
193*49cdfc7eSAndroid Build Coastguard Worker name, expected, value);
194*49cdfc7eSAndroid Build Coastguard Worker }
195*49cdfc7eSAndroid Build Coastguard Worker
get_vmas(char * retbuf,void * addr_s,void * addr_e)196*49cdfc7eSAndroid Build Coastguard Worker static void get_vmas(char *retbuf, void *addr_s, void *addr_e)
197*49cdfc7eSAndroid Build Coastguard Worker {
198*49cdfc7eSAndroid Build Coastguard Worker FILE *fp;
199*49cdfc7eSAndroid Build Coastguard Worker void *s, *t;
200*49cdfc7eSAndroid Build Coastguard Worker char buf[BUFSIZ], tmpstr[BUFSIZ];
201*49cdfc7eSAndroid Build Coastguard Worker int flag;
202*49cdfc7eSAndroid Build Coastguard Worker
203*49cdfc7eSAndroid Build Coastguard Worker retbuf[0] = '\0';
204*49cdfc7eSAndroid Build Coastguard Worker flag = 0;
205*49cdfc7eSAndroid Build Coastguard Worker fp = fopen("/proc/self/maps", "r");
206*49cdfc7eSAndroid Build Coastguard Worker if (fp == NULL)
207*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TBROK | TERRNO, cleanup, "fopen");
208*49cdfc7eSAndroid Build Coastguard Worker while (fgets(buf, BUFSIZ, fp) != NULL) {
209*49cdfc7eSAndroid Build Coastguard Worker if (sscanf(buf, "%p-%p ", &s, &t) != 2)
210*49cdfc7eSAndroid Build Coastguard Worker continue;
211*49cdfc7eSAndroid Build Coastguard Worker if (addr_s <= s && s < addr_e) {
212*49cdfc7eSAndroid Build Coastguard Worker if (!flag) {
213*49cdfc7eSAndroid Build Coastguard Worker sprintf(tmpstr, "%ld", (t - s) / pagesize);
214*49cdfc7eSAndroid Build Coastguard Worker flag = 1;
215*49cdfc7eSAndroid Build Coastguard Worker } else {
216*49cdfc7eSAndroid Build Coastguard Worker sprintf(tmpstr, ",%ld", (t - s) / pagesize);
217*49cdfc7eSAndroid Build Coastguard Worker }
218*49cdfc7eSAndroid Build Coastguard Worker strncat(retbuf, tmpstr, 32);
219*49cdfc7eSAndroid Build Coastguard Worker }
220*49cdfc7eSAndroid Build Coastguard Worker }
221*49cdfc7eSAndroid Build Coastguard Worker fclose(fp);
222*49cdfc7eSAndroid Build Coastguard Worker }
223*49cdfc7eSAndroid Build Coastguard Worker
224*49cdfc7eSAndroid Build Coastguard Worker /*
225*49cdfc7eSAndroid Build Coastguard Worker * AAAA
226*49cdfc7eSAndroid Build Coastguard Worker * PPPPPPNNNNNN
227*49cdfc7eSAndroid Build Coastguard Worker * might become
228*49cdfc7eSAndroid Build Coastguard Worker * PPNNNNNNNNNN
229*49cdfc7eSAndroid Build Coastguard Worker * case 4 below
230*49cdfc7eSAndroid Build Coastguard Worker */
case4(void)231*49cdfc7eSAndroid Build Coastguard Worker static void case4(void)
232*49cdfc7eSAndroid Build Coastguard Worker {
233*49cdfc7eSAndroid Build Coastguard Worker init();
234*49cdfc7eSAndroid Build Coastguard Worker mem_bind(0, 4);
235*49cdfc7eSAndroid Build Coastguard Worker mem_unbind(2, 2);
236*49cdfc7eSAndroid Build Coastguard Worker get_vmas(retbuf, mmap_addr, mmap_addr + pagesize * 6);
237*49cdfc7eSAndroid Build Coastguard Worker assertion("2,4", retbuf, "case4");
238*49cdfc7eSAndroid Build Coastguard Worker fin();
239*49cdfc7eSAndroid Build Coastguard Worker }
240*49cdfc7eSAndroid Build Coastguard Worker
241*49cdfc7eSAndroid Build Coastguard Worker /*
242*49cdfc7eSAndroid Build Coastguard Worker * AAAA
243*49cdfc7eSAndroid Build Coastguard Worker * PPPPPPNNNNNN
244*49cdfc7eSAndroid Build Coastguard Worker * might become
245*49cdfc7eSAndroid Build Coastguard Worker * PPPPPPPPPPNN
246*49cdfc7eSAndroid Build Coastguard Worker * case 5 below
247*49cdfc7eSAndroid Build Coastguard Worker */
case5(void)248*49cdfc7eSAndroid Build Coastguard Worker static void case5(void)
249*49cdfc7eSAndroid Build Coastguard Worker {
250*49cdfc7eSAndroid Build Coastguard Worker init();
251*49cdfc7eSAndroid Build Coastguard Worker mem_bind(0, 2);
252*49cdfc7eSAndroid Build Coastguard Worker mem_bind(2, 2);
253*49cdfc7eSAndroid Build Coastguard Worker get_vmas(retbuf, mmap_addr, mmap_addr + pagesize * 6);
254*49cdfc7eSAndroid Build Coastguard Worker assertion("4,2", retbuf, "case5");
255*49cdfc7eSAndroid Build Coastguard Worker fin();
256*49cdfc7eSAndroid Build Coastguard Worker }
257*49cdfc7eSAndroid Build Coastguard Worker
258*49cdfc7eSAndroid Build Coastguard Worker /*
259*49cdfc7eSAndroid Build Coastguard Worker * AAAA
260*49cdfc7eSAndroid Build Coastguard Worker * PPPPNNNNXXXX
261*49cdfc7eSAndroid Build Coastguard Worker * might become
262*49cdfc7eSAndroid Build Coastguard Worker * PPPPPPPPPPPP 6
263*49cdfc7eSAndroid Build Coastguard Worker */
case6(void)264*49cdfc7eSAndroid Build Coastguard Worker static void case6(void)
265*49cdfc7eSAndroid Build Coastguard Worker {
266*49cdfc7eSAndroid Build Coastguard Worker init();
267*49cdfc7eSAndroid Build Coastguard Worker mem_bind(0, 2);
268*49cdfc7eSAndroid Build Coastguard Worker mem_bind(4, 2);
269*49cdfc7eSAndroid Build Coastguard Worker mem_bind(2, 2);
270*49cdfc7eSAndroid Build Coastguard Worker get_vmas(retbuf, mmap_addr, mmap_addr + pagesize * 6);
271*49cdfc7eSAndroid Build Coastguard Worker assertion("6", retbuf, "case6");
272*49cdfc7eSAndroid Build Coastguard Worker fin();
273*49cdfc7eSAndroid Build Coastguard Worker }
274*49cdfc7eSAndroid Build Coastguard Worker
275*49cdfc7eSAndroid Build Coastguard Worker /*
276*49cdfc7eSAndroid Build Coastguard Worker * AAAA
277*49cdfc7eSAndroid Build Coastguard Worker * PPPPNNNNXXXX
278*49cdfc7eSAndroid Build Coastguard Worker * might become
279*49cdfc7eSAndroid Build Coastguard Worker * PPPPPPPPXXXX 7
280*49cdfc7eSAndroid Build Coastguard Worker */
case7(void)281*49cdfc7eSAndroid Build Coastguard Worker static void case7(void)
282*49cdfc7eSAndroid Build Coastguard Worker {
283*49cdfc7eSAndroid Build Coastguard Worker init();
284*49cdfc7eSAndroid Build Coastguard Worker mem_bind(0, 2);
285*49cdfc7eSAndroid Build Coastguard Worker mem_interleave(4, 2);
286*49cdfc7eSAndroid Build Coastguard Worker mem_bind(2, 2);
287*49cdfc7eSAndroid Build Coastguard Worker get_vmas(retbuf, mmap_addr, mmap_addr + pagesize * 6);
288*49cdfc7eSAndroid Build Coastguard Worker assertion("4,2", retbuf, "case7");
289*49cdfc7eSAndroid Build Coastguard Worker fin();
290*49cdfc7eSAndroid Build Coastguard Worker }
291*49cdfc7eSAndroid Build Coastguard Worker
292*49cdfc7eSAndroid Build Coastguard Worker /*
293*49cdfc7eSAndroid Build Coastguard Worker * AAAA
294*49cdfc7eSAndroid Build Coastguard Worker * PPPPNNNNXXXX
295*49cdfc7eSAndroid Build Coastguard Worker * might become
296*49cdfc7eSAndroid Build Coastguard Worker * PPPPNNNNNNNN 8
297*49cdfc7eSAndroid Build Coastguard Worker */
case8(void)298*49cdfc7eSAndroid Build Coastguard Worker static void case8(void)
299*49cdfc7eSAndroid Build Coastguard Worker {
300*49cdfc7eSAndroid Build Coastguard Worker init();
301*49cdfc7eSAndroid Build Coastguard Worker mem_bind(0, 2);
302*49cdfc7eSAndroid Build Coastguard Worker mem_interleave(4, 2);
303*49cdfc7eSAndroid Build Coastguard Worker mem_interleave(2, 2);
304*49cdfc7eSAndroid Build Coastguard Worker get_vmas(retbuf, mmap_addr, mmap_addr + pagesize * 6);
305*49cdfc7eSAndroid Build Coastguard Worker assertion("2,4", retbuf, "case8");
306*49cdfc7eSAndroid Build Coastguard Worker fin();
307*49cdfc7eSAndroid Build Coastguard Worker }
308*49cdfc7eSAndroid Build Coastguard Worker
setup(void)309*49cdfc7eSAndroid Build Coastguard Worker static void setup(void)
310*49cdfc7eSAndroid Build Coastguard Worker {
311*49cdfc7eSAndroid Build Coastguard Worker tst_sig(FORK, DEF_HANDLER, cleanup);
312*49cdfc7eSAndroid Build Coastguard Worker
313*49cdfc7eSAndroid Build Coastguard Worker TEST_PAUSE;
314*49cdfc7eSAndroid Build Coastguard Worker
315*49cdfc7eSAndroid Build Coastguard Worker pagesize = getpagesize();
316*49cdfc7eSAndroid Build Coastguard Worker }
317*49cdfc7eSAndroid Build Coastguard Worker
cleanup(void)318*49cdfc7eSAndroid Build Coastguard Worker static void cleanup(void)
319*49cdfc7eSAndroid Build Coastguard Worker {
320*49cdfc7eSAndroid Build Coastguard Worker }
321*49cdfc7eSAndroid Build Coastguard Worker
usage(void)322*49cdfc7eSAndroid Build Coastguard Worker static void usage(void)
323*49cdfc7eSAndroid Build Coastguard Worker {
324*49cdfc7eSAndroid Build Coastguard Worker printf(" -n Number of NUMA nodes\n");
325*49cdfc7eSAndroid Build Coastguard Worker }
326*49cdfc7eSAndroid Build Coastguard Worker
327*49cdfc7eSAndroid Build Coastguard Worker #else
main(void)328*49cdfc7eSAndroid Build Coastguard Worker int main(void)
329*49cdfc7eSAndroid Build Coastguard Worker {
330*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TCONF, NULL, NUMA_ERROR_MSG);
331*49cdfc7eSAndroid Build Coastguard Worker }
332*49cdfc7eSAndroid Build Coastguard Worker #endif
333