* [PATCH] mm,oom: Reduce needless dereference.
@ 2016-03-08 11:02 Tetsuo Handa
2016-03-08 13:32 ` Vlastimil Babka
2016-03-08 18:30 ` Johannes Weiner
0 siblings, 2 replies; 4+ messages in thread
From: Tetsuo Handa @ 2016-03-08 11:02 UTC (permalink / raw)
To: linux-mm; +Cc: Tetsuo Handa
Since we assigned mm = victim->mm before pr_err(),
we don't need to dereference victim->mm again at pr_err().
This saves a few instructions.
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
mm/oom_kill.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index c84e784..1808db32 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -756,10 +756,10 @@ void oom_kill_process(struct oom_control *oc, struct task_struct *p,
do_send_sig_info(SIGKILL, SEND_SIG_FORCED, victim, true);
mark_oom_victim(victim);
pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB\n",
- task_pid_nr(victim), victim->comm, K(victim->mm->total_vm),
- K(get_mm_counter(victim->mm, MM_ANONPAGES)),
- K(get_mm_counter(victim->mm, MM_FILEPAGES)),
- K(get_mm_counter(victim->mm, MM_SHMEMPAGES)));
+ task_pid_nr(victim), victim->comm, K(mm->total_vm),
+ K(get_mm_counter(mm, MM_ANONPAGES)),
+ K(get_mm_counter(mm, MM_FILEPAGES)),
+ K(get_mm_counter(mm, MM_SHMEMPAGES)));
task_unlock(victim);
/*
--
1.8.3.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mm,oom: Reduce needless dereference.
2016-03-08 11:02 [PATCH] mm,oom: Reduce needless dereference Tetsuo Handa
@ 2016-03-08 13:32 ` Vlastimil Babka
2016-03-08 18:30 ` Johannes Weiner
1 sibling, 0 replies; 4+ messages in thread
From: Vlastimil Babka @ 2016-03-08 13:32 UTC (permalink / raw)
To: Tetsuo Handa, linux-mm
On 03/08/2016 12:02 PM, Tetsuo Handa wrote:
> Since we assigned mm = victim->mm before pr_err(),
> we don't need to dereference victim->mm again at pr_err().
> This saves a few instructions.
That sounds obvious, right. Yet once in a while I try to test these for
fun, and there can be indeed surprises :)
./scripts/bloat-o-meter says:
add/remove: 0/0 grow/shrink: 1/0 up/down: 1/0 (1)
function old new delta
oom_kill_process 1085 1086 +1
a naive asmdiff is too complicated to follow but it seems from the
number of lines that indeed there are less instructions in your case,
but still the code is a bit larger.
Just a reminder that compilers can be quite counter-intuitive. Anyway, a
liquid-helium-path like this probably doesn't need such
microoptimisations as an extra patch, given the ongoing churn in the oom
area?
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> ---
> mm/oom_kill.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index c84e784..1808db32 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -756,10 +756,10 @@ void oom_kill_process(struct oom_control *oc, struct task_struct *p,
> do_send_sig_info(SIGKILL, SEND_SIG_FORCED, victim, true);
> mark_oom_victim(victim);
> pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB\n",
> - task_pid_nr(victim), victim->comm, K(victim->mm->total_vm),
> - K(get_mm_counter(victim->mm, MM_ANONPAGES)),
> - K(get_mm_counter(victim->mm, MM_FILEPAGES)),
> - K(get_mm_counter(victim->mm, MM_SHMEMPAGES)));
> + task_pid_nr(victim), victim->comm, K(mm->total_vm),
> + K(get_mm_counter(mm, MM_ANONPAGES)),
> + K(get_mm_counter(mm, MM_FILEPAGES)),
> + K(get_mm_counter(mm, MM_SHMEMPAGES)));
> task_unlock(victim);
>
> /*
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm,oom: Reduce needless dereference.
2016-03-08 11:02 [PATCH] mm,oom: Reduce needless dereference Tetsuo Handa
2016-03-08 13:32 ` Vlastimil Babka
@ 2016-03-08 18:30 ` Johannes Weiner
2016-03-09 14:55 ` Michal Hocko
1 sibling, 1 reply; 4+ messages in thread
From: Johannes Weiner @ 2016-03-08 18:30 UTC (permalink / raw)
To: Tetsuo Handa; +Cc: linux-mm
On Tue, Mar 08, 2016 at 08:02:31PM +0900, Tetsuo Handa wrote:
> Since we assigned mm = victim->mm before pr_err(),
> we don't need to dereference victim->mm again at pr_err().
> This saves a few instructions.
>
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Yes. Once we introduce a local variable for something, we should use
it consistently to refer to that thing. Anything else is confusing.
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm,oom: Reduce needless dereference.
2016-03-08 18:30 ` Johannes Weiner
@ 2016-03-09 14:55 ` Michal Hocko
0 siblings, 0 replies; 4+ messages in thread
From: Michal Hocko @ 2016-03-09 14:55 UTC (permalink / raw)
To: Johannes Weiner; +Cc: Tetsuo Handa, linux-mm
On Tue 08-03-16 13:30:32, Johannes Weiner wrote:
> On Tue, Mar 08, 2016 at 08:02:31PM +0900, Tetsuo Handa wrote:
> > Since we assigned mm = victim->mm before pr_err(),
> > we don't need to dereference victim->mm again at pr_err().
> > This saves a few instructions.
> >
> > Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
>
> Yes. Once we introduce a local variable for something, we should use
> it consistently to refer to that thing. Anything else is confusing.
The victim->mm association is stable here because of the task_lock but I
agree that this might be not obvious and reusing the local variable is
easier to read and understand. I doubt we care about the change in the
generated code as an argument though. So just for the sake of clean up
Acked-by: Michal Hocko <mhocko@suse.com>
>
> Acked-by: Johannes Weiner <hannes@cmpxchg.org>
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
--
Michal Hocko
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-03-09 14:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-08 11:02 [PATCH] mm,oom: Reduce needless dereference Tetsuo Handa
2016-03-08 13:32 ` Vlastimil Babka
2016-03-08 18:30 ` Johannes Weiner
2016-03-09 14:55 ` Michal Hocko
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.