* Out of memory handling broken
@ 2001-09-24 22:34 Pavel Machek
2001-09-25 20:05 ` Rik van Riel
0 siblings, 1 reply; 5+ messages in thread
From: Pavel Machek @ 2001-09-24 22:34 UTC (permalink / raw)
To: riel, kernel list
Hi!
I need to allocate as much memory as possible (but not more). Okay, so
I use out_of_memory, right?
Does this code look sane?
static void eat_memory(void)
{
int i = 0;
void **c= eaten_memory, *m;
printk("Eating pages ");
while ((m = (void *) get_free_page(GFP_USER))) {
memset(m, 0, PAGE_SIZE);
eaten_memory = m;
if (!(i%5000))
printk( "." );
*eaten_memory = c;
c = eaten_memory;
i++;
if (out_of_memory())
break;
}
printk("(%dK)\n", i*4);
}
[if not, how should I code it?]
But, when I looked into out_of_memory... Of course its
wrong. out_of_memory() contains
if (nr_swap_pages > 0)
return 0;
...which is obviously wrong. It is well possible to have free swap
_and_ be out of memory -- eat_memory() loop gets system to this state
easily.
Pavel
--
I'm pavel@ucw.cz. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents at discuss@linmodems.org
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: Out of memory handling broken
2001-09-24 22:34 Out of memory handling broken Pavel Machek
@ 2001-09-25 20:05 ` Rik van Riel
2001-09-26 14:03 ` Pavel Machek
0 siblings, 1 reply; 5+ messages in thread
From: Rik van Riel @ 2001-09-25 20:05 UTC (permalink / raw)
To: Pavel Machek; +Cc: kernel list
On Tue, 25 Sep 2001, Pavel Machek wrote:
> I need to allocate as much memory as possible (but not more).
> Okay, so I use out_of_memory, right?
Nope, out_of_memory() is about virtual memory handling,
not at all about physical memory.
> But, when I looked into out_of_memory... Of course its
> wrong. out_of_memory() contains
>
> if (nr_swap_pages > 0)
> return 0;
>
> ...which is obviously wrong. It is well possible to have free
> swap _and_ be out of memory -- eat_memory() loop gets system to
> this state easily.
This is because you're using out_of_memory() for something
it was never meant for. ;)
Even if it didn't take swap into account, you'd still end
up counting highmem pages your code cannot use...
cheers,
Rik
--
IA64: a worthy successor to the i860.
http://www.surriel.com/
http://www.conectiva.com/ http://distro.conectiva.com/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Out of memory handling broken
2001-09-25 20:05 ` Rik van Riel
@ 2001-09-26 14:03 ` Pavel Machek
2001-09-26 14:08 ` Rik van Riel
0 siblings, 1 reply; 5+ messages in thread
From: Pavel Machek @ 2001-09-26 14:03 UTC (permalink / raw)
To: Rik van Riel; +Cc: kernel list
Hi!
> > I need to allocate as much memory as possible (but not more).
> > Okay, so I use out_of_memory, right?
>
> Nope, out_of_memory() is about virtual memory handling,
> not at all about physical memory.
Yes, so... What happens at physical memory exhaustion? System crash?
> > But, when I looked into out_of_memory... Of course its
> > wrong. out_of_memory() contains
> >
> > if (nr_swap_pages > 0)
> > return 0;
> >
> > ...which is obviously wrong. It is well possible to have free
> > swap _and_ be out of memory -- eat_memory() loop gets system to
> > this state easily.
>
> This is because you're using out_of_memory() for something
> it was never meant for. ;)
Okay, okay. Is there any solution (in 2.4.10) in doing what I want to
do?
Pavel
--
Causalities in World Trade Center: 6453 dead inside the building,
cryptography in U.S.A. and free speech in Czech Republic.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Out of memory handling broken
2001-09-26 14:03 ` Pavel Machek
@ 2001-09-26 14:08 ` Rik van Riel
2001-09-26 14:25 ` Pavel Machek
0 siblings, 1 reply; 5+ messages in thread
From: Rik van Riel @ 2001-09-26 14:08 UTC (permalink / raw)
To: Pavel Machek; +Cc: kernel list
On Wed, 26 Sep 2001, Pavel Machek wrote:
> > > I need to allocate as much memory as possible (but not more).
> > > Okay, so I use out_of_memory, right?
> >
> > Nope, out_of_memory() is about virtual memory handling,
> > not at all about physical memory.
>
> Yes, so... What happens at physical memory exhaustion? System crash?
We swap something out.
But indeed, when the kernel needs memory for itself
and no more memory is available, we'd crash. This is
not something I've ever seen any system get close to,
however...
> Okay, okay. Is there any solution (in 2.4.10) in doing what I want to
> do?
GPF_ATOMIC and giving kswapd a chance to run whenever the
atomic allocations fail ?
regards,
Rik
--
IA64: a worthy successor to i860.
http://www.surriel.com/ http://distro.conectiva.com/
Send all your spam to aardvark@nl.linux.org (spam digging piggy)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Out of memory handling broken
2001-09-26 14:08 ` Rik van Riel
@ 2001-09-26 14:25 ` Pavel Machek
0 siblings, 0 replies; 5+ messages in thread
From: Pavel Machek @ 2001-09-26 14:25 UTC (permalink / raw)
To: Rik van Riel; +Cc: kernel list
Hi!
> We swap something out.
>
> But indeed, when the kernel needs memory for itself
> and no more memory is available, we'd crash. This is
> not something I've ever seen any system get close to,
> however...
Yep...
> > Okay, okay. Is there any solution (in 2.4.10) in doing what I want to
> > do?
>
> GPF_ATOMIC and giving kswapd a chance to run whenever the
> atomic allocations fail ?
But how do I know when to stop? I'd have to place timeout there
:-(. How do I know no more memory is available?
Pavel
--
Causalities in World Trade Center: 6453 dead inside the building,
cryptography in U.S.A. and free speech in Czech Republic.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2001-09-26 14:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-09-24 22:34 Out of memory handling broken Pavel Machek
2001-09-25 20:05 ` Rik van Riel
2001-09-26 14:03 ` Pavel Machek
2001-09-26 14:08 ` Rik van Riel
2001-09-26 14:25 ` Pavel Machek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.