Commit 9059049c authored by Swann Perarnau's avatar Swann Perarnau
Browse files

[refactor] convert area to new errors, create

Convert area/area_linux to new error handler.
Implement #31 for area.
Checkpatch area

Note that area_linux is still using a dynamic data structure no matter
what: a bitmask to the set of authorized nodes. The conversion to
aml_bitmap wouldn't help as there's no default value available for all
nodes on that type (similar to numa_all_nodes_ptr).
parent e243f7eb
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
# files # files
include/aml.h include/aml.h
include/aml/area/linux.h
include/aml/utils/error.h include/aml/utils/error.h
src/aml.c src/aml.c
src/area/area.c
src/area/linux.c
src/utils/error.c src/utils/error.c
...@@ -34,10 +34,10 @@ int main(int argc, char *argv[]) ...@@ -34,10 +34,10 @@ int main(int argc, char *argv[])
long int N = atol(argv[3]); long int N = atol(argv[3]);
unsigned long memsize = sizeof(double)*N*N; unsigned long memsize = sizeof(double)*N*N;
slow = aml_area_linux_create(AML_AREA_LINUX_MMAP_FLAG_PRIVATE, aml_area_linux_create(&slow, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
&slowb, AML_AREA_LINUX_BINDING_FLAG_BIND); &slowb, AML_AREA_LINUX_BINDING_FLAG_BIND);
assert(slow != NULL); assert(slow != NULL);
fast = aml_area_linux_create(AML_AREA_LINUX_MMAP_FLAG_PRIVATE, aml_area_linux_create(&fast, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
&fastb, AML_AREA_LINUX_BINDING_FLAG_BIND); &fastb, AML_AREA_LINUX_BINDING_FLAG_BIND);
assert(fast != NULL); assert(fast != NULL);
...@@ -65,8 +65,8 @@ int main(int argc, char *argv[]) ...@@ -65,8 +65,8 @@ int main(int argc, char *argv[])
aml_area_munmap(slow, a, memsize); aml_area_munmap(slow, a, memsize);
aml_area_munmap(slow, b, memsize); aml_area_munmap(slow, b, memsize);
aml_area_munmap(fast, c, memsize); aml_area_munmap(fast, c, memsize);
aml_area_linux_destroy(slow); aml_area_linux_destroy(&slow);
aml_area_linux_destroy(fast); aml_area_linux_destroy(&fast);
aml_finalize(); aml_finalize();
return 0; return 0;
} }
...@@ -77,10 +77,10 @@ int main(int argc, char* argv[]) ...@@ -77,10 +77,10 @@ int main(int argc, char* argv[])
assert(!aml_tiling_init(&tiling_col, AML_TILING_TYPE_2D_COLMAJOR, assert(!aml_tiling_init(&tiling_col, AML_TILING_TYPE_2D_COLMAJOR,
tilesize, memsize, N/T , N/T)); tilesize, memsize, N/T , N/T));
slow = aml_area_linux_create(AML_AREA_LINUX_MMAP_FLAG_PRIVATE, aml_area_linux_create(&slow, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
&slowb, AML_AREA_LINUX_BINDING_FLAG_BIND); &slowb, AML_AREA_LINUX_BINDING_FLAG_BIND);
assert(slow != NULL); assert(slow != NULL);
fast = aml_area_linux_create(AML_AREA_LINUX_MMAP_FLAG_PRIVATE, aml_area_linux_create(&fast, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
&fastb, AML_AREA_LINUX_BINDING_FLAG_BIND); &fastb, AML_AREA_LINUX_BINDING_FLAG_BIND);
assert(fast != NULL); assert(fast != NULL);
...@@ -154,8 +154,8 @@ int main(int argc, char* argv[]) ...@@ -154,8 +154,8 @@ int main(int argc, char* argv[])
aml_area_munmap(slow, a, memsize); aml_area_munmap(slow, a, memsize);
aml_area_munmap(slow, b, memsize); aml_area_munmap(slow, b, memsize);
aml_area_munmap(fast, c, memsize); aml_area_munmap(fast, c, memsize);
aml_area_linux_destroy(slow); aml_area_linux_destroy(&slow);
aml_area_linux_destroy(fast); aml_area_linux_destroy(&fast);
aml_tiling_destroy(&tiling_row, AML_TILING_TYPE_2D_ROWMAJOR); aml_tiling_destroy(&tiling_row, AML_TILING_TYPE_2D_ROWMAJOR);
aml_tiling_destroy(&tiling_col, AML_TILING_TYPE_2D_ROWMAJOR); aml_tiling_destroy(&tiling_col, AML_TILING_TYPE_2D_ROWMAJOR);
aml_finalize(); aml_finalize();
......
...@@ -105,10 +105,10 @@ int main(int argc, char* argv[]) ...@@ -105,10 +105,10 @@ int main(int argc, char* argv[])
assert(!aml_tiling_init(&tiling_prefetch, AML_TILING_TYPE_1D, assert(!aml_tiling_init(&tiling_prefetch, AML_TILING_TYPE_1D,
tilesize*(N/T), memsize)); tilesize*(N/T), memsize));
slow = aml_area_linux_create(AML_AREA_LINUX_MMAP_FLAG_PRIVATE, aml_area_linux_create(&slow, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
&slowb, AML_AREA_LINUX_BINDING_FLAG_BIND); &slowb, AML_AREA_LINUX_BINDING_FLAG_BIND);
assert(slow != NULL); assert(slow != NULL);
fast = aml_area_linux_create(AML_AREA_LINUX_MMAP_FLAG_PRIVATE, aml_area_linux_create(&fast, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
&fastb, AML_AREA_LINUX_BINDING_FLAG_BIND); &fastb, AML_AREA_LINUX_BINDING_FLAG_BIND);
assert(fast != NULL); assert(fast != NULL);
...@@ -188,8 +188,8 @@ int main(int argc, char* argv[]) ...@@ -188,8 +188,8 @@ int main(int argc, char* argv[])
aml_area_munmap(slow, a, memsize); aml_area_munmap(slow, a, memsize);
aml_area_munmap(slow, b, memsize); aml_area_munmap(slow, b, memsize);
aml_area_munmap(fast, c, memsize); aml_area_munmap(fast, c, memsize);
aml_area_linux_destroy(slow); aml_area_linux_destroy(&slow);
aml_area_linux_destroy(fast); aml_area_linux_destroy(&fast);
aml_tiling_destroy(&tiling_row, AML_TILING_TYPE_2D_ROWMAJOR); aml_tiling_destroy(&tiling_row, AML_TILING_TYPE_2D_ROWMAJOR);
aml_tiling_destroy(&tiling_col, AML_TILING_TYPE_2D_ROWMAJOR); aml_tiling_destroy(&tiling_col, AML_TILING_TYPE_2D_ROWMAJOR);
aml_tiling_destroy(&tiling_prefetch, AML_TILING_TYPE_1D); aml_tiling_destroy(&tiling_prefetch, AML_TILING_TYPE_1D);
......
...@@ -64,10 +64,10 @@ int main(int argc, char *argv[]) ...@@ -64,10 +64,10 @@ int main(int argc, char *argv[])
/* initialize all the supporting struct */ /* initialize all the supporting struct */
assert(!aml_tiling_init(&tiling, AML_TILING_TYPE_1D, tilesz, memsize)); assert(!aml_tiling_init(&tiling, AML_TILING_TYPE_1D, tilesz, memsize));
slow = aml_area_linux_create(AML_AREA_LINUX_MMAP_FLAG_PRIVATE, aml_area_linux_create(&slow, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
&slowb, AML_AREA_LINUX_BINDING_FLAG_BIND); &slowb, AML_AREA_LINUX_BINDING_FLAG_BIND);
assert(slow != NULL); assert(slow != NULL);
fast = aml_area_linux_create(AML_AREA_LINUX_MMAP_FLAG_PRIVATE, aml_area_linux_create(&fast, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
&fastb, AML_AREA_LINUX_BINDING_FLAG_BIND); &fastb, AML_AREA_LINUX_BINDING_FLAG_BIND);
assert(fast != NULL); assert(fast != NULL);
assert(!aml_dma_linux_par_init(&dma, numthreads*2, numthreads)); assert(!aml_dma_linux_par_init(&dma, numthreads*2, numthreads));
...@@ -124,8 +124,8 @@ int main(int argc, char *argv[]) ...@@ -124,8 +124,8 @@ int main(int argc, char *argv[])
aml_area_munmap(slow, a, memsize); aml_area_munmap(slow, a, memsize);
aml_area_munmap(slow, b, memsize); aml_area_munmap(slow, b, memsize);
aml_area_munmap(fast, c, memsize); aml_area_munmap(fast, c, memsize);
aml_area_linux_destroy(slow); aml_area_linux_destroy(&slow);
aml_area_linux_destroy(fast); aml_area_linux_destroy(&fast);
aml_tiling_destroy(&tiling, AML_TILING_TYPE_1D); aml_tiling_destroy(&tiling, AML_TILING_TYPE_1D);
aml_finalize(); aml_finalize();
return 0; return 0;
......
...@@ -95,10 +95,10 @@ int main(int argc, char *argv[]) ...@@ -95,10 +95,10 @@ int main(int argc, char *argv[])
/* initialize all the supporting struct */ /* initialize all the supporting struct */
assert(!aml_tiling_init(&tiling, AML_TILING_TYPE_1D, tilesz, memsize)); assert(!aml_tiling_init(&tiling, AML_TILING_TYPE_1D, tilesz, memsize));
slow = aml_area_linux_create(AML_AREA_LINUX_MMAP_FLAG_PRIVATE, aml_area_linux_create(&slow, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
&slowb, AML_AREA_LINUX_BINDING_FLAG_BIND); &slowb, AML_AREA_LINUX_BINDING_FLAG_BIND);
assert(slow != NULL); assert(slow != NULL);
fast = aml_area_linux_create(AML_AREA_LINUX_MMAP_FLAG_PRIVATE, aml_area_linux_create(&fast, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
&fastb, AML_AREA_LINUX_BINDING_FLAG_BIND); &fastb, AML_AREA_LINUX_BINDING_FLAG_BIND);
assert(fast != NULL); assert(fast != NULL);
assert(!aml_dma_linux_seq_init(&dma, numthreads*2)); assert(!aml_dma_linux_seq_init(&dma, numthreads*2));
...@@ -137,8 +137,8 @@ int main(int argc, char *argv[]) ...@@ -137,8 +137,8 @@ int main(int argc, char *argv[])
aml_area_munmap(slow, a, memsize); aml_area_munmap(slow, a, memsize);
aml_area_munmap(slow, b, memsize); aml_area_munmap(slow, b, memsize);
aml_area_munmap(fast, c, memsize); aml_area_munmap(fast, c, memsize);
aml_area_linux_destroy(slow); aml_area_linux_destroy(&slow);
aml_area_linux_destroy(fast); aml_area_linux_destroy(&fast);
aml_tiling_destroy(&tiling, AML_TILING_TYPE_1D); aml_tiling_destroy(&tiling, AML_TILING_TYPE_1D);
aml_finalize(); aml_finalize();
return 0; return 0;
......
...@@ -101,10 +101,10 @@ int main(int argc, char *argv[]) ...@@ -101,10 +101,10 @@ int main(int argc, char *argv[])
/* initialize all the supporting struct */ /* initialize all the supporting struct */
assert(!aml_tiling_init(&tiling, AML_TILING_TYPE_1D, tilesz, memsize)); assert(!aml_tiling_init(&tiling, AML_TILING_TYPE_1D, tilesz, memsize));
slow = aml_area_linux_create(AML_AREA_LINUX_MMAP_FLAG_PRIVATE, aml_area_linux_create(&slow, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
&slowb, AML_AREA_LINUX_BINDING_FLAG_BIND); &slowb, AML_AREA_LINUX_BINDING_FLAG_BIND);
assert(slow != NULL); assert(slow != NULL);
fast = aml_area_linux_create(AML_AREA_LINUX_MMAP_FLAG_PRIVATE, aml_area_linux_create(&fast, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
&fastb, AML_AREA_LINUX_BINDING_FLAG_BIND); &fastb, AML_AREA_LINUX_BINDING_FLAG_BIND);
assert(fast != NULL); assert(fast != NULL);
assert(!aml_dma_linux_seq_init(&dma, (size_t)numthreads*4)); assert(!aml_dma_linux_seq_init(&dma, (size_t)numthreads*4));
...@@ -148,8 +148,8 @@ int main(int argc, char *argv[]) ...@@ -148,8 +148,8 @@ int main(int argc, char *argv[])
aml_area_munmap(slow, a, memsize); aml_area_munmap(slow, a, memsize);
aml_area_munmap(slow, b, memsize); aml_area_munmap(slow, b, memsize);
aml_area_munmap(fast, c, memsize); aml_area_munmap(fast, c, memsize);
aml_area_linux_destroy(slow); aml_area_linux_destroy(&slow);
aml_area_linux_destroy(fast); aml_area_linux_destroy(&fast);
aml_tiling_destroy(&tiling, AML_TILING_TYPE_1D); aml_tiling_destroy(&tiling, AML_TILING_TYPE_1D);
aml_finalize(); aml_finalize();
return 0; return 0;
......
...@@ -37,38 +37,12 @@ struct aml_area_linux_data { ...@@ -37,38 +37,12 @@ struct aml_area_linux_data {
}; };
/* Default linux area with private mapping and no binding. */ /* Default linux area with private mapping and no binding. */
extern const struct aml_area aml_area_linux; extern struct aml_area aml_area_linux;
#define AML_AREA_LINUX_DECL(name) \
struct aml_area_linux_data __ ##name## _inner_data; \
struct aml_area name = { \
&aml_area_linux_ops, \
(struct aml_area_data *)&__ ## name ## _inner_data, \
}
#define AML_AREA_LINUX_ALLOCSIZE \
(sizeof(struct aml_area_linux_data) + \
sizeof(struct aml_area))
/**
* Initialize area data with struct aml_area_linux_binding. Subsequent calls to
* aml_area_mmap() with this returned area will apply binding settings.
* Returns NULL on failure with aml_errno set to:
* - AML_AREA_ENOMEM if there is not enough memory available for the operation
* - AML_AREA_EINVAL flags were not one of linux area flags.
* - AML_AREA_EDOM if binding nodeset is out of allowed nodeset.
**/
struct aml_area* aml_area_linux_create(const int mmap_flags,
const struct aml_bitmap *nodemask,
const int binding_flags);
/** /*******************************************************************************
* Destroy area data containing struct aml_area_linux_binding * Linux operators
**/ *******************************************************************************/
void
aml_area_linux_destroy(struct aml_area* area);
/** /**
* Bind memory of size "size" pointed by "ptr" to binding set in "bind". * Bind memory of size "size" pointed by "ptr" to binding set in "bind".
...@@ -107,8 +81,64 @@ aml_area_linux_mmap(const struct aml_area_data *area_data, ...@@ -107,8 +81,64 @@ aml_area_linux_mmap(const struct aml_area_data *area_data,
* error investigations. * error investigations.
**/ **/
int int
aml_area_linux_munmap(const struct aml_area_data* area_data, aml_area_linux_munmap(const struct aml_area_data *area_data,
void *ptr, void *ptr,
const size_t size); const size_t size);
/*******************************************************************************
* create/destroy and others
*******************************************************************************/
#define AML_AREA_LINUX_DECL(name) \
struct aml_area_linux_data __ ##name## _inner_data; \
struct aml_area name = { \
&aml_area_linux_ops, \
(struct aml_area_data *)&__ ## name ## _inner_data, \
}
#define AML_AREA_LINUX_ALLOCSIZE \
(sizeof(struct aml_area_linux_data) + \
sizeof(struct aml_area))
/**
* Allocate and initialize a struct aml_area implemented by aml_area_linux
* operations.
* @param[out] area pointer to an uninitialized struct aml_area pointer to
* receive the new area.
* @param[in] mmap_flags flags to use when retrieving virtual memory with mmap
* @param[in] binding_flags, flags to use when binding memory.
* @param[in] nodemask list of memory nodes to use. Default to allowed memory
* nodes if NULL.
* @return On success, returns 0 and area points to the new aml_area.
* @return On failure, sets area to NULL and returns one of AML error codes:
* - AML_ENOMEM if there wasn't enough memory available.
* - AML_EINVAL if inputs flags were invalid.
* - AML_EDOM the nodemask provided is out of bounds (allowed nodeset).
**/
int aml_area_linux_create(struct aml_area **area, const int mmap_flags,
const struct aml_bitmap *nodemask,
const int binding_flags);
/**
* Initialize a struct aml_area declared using the AML_AREA_LINUX_DECL macro.
* See aml_area_linux_create for details on arguments.
*/
int aml_area_linux_init(struct aml_area *area, const int mmap_flags,
const struct aml_bitmap *nodemask,
const int binding_flags);
/**
* Finalize a struct aml_area initialized with aml_area_linux_init.
*/
void aml_area_linux_fini(struct aml_area *area);
/**
* Destroy (finalize and free resources) a struct aml_area created by
* aml_area_linux_create.
*
* @param area is NULL after this call.
**/
void aml_area_linux_destroy(struct aml_area **area);
#endif //AML_AREA_LINUX_NUMA_H #endif //AML_AREA_LINUX_NUMA_H
...@@ -8,24 +8,21 @@ ...@@ -8,24 +8,21 @@
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/ *******************************************************************************/
#include <stdlib.h>
#include "aml.h" #include "aml.h"
#include <stdlib.h>
void* void *aml_area_mmap(const struct aml_area *area, void **ptr, size_t size)
aml_area_mmap(const struct aml_area *area,
void **ptr,
size_t size)
{ {
if(size == 0) if (size == 0)
return NULL; return NULL;
if(area == NULL){ if (area == NULL) {
aml_errno = AML_AREA_EINVAL; aml_errno = AML_EINVAL;
return NULL; return NULL;
} }
if(area->ops->mmap == NULL){ if (area->ops->mmap == NULL) {
aml_errno = AML_AREA_ENOTSUP; aml_errno = AML_ENOTSUP;
return NULL; return NULL;
} }
...@@ -33,19 +30,16 @@ aml_area_mmap(const struct aml_area *area, ...@@ -33,19 +30,16 @@ aml_area_mmap(const struct aml_area *area,
return area->ops->mmap(area->data, ptr, size); return area->ops->mmap(area->data, ptr, size);
} }
int int aml_area_munmap(const struct aml_area *area, void *ptr, size_t size)
aml_area_munmap(const struct aml_area *area,
void *ptr,
size_t size)
{ {
if(ptr == NULL || size == 0) if (ptr == NULL || size == 0)
return AML_SUCCESS; return AML_SUCCESS;
if(area == NULL) if (area == NULL)
return AML_AREA_EINVAL; return -AML_EINVAL;
if(area->ops->munmap == NULL) if (area->ops->munmap == NULL)
return AML_AREA_ENOTSUP; return -AML_ENOTSUP;
return area->ops->munmap(area->data, ptr, size); return area->ops->munmap(area->data, ptr, size);
} }
......
...@@ -15,108 +15,6 @@ ...@@ -15,108 +15,6 @@
#define AML_AREA_LINUX_MBIND_FLAGS MPOL_MF_MOVE #define AML_AREA_LINUX_MBIND_FLAGS MPOL_MF_MOVE
static int aml_area_linux_check_mmap_flags(const int mmap_flags){
switch(mmap_flags){
case AML_AREA_LINUX_MMAP_FLAG_PRIVATE:
break;
case AML_AREA_LINUX_MMAP_FLAG_SHARED:
break;
default:
return 0;
}
return 1;
}
static int aml_area_linux_check_binding_flags(const int binding_flags){
switch(binding_flags){
case AML_AREA_LINUX_BINDING_FLAG_BIND:
break;
case AML_AREA_LINUX_BINDING_FLAG_INTERLEAVE:
break;
case AML_AREA_LINUX_BINDING_FLAG_PREFERRED:
break;
default:
return 0;
}
return 1;
}
struct aml_area* aml_area_linux_create(const int mmap_flags,
const struct aml_bitmap *nodemask,
const int binding_flags)
{
struct aml_area_linux_data *d;
struct aml_area *area;
/* Check flags */
if(!aml_area_linux_check_mmap_flags(mmap_flags) ||
!aml_area_linux_check_binding_flags(binding_flags)){
aml_errno = AML_AREA_EINVAL;
return NULL;
}
d = malloc(sizeof(*d));
if(d == NULL){
aml_errno = AML_AREA_ENOMEM;
return NULL;
}
/* Check/set nodemask */
d->nodeset = numa_get_mems_allowed();
if(d->nodeset == NULL){
aml_errno = AML_AREA_ENOMEM;
goto err_with_data;
}
if(nodemask != NULL){
int aml_last = aml_bitmap_last(nodemask);
int allowed_last = numa_bitmask_weight(d->nodeset);
while(!numa_bitmask_isbitset(d->nodeset, --allowed_last));
if(aml_last > allowed_last){
aml_errno = AML_AREA_EDOM;
goto err_with_nodeset;
}
aml_bitmap_copy_to_ulong(nodemask,
d->nodeset->maskp,
d->nodeset->size);
}
/* set area_data and area */
d->binding_flags = binding_flags;
d->mmap_flags = mmap_flags;
area = malloc(sizeof(*area));
if(area == NULL){
aml_errno = AML_AREA_ENOMEM;
goto err_with_nodeset;
}
area->data = (struct aml_area_data*)d;
area->ops = &aml_area_linux_ops;
return area;
err_with_nodeset:
numa_free_nodemask(d->nodeset);
err_with_data:
free(d);
return NULL;
}
void
aml_area_linux_destroy(struct aml_area* area){
if(area == NULL || area->data == NULL)
return;
struct aml_area_linux_data *d = (struct aml_area_linux_data *)area->data;
if(d->nodeset != NULL)
numa_free_nodemask(d->nodeset);
free(d);
}
int int
aml_area_linux_mbind(struct aml_area_linux_data *bind, aml_area_linux_mbind(struct aml_area_linux_data *bind,
void *ptr, void *ptr,
...@@ -124,10 +22,12 @@ aml_area_linux_mbind(struct aml_area_linux_data *bind, ...@@ -124,10 +22,12 @@ aml_area_linux_mbind(struct aml_area_linux_data *bind,
{ {
struct bitmask *nodeset; struct bitmask *nodeset;
if(bind->nodeset != NULL) assert(bind != NULL);
nodeset = bind->nodeset; nodeset = bind->nodeset;
else if (nodeset == NULL)
nodeset = numa_get_mems_allowed(); nodeset = numa_all_nodes_ptr;
long err = mbind(ptr, long err = mbind(ptr,
size, size,
...@@ -136,9 +36,9 @@ aml_area_linux_mbind(struct aml_area_linux_data *bind, ...@@ -136,9 +36,9 @@ aml_area_linux_mbind(struct aml_area_linux_data *bind,
nodeset->size, nodeset->size,
AML_AREA_LINUX_MBIND_FLAGS); AML_AREA_LINUX_MBIND_FLAGS);
if(err == 0) if (err == 0)
return AML_SUCCESS; return AML_SUCCESS;
return AML_FAILURE; return -AML_FAILURE;
} }
int int
...@@ -150,8 +50,8 @@ aml_area_linux_check_binding(struct aml_area_linux_data *area_data, ...@@ -150,8 +50,8 @@ aml_area_linux_check_binding(struct aml_area_linux_data *area_data,
struct bitmask *nodeset; struct bitmask *nodeset;
nodeset = numa_allocate_nodemask(); nodeset = numa_allocate_nodemask();
if(nodeset == NULL) if (nodeset == NULL)
return AML_AREA_ENOMEM; return -AML_ENOMEM;
err = get_mempolicy(&mode, err = get_mempolicy(&mode,
nodeset->maskp, nodeset->maskp,
...@@ -159,20 +59,23 @@ aml_area_linux_check_binding(struct aml_area_linux_data *area_data, ...@@ -159,20 +59,23 @@ aml_area_linux_check_binding(struct aml_area_linux_data *area_data,
ptr, ptr,
AML_AREA_LINUX_MBIND_FLAGS); AML_AREA_LINUX_MBIND_FLAGS);
if(err < 0){ if (err < 0) {
err = AML_AREA_EINVAL; err = -AML_EINVAL;
goto out; goto out;
} }
err = 1; err = 1;
if(mode != area_data->binding_flags) if (mode != area_data->binding_flags)
err = 0; err = 0;
for(i=0; i<numa_max_possible_node(); i++){ for (i = 0; i < numa_max_possible_node(); i++) {
int ptr_set = numa_bitmask_isbitset(nodeset, i); int ptr_set = numa_bitmask_isbitset(nodeset, i);
int bitmask_set = numa_bitmask_isbitset(area_data->nodeset, i); int bitmask_set = numa_bitmask_isbitset(area_data->nodeset, i);
if(mode == AML_AREA_LINUX_BINDING_FLAG_BIND && ptr_set != bitmask_set)
if (mode == AML_AREA_LINUX_BINDING_FLAG_BIND &&
ptr_set != bitmask_set)
goto binding_failed; goto binding_failed;
if(mode == AML_AREA_LINUX_BINDING_FLAG_INTERLEAVE && ptr_set && !bitmask_set) if (mode == AML_AREA_LINUX_BINDING_FLAG_INTERLEAVE &&
ptr_set && !bitmask_set)