All of lore.kernel.org
 help / color / mirror / Atom feed
* 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

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.