mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* can you switch between GFP_ATOMIC and GFP_KERNEL?
@ 2005-01-01  4:04 Michael Hines
  2005-01-01  4:16 ` Roland Dreier
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Hines @ 2005-01-01  4:04 UTC (permalink / raw)
  To: linux-kernel

Hi,

	I've been working on some code that puts a hook in net/core/dev.c
to intercept packets and redirect them to a module of mine, depending
on the type of packet it is....

	My question is, new sk_buffs are always allocated with GFP_KERNEL
and can be swapped out. Is it possible to change the allocation status of
already-allocated memory to GFP_ATOMIC on the fly? (i.e. both the
slab-cache sk_buff header memory as well as the kmalloc'd data area).

	My module keeps these packets for some time. My machine has plenty
of memory, and I'd much prefer that the memory belonging to these newly
receive packets never gets swapped out.

Thanks,
/*********************************/
Michael R. Hines
Grad Student, Florida State
Dept. Computer Science
http://www.cs.fsu.edu/~mhines/
Jusqu'a ce que le futur vienne...
/*********************************/



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

* Re: can you switch between GFP_ATOMIC and GFP_KERNEL?
  2005-01-01  4:04 can you switch between GFP_ATOMIC and GFP_KERNEL? Michael Hines
@ 2005-01-01  4:16 ` Roland Dreier
  2005-01-01  4:21   ` Michael Hines
  0 siblings, 1 reply; 3+ messages in thread
From: Roland Dreier @ 2005-01-01  4:16 UTC (permalink / raw)
  To: Michael Hines; +Cc: linux-kernel

    Michael> My question is, new sk_buffs are always allocated with
    Michael> GFP_KERNEL and can be swapped out. Is it possible to
    Michael> change the allocation status of already-allocated memory
    Michael> to GFP_ATOMIC on the fly? (i.e. both the slab-cache
    Michael> sk_buff header memory as well as the kmalloc'd data
    Michael> area).

This question is ill-posed -- kernel memory can never be swapped out,
whether it's allocated with GFP_KERNEL or GFP_ATOMIC.  The difference
between GFP_KERNEL and GFP_ATOMIC is whether the actual allocation can
sleep, that is:

	foo = kmalloc(sizeof foo, GFP_ATOMIC);	/* will not sleep */
	foo = kmalloc(sizeof foo, GFP_KERNEL);	/* can sleep */

However, whichever gfp flags are used to allocate memory, the memory
is the same once the allocation is done.  Neither kmalloc'ed memory
nor sk_buffs will ever be swapped.

 - Roland

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

* Re: can you switch between GFP_ATOMIC and GFP_KERNEL?
  2005-01-01  4:16 ` Roland Dreier
@ 2005-01-01  4:21   ` Michael Hines
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Hines @ 2005-01-01  4:21 UTC (permalink / raw)
  To: Roland Dreier; +Cc: linux-kernel


Oh, that's right.

Stupid me =)

Thanks,
/*********************************/
Michael R. Hines
Grad Student, Florida State
Dept. Computer Science
http://www.cs.fsu.edu/~mhines/
Jusqu'a ce que le futur vienne...
/*********************************/


On Fri, 31 Dec 2004, Roland Dreier wrote:

>     Michael> My question is, new sk_buffs are always allocated with
>     Michael> GFP_KERNEL and can be swapped out. Is it possible to
>     Michael> change the allocation status of already-allocated memory
>     Michael> to GFP_ATOMIC on the fly? (i.e. both the slab-cache
>     Michael> sk_buff header memory as well as the kmalloc'd data
>     Michael> area).
>
> This question is ill-posed -- kernel memory can never be swapped out,
> whether it's allocated with GFP_KERNEL or GFP_ATOMIC.  The difference
> between GFP_KERNEL and GFP_ATOMIC is whether the actual allocation can
> sleep, that is:
>
> 	foo = kmalloc(sizeof foo, GFP_ATOMIC);	/* will not sleep */
> 	foo = kmalloc(sizeof foo, GFP_KERNEL);	/* can sleep */
>
> However, whichever gfp flags are used to allocate memory, the memory
> is the same once the allocation is done.  Neither kmalloc'ed memory
> nor sk_buffs will ever be swapped.
>
>  - Roland
>


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

end of thread, other threads:[~2005-01-01  4:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-01  4:04 can you switch between GFP_ATOMIC and GFP_KERNEL? Michael Hines
2005-01-01  4:16 ` Roland Dreier
2005-01-01  4:21   ` Michael Hines

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®