mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* current->state after kmalloc
@ 2002-02-05  0:06 Oliver Neukum
  2002-02-05  0:23 ` arjan
  0 siblings, 1 reply; 7+ messages in thread
From: Oliver Neukum @ 2002-02-05  0:06 UTC (permalink / raw)
  To: linux-kernel

Hi,

if I do

set_current_state(TASK_INTERRUPTIBLE);
kmalloc(sizeof(struct x), GFP_KERNEL);

what is current->state after kmalloc ?

	Regards
		Oliver

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: current->state after kmalloc
  2002-02-05  0:06 current->state after kmalloc Oliver Neukum
@ 2002-02-05  0:23 ` arjan
  2002-02-05  0:43   ` Oliver Neukum
  2002-02-05  0:50   ` Robert Love
  0 siblings, 2 replies; 7+ messages in thread
From: arjan @ 2002-02-05  0:23 UTC (permalink / raw)
  To: Oliver.Neukum; +Cc: linux-kernel

In article <16Xt8Y-1SQ44eC@fwd04.sul.t-online.com> you wrote:

> set_current_state(TASK_INTERRUPTIBLE);
> kmalloc(sizeof(struct x), GFP_KERNEL);

> what is current->state after kmalloc ?

undefined. If kmalloc slept and you survived (due to setting
TASK_INTERRUPTIBLE that's not guaranteed)  then it'll most likely be
TASK_RUNNING. 
If you depend on this your kernel code is broken in that has subtle
dependencies on unspecified behavior and will break whenever kmalloc changes
internal behavior.

Greetings,
   Arjan van de Ven


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: current->state after kmalloc
  2002-02-05  0:23 ` arjan
@ 2002-02-05  0:43   ` Oliver Neukum
  2002-02-05  0:50   ` Robert Love
  1 sibling, 0 replies; 7+ messages in thread
From: Oliver Neukum @ 2002-02-05  0:43 UTC (permalink / raw)
  To: arjan; +Cc: linux-kernel

On Tuesday 05 February 2002 01:23, arjan@fenrus.demon.nl wrote:
> In article <16Xt8Y-1SQ44eC@fwd04.sul.t-online.com> you wrote:
> > set_current_state(TASK_INTERRUPTIBLE);
> > kmalloc(sizeof(struct x), GFP_KERNEL);
> >
> > what is current->state after kmalloc ?
>
> undefined. If kmalloc slept and you survived (due to setting
> TASK_INTERRUPTIBLE that's not guaranteed)  then it'll most likely be
> TASK_RUNNING.
> If you depend on this your kernel code is broken in that has subtle
> dependencies on unspecified behavior and will break whenever kmalloc
> changes internal behavior.

Is it safe with GFP_ATOMIC ?

	Regards
		Oliver

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: current->state after kmalloc
  2002-02-05  0:23 ` arjan
  2002-02-05  0:43   ` Oliver Neukum
@ 2002-02-05  0:50   ` Robert Love
  2002-02-05  1:08     ` Oliver Neukum
  1 sibling, 1 reply; 7+ messages in thread
From: Robert Love @ 2002-02-05  0:50 UTC (permalink / raw)
  To: Oliver.Neukum; +Cc: arjan, linux-kernel

On Mon, 2002-02-04 at 19:43, Oliver Neukum wrote:

> Is it safe with GFP_ATOMIC ?

You are guaranteed kmalloc will not sleep if you use GFP_ATOMIC, yes.

But I still find it gross to mark yourself sleeping but not sleep
immediately.

	Robert Love


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: current->state after kmalloc
  2002-02-05  0:50   ` Robert Love
@ 2002-02-05  1:08     ` Oliver Neukum
  2002-02-05  8:16       ` arjan
  0 siblings, 1 reply; 7+ messages in thread
From: Oliver Neukum @ 2002-02-05  1:08 UTC (permalink / raw)
  To: Robert Love; +Cc: arjan, linux-kernel

On Tuesday 05 February 2002 01:50, Robert Love wrote:
> On Mon, 2002-02-04 at 19:43, Oliver Neukum wrote:
> > Is it safe with GFP_ATOMIC ?
>
> You are guaranteed kmalloc will not sleep if you use GFP_ATOMIC, yes.
>
> But I still find it gross to mark yourself sleeping but not sleep
> immediately.

usb_submit_urb() uses kmalloc internally.
To code a simple waiting for the results of an urb,
it is necessary.

	Regards
		Oliver

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: current->state after kmalloc
  2002-02-05  1:08     ` Oliver Neukum
@ 2002-02-05  8:16       ` arjan
  2002-02-05  8:35         ` Oliver Neukum
  0 siblings, 1 reply; 7+ messages in thread
From: arjan @ 2002-02-05  8:16 UTC (permalink / raw)
  To: Oliver.Neukum; +Cc: linux-kernel

In article <16Xu62-2F1K08C@fwd04.sul.t-online.com> you wrote:

> usb_submit_urb() uses kmalloc internally.
> To code a simple waiting for the results of an urb,
> it is necessary.

Can't you just alloc the memory outside this "current" area ?
Even if that means you have to release it if you don't use it

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: current->state after kmalloc
  2002-02-05  8:16       ` arjan
@ 2002-02-05  8:35         ` Oliver Neukum
  0 siblings, 0 replies; 7+ messages in thread
From: Oliver Neukum @ 2002-02-05  8:35 UTC (permalink / raw)
  To: arjan; +Cc: linux-kernel

On Tuesday 05 February 2002 09:16, arjan@fenrus.demon.nl wrote:
> In article <16Xu62-2F1K08C@fwd04.sul.t-online.com> you wrote:
> > usb_submit_urb() uses kmalloc internally.
> > To code a simple waiting for the results of an urb,
> > it is necessary.
>
> Can't you just alloc the memory outside this "current" area ?
> Even if that means you have to release it if you don't use it

No. The individual USB device drivers must not know the memory
requirements of the HCD layer.

	Regards
		Oliver


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-02-05  8:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-05  0:06 current->state after kmalloc Oliver Neukum
2002-02-05  0:23 ` arjan
2002-02-05  0:43   ` Oliver Neukum
2002-02-05  0:50   ` Robert Love
2002-02-05  1:08     ` Oliver Neukum
2002-02-05  8:16       ` arjan
2002-02-05  8:35         ` Oliver Neukum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®