call_usermodehelper_setup() should use GFP_KERNEL
PATCH 1/1 call_usermodehelper_setup() should use GFP_KERNEL
Now, call_usermodehelper_setup() use GFP_ATOMIC.
but it is slighly odd.
because call_usermodehelper() is always called process context.
GFP_KERNEL is robust and better.
--- kernel/kmod.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kmod.c +1 -1
@@ -360,7 +360,7 @@ struct subprocess_info *call_usermodehel char **argv, char **envp) { struct subprocess_info *sub_info; - sub_info =kzalloc (sizeof (struct subprocess_info ),GFP_ATOMIC ); + sub_info =kzalloc (sizeof (struct subprocess_info ),GFP_KERNEL );if (!sub_info) goto out;
Quoted 4 lines · KOSAKI Motohiro
Now,
call_usermodehelper_setup()useGFP_ATOMIC.
but it is slighly odd.
becausecall_usermodehelper()is always called process context.
Are you sure? I found the following call chain:
static irqreturn_t power_handler(int irq, void *dev_id)
->orderly_poweroff(true);
->call_usermodehelper_setup()Quoted 31 lines
GFP_KERNELis robust and better.Signed-off-by KOSAKI Motohiro <[email protected]>CC "Paul Menage" <[email protected]>CC Li Zefan <[email protected]>CC Jeremy Fitzhardinge <[email protected]>CC Andi Kleen <[email protected]>CC Rusty Russell <[email protected]>--- kernel/kmod.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Index:
b/kernel/kmod.c
===================================================================kernel/kmod.c +1
-1@@ -360,7 +360,7 @@ struct subprocess_info *call_usermodehel char **argv, char **envp) { struct subprocess_info *sub_info; - sub_info =kzalloc (sizeof (struct subprocess_info ),GFP_ATOMIC ); + sub_info =kzalloc (sizeof (struct subprocess_info ),GFP_KERNEL );if (!sub_info) goto out;
Quoted 11 lines
Quoted 4 lines · KOSAKI Motohiro
Now,
call_usermodehelper_setup()useGFP_ATOMIC.
but it is slighly odd.
becausecall_usermodehelper()is always called process context.Are you sure? I found the following call chain:
static irqreturn_t power_handler(int irq, void *dev_id) ->orderly_poweroff(true); ->call_usermodehelper_setup()
sorry, you are right.
I'll make patch again.
Quoted 6 lines · On Thu, 08 May 2008 16:31:29 +0900 KOSAKI Motohiro…
Quoted 6 lines
Quoted 4 lines · KOSAKI Motohiro
Now,
call_usermodehelper_setup()useGFP_ATOMIC.
but it is slighly odd.
becausecall_usermodehelper()is always called process context.
Quoted 8 lines
Quoted 5 lines
Are you sure? I found the following call chain:
static irqreturn_t power_handler(int irq, void *dev_id) ->orderly_poweroff(true); ->call_usermodehelper_setup()sorry, you are right.
I'll make patch again.
How many times do we have to make this mistake :(
Only the caller knows what allocation mode the callee can use. call_usermodehelper_setup() should be extended to take a gfp_t argument.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Are you sure? I found the following call chain:
static irqreturn_t power_handler(int irq, void *dev_id) ->orderly_poweroff(true); ->call_usermodehelper_setup()
Quoted 7 lines
Quoted 2 lines
sorry, you are right.
I'll make patch again.How many times do we have to make this mistake :(
Only the caller knows what allocation mode the callee can use.
call_usermodehelper_setup()should be extended to take agfp_targument.
Agreed.
I'm testing so patch.
I'll post tommorow, myabe.
Quoted 16 lines · Andrew Morton
Quoted 13 lines · On Thu, 08 May 2008 16:31:29 +0900 KOSAKI Motohiro…
Quoted 13 lines
Quoted 5 lines · KOSAKI Motohiro
Now,
call_usermodehelper_setup()useGFP_ATOMIC.
but it is slighly odd.
becausecall_usermodehelper()is always called process context.Are you sure? I found the following call chain:
static irqreturn_t power_handler(int irq, void *dev_id) ->orderly_poweroff(true); ->call_usermodehelper_setup()
Quoted 8 lines
Quoted 3 lines
sorry, you are right.
I'll make patch again.How many times do we have to make this mistake :(
Only the caller knows what allocation mode the callee can use.
call_usermodehelper_setup()should be extended to take agfp_targument.
Yeah, but making the caller need to know about the internal implementation details of the callee (ie, whether it needs to allocate memory or not) leads to pretty warty interfaces. In this case, you could push the gfp_t up to the call_usermodehelper_setup() level, but pushing it any higher wouldn't make much sense.
Not that I have a better answer.
J
Hi
Thanks good comment!
Quoted 10 lines
Quoted 4 lines
How many times do we have to make this mistake :(
Only the caller knows what allocation mode the callee can use.
call_usermodehelper_setup()should be extended to take agfp_targument.Yeah, but making the caller need to know about the internal implementation details of the callee (ie, whether it needs to allocate memory or not) leads to pretty warty interfaces. In this case, you could push the
gfp_tup to thecall_usermodehelper_setup()level, but pushing it any higher wouldn't make much sense.
No problem :)
almost caller doesn't call call_usermodehelper_setup() directly.
thus, call_usermodehelper_setup() chage is hided in call_usermodehelper().
----------------chunk of my current testing patch-----------------------------
@@ -68,8 +69,9 @@ static inline int
call_usermodehelper(char *path, char **argv, char **envp, enum umh_wait wait) {
struct subprocess_info *info;
+ gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL;
- info = call_usermodehelper_setup(path, argv, envp);
+ info = call_usermodehelper_setup(path, argv, envp, gfp_mask);
if (info == NULL)
return -ENOMEM;
return call_usermodehelper_exec(info, wait);
Quoted 9 lines · KOSAKI Motohiro
Hi
Thanks good comment!
Quoted 4 lines
Quoted 4 lines
How many times do we have to make this mistake :(
Only the caller knows what allocation mode the callee can use.
call_usermodehelper_setup()should be extended to take agfp_targument.
Quoted 8 lines
Quoted 2 lines
Yeah, but making the caller need to know about the internal implementation details of the callee (ie, whether it needs to allocate memory or not) leads to pretty warty interfaces. In this case, you could push the
gfp_tup to thecall_usermodehelper_setup()level, but pushing it any higher wouldn't make much sense.No problem :)
almost caller doesn't callcall_usermodehelper_setup()directly.thus,
call_usermodehelper_setup()chage is hided incall_usermodehelper().
Yep, seems reasonable. Are there any UMH_NO_WAIT callers who could be using GFP_KERNEL?
Quoted 5 lines
----------------chunk of my current testing patch-----------------------------
Review static inline int · line 77
Quoted 10 lines
(quoted diff) +2
-1@@ -68,8 +69,9 @@ static inline int call_usermodehelper(char *path, char **argv, char **envp, enum umh_wait wait) { struct subprocess_info *info; + gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL; - info = call_usermodehelper_setup(path, argv, envp); + info = call_usermodehelper_setup(path, argv, envp, gfp_mask); if (info == NULL) return -ENOMEM; return call_usermodehelper_exec(info, wait);
J
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Yeah, but making the caller need to know about the internal implementation details of the callee (ie, whether it needs to allocate memory or not) leads to pretty warty interfaces. In this case, you could push the
gfp_tup to thecall_usermodehelper_setup()level, but pushing it any higher wouldn't make much sense.
Quoted 7 lines
Quoted 4 lines
No problem :)
almost caller doesn't callcall_usermodehelper_setup()directly.thus,
call_usermodehelper_setup()chage is hided incall_usermodehelper().Yep, seems reasonable. Are there any
UMH_NO_WAITcallers who could be usingGFP_KERNEL?
UMH_WAIT_EXEC and UMH_WAIT_PROC mean wait on finish of exec or process exit. I can't imagine situation that exec is waitable *and* allocate isn't waitable.
Quoted 3 lines · KOSAKI Motohiro
UMH_WAIT_EXECandUMH_WAIT_PROCmean wait on finish of exec or process exit. I can't imagine situation that exec is waitable *and* allocate isn't waitable.
Yeah, that's why I was asking about UMH_NO_WAIT, where the caller may not want to wait, but the context would allow the allocation to block if necessary.
J
Quoted 7 lines
Quoted 2 lines · KOSAKI Motohiro
UMH_WAIT_EXECandUMH_WAIT_PROCmean wait on finish of exec or process exit. I can't imagine situation that exec is waitable *and* allocate isn't waitable.Yeah, that's why I was asking about
UMH_NO_WAIT, where the caller may not want to wait, but the context would allow the allocation to block if necessary.
sorry, I misunderstood ;)
Yeah, you are right.
but it is no regression.
I agree with my plan have improve chance, but it is better than current.
Quoted 4 lines · KOSAKI Motohiro
Yeah, you are right.
but it is no regression.
I agree with my plan have improve chance, but it is better than current.
Sure. I was just curious and wondered if you'd already looked at it.
J