@@ -98,20 +98,29 @@ static int perf_mmap__aio_bind(struct mmap *map, int idx, int cpu, int affinity)
98
98
{
99
99
void * data ;
100
100
size_t mmap_len ;
101
- unsigned long node_mask ;
101
+ unsigned long * node_mask ;
102
+ unsigned long node_index ;
103
+ int err = 0 ;
102
104
103
105
if (affinity != PERF_AFFINITY_SYS && cpu__max_node () > 1 ) {
104
106
data = map -> aio .data [idx ];
105
107
mmap_len = mmap__mmap_len (map );
106
- node_mask = 1UL << cpu__get_node (cpu );
107
- if ( mbind ( data , mmap_len , MPOL_BIND , & node_mask , 1 , 0 )) {
108
- pr_err ( "Failed to bind [%p-%p] AIO buffer to node %d: error %m\n" ,
109
- data , data + mmap_len , cpu__get_node ( cpu ) );
108
+ node_index = cpu__get_node (cpu );
109
+ node_mask = bitmap_alloc ( node_index + 1 );
110
+ if (! node_mask ) {
111
+ pr_err ( "Failed to allocate node mask for mbind: error %m\n" );
110
112
return -1 ;
111
113
}
114
+ set_bit (node_index , node_mask );
115
+ if (mbind (data , mmap_len , MPOL_BIND , node_mask , node_index + 1 + 1 , 0 )) {
116
+ pr_err ("Failed to bind [%p-%p] AIO buffer to node %lu: error %m\n" ,
117
+ data , data + mmap_len , node_index );
118
+ err = -1 ;
119
+ }
120
+ bitmap_free (node_mask );
112
121
}
113
122
114
- return 0 ;
123
+ return err ;
115
124
}
116
125
#else /* !HAVE_LIBNUMA_SUPPORT */
117
126
static int perf_mmap__aio_alloc (struct mmap * map , int idx )
0 commit comments