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 print_nodemask(struct tcb *tcp, unsigned long addr, unsigned long maxnodes)
34 const unsigned long nlongs =
35 (maxnodes + 8 * current_wordsize - 2) / (8 * current_wordsize);
36 const unsigned long size = nlongs * current_wordsize;
37 const unsigned long end = addr + size;
39 if (!verbose(tcp) || (exiting(tcp) && syserror(tcp))
40 || end <= addr || size / current_wordsize != nlongs
41 || nlongs < maxnodes / (8 * current_wordsize)) {
46 const unsigned long abbrev_end =
47 (abbrev(tcp) && max_strlen < nlongs) ?
48 addr + max_strlen * current_wordsize : end;
50 for (cur = addr; cur < end; cur += current_wordsize) {
55 if (umove_ulong_or_printaddr(tcp, cur, &n))
61 if (cur >= abbrev_end) {
67 tprintf("%#0*lx", (int) current_wordsize * 2 + 2, n);
73 SYS_FUNC(migrate_pages)
75 tprintf("%d, %lu, ", (int) tcp->u_arg[0], tcp->u_arg[1]);
76 print_nodemask(tcp, tcp->u_arg[2], tcp->u_arg[1]);
78 print_nodemask(tcp, tcp->u_arg[3], tcp->u_arg[1]);
83 #include "xlat/policies.h"
84 #include "xlat/mbindflags.h"
88 printaddr(tcp->u_arg[0]);
89 tprintf(", %lu, ", tcp->u_arg[1]);
90 printxval(policies, tcp->u_arg[2], "MPOL_???");
92 print_nodemask(tcp, tcp->u_arg[3], tcp->u_arg[4]);
93 tprintf(", %lu, ", tcp->u_arg[4]);
94 printflags(mbindflags, tcp->u_arg[5], "MPOL_???");
99 SYS_FUNC(set_mempolicy)
101 printxval(policies, tcp->u_arg[0], "MPOL_???");
103 print_nodemask(tcp, tcp->u_arg[1], tcp->u_arg[2]);
104 tprintf(", %lu", tcp->u_arg[2]);
109 #include "xlat/mempolicyflags.h"
111 SYS_FUNC(get_mempolicy)
115 if (!umove_or_printaddr(tcp, tcp->u_arg[0], &pol)) {
117 printxval(policies, pol, "MPOL_???");
121 print_nodemask(tcp, tcp->u_arg[1], tcp->u_arg[2]);
122 tprintf(", %lu, ", tcp->u_arg[2]);
123 printaddr(tcp->u_arg[3]);
125 printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???");
130 #include "xlat/move_pages_flags.h"
135 unsigned long npages = tcp->u_arg[1];
136 tprintf("%ld, %lu, ", tcp->u_arg[0], npages);
137 if (tcp->u_arg[2] == 0)
141 long puser = tcp->u_arg[2];
143 for (i = 0; i < npages; ++i) {
147 if (umove(tcp, puser, &p) < 0) {
152 puser += sizeof(void *);
156 if (tcp->u_arg[3] == 0)
160 long nodeuser = tcp->u_arg[3];
162 for (i = 0; i < npages; ++i) {
166 if (umove(tcp, nodeuser, &node) < 0) {
170 tprintf("%#x", node);
171 nodeuser += sizeof(int);
176 unsigned long npages = tcp->u_arg[1];
177 if (tcp->u_arg[4] == 0)
181 long statususer = tcp->u_arg[4];
183 for (i = 0; i < npages; ++i) {
187 if (umove(tcp, statususer, &status) < 0) {
191 tprintf("%#x", status);
192 statususer += sizeof(int);
196 printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???");