* [patch 1/2] mm, counters: remove task argument to sync_mm_rss and __sync_task_rss_stat
@ 2012-03-07 3:21 David Rientjes
2012-03-07 3:21 ` [patch 2/2] mm, counters: fold __sync_task_rss_stat into sync_mm_rss David Rientjes
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: David Rientjes @ 2012-03-07 3:21 UTC (permalink / raw)
To: Andrew Morton; +Cc: KAMEZAWA Hiroyuki, linux-kernel, linux-mm
sync_mm_rss() can only be used for current to avoid race conditions in
iterating and clearing its per-task counters. Remove the task argument
for it and its helper function, __sync_task_rss_stat(), to avoid thinking
it can be used safely for anything other than current.
Signed-off-by: David Rientjes <rientjes@google.com>
---
fs/exec.c | 2 +-
include/linux/mm.h | 4 ++--
kernel/exit.c | 2 +-
mm/memory.c | 18 +++++++++---------
mm/mmu_context.c | 2 +-
5 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/fs/exec.c b/fs/exec.c
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -822,7 +822,7 @@ static int exec_mmap(struct mm_struct *mm)
/* Notify parent that we're no longer interested in the old VM */
tsk = current;
old_mm = current->mm;
- sync_mm_rss(tsk, old_mm);
+ sync_mm_rss(old_mm);
mm_release(tsk, old_mm);
if (old_mm) {
diff --git a/include/linux/mm.h b/include/linux/mm.h
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1127,9 +1127,9 @@ static inline void setmax_mm_hiwater_rss(unsigned long *maxrss,
}
#if defined(SPLIT_RSS_COUNTING)
-void sync_mm_rss(struct task_struct *task, struct mm_struct *mm);
+void sync_mm_rss(struct mm_struct *mm);
#else
-static inline void sync_mm_rss(struct task_struct *task, struct mm_struct *mm)
+static inline void sync_mm_rss(struct mm_struct *mm)
{
}
#endif
diff --git a/kernel/exit.c b/kernel/exit.c
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -953,7 +953,7 @@ void do_exit(long code)
acct_update_integrals(tsk);
/* sync mm's RSS info before statistics gathering */
if (tsk->mm)
- sync_mm_rss(tsk, tsk->mm);
+ sync_mm_rss(tsk->mm);
group_dead = atomic_dec_and_test(&tsk->signal->live);
if (group_dead) {
hrtimer_cancel(&tsk->signal->real_timer);
diff --git a/mm/memory.c b/mm/memory.c
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -125,17 +125,17 @@ core_initcall(init_zero_pfn);
#if defined(SPLIT_RSS_COUNTING)
-static void __sync_task_rss_stat(struct task_struct *task, struct mm_struct *mm)
+static void __sync_task_rss_stat(struct mm_struct *mm)
{
int i;
for (i = 0; i < NR_MM_COUNTERS; i++) {
- if (task->rss_stat.count[i]) {
- add_mm_counter(mm, i, task->rss_stat.count[i]);
- task->rss_stat.count[i] = 0;
+ if (current->rss_stat.count[i]) {
+ add_mm_counter(mm, i, current->rss_stat.count[i]);
+ current->rss_stat.count[i] = 0;
}
}
- task->rss_stat.events = 0;
+ current->rss_stat.events = 0;
}
static void add_mm_counter_fast(struct mm_struct *mm, int member, int val)
@@ -157,7 +157,7 @@ static void check_sync_rss_stat(struct task_struct *task)
if (unlikely(task != current))
return;
if (unlikely(task->rss_stat.events++ > TASK_RSS_EVENTS_THRESH))
- __sync_task_rss_stat(task, task->mm);
+ __sync_task_rss_stat(task->mm);
}
unsigned long get_mm_counter(struct mm_struct *mm, int member)
@@ -178,9 +178,9 @@ unsigned long get_mm_counter(struct mm_struct *mm, int member)
return (unsigned long)val;
}
-void sync_mm_rss(struct task_struct *task, struct mm_struct *mm)
+void sync_mm_rss(struct mm_struct *mm)
{
- __sync_task_rss_stat(task, mm);
+ __sync_task_rss_stat(mm);
}
#else /* SPLIT_RSS_COUNTING */
@@ -661,7 +661,7 @@ static inline void add_mm_rss_vec(struct mm_struct *mm, int *rss)
int i;
if (current->mm == mm)
- sync_mm_rss(current, mm);
+ sync_mm_rss(mm);
for (i = 0; i < NR_MM_COUNTERS; i++)
if (rss[i])
add_mm_counter(mm, i, rss[i]);
diff --git a/mm/mmu_context.c b/mm/mmu_context.c
--- a/mm/mmu_context.c
+++ b/mm/mmu_context.c
@@ -53,7 +53,7 @@ void unuse_mm(struct mm_struct *mm)
struct task_struct *tsk = current;
task_lock(tsk);
- sync_mm_rss(tsk, mm);
+ sync_mm_rss(mm);
tsk->mm = NULL;
/* active_mm is still 'mm' */
enter_lazy_tlb(mm, tsk);
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [patch 2/2] mm, counters: fold __sync_task_rss_stat into sync_mm_rss
2012-03-07 3:21 [patch 1/2] mm, counters: remove task argument to sync_mm_rss and __sync_task_rss_stat David Rientjes
@ 2012-03-07 3:21 ` David Rientjes
2012-03-08 5:41 ` KAMEZAWA Hiroyuki
2012-03-08 1:11 ` [patch 1/2] mm, counters: remove task argument to sync_mm_rss and __sync_task_rss_stat Andrew Morton
2012-03-08 5:40 ` KAMEZAWA Hiroyuki
2 siblings, 1 reply; 7+ messages in thread
From: David Rientjes @ 2012-03-07 3:21 UTC (permalink / raw)
To: Andrew Morton; +Cc: KAMEZAWA Hiroyuki, linux-kernel, linux-mm
There's no difference between sync_mm_rss() and __sync_task_rss_stat(),
so fold the latter into the former.
Signed-off-by: David Rientjes <rientjes@google.com>
---
mm/memory.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/mm/memory.c b/mm/memory.c
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -125,7 +125,7 @@ core_initcall(init_zero_pfn);
#if defined(SPLIT_RSS_COUNTING)
-static void __sync_task_rss_stat(struct mm_struct *mm)
+void sync_mm_rss(struct mm_struct *mm)
{
int i;
@@ -157,7 +157,7 @@ static void check_sync_rss_stat(struct task_struct *task)
if (unlikely(task != current))
return;
if (unlikely(task->rss_stat.events++ > TASK_RSS_EVENTS_THRESH))
- __sync_task_rss_stat(task->mm);
+ sync_mm_rss(task->mm);
}
unsigned long get_mm_counter(struct mm_struct *mm, int member)
@@ -177,11 +177,6 @@ unsigned long get_mm_counter(struct mm_struct *mm, int member)
return 0;
return (unsigned long)val;
}
-
-void sync_mm_rss(struct mm_struct *mm)
-{
- __sync_task_rss_stat(mm);
-}
#else /* SPLIT_RSS_COUNTING */
#define inc_mm_counter_fast(mm, member) inc_mm_counter(mm, member)
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch 1/2] mm, counters: remove task argument to sync_mm_rss and __sync_task_rss_stat
2012-03-07 3:21 [patch 1/2] mm, counters: remove task argument to sync_mm_rss and __sync_task_rss_stat David Rientjes
2012-03-07 3:21 ` [patch 2/2] mm, counters: fold __sync_task_rss_stat into sync_mm_rss David Rientjes
@ 2012-03-08 1:11 ` Andrew Morton
2012-03-08 1:40 ` David Rientjes
2012-03-08 5:40 ` KAMEZAWA Hiroyuki
2 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2012-03-08 1:11 UTC (permalink / raw)
To: David Rientjes; +Cc: KAMEZAWA Hiroyuki, linux-kernel, linux-mm
On Tue, 6 Mar 2012 19:21:39 -0800 (PST)
David Rientjes <rientjes@google.com> wrote:
> -static void __sync_task_rss_stat(struct task_struct *task, struct mm_struct *mm)
> +static void __sync_task_rss_stat(struct mm_struct *mm)
> {
> int i;
>
> for (i = 0; i < NR_MM_COUNTERS; i++) {
> - if (task->rss_stat.count[i]) {
> - add_mm_counter(mm, i, task->rss_stat.count[i]);
> - task->rss_stat.count[i] = 0;
> + if (current->rss_stat.count[i]) {
> + add_mm_counter(mm, i, current->rss_stat.count[i]);
> + current->rss_stat.count[i] = 0;
> }
> }
> - task->rss_stat.events = 0;
> + current->rss_stat.events = 0;
> }
hm, with my gcc it's beneficial to cache `current' in a local. But
when I tried that, Weird Things happened, because gcc has gone and
decided to inline __sync_task_rss_stat() into its callers. I don't see
how that could have been the right thing to do.
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch 1/2] mm, counters: remove task argument to sync_mm_rss and __sync_task_rss_stat
2012-03-08 1:11 ` [patch 1/2] mm, counters: remove task argument to sync_mm_rss and __sync_task_rss_stat Andrew Morton
@ 2012-03-08 1:40 ` David Rientjes
2012-03-08 2:09 ` Andrew Morton
0 siblings, 1 reply; 7+ messages in thread
From: David Rientjes @ 2012-03-08 1:40 UTC (permalink / raw)
To: Andrew Morton; +Cc: KAMEZAWA Hiroyuki, linux-kernel, linux-mm
On Wed, 7 Mar 2012, Andrew Morton wrote:
> hm, with my gcc it's beneficial to cache `current' in a local. But
> when I tried that, Weird Things happened, because gcc has gone and
> decided to inline __sync_task_rss_stat() into its callers. I don't see
> how that could have been the right thing to do.
>
c06b1fca18c3 offers some advice :)
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch 1/2] mm, counters: remove task argument to sync_mm_rss and __sync_task_rss_stat
2012-03-08 1:40 ` David Rientjes
@ 2012-03-08 2:09 ` Andrew Morton
0 siblings, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2012-03-08 2:09 UTC (permalink / raw)
To: David Rientjes; +Cc: KAMEZAWA Hiroyuki, linux-kernel, linux-mm
On Wed, 7 Mar 2012 17:40:04 -0800 (PST) David Rientjes <rientjes@google.com> wrote:
> On Wed, 7 Mar 2012, Andrew Morton wrote:
>
> > hm, with my gcc it's beneficial to cache `current' in a local. But
> > when I tried that, Weird Things happened, because gcc has gone and
> > decided to inline __sync_task_rss_stat() into its callers. I don't see
> > how that could have been the right thing to do.
> >
>
> c06b1fca18c3 offers some advice :)
But is it right? I handled a patch a month or two ago where caching
current made a nice improvement.
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch 1/2] mm, counters: remove task argument to sync_mm_rss and __sync_task_rss_stat
2012-03-07 3:21 [patch 1/2] mm, counters: remove task argument to sync_mm_rss and __sync_task_rss_stat David Rientjes
2012-03-07 3:21 ` [patch 2/2] mm, counters: fold __sync_task_rss_stat into sync_mm_rss David Rientjes
2012-03-08 1:11 ` [patch 1/2] mm, counters: remove task argument to sync_mm_rss and __sync_task_rss_stat Andrew Morton
@ 2012-03-08 5:40 ` KAMEZAWA Hiroyuki
2 siblings, 0 replies; 7+ messages in thread
From: KAMEZAWA Hiroyuki @ 2012-03-08 5:40 UTC (permalink / raw)
To: David Rientjes; +Cc: Andrew Morton, linux-kernel, linux-mm
On Tue, 6 Mar 2012 19:21:39 -0800 (PST)
David Rientjes <rientjes@google.com> wrote:
> sync_mm_rss() can only be used for current to avoid race conditions in
> iterating and clearing its per-task counters. Remove the task argument
> for it and its helper function, __sync_task_rss_stat(), to avoid thinking
> it can be used safely for anything other than current.
>
> Signed-off-by: David Rientjes <rientjes@google.com>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-03-08 5:43 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-07 3:21 [patch 1/2] mm, counters: remove task argument to sync_mm_rss and __sync_task_rss_stat David Rientjes
2012-03-07 3:21 ` [patch 2/2] mm, counters: fold __sync_task_rss_stat into sync_mm_rss David Rientjes
2012-03-08 5:41 ` KAMEZAWA Hiroyuki
2012-03-08 1:11 ` [patch 1/2] mm, counters: remove task argument to sync_mm_rss and __sync_task_rss_stat Andrew Morton
2012-03-08 1:40 ` David Rientjes
2012-03-08 2:09 ` Andrew Morton
2012-03-08 5:40 ` KAMEZAWA Hiroyuki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).