Skip to contentSkip to conversation

OOM: initialise points variable in out_of_memory()

PATCH Kurt Garloff 2 participants 2 messages Feb 28, 2006 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi Carlos,

Quoted 2 lines · Carlos Martin

We didn't initialise points, so the value reported was completely random. This doesn't affect the behaviour of the funcion.

Did you observe it?

In the original patch, there is
+static struct task_struct * select_bad_process(unsigned long *ppoints)
{

-       unsigned long maxpoints = 0;
        struct task_struct *g, *p;
        struct task_struct *chosen = NULL;
        struct timespec uptime;

+ *ppoints = 0;

And this is called from out_of_memory().

But the constrained_alloc stuff seems to use points before select_bad_process() is called, so initializing to 0 is a good idea. I don't remember having see the constrained_alloc stuff, though, so I either did not look carefully enough or a merge error happened afterwards.

Thanks for noticing and thanks for sending the fix!

Best,

Signature · 1 line
Kurt Garloff, Head Architect Linux, Novell Inc.
#2 lore raw
Quoted 7 lines · Kurt Garloff

Hi Carlos,

Quoted 2 lines · Carlos Martin

We didn't initialise points, so the value reported was completely random. This doesn't affect the behaviour of the funcion.

Did you observe it?

No. GCC complained about it.

Quoted 10 lines

In the original patch, there is

(quoted diff) +2 -1
+static struct task_struct * select_bad_process(unsigned long *ppoints)
 {
-       unsigned long maxpoints = 0;
        struct task_struct *g, *p;
        struct task_struct *chosen = NULL;
        struct timespec uptime;
+       *ppoints = 0;
Quoted 7 lines

And this is called from out_of_memory().

But the constrained_alloc stuff seems to use points before select_bad_process() is called, so initializing to 0 is a good idea. I don't remember having see the constrained_alloc stuff, though, so I either did not look carefully enough or a merge error happened afterwards.

It never used to be a problem because it was initialised when calling select_bad_process().

I though it was your change, but I've looked again and it was Christoph Lameter's commit 9b0f8b040acd8dfd23860754c0d09ff4f44e2cbc which introduced the problem.

cmn

Signature · 2 lines
Carlos Martín Nieto    |   http://www.cmartin.tk
Hobbyist programmer    |