linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] nohz: Cputime cleanups and tilegx isolation
@ 2015-07-14 22:37 Frederic Weisbecker
  2015-07-14 22:37 ` [PATCH 1/4] jiffies: Remove HZ > USEC_PER_SEC special case Frederic Weisbecker
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Frederic Weisbecker @ 2015-07-14 22:37 UTC (permalink / raw)
  To: LKML
  Cc: Frederic Weisbecker, Ivan Kokshaysky, Peter Zijlstra,
	Chris Metcalf, Thomas Gleixner, Preeti U Murthy,
	Christoph Lameter, Richard Henderson, Ingo Molnar, Viresh Kumar,
	Rik van Riel

That set has jiffies/cputime cleanups and fixes that were previously
posted and a change on tilegx driver to be isolation-friendly.

If nobody opposes, I'll make a pull request to Ingo in a few days.

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git
	timers/core-v3

HEAD: 572536be5b8e84c507d66203f53faa0ae2c8c244

Thanks,
	Frederic
---

Frederic Weisbecker (3):
      jiffies: Remove HZ > USEC_PER_SEC special case
      apm32: Fix cputime == jiffies assumption
      alpha: Fix jiffies based cputime assumption

Chris Metcalf (1):
      nohz: Prevent tilegx network driver interrupts


 arch/alpha/kernel/osf_sys.c        | 13 +++++++++----
 arch/x86/kernel/apm_32.c           |  2 +-
 drivers/net/ethernet/tile/tilegx.c |  4 +++-
 include/linux/jiffies.h            |  9 +--------
 include/linux/tick.h               |  9 +++++++++
 kernel/time/time.c                 | 10 +++++++---
 6 files changed, 30 insertions(+), 17 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] jiffies: Remove HZ > USEC_PER_SEC special case
  2015-07-14 22:37 [PATCH 0/4] nohz: Cputime cleanups and tilegx isolation Frederic Weisbecker
@ 2015-07-14 22:37 ` Frederic Weisbecker
  2015-07-14 22:37 ` [PATCH 2/4] apm32: Fix cputime == jiffies assumption Frederic Weisbecker
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Frederic Weisbecker @ 2015-07-14 22:37 UTC (permalink / raw)
  To: LKML
  Cc: Frederic Weisbecker, Ivan Kokshaysky, Peter Zijlstra,
	Chris Metcalf, Thomas Gleixner, Preeti U Murthy,
	Christoph Lameter, Richard Henderson, Ingo Molnar, Viresh Kumar,
	Rik van Riel

HZ never goes much further 1000 and a bit. And if we ever reach one tick
per microsecond, we might be having a problem.

Lets stop maintaining this special case, just leave a paranoid check.

Reviewed-by: Rik van Riel <riel@redhat.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc; John Stultz <john.stultz@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Preeti U Murthy <preeti@linux.vnet.ibm.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 include/linux/jiffies.h |  9 +--------
 kernel/time/time.c      | 10 +++++++---
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index 535fd3b..7c6febe 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -363,18 +363,11 @@ static inline unsigned long msecs_to_jiffies(const unsigned int m)
 }
 
 extern unsigned long __usecs_to_jiffies(const unsigned int u);
-#if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ)
+#if !(USEC_PER_SEC % HZ)
 static inline unsigned long _usecs_to_jiffies(const unsigned int u)
 {
 	return (u + (USEC_PER_SEC / HZ) - 1) / (USEC_PER_SEC / HZ);
 }
-#elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC)
-static inline unsigned long _usecs_to_jiffies(const unsigned int u)
-{
-	return u * (HZ / USEC_PER_SEC);
-}
-static inline unsigned long _usecs_to_jiffies(const unsigned int u)
-{
 #else
 static inline unsigned long _usecs_to_jiffies(const unsigned int u)
 {
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 85d5bb1..ad1bf23 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -268,10 +268,14 @@ EXPORT_SYMBOL(jiffies_to_msecs);
 
 unsigned int jiffies_to_usecs(const unsigned long j)
 {
-#if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ)
+	/*
+	 * Hz usually doesn't go much further MSEC_PER_SEC.
+	 * jiffies_to_usecs() and usecs_to_jiffies() depend on that.
+	 */
+	BUILD_BUG_ON(HZ > USEC_PER_SEC);
+
+#if !(USEC_PER_SEC % HZ)
 	return (USEC_PER_SEC / HZ) * j;
-#elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC)
-	return (j + (HZ / USEC_PER_SEC) - 1)/(HZ / USEC_PER_SEC);
 #else
 # if BITS_PER_LONG == 32
 	return (HZ_TO_USEC_MUL32 * j) >> HZ_TO_USEC_SHR32;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] apm32: Fix cputime == jiffies assumption
  2015-07-14 22:37 [PATCH 0/4] nohz: Cputime cleanups and tilegx isolation Frederic Weisbecker
  2015-07-14 22:37 ` [PATCH 1/4] jiffies: Remove HZ > USEC_PER_SEC special case Frederic Weisbecker
@ 2015-07-14 22:37 ` Frederic Weisbecker
  2015-07-14 22:37 ` [PATCH 3/4] alpha: Fix jiffies based cputime assumption Frederic Weisbecker
  2015-07-14 22:37 ` [PATCH 4/4] nohz: Prevent tilegx network driver interrupts Frederic Weisbecker
  3 siblings, 0 replies; 5+ messages in thread
From: Frederic Weisbecker @ 2015-07-14 22:37 UTC (permalink / raw)
  To: LKML
  Cc: Frederic Weisbecker, Ivan Kokshaysky, Peter Zijlstra,
	Chris Metcalf, Thomas Gleixner, Preeti U Murthy,
	Christoph Lameter, Richard Henderson, Ingo Molnar, Viresh Kumar,
	Rik van Riel

That code wrongly assumes that cputime_t wraps jiffies_t. Lets use
the correct accessors/mutators.

No real harm now as that code can't be used with full dynticks.

Reviewed-by: Rik van Riel <riel@redhat.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc; John Stultz <john.stultz@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Preeti U Murthy <preeti@linux.vnet.ibm.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 arch/x86/kernel/apm_32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index 927ec92..052c9c3 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -919,7 +919,7 @@ recalc:
 	} else if (jiffies_since_last_check > idle_period) {
 		unsigned int idle_percentage;
 
-		idle_percentage = stime - last_stime;
+		idle_percentage = cputime_to_jiffies(stime - last_stime);
 		idle_percentage *= 100;
 		idle_percentage /= jiffies_since_last_check;
 		use_apm_idle = (idle_percentage > idle_threshold);
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] alpha: Fix jiffies based cputime assumption
  2015-07-14 22:37 [PATCH 0/4] nohz: Cputime cleanups and tilegx isolation Frederic Weisbecker
  2015-07-14 22:37 ` [PATCH 1/4] jiffies: Remove HZ > USEC_PER_SEC special case Frederic Weisbecker
  2015-07-14 22:37 ` [PATCH 2/4] apm32: Fix cputime == jiffies assumption Frederic Weisbecker
@ 2015-07-14 22:37 ` Frederic Weisbecker
  2015-07-14 22:37 ` [PATCH 4/4] nohz: Prevent tilegx network driver interrupts Frederic Weisbecker
  3 siblings, 0 replies; 5+ messages in thread
From: Frederic Weisbecker @ 2015-07-14 22:37 UTC (permalink / raw)
  To: LKML
  Cc: Frederic Weisbecker, Ivan Kokshaysky, Peter Zijlstra,
	Chris Metcalf, Thomas Gleixner, Preeti U Murthy,
	Christoph Lameter, Richard Henderson, Ingo Molnar, Viresh Kumar,
	Rik van Riel

That code wrongly assumes that cputime_t wraps jiffies_t. Lets use
the correct accessors/mutators.

In practice there should be no harm yet because alpha currently
only support tick based cputime accounting which is always jiffies
based.

Reviewed-by: Rik van Riel <riel@redhat.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Christoph Lameter <cl@linux.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc; John Stultz <john.stultz@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Preeti U Murthy <preeti@linux.vnet.ibm.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 arch/alpha/kernel/osf_sys.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 36dc91a..6cc0816 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -1138,6 +1138,7 @@ SYSCALL_DEFINE2(osf_getrusage, int, who, struct rusage32 __user *, ru)
 {
 	struct rusage32 r;
 	cputime_t utime, stime;
+	unsigned long utime_jiffies, stime_jiffies;
 
 	if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN)
 		return -EINVAL;
@@ -1146,14 +1147,18 @@ SYSCALL_DEFINE2(osf_getrusage, int, who, struct rusage32 __user *, ru)
 	switch (who) {
 	case RUSAGE_SELF:
 		task_cputime(current, &utime, &stime);
-		jiffies_to_timeval32(utime, &r.ru_utime);
-		jiffies_to_timeval32(stime, &r.ru_stime);
+		utime_jiffies = cputime_to_jiffies(utime);
+		stime_jiffies = cputime_to_jiffies(stime);
+		jiffies_to_timeval32(utime_jiffies, &r.ru_utime);
+		jiffies_to_timeval32(stime_jiffies, &r.ru_stime);
 		r.ru_minflt = current->min_flt;
 		r.ru_majflt = current->maj_flt;
 		break;
 	case RUSAGE_CHILDREN:
-		jiffies_to_timeval32(current->signal->cutime, &r.ru_utime);
-		jiffies_to_timeval32(current->signal->cstime, &r.ru_stime);
+		utime_jiffies = cputime_to_jiffies(current->signal->cutime);
+		stime_jiffies = cputime_to_jiffies(current->signal->cstime);
+		jiffies_to_timeval32(utime_jiffies, &r.ru_utime);
+		jiffies_to_timeval32(stime_jiffies, &r.ru_stime);
 		r.ru_minflt = current->signal->cmin_flt;
 		r.ru_majflt = current->signal->cmaj_flt;
 		break;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] nohz: Prevent tilegx network driver interrupts
  2015-07-14 22:37 [PATCH 0/4] nohz: Cputime cleanups and tilegx isolation Frederic Weisbecker
                   ` (2 preceding siblings ...)
  2015-07-14 22:37 ` [PATCH 3/4] alpha: Fix jiffies based cputime assumption Frederic Weisbecker
@ 2015-07-14 22:37 ` Frederic Weisbecker
  3 siblings, 0 replies; 5+ messages in thread
From: Frederic Weisbecker @ 2015-07-14 22:37 UTC (permalink / raw)
  To: LKML
  Cc: Chris Metcalf, Ivan Kokshaysky, Peter Zijlstra, Thomas Gleixner,
	Preeti U Murthy, Christoph Lameter, Richard Henderson,
	Frederic Weisbecker, Ingo Molnar, Viresh Kumar, Rik van Riel

From: Chris Metcalf <cmetcalf@ezchip.com>

Normally the tilegx networking shim sends irqs to all the cores
to distribute the load of processing incoming-packet interrupts,
so that you can get to multiple Gb's of traffic inbound.

However, in nohz_full mode we don't want to interrupt the
nohz_full cores by default, so we limit the set of cores we use
to only the online housekeeping cores.

To make client code easier to read, we introduce a new nohz_full
accessor, housekeeping_cpumask(), which returns a pointer to the
housekeeping_mask if nohz_full is enabled, and otherwise returns
the cpu_possible_mask.

Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Preeti U Murthy <preeti@linux.vnet.ibm.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 drivers/net/ethernet/tile/tilegx.c | 4 +++-
 include/linux/tick.h               | 9 +++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c
index a3f7610..0a15acc 100644
--- a/drivers/net/ethernet/tile/tilegx.c
+++ b/drivers/net/ethernet/tile/tilegx.c
@@ -40,6 +40,7 @@
 #include <linux/tcp.h>
 #include <linux/net_tstamp.h>
 #include <linux/ptp_clock_kernel.h>
+#include <linux/tick.h>
 
 #include <asm/checksum.h>
 #include <asm/homecache.h>
@@ -2273,7 +2274,8 @@ static int __init tile_net_init_module(void)
 		tile_net_dev_init(name, mac);
 
 	if (!network_cpus_init())
-		network_cpus_map = *cpu_online_mask;
+		cpumask_and(&network_cpus_map, housekeeping_cpumask(),
+			    cpu_online_mask);
 
 	return 0;
 }
diff --git a/include/linux/tick.h b/include/linux/tick.h
index edbfc9a..1ca93f2 100644
--- a/include/linux/tick.h
+++ b/include/linux/tick.h
@@ -163,6 +163,15 @@ static inline void tick_nohz_full_kick_all(void) { }
 static inline void __tick_nohz_task_switch(struct task_struct *tsk) { }
 #endif
 
+static inline const struct cpumask *housekeeping_cpumask(void)
+{
+#ifdef CONFIG_NO_HZ_FULL
+	if (tick_nohz_full_enabled())
+		return housekeeping_mask;
+#endif
+	return cpu_possible_mask;
+}
+
 static inline bool is_housekeeping_cpu(int cpu)
 {
 #ifdef CONFIG_NO_HZ_FULL
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-07-14 22:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-14 22:37 [PATCH 0/4] nohz: Cputime cleanups and tilegx isolation Frederic Weisbecker
2015-07-14 22:37 ` [PATCH 1/4] jiffies: Remove HZ > USEC_PER_SEC special case Frederic Weisbecker
2015-07-14 22:37 ` [PATCH 2/4] apm32: Fix cputime == jiffies assumption Frederic Weisbecker
2015-07-14 22:37 ` [PATCH 3/4] alpha: Fix jiffies based cputime assumption Frederic Weisbecker
2015-07-14 22:37 ` [PATCH 4/4] nohz: Prevent tilegx network driver interrupts Frederic Weisbecker

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).