From: Rusty Russell <rusty@rustcorp.com.au>
To: David Rientjes <rientjes@google.com>
Cc: linux-kernel@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org>
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 [thread overview]
Message-ID: <87fvwhpf8c.fsf@rustcorp.com.au> (raw)
In-Reply-To: <alpine.DEB.2.02.1306161111180.22688@chino.kir.corp.google.com>
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;
next prev parent reply other threads:[~2013-06-17 4:03 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-01 9:56 [PATCH] virtio-mmio: Cocci spatch "ptr_ret.spatch" Thomas Meyer
2013-06-03 2:29 ` [RFC] PTR_ERR: return 0 if ptr isn't an error value Rusty Russell
2013-06-03 7:15 ` Uwe Kleine-König
2013-06-08 21:07 ` Julia Lawall
2013-06-13 4:37 ` Rusty Russell
2013-06-13 7:30 ` Michael S. Tsirkin
2013-06-13 7:56 ` Julia Lawall
2013-06-16 2:44 ` Rusty Russell
2013-06-16 4:42 ` [PATCH 1/9] PTR_RET is now PTR_ERR_OR_ZERO Rusty Russell
2013-06-16 4:42 ` [PATCH 2/9] PTR_RET is now PTR_ERR_OR_ZERO(): Replace most Rusty Russell
2013-06-20 6:05 ` David Miller
2013-06-25 7:47 ` Benjamin Herrenschmidt
2013-06-16 4:42 ` [PATCH 3/9] s390: Replace weird use of PTR_RET Rusty Russell
2013-06-17 5:03 ` Heiko Carstens
2013-06-16 4:42 ` [PATCH 4/9] acpi: " Rusty Russell
2013-06-16 11:55 ` Rafael J. Wysocki
2013-06-16 4:42 ` [PATCH 5/9] pinctrl: don't use PTR_RET() Rusty Russell
2013-06-16 4:42 ` [PATCH 6/9] remoteproc: " Rusty Russell
2013-06-17 3:15 ` Ohad Ben-Cohen
2013-06-17 3:49 ` Rusty Russell
2013-06-16 4:42 ` [PATCH 7/9] staging/zcache: " Rusty Russell
2013-06-16 4:42 ` [PATCH 8/9] x86: remove weird PTR_ERR() in do_debug Rusty Russell
2013-06-19 18:43 ` [tip:x86/debug] x86: Remove " tip-bot for Rusty Russell
2013-06-16 4:42 ` [PATCH 9/9] mm/oom_kill: remove weird use of ERR_PTR()/PTR_ERR() Rusty Russell
2013-06-16 18:11 ` David Rientjes
2013-06-17 3:50 ` Rusty Russell [this message]
2013-06-09 5:55 ` [RFC] PTR_ERR: return 0 if ptr isn't an error value Rusty Russell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fvwhpf8c.fsf@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rientjes@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome