Skip to content

Commit 05af2e1

Browse files
rientjestorvalds
authored andcommitted
mm, counters: remove task argument to sync_mm_rss() and __sync_task_rss_stat()
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> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 9048162 commit 05af2e1

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

fs/exec.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ static int exec_mmap(struct mm_struct *mm)
824824
/* Notify parent that we're no longer interested in the old VM */
825825
tsk = current;
826826
old_mm = current->mm;
827-
sync_mm_rss(tsk, old_mm);
827+
sync_mm_rss(old_mm);
828828
mm_release(tsk, old_mm);
829829

830830
if (old_mm) {

include/linux/mm.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1131,9 +1131,9 @@ static inline void setmax_mm_hiwater_rss(unsigned long *maxrss,
11311131
}
11321132

11331133
#if defined(SPLIT_RSS_COUNTING)
1134-
void sync_mm_rss(struct task_struct *task, struct mm_struct *mm);
1134+
void sync_mm_rss(struct mm_struct *mm);
11351135
#else
1136-
static inline void sync_mm_rss(struct task_struct *task, struct mm_struct *mm)
1136+
static inline void sync_mm_rss(struct mm_struct *mm)
11371137
{
11381138
}
11391139
#endif

kernel/exit.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ void do_exit(long code)
934934
acct_update_integrals(tsk);
935935
/* sync mm's RSS info before statistics gathering */
936936
if (tsk->mm)
937-
sync_mm_rss(tsk, tsk->mm);
937+
sync_mm_rss(tsk->mm);
938938
group_dead = atomic_dec_and_test(&tsk->signal->live);
939939
if (group_dead) {
940940
hrtimer_cancel(&tsk->signal->real_timer);

mm/memory.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,17 @@ core_initcall(init_zero_pfn);
125125

126126
#if defined(SPLIT_RSS_COUNTING)
127127

128-
static void __sync_task_rss_stat(struct task_struct *task, struct mm_struct *mm)
128+
static void __sync_task_rss_stat(struct mm_struct *mm)
129129
{
130130
int i;
131131

132132
for (i = 0; i < NR_MM_COUNTERS; i++) {
133-
if (task->rss_stat.count[i]) {
134-
add_mm_counter(mm, i, task->rss_stat.count[i]);
135-
task->rss_stat.count[i] = 0;
133+
if (current->rss_stat.count[i]) {
134+
add_mm_counter(mm, i, current->rss_stat.count[i]);
135+
current->rss_stat.count[i] = 0;
136136
}
137137
}
138-
task->rss_stat.events = 0;
138+
current->rss_stat.events = 0;
139139
}
140140

141141
static void add_mm_counter_fast(struct mm_struct *mm, int member, int val)
@@ -157,12 +157,12 @@ static void check_sync_rss_stat(struct task_struct *task)
157157
if (unlikely(task != current))
158158
return;
159159
if (unlikely(task->rss_stat.events++ > TASK_RSS_EVENTS_THRESH))
160-
__sync_task_rss_stat(task, task->mm);
160+
__sync_task_rss_stat(task->mm);
161161
}
162162

163-
void sync_mm_rss(struct task_struct *task, struct mm_struct *mm)
163+
void sync_mm_rss(struct mm_struct *mm)
164164
{
165-
__sync_task_rss_stat(task, mm);
165+
__sync_task_rss_stat(mm);
166166
}
167167
#else /* SPLIT_RSS_COUNTING */
168168

@@ -643,7 +643,7 @@ static inline void add_mm_rss_vec(struct mm_struct *mm, int *rss)
643643
int i;
644644

645645
if (current->mm == mm)
646-
sync_mm_rss(current, mm);
646+
sync_mm_rss(mm);
647647
for (i = 0; i < NR_MM_COUNTERS; i++)
648648
if (rss[i])
649649
add_mm_counter(mm, i, rss[i]);

mm/mmu_context.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void unuse_mm(struct mm_struct *mm)
5353
struct task_struct *tsk = current;
5454

5555
task_lock(tsk);
56-
sync_mm_rss(tsk, mm);
56+
sync_mm_rss(mm);
5757
tsk->mm = NULL;
5858
/* active_mm is still 'mm' */
5959
enter_lazy_tlb(mm, tsk);

0 commit comments

Comments
 (0)