~dannf/ubuntu/trusty/numactl/arm64

« back to all changes in this revision

Viewing changes to migratepages.c

  • Committer: Bazaar Package Importer
  • Author(s): Ian Wienand
  • Date: 2006-11-03 10:31:24 UTC
  • mfrom: (1.2.1 upstream) (3.1.3 edgy)
  • Revision ID: james.westby@ubuntu.com-20061103103124-9dy65897wxq3g7ku
add powerpc.patch; fix FTBFS due to typo on PowerPC

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2005 Christoph Lameter, Silicon Graphics, Incorporated.
 
3
 * based on Andi Kleen's numactl.c.
 
4
 *
 
5
 * Manual process migration
 
6
 *
 
7
 * migratepages is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU General Public
 
9
 * License as published by the Free Software Foundation; version 2.
 
10
 *
 
11
 * migratepages is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * General Public License for more details.
 
15
 *
 
16
 * You should find a copy of v2 of the GNU General Public License somewhere
 
17
 * on your Linux system; if not, write to the Free Software Foundation,
 
18
 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
19
 */
 
20
 
 
21
#define _GNU_SOURCE
 
22
#include <getopt.h>
 
23
#include <errno.h>
 
24
#include <stdio.h> 
 
25
#include <stdlib.h>
 
26
#include <string.h>
 
27
#include <unistd.h>
 
28
#include <stdarg.h>
 
29
#include "numaif.h"
 
30
#include "numa.h"
 
31
#include "numaint.h"
 
32
#include "util.h"
 
33
 
 
34
struct option opts[] = {
 
35
        {"help", 0, 0, 'h' },
 
36
        { 0 }
 
37
};
 
38
 
 
39
void usage(void)
 
40
{
 
41
        fprintf(stderr,
 
42
                "usage: migratepages pid from-nodes to-nodes\n"
 
43
                "\n"
 
44
                "nodes is a comma delimited list of node numbers or A-B ranges or all.\n"
 
45
);
 
46
        exit(1);
 
47
}
 
48
 
 
49
void checknuma(void)
 
50
{
 
51
        static int numa = -1;
 
52
        if (numa < 0) {
 
53
                if (numa_available() < 0)
 
54
                        complain("This system does not support NUMA functionality");
 
55
        }
 
56
        numa = 0;
 
57
}
 
58
 
 
59
int main(int argc, char *argv[])
 
60
{
 
61
        int c;
 
62
        char *end;
 
63
        int rc;
 
64
        int pid;
 
65
        nodemask_t fromnodes;
 
66
        nodemask_t tonodes;
 
67
 
 
68
        while ((c = getopt_long(argc,argv,"h", opts, NULL)) != -1) {
 
69
                switch (c) {
 
70
                default:
 
71
                        usage();
 
72
                }
 
73
        }
 
74
 
 
75
        argv += optind;
 
76
        argc -= optind;
 
77
 
 
78
        if (argc != 3)
 
79
                usage();
 
80
 
 
81
        checknuma();
 
82
 
 
83
        pid = strtoul(argv[0], &end, 0);
 
84
        if (*end || end == argv[0])
 
85
                usage();
 
86
 
 
87
        fromnodes = nodemask(argv[1]);
 
88
        tonodes = nodemask(argv[2]);
 
89
 
 
90
        rc = numa_migrate_pages(pid, &fromnodes, &tonodes);
 
91
 
 
92
        if (rc < 0) {
 
93
                perror("migrate_pages");
 
94
                return 1;
 
95
        }
 
96
        return 0;
 
97
}