~ubuntu-branches/ubuntu/vivid/numactl/vivid-proposed

« back to all changes in this revision

Viewing changes to stream_main.c

  • Committer: Package Import Robot
  • Author(s): Daniel J Blueman
  • Date: 2015-04-08 05:30:55 UTC
  • Revision ID: package-import@ubuntu.com-20150408053055-u80t7q2kbrmzfnqt
Tags: 2.0.10-1ubuntu2
d/patches/from-git-6a7c2cf3-fix-uninitialised-mask.patch: Fix libnuma SEGV
due to uninitialised mask. (LP: #1441388)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <stdio.h>
2
 
#include <sys/mman.h>
3
 
#include <stdlib.h>
4
 
#include "numa.h"
5
 
#include "numaif.h"
6
 
#include "util.h"
7
 
#include "stream_lib.h"
8
 
 
9
 
void usage(void)
10
 
{
11
 
        exit(1);
12
 
}
13
 
 
14
 
char *policy = "default";
15
 
 
16
 
/* Run STREAM with a numa policy */
17
 
int main(int ac, char **av)
18
 
{
19
 
        struct bitmask *nodes;
20
 
        char *map;
21
 
        long size;
22
 
        int policy;
23
 
 
24
 
        policy = parse_policy(av[1], av[2]);
25
 
 
26
 
        nodes = numa_allocate_nodemask();
27
 
 
28
 
        if (av[1] && av[2])
29
 
                nodes = numa_parse_nodestring(av[2]);
30
 
        if (!nodes) {
31
 
                printf ("<%s> is invalid\n", av[2]);
32
 
                exit(1);
33
 
        }
34
 
        size = stream_memsize();
35
 
        map = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
36
 
                   0, 0);
37
 
        if (map == (char*)-1) exit(1);
38
 
        if (mbind(map, size, policy, nodes->maskp, nodes->size, 0) < 0)
39
 
                perror("mbind"), exit(1);
40
 
        stream_init(map);
41
 
        stream_test(NULL);
42
 
        return 0;
43
 
}