Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1273227 > unrolled thread

[PATCH 6/7] cputime: Introduce vtime accounting check for readers

Started byFrederic Weisbecker <fweisbec@gmail.com>
First post2015-11-19 16:50 +0100
Last post2015-11-23 16:30 +0100
Articles 5 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 6/7] cputime: Introduce vtime accounting check for readers Frederic Weisbecker <fweisbec@gmail.com> - 2015-11-19 16:50 +0100
    Re: [PATCH 6/7] cputime: Introduce vtime accounting check for readers Peter Zijlstra <peterz@infradead.org> - 2015-11-19 21:30 +0100
      Re: [PATCH 6/7] cputime: Introduce vtime accounting check for readers Frederic Weisbecker <fweisbec@gmail.com> - 2015-11-23 15:20 +0100
        Re: [PATCH 6/7] cputime: Introduce vtime accounting check for readers Peter Zijlstra <peterz@infradead.org> - 2015-11-23 15:40 +0100
          Re: [PATCH 6/7] cputime: Introduce vtime accounting check for readers Frederic Weisbecker <fweisbec@gmail.com> - 2015-11-23 16:30 +0100

#1273227 — [PATCH 6/7] cputime: Introduce vtime accounting check for readers

FromFrederic Weisbecker <fweisbec@gmail.com>
Date2015-11-19 16:50 +0100
Subject[PATCH 6/7] cputime: Introduce vtime accounting check for readers
Message-ID<qwzDb-2M9-7@gated-at.bofh.it>
Readers need to know if vtime runs at all on some CPU somewhere, this
is a fast-path check to determine if we need to check further the need
to add up any tickless cputime delta.

This fast path check uses context tracking state because vtime is tied
to context tracking as of now. This check appears to be confusing though
so lets use a vtime function that deals with context tracking details
in vtime implementation instead.

Cc: Christoph Lameter <cl@linux.com>
Cc: Chris Metcalf <cmetcalf@ezchip.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 include/linux/vtime.h  | 13 ++++++++++++-
 kernel/sched/cputime.c |  6 +++---
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/include/linux/vtime.h b/include/linux/vtime.h
index ca23e83..fa21969 100644
--- a/include/linux/vtime.h
+++ b/include/linux/vtime.h
@@ -17,9 +17,20 @@ static inline bool vtime_accounting_cpu_enabled(void) { return true; }
 #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
 
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
+/*
+ * Checks if vtime is enabled on some CPU. Cputime readers want to be careful
+ * in that case and compute the tickless cputime.
+ * For now vtime state is tied to context tracking. We might want to decouple
+ * those later if necessary.
+ */
+static inline bool vtime_accounting_enabled(void)
+{
+	return context_tracking_is_enabled();
+}
+
 static inline bool vtime_accounting_cpu_enabled(void)
 {
-	if (context_tracking_is_enabled()) {
+	if (vtime_accounting_enabled()) {
 		if (context_tracking_cpu_is_enabled())
 			return true;
 	}
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 5727217..9989c3f 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -788,7 +788,7 @@ cputime_t task_gtime(struct task_struct *t)
 	unsigned int seq;
 	cputime_t gtime;
 
-	if (!context_tracking_is_enabled())
+	if (!vtime_accounting_enabled())
 		return t->gtime;
 
 	do {
@@ -853,7 +853,7 @@ void task_cputime(struct task_struct *t, cputime_t *utime, cputime_t *stime)
 {
 	cputime_t udelta, sdelta;
 
-	if (!context_tracking_is_enabled()) {
+	if (!vtime_accounting_enabled()) {
 		if (utime)
 			*utime = t->utime;
 		if (stime)
@@ -874,7 +874,7 @@ void task_cputime_scaled(struct task_struct *t,
 {
 	cputime_t udelta, sdelta;
 
-	if (!context_tracking_is_enabled()) {
+	if (!vtime_accounting_enabled()) {
 		if (utimescaled)
 			*utimescaled = t->utimescaled;
 		if (stimescaled)
-- 
2.5.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1273469

FromPeter Zijlstra <peterz@infradead.org>
Date2015-11-19 21:30 +0100
Message-ID<qwE0a-5Mi-1@gated-at.bofh.it>
In reply to#1273227
On Thu, Nov 19, 2015 at 04:47:33PM +0100, Frederic Weisbecker wrote:
> +++ b/include/linux/vtime.h
> @@ -17,9 +17,20 @@ static inline bool vtime_accounting_cpu_enabled(void) { return true; }
>  #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
>  
>  #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
> +/*
> + * Checks if vtime is enabled on some CPU. Cputime readers want to be careful
> + * in that case and compute the tickless cputime.
> + * For now vtime state is tied to context tracking. We might want to decouple
> + * those later if necessary.
> + */
> +static inline bool vtime_accounting_enabled(void)
> +{
> +	return context_tracking_is_enabled();
> +}

Should this not also include a definition of this function for
CONFIG_VIRT_CPU_ACCOUNTING_NATIVE and CONFIG_VIRT_CPU_ACCOUNTING ?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1275421

FromFrederic Weisbecker <fweisbec@gmail.com>
Date2015-11-23 15:20 +0100
Message-ID<qy08i-2R4-19@gated-at.bofh.it>
In reply to#1273469
On Thu, Nov 19, 2015 at 09:28:28PM +0100, Peter Zijlstra wrote:
> On Thu, Nov 19, 2015 at 04:47:33PM +0100, Frederic Weisbecker wrote:
> > +++ b/include/linux/vtime.h
> > @@ -17,9 +17,20 @@ static inline bool vtime_accounting_cpu_enabled(void) { return true; }
> >  #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
> >  
> >  #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
> > +/*
> > + * Checks if vtime is enabled on some CPU. Cputime readers want to be careful
> > + * in that case and compute the tickless cputime.
> > + * For now vtime state is tied to context tracking. We might want to decouple
> > + * those later if necessary.
> > + */
> > +static inline bool vtime_accounting_enabled(void)
> > +{
> > +	return context_tracking_is_enabled();
> > +}
> 
> Should this not also include a definition of this function for
> CONFIG_VIRT_CPU_ACCOUNTING_NATIVE and CONFIG_VIRT_CPU_ACCOUNTING ?

I could but I haven't found any user of it yet for others than
CONFIG_VIRT_CPU_ACCOUNTING_GEN. The NATIVE version, when enabled, runs on
all CPUs anyway.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1275446

FromPeter Zijlstra <peterz@infradead.org>
Date2015-11-23 15:40 +0100
Message-ID<qy0rE-30z-33@gated-at.bofh.it>
In reply to#1275421
On Mon, Nov 23, 2015 at 03:19:19PM +0100, Frederic Weisbecker wrote:
> On Thu, Nov 19, 2015 at 09:28:28PM +0100, Peter Zijlstra wrote:
> > On Thu, Nov 19, 2015 at 04:47:33PM +0100, Frederic Weisbecker wrote:
> > > +++ b/include/linux/vtime.h
> > > @@ -17,9 +17,20 @@ static inline bool vtime_accounting_cpu_enabled(void) { return true; }
> > >  #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
> > >  
> > >  #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
> > > +/*
> > > + * Checks if vtime is enabled on some CPU. Cputime readers want to be careful
> > > + * in that case and compute the tickless cputime.
> > > + * For now vtime state is tied to context tracking. We might want to decouple
> > > + * those later if necessary.
> > > + */
> > > +static inline bool vtime_accounting_enabled(void)
> > > +{
> > > +	return context_tracking_is_enabled();
> > > +}
> > 
> > Should this not also include a definition of this function for
> > CONFIG_VIRT_CPU_ACCOUNTING_NATIVE and CONFIG_VIRT_CPU_ACCOUNTING ?
> 
> I could but I haven't found any user of it yet for others than
> CONFIG_VIRT_CPU_ACCOUNTING_GEN. The NATIVE version, when enabled, runs on
> all CPUs anyway.

Aah, I see, task_gtime() etc.. have a different definition for !GEN.
tricky.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1275478

FromFrederic Weisbecker <fweisbec@gmail.com>
Date2015-11-23 16:30 +0100
Message-ID<qy1e2-3DU-19@gated-at.bofh.it>
In reply to#1275446
On Mon, Nov 23, 2015 at 03:35:16PM +0100, Peter Zijlstra wrote:
> On Mon, Nov 23, 2015 at 03:19:19PM +0100, Frederic Weisbecker wrote:
> > On Thu, Nov 19, 2015 at 09:28:28PM +0100, Peter Zijlstra wrote:
> > > On Thu, Nov 19, 2015 at 04:47:33PM +0100, Frederic Weisbecker wrote:
> > > > +++ b/include/linux/vtime.h
> > > > @@ -17,9 +17,20 @@ static inline bool vtime_accounting_cpu_enabled(void) { return true; }
> > > >  #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
> > > >  
> > > >  #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
> > > > +/*
> > > > + * Checks if vtime is enabled on some CPU. Cputime readers want to be careful
> > > > + * in that case and compute the tickless cputime.
> > > > + * For now vtime state is tied to context tracking. We might want to decouple
> > > > + * those later if necessary.
> > > > + */
> > > > +static inline bool vtime_accounting_enabled(void)
> > > > +{
> > > > +	return context_tracking_is_enabled();
> > > > +}
> > > 
> > > Should this not also include a definition of this function for
> > > CONFIG_VIRT_CPU_ACCOUNTING_NATIVE and CONFIG_VIRT_CPU_ACCOUNTING ?
> > 
> > I could but I haven't found any user of it yet for others than
> > CONFIG_VIRT_CPU_ACCOUNTING_GEN. The NATIVE version, when enabled, runs on
> > all CPUs anyway.
> 
> Aah, I see, task_gtime() etc.. have a different definition for !GEN.
> tricky.

Right, this whole CONFIG_VIRT_CPU_ACCOUNTING stuff is a bit messy. I tried
to consolidate as much code I could between NATIVE and GEN but the result
is hard to parse. I'll see if I can clean a few things up there.

To begin with, VIRT_CPU_ACCOUNTING is a horrible misnomer, as vtime.
VIRT suggests we are dealing with virtualization while it's absolutely
not the case. Perhaps something like BOUNDARY_CPU_ACCOUNTING would parse
better. Or TICKLESS_CPU_ACCOUNTING.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web