From: tip-bot for Jason Low <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: preeti@linux.vnet.ibm.com, scott.norton@hp.com,
umgwanakikbuti@gmail.com, riel@redhat.com,
linux-kernel@vger.kernel.org, tglx@linutronix.de, aswin@hp.com,
jason.low2@hp.com, akpm@linux-foundation.org,
paulmck@linux.vnet.ibm.com, Waiman.Long@hp.com,
rostedt@goodmis.org, mingo@kernel.org, oleg@redhat.com,
peterz@infradead.org, mgorman@suse.de, fweisbec@gmail.com,
dave@stgolabs.net, torvalds@linux-foundation.org, bp@alien8.de,
hpa@zytor.com
Subject: [tip:sched/core] sched, timer: Use the atomic task_cputime in thread_group_cputimer
Date: Fri, 8 May 2015 06:23:13 -0700 [thread overview]
Message-ID: <tip-7110744516276e906f9197e2857d026eb2343393@git.kernel.org> (raw)
In-Reply-To: <1430251224-5764-6-git-send-email-jason.low2@hp.com>
Commit-ID: 7110744516276e906f9197e2857d026eb2343393
Gitweb: http://git.kernel.org/tip/7110744516276e906f9197e2857d026eb2343393
Author: Jason Low <jason.low2@hp.com>
AuthorDate: Tue, 28 Apr 2015 13:00:24 -0700
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 8 May 2015 12:17:46 +0200
sched, timer: Use the atomic task_cputime in thread_group_cputimer
Recent optimizations were made to thread_group_cputimer to improve its
scalability by keeping track of cputime stats without a lock. However,
the values were open coded to the structure, causing them to be at
a different abstraction level from the regular task_cputime structure.
Furthermore, any subsequent similar optimizations would not be able to
share the new code, since they are specific to thread_group_cputimer.
This patch adds the new task_cputime_atomic data structure (introduced in
the previous patch in the series) to thread_group_cputimer for keeping
track of the cputime atomically, which also helps generalize the code.
Suggested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Jason Low <jason.low2@hp.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Rik van Riel <riel@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Aswin Chandramouleeswaran <aswin@hp.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Mike Galbraith <umgwanakikbuti@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Preeti U Murthy <preeti@linux.vnet.ibm.com>
Cc: Scott J Norton <scott.norton@hp.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Waiman Long <Waiman.Long@hp.com>
Link: http://lkml.kernel.org/r/1430251224-5764-6-git-send-email-jason.low2@hp.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
include/linux/init_task.h | 6 ++----
include/linux/sched.h | 4 +---
kernel/sched/stats.h | 6 +++---
kernel/time/posix-cpu-timers.c | 26 +++++++++++++-------------
4 files changed, 19 insertions(+), 23 deletions(-)
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index 7b9d8b5..bb9b075 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -50,10 +50,8 @@ extern struct fs_struct init_fs;
.cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \
.rlim = INIT_RLIMITS, \
.cputimer = { \
- .utime = ATOMIC64_INIT(0), \
- .stime = ATOMIC64_INIT(0), \
- .sum_exec_runtime = ATOMIC64_INIT(0), \
- .running = 0 \
+ .cputime_atomic = INIT_CPUTIME_ATOMIC, \
+ .running = 0, \
}, \
.cred_guard_mutex = \
__MUTEX_INITIALIZER(sig.cred_guard_mutex), \
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 6eb78cd..4adc536 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -615,9 +615,7 @@ struct task_cputime_atomic {
* used for thread group CPU timer calculations.
*/
struct thread_group_cputimer {
- atomic64_t utime;
- atomic64_t stime;
- atomic64_t sum_exec_runtime;
+ struct task_cputime_atomic cputime_atomic;
int running;
};
diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h
index c6d1c7d..077ebbd 100644
--- a/kernel/sched/stats.h
+++ b/kernel/sched/stats.h
@@ -216,7 +216,7 @@ static inline void account_group_user_time(struct task_struct *tsk,
if (!cputimer_running(tsk))
return;
- atomic64_add(cputime, &cputimer->utime);
+ atomic64_add(cputime, &cputimer->cputime_atomic.utime);
}
/**
@@ -237,7 +237,7 @@ static inline void account_group_system_time(struct task_struct *tsk,
if (!cputimer_running(tsk))
return;
- atomic64_add(cputime, &cputimer->stime);
+ atomic64_add(cputime, &cputimer->cputime_atomic.stime);
}
/**
@@ -258,5 +258,5 @@ static inline void account_group_exec_runtime(struct task_struct *tsk,
if (!cputimer_running(tsk))
return;
- atomic64_add(ns, &cputimer->sum_exec_runtime);
+ atomic64_add(ns, &cputimer->cputime_atomic.sum_exec_runtime);
}
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index d857306..892e3da 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -211,20 +211,20 @@ retry:
}
}
-static void update_gt_cputime(struct thread_group_cputimer *cputimer, struct task_cputime *sum)
+static void update_gt_cputime(struct task_cputime_atomic *cputime_atomic, struct task_cputime *sum)
{
- __update_gt_cputime(&cputimer->utime, sum->utime);
- __update_gt_cputime(&cputimer->stime, sum->stime);
- __update_gt_cputime(&cputimer->sum_exec_runtime, sum->sum_exec_runtime);
+ __update_gt_cputime(&cputime_atomic->utime, sum->utime);
+ __update_gt_cputime(&cputime_atomic->stime, sum->stime);
+ __update_gt_cputime(&cputime_atomic->sum_exec_runtime, sum->sum_exec_runtime);
}
-/* Sample thread_group_cputimer values in "cputimer", store results in "times". */
-static inline void sample_group_cputimer(struct task_cputime *times,
- struct thread_group_cputimer *cputimer)
+/* Sample task_cputime_atomic values in "atomic_timers", store results in "times". */
+static inline void sample_cputime_atomic(struct task_cputime *times,
+ struct task_cputime_atomic *atomic_times)
{
- times->utime = atomic64_read(&cputimer->utime);
- times->stime = atomic64_read(&cputimer->stime);
- times->sum_exec_runtime = atomic64_read(&cputimer->sum_exec_runtime);
+ times->utime = atomic64_read(&atomic_times->utime);
+ times->stime = atomic64_read(&atomic_times->stime);
+ times->sum_exec_runtime = atomic64_read(&atomic_times->sum_exec_runtime);
}
void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times)
@@ -240,7 +240,7 @@ void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times)
* to synchronize the timer to the clock every time we start it.
*/
thread_group_cputime(tsk, &sum);
- update_gt_cputime(cputimer, &sum);
+ update_gt_cputime(&cputimer->cputime_atomic, &sum);
/*
* We're setting cputimer->running without a lock. Ensure
@@ -251,7 +251,7 @@ void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times)
*/
WRITE_ONCE(cputimer->running, 1);
}
- sample_group_cputimer(times, cputimer);
+ sample_cputime_atomic(times, &cputimer->cputime_atomic);
}
/*
@@ -1137,7 +1137,7 @@ static inline int fastpath_timer_check(struct task_struct *tsk)
if (READ_ONCE(sig->cputimer.running)) {
struct task_cputime group_sample;
- sample_group_cputimer(&group_sample, &sig->cputimer);
+ sample_cputime_atomic(&group_sample, &sig->cputimer.cputime_atomic);
if (task_cputime_expired(&group_sample, &sig->cputime_expires))
return 1;
prev parent reply other threads:[~2015-05-08 13:24 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-28 20:00 [PATCH v2 0/5] sched, timer: Improve scalability of itimers Jason Low
2015-04-28 20:00 ` [PATCH v2 1/5] sched, timer: Remove usages of ACCESS_ONCE in the scheduler Jason Low
2015-04-29 14:34 ` Rik van Riel
2015-04-29 17:05 ` Waiman Long
2015-04-29 17:15 ` Steven Rostedt
2015-04-29 18:25 ` Jason Low
2015-05-08 13:22 ` [tip:sched/core] sched, timer: Convert usages of ACCESS_ONCE() in the scheduler to READ_ONCE()/WRITE_ONCE() tip-bot for Jason Low
2015-04-28 20:00 ` [PATCH v2 2/5] sched, numa: Document usages of mm->numa_scan_seq Jason Low
2015-04-29 14:35 ` Rik van Riel
2015-04-29 18:14 ` Waiman Long
2015-04-29 18:45 ` Jason Low
2015-04-30 18:42 ` Waiman Long
2015-04-30 18:54 ` Davidlohr Bueso
2015-04-30 20:58 ` Waiman Long
2015-04-30 21:26 ` Jason Low
2015-04-30 21:13 ` Jason Low
2015-05-01 0:28 ` [PATCH v3 " Jason Low
2015-05-08 13:22 ` [tip:sched/core] sched/numa: " tip-bot for Jason Low
2015-05-01 15:21 ` [PATCH v2 2/5] sched, numa: " Paul E. McKenney
2015-05-01 17:40 ` Jason Low
2015-04-28 20:00 ` [PATCH v2 3/5] sched, timer: Use atomics in thread_group_cputimer to improve scalability Jason Low
2015-04-29 14:38 ` Rik van Riel
2015-04-29 20:45 ` Jason Low
2015-04-29 18:43 ` Waiman Long
2015-04-29 20:14 ` Jason Low
2015-05-08 13:22 ` [tip:sched/core] sched, timer: Replace spinlocks with atomics in thread_group_cputimer(), " tip-bot for Jason Low
2015-05-08 21:31 ` [PATCH] sched, timer: Fix documentation for 'struct thread_group_cputimer' Jason Low
2015-05-11 6:41 ` [tip:sched/core] sched, timer: Fix documentation for ' struct thread_group_cputimer' tip-bot for Jason Low
2015-04-28 20:00 ` [PATCH v2 4/5] sched, timer: Provide an atomic task_cputime data structure Jason Low
2015-04-29 14:47 ` Rik van Riel
2015-05-08 13:22 ` [tip:sched/core] sched, timer: Provide an atomic ' struct task_cputime' " tip-bot for Jason Low
2015-04-28 20:00 ` [PATCH v2 5/5] sched, timer: Use the atomic task_cputime in thread_group_cputimer Jason Low
2015-04-29 14:48 ` Rik van Riel
2015-05-08 13:23 ` tip-bot for Jason Low [this message]
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=tip-7110744516276e906f9197e2857d026eb2343393@git.kernel.org \
--to=tipbot@zytor.com \
--cc=Waiman.Long@hp.com \
--cc=akpm@linux-foundation.org \
--cc=aswin@hp.com \
--cc=bp@alien8.de \
--cc=dave@stgolabs.net \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=jason.low2@hp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=preeti@linux.vnet.ibm.com \
--cc=riel@redhat.com \
--cc=rostedt@goodmis.org \
--cc=scott.norton@hp.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=umgwanakikbuti@gmail.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