Messages in this thread Patch in this message | | | From | Rusty Russell <> | Subject | Re: [PATCH 9/9] mm/oom_kill: remove weird use of ERR_PTR()/PTR_ERR(). | Date | Mon, 17 Jun 2013 13:20:59 +0930 |
| |
David Rientjes <rientjes@google.com> writes: > On Sun, 16 Jun 2013, Rusty Russell wrote: > >> diff --git a/mm/oom_kill.c b/mm/oom_kill.c >> index 79e451a..f9b9cd7 100644 >> --- a/mm/oom_kill.c >> +++ b/mm/oom_kill.c >> @@ -288,7 +288,7 @@ enum oom_scan_t oom_scan_process_thread(struct task_struct *task, >> >> /* >> * Simple selection loop. We chose the process with the highest >> - * number of 'points'. >> + * number of 'points'. Returns -1 on scan abort. >> * >> * (not docbooked, we don't want this one cluttering up the manual) >> */ >> @@ -314,7 +314,7 @@ static struct task_struct *select_bad_process(unsigned int *ppoints, >> continue; >> case OOM_SCAN_ABORT: >> rcu_read_unlock(); >> - return ERR_PTR(-1UL); >> + return (void *)(-1UL); >> case OOM_SCAN_OK: >> break; >> }; > > Any reason it's not struct task_struct *?
No good one. Changed.
Cheers, Rusty.
Subject: mm/oom_kill: remove weird use of ERR_PTR()/PTR_ERR().
The normal expectation for ERR_PTR() is to put a negative errno into a pointer. oom_kill puts the magic -1 in the result (and has since pre-git), which is probably clearer with an explicit cast.
Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 79e451a..f9b9cd7 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -288,7 +288,7 @@ enum oom_scan_t oom_scan_process_thread(struct task_struct *task, /* * Simple selection loop. We chose the process with the highest - * number of 'points'. + * number of 'points'. Returns -1 on scan abort. * * (not docbooked, we don't want this one cluttering up the manual) */ @@ -314,7 +314,7 @@ static struct task_struct *select_bad_process(unsigned int *ppoints, continue; case OOM_SCAN_ABORT: rcu_read_unlock(); - return ERR_PTR(-1UL); + return (struct task_struct *)(-1UL); case OOM_SCAN_OK: break; }; @@ -657,7 +657,7 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, dump_header(NULL, gfp_mask, order, NULL, mpol_mask); panic("Out of memory and no killable processes...\n"); } - if (PTR_ERR(p) != -1UL) { + if (p != (void *)-1UL) { oom_kill_process(p, gfp_mask, order, points, totalpages, NULL, nodemask, "Out of memory"); killed = 1;
| |