Skip to contentSkip to conversation

GFP_FAIL?

DISCUSSION Pavel Machek 3 participants 4 messages Sep 25, 2001

lore
Share & tools
lore
#0 lore raw

Hi!

I need to alloc as much memory as possible, *but not more*. I do not want to OOM-kill anything. How do I do this? Tried GFP_KERNEL, will oom-kill. GFP_USER will OOM-kill, too.
Pavel

Signature · 2 lines
I'm [email protected]. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents at [email protected]
#1 lore raw

Pavel Machek <[email protected]> was pleased to say:

Quoted 5 lines

Hi!

I need to alloc as much memory as possible, *but not more*. I do not want to OOM-kill anything. How do I do this? Tried GFP_KERNEL, will oom-kill. GFP_USER will OOM-kill, too.

Try GFP_ATOMIC; GFP_KERNEL sets the __GFP_WAIT flag and you don't want that. But, if you're really asking how to know how large the current working set is, so that you don't grab more than your applications are going to need and eventually OOM, you'll need to set GFP_HAVE_CRYSTAL_BALL ;-)

Signature · 7 lines
Tommy Reynolds                               |
Red Hat, Inc. (Embedded Development)         | "The quickest way to do anything
307 Wynn Drive NW, Huntsville, AL 35805 USA  |  is right the first time."
mailto:[email protected]                   |       - The Lieutenant (Rick
Phone:  +1.256.704.9286                      |         Jason), "Combat!",
Mobile: +1.919.641.2923                      |         1962 TV series
FAX:    +1.256.837.3839                      |
#2 lore raw
In reply to Pavel Machek

Hi!

Quoted 6 lines
Quoted 3 lines

I need to alloc as much memory as possible, *but not more*. I do not want to OOM-kill anything. How do I do this? Tried GFP_KERNEL, will oom-kill. GFP_USER will OOM-kill, too.

Try GFP_ATOMIC; GFP_KERNEL sets the __GFP_WAIT flag and you don't want that.

No, I want other apps to be moved to swap, dirty data written out etc. I really can't live with GFP_ATOMIC.

Quoted 3 lines

But, if you're really asking how to know how large the current working set is, so that you don't grab more than your applications are going to need and eventually OOM, you'll need to set GFP_HAVE_CRYSTAL_BALL ;-)

I want to push just as much that I do not cause OOM. I'll stop applications real soon after that.

Pavel

Signature · 2 lines
Causalities in World Trade Center: 6453 dead inside the building,
cryptography in U.S.A. and free speech in Czech Republic.
#3 lore raw
In reply to Pavel Machek
Quoted 5 lines · Pavel Machek

Hi!

I need to alloc as much memory as possible, *but not more*. I do not want to OOM-kill anything. How do I do this? Tried GFP_KERNEL, will oom-kill. GFP_USER will OOM-kill, too.

Currently, you can't.

I've added a GFP_FAIL flag at 2.4.5-ac1 to be used by the bounce buffering allocation code to avoid highmem deadlocks, but it was removed due to no more need.
(http://oss.sgi.com/projects/xfs/mail_archive/0103/msg00110.html is a similar patch which I proposed to the XFS people)

The only problem by of a GFP_FAIL flag for some users is that it cannot fail _too_ easily. Think about the SCSI layer trying to allocate big memory chunks to do more effective (bigger) scatter-gather transfers.

If we use GFP_FAIL to mean "get memory without any efforts", the scatter-gather big tables are never going to happen, thus we'll have crappy performance. For _those_ kind of allocations, we want to try a bit more instead failing so easily. See?

Thats why I think Linus will not like such a flag with no exact meaning.

Well, ask him. :)