librte_eal: ease init in a docker container
PATCH 1/1 librte_eal: ease init in a docker container
move_pages() is only used to get the numa node id, but this function is not allowed by default in docker (it needs CAP_SYS_NICE and an update of the seccomp profile).get_mempolicy() also requires CAP_SYS_NICE but doesn't need any change in the default seccomp profile.
Note that the returned value of move_pages() was not checked, thus some errors could be hidden (if the requested id was 0).
--- lib/librte_eal/linux/eal/eal_memalloc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
lib/librte_eal/linux/eal/eal_memalloc.c +7 -3
@@ -600,9 +600,13 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id, }#ifdef RTE_EAL_NUMA_AWARE_HUGEPAGES -move_pages (getpid (),1 , &addr,NULL , &cur_socket_id,0 ); - -if (cur_socket_id != socket_id) { + ret =get_mempolicy (&cur_socket_id,NULL ,0 , addr, +MPOL_F_NODE |MPOL_F_ADDR ); +if (ret <0 ) { +RTE_LOG (DEBUG ,EAL ,"%s(): get_mempolicy: %s\n" , + __func__,strerror (errno)); + goto mapped; + }else if (cur_socket_id != socket_id) {RTE_LOG (DEBUG ,EAL ,"%s(): allocation happened on wrong socket (wanted %d, got %d)\n" , __func__, socket_id, cur_socket_id);
Signature · 1 line
2.21.0
Quoted 6 lines · Nicolas Dichtel
move_pages()is only used to get the numa node id, but this function is not allowed by default in docker (it needsCAP_SYS_NICEand an update of the seccomp profile).get_mempolicy()also requiresCAP_SYS_NICEbut doesn't need any change in the default seccomp profile.
Quoted 7 lines
Note that the returned value of
move_pages()was not checked, thus some errors could be hidden (if the requested id was 0).Signed-off-by Nicolas Dichtel <[email protected]>Reviewed-by Olivier Matz <[email protected]>Reviewed-by Didier Pallard <[email protected]>---
I can see the check for move_pages and it's a good fix, but what is the relation to docker init here? The patch by itself only enables handling of move_pages() failure and adds nothing else. The commit message doesn't match the patch in question IMO.
Also, Cc: stable and Fixes: ?
Signature · 2 lines
Thanks, Anatoly
Le 22/05/2019 à 17:57, Burakov, Anatoly a écrit :
Quoted 15 lines · Nicolas Dichtel
Quoted 6 lines
move_pages()is only used to get the numa node id, but this function is not allowed by default in docker (it needsCAP_SYS_NICEand an update of the seccomp profile).get_mempolicy()also requiresCAP_SYS_NICEbut doesn't need any change in the default seccomp profile.Quoted 7 lines
Note that the returned value of
move_pages()was not checked, thus some errors could be hidden (if the requested id was 0).Signed-off-by Nicolas Dichtel <[email protected]>Reviewed-by Olivier Matz <[email protected]>Reviewed-by Didier Pallard <[email protected]>---
Quoted 4 lines
I can see the check for
move_pagesand it's a good fix, but what is the relation to docker init here? The patch by itself only enables handling ofmove_pages()failure and adds nothing else. The commit message doesn't match the patch in question IMO.
I'm not sure to understand your comment. The call to move_pages() is replaced by a call to get_mempolicy().
What am I missing?
Regards,
Nicolas
Quoted 17 lines · Nicolas Dichtel
Le 22/05/2019 à 17:57, Burakov, Anatoly a écrit :
Quoted 15 lines · Nicolas Dichtel
Quoted 13 lines
move_pages()is only used to get the numa node id, but this function is not allowed by default in docker (it needsCAP_SYS_NICEand an update of the seccomp profile).get_mempolicy()also requiresCAP_SYS_NICEbut doesn't need any change in the default seccomp profile.Note that the returned value of
move_pages()was not checked, thus some errors could be hidden (if the requested id was 0).Signed-off-by Nicolas Dichtel <[email protected]>Reviewed-by Olivier Matz <[email protected]>Reviewed-by Didier Pallard <[email protected]>---
Quoted 8 lines
Quoted 4 lines
I can see the check for
move_pagesand it's a good fix, but what is the relation to docker init here? The patch by itself only enables handling ofmove_pages()failure and adds nothing else. The commit message doesn't match the patch in question IMO.I'm not sure to understand your comment. The call to
move_pages()is replaced by a call toget_mempolicy().
What am I missing?
Oh, apologies, i misread the patch. It is i who was missing something :)
Quoted 4 lines
Regards,
Nicolas
Signature · 2 lines
Thanks, Anatoly
Quoted 6 lines · Nicolas Dichtel
move_pages()is only used to get the numa node id, but this function is not allowed by default in docker (it needsCAP_SYS_NICEand an update of the seccomp profile).get_mempolicy()also requiresCAP_SYS_NICEbut doesn't need any change in the default seccomp profile.
Quoted 7 lines
Note that the returned value of
move_pages()was not checked, thus some errors could be hidden (if the requested id was 0).Signed-off-by Nicolas Dichtel <[email protected]>Reviewed-by Olivier Matz <[email protected]>Reviewed-by Didier Pallard <[email protected]>---
Still, should at least specify Cc: stable, if not Fixes tag too (since ignoring return value of move_pages() is technically a bug).
Signature · 2 lines
Thanks, Anatoly
s/librte_eal/mem/ for the title prefix.
Quoted 16 lines · Anatoly
Quoted 2 lines · Nicolas Dichtel
move_pages()is only used to get the numa node id, but this function is not allowed by default in docker (it needsCAP_SYS_NICEand an updateof
Quoted 11 lines
the seccomp profile).
get_mempolicy()also requiresCAP_SYS_NICEbut doesn't need any change in the default seccomp profile.Note that the returned value of
move_pages()was not checked, thus some errors could be hidden (if the requested id was 0).Signed-off-by Nicolas Dichtel <[email protected]>Reviewed-by Olivier Matz <[email protected]>Reviewed-by Didier Pallard <[email protected]>---
Quoted 5 lines
Acked-by Anatoly Burakov <[email protected]>Still, should at least specify Cc: stable, if not Fixes tag too (since ignoring return value of
move_pages()is technically a bug).
+1
At first I was wondering if we should separate the fix from the enhancement, but I suppose backporting both things as one patch is fine too.
Signature · 1 line
David Marchand
PATCH v2 1/1 mem: ease init in a docker container
move_pages() is only used to get the numa node id, but this function is not allowed by default in docker (it needs CAP_SYS_NICE and an update of the seccomp profile).get_mempolicy() also requires CAP_SYS_NICE but doesn't need any change in the default seccomp profile.
Note that the returned value of move_pages() was not checked, thus some errors could be hidden (if the requested id was 0).
---
v2: add fixes tag + cc stable
fix title prefix
lib/librte_eal/linux/eal/eal_memalloc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
lib/librte_eal/linux/eal/eal_memalloc.c +7 -3
@@ -600,9 +600,13 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id, }#ifdef RTE_EAL_NUMA_AWARE_HUGEPAGES -move_pages (getpid (),1 , &addr,NULL , &cur_socket_id,0 ); - -if (cur_socket_id != socket_id) { + ret =get_mempolicy (&cur_socket_id,NULL ,0 , addr, +MPOL_F_NODE |MPOL_F_ADDR ); +if (ret <0 ) { +RTE_LOG (DEBUG ,EAL ,"%s(): get_mempolicy: %s\n" , + __func__,strerror (errno)); + goto mapped; + }else if (cur_socket_id != socket_id) {RTE_LOG (DEBUG ,EAL ,"%s(): allocation happened on wrong socket (wanted %d, got %d)\n" , __func__, socket_id, cur_socket_id);
Signature · 1 line
2.21.0
Re: [dpdk-dev] [dpdk-stable] [PATCH v2] mem: ease init in a docker container
Quoted 46 lines · Nicolas Dichtel
move_pages()is only used to get the numa node id, but this function is not allowed by default in docker (it needsCAP_SYS_NICEand an update of the seccomp profile).get_mempolicy()also requiresCAP_SYS_NICEbut doesn't need any change in the default seccomp profile.Note that the returned value of
move_pages()was not checked, thus some errors could be hidden (if the requested id was 0).Fixes 582bed1e1d1d ("mem: support mapping hugepages at runtime")Signed-off-by Nicolas Dichtel <[email protected]>Reviewed-by Olivier Matz <[email protected]>Reviewed-by Didier Pallard <[email protected]>Acked-by Anatoly Burakov <[email protected]>---
v2: add fixes tag + cc stable
fix title prefixlib/librte_eal/linux/eal/eal_memalloc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)lib/librte_eal/linux/eal/eal_memalloc.c +7
-3@@ -600,9 +600,13 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id, }#ifdef RTE_EAL_NUMA_AWARE_HUGEPAGES -move_pages (getpid (),1 , &addr,NULL , &cur_socket_id,0 ); - -if (cur_socket_id != socket_id) { + ret =get_mempolicy (&cur_socket_id,NULL ,0 , addr, +MPOL_F_NODE |MPOL_F_ADDR ); +if (ret <0 ) { +RTE_LOG (DEBUG ,EAL ,"%s(): get_mempolicy: %s\n" , + __func__,strerror (errno)); + goto mapped; + }else if (cur_socket_id != socket_id) { RTE_LOG(DEBUG, EAL, "%s(): allocation happened on wrong socket(wanted %d, got %d)\n",
Quoted 5 lines
__func__, socket_id, cur_socket_id);--
2.21.0
Signature · 1 line
David Marchand
Thomas Monjalon
AppliedRe: [dpdk-dev] [dpdk-stable] [PATCH v2] mem: ease init in a docker container
23/05/2019 16:29, David Marchand:
Quoted 12 lines
Quoted 9 lines · Nicolas Dichtel
move_pages()is only used to get the numa node id, but this function is not allowed by default in docker (it needsCAP_SYS_NICEand an update of the seccomp profile).get_mempolicy()also requiresCAP_SYS_NICEbut doesn't need any change in the default seccomp profile.Note that the returned value of
move_pages()was not checked, thus some errors could be hidden (if the requested id was 0).
Quoted 7 lines
Quoted 6 lines
Fixes 582bed1e1d1d ("mem: support mapping hugepages at runtime")Signed-off-by Nicolas Dichtel <[email protected]>Reviewed-by Olivier Matz <[email protected]>Reviewed-by Didier Pallard <[email protected]>Acked-by Anatoly Burakov <[email protected]>Reviewed-by David Marchand <[email protected]>
Applied, thanks Nico