2 * Copyright (c) 2003-2007 Ulrich Drepper <drepper@redhat.com>
3 * Copyright (c) 2005-2016 Dmitry V. Levin <ldv@altlinux.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 get_nodes(struct tcb *tcp, unsigned long ptr, unsigned long maxnodes, int err)
34 unsigned long nlongs, size, end;
36 nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long));
37 size = nlongs * sizeof(long);
39 if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes)
41 unsigned long n, cur, abbrev_end;
45 abbrev_end = ptr + max_strlen * sizeof(long);
52 for (cur = ptr; cur < end; cur += sizeof(long)) {
55 if (cur >= abbrev_end) {
59 if (umoven(tcp, cur, sizeof(n), &n) < 0) {
64 tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n);
75 tprintf(", %lu", maxnodes);
78 SYS_FUNC(migrate_pages)
80 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
81 get_nodes(tcp, tcp->u_arg[2], tcp->u_arg[1], 0);
83 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[1], 0);
88 #include "xlat/policies.h"
89 #include "xlat/mbindflags.h"
93 printaddr(tcp->u_arg[0]);
94 tprintf(", %lu, ", tcp->u_arg[1]);
95 printxval(policies, tcp->u_arg[2], "MPOL_???");
96 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0);
98 printflags(mbindflags, tcp->u_arg[5], "MPOL_???");
103 SYS_FUNC(set_mempolicy)
105 printxval(policies, tcp->u_arg[0], "MPOL_???");
106 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0);
111 #include "xlat/mempolicyflags.h"
113 SYS_FUNC(get_mempolicy)
117 if (!umove_or_printaddr(tcp, tcp->u_arg[0], &pol))
118 printxval(policies, pol, "MPOL_???");
119 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp));
121 printaddr(tcp->u_arg[3]);
123 printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???");
128 #include "xlat/move_pages_flags.h"
133 unsigned long npages = tcp->u_arg[1];
134 tprintf("%ld, %lu, ", tcp->u_arg[0], npages);
135 if (tcp->u_arg[2] == 0)
139 long puser = tcp->u_arg[2];
141 for (i = 0; i < npages; ++i) {
145 if (umove(tcp, puser, &p) < 0) {
150 puser += sizeof(void *);
154 if (tcp->u_arg[3] == 0)
158 long nodeuser = tcp->u_arg[3];
160 for (i = 0; i < npages; ++i) {
164 if (umove(tcp, nodeuser, &node) < 0) {
168 tprintf("%#x", node);
169 nodeuser += sizeof(int);
174 unsigned long npages = tcp->u_arg[1];
175 if (tcp->u_arg[4] == 0)
179 long statususer = tcp->u_arg[4];
181 for (i = 0; i < npages; ++i) {
185 if (umove(tcp, statususer, &status) < 0) {
189 tprintf("%#x", status);
190 statususer += sizeof(int);
194 printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???");