[tip:sched/core] sched/fair: Set se-> vruntime directly in place_entity()

2013-01-24 Thread tip-bot for Viresh Kumar
Commit-ID:  16c8f1c72ece3871a6c93003cd888fc2d003a7eb
Gitweb: http://git.kernel.org/tip/16c8f1c72ece3871a6c93003cd888fc2d003a7eb
Author: Viresh Kumar 
AuthorDate: Thu, 8 Nov 2012 13:33:46 +0530
Committer:  Ingo Molnar 
CommitDate: Thu, 24 Jan 2013 18:06:11 +0100

sched/fair: Set se->vruntime directly in place_entity()

We are first storing the new vruntime in a variable and then
storing it in se->vruntime. Simply update se->vruntime directly.

Signed-off-by: Viresh Kumar 
Cc: linaro-...@lists.linaro.org
Cc: patc...@linaro.org
Cc: pet...@infradead.org
Link: 
http://lkml.kernel.org/r/ae59db1945518d6f6250920d46eb1f1a9cc0024e.1352361704.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/fair.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index a7a19ff..8dbee9f 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1680,9 +1680,7 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity 
*se, int initial)
}
 
/* ensure we never gain time by being placed backwards. */
-   vruntime = max_vruntime(se->vruntime, vruntime);
-
-   se->vruntime = vruntime;
+   se->vruntime = max_vruntime(se->vruntime, vruntime);
 }
 
 static void check_enqueue_throttle(struct cfs_rq *cfs_rq);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/core] sched: Don' t initialize alloc_state in build_sched_domains()

2013-06-19 Thread tip-bot for Viresh Kumar
Commit-ID:  1c6321694074163b5863c13d71c19ca953a3fb08
Gitweb: http://git.kernel.org/tip/1c6321694074163b5863c13d71c19ca953a3fb08
Author: Viresh Kumar 
AuthorDate: Mon, 10 Jun 2013 16:27:18 +0530
Committer:  Ingo Molnar 
CommitDate: Wed, 19 Jun 2013 12:58:44 +0200

sched: Don't initialize alloc_state in build_sched_domains()

alloc_state will be overwritten by __visit_domain_allocation_hell() and so we
don't actually need to initialize alloc_state.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/df57734a075cc5ad130e1ae498702e24f2529ab8.1370861520.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 137dcc0..3de6264 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5969,7 +5969,7 @@ struct sched_domain *build_sched_domain(struct 
sched_domain_topology_level *tl,
 static int build_sched_domains(const struct cpumask *cpu_map,
   struct sched_domain_attr *attr)
 {
-   enum s_alloc alloc_state = sa_none;
+   enum s_alloc alloc_state;
struct sched_domain *sd;
struct s_data d;
int i, ret = -ENOMEM;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/core] sched: Don't set sd-> child to NULL when it is already NULL

2013-06-19 Thread tip-bot for Viresh Kumar
Commit-ID:  c75e01288ce9c9a6b7beb6b23c07d2e4d1db8c84
Gitweb: http://git.kernel.org/tip/c75e01288ce9c9a6b7beb6b23c07d2e4d1db8c84
Author: Viresh Kumar 
AuthorDate: Mon, 10 Jun 2013 16:27:19 +0530
Committer:  Ingo Molnar 
CommitDate: Wed, 19 Jun 2013 12:58:45 +0200

sched: Don't set sd->child to NULL when it is already NULL

Memory for sd is allocated with kzalloc_node() which will initialize its fields
with zero. In build_sched_domain() we are setting sd->child to child even if
child is NULL, which isn't required.

Lets do it only if child isn't NULL.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/f4753a1730051341003ad2ad29a3229c7356678e.1370861520.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 3de6264..88c2c0e 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5955,8 +5955,8 @@ struct sched_domain *build_sched_domain(struct 
sched_domain_topology_level *tl,
sd->level = child->level + 1;
sched_domain_level_max = max(sched_domain_level_max, sd->level);
child->parent = sd;
+   sd->child = child;
}
-   sd->child = child;
set_domain_attribute(sd, attr);
 
return sd;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/core] sched: Use cached value of span instead of calling sched_domain_span()

2013-06-19 Thread tip-bot for Viresh Kumar
Commit-ID:  0936629f01bb1b11772db8c36be421365238cbec
Gitweb: http://git.kernel.org/tip/0936629f01bb1b11772db8c36be421365238cbec
Author: Viresh Kumar 
AuthorDate: Tue, 11 Jun 2013 16:32:43 +0530
Committer:  Ingo Molnar 
CommitDate: Wed, 19 Jun 2013 12:58:46 +0200

sched: Use cached value of span instead of calling sched_domain_span()

In the beginning of build_sched_groups() we called sched_domain_span() and
cached its return value in span. Few statements later we are calling it again to
get the same pointer.

Lets use the cached value instead as it hasn't changed in between.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/834ecd507071ad88aff039352dbc7e063dd996a7.1370948150.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 547b7d3..3388387 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5347,7 +5347,7 @@ build_sched_groups(struct sched_domain *sd, int cpu)
get_group(cpu, sdd, &sd->groups);
atomic_inc(&sd->groups->ref);
 
-   if (cpu != cpumask_first(sched_domain_span(sd)))
+   if (cpu != cpumask_first(span))
return 0;
 
lockdep_assert_held(&sched_domains_mutex);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/core] sched: Optimize build_sched_domains() for saving first SD node for a cpu

2013-06-19 Thread tip-bot for Viresh Kumar
Commit-ID:  22da956953f371c1ee7a578c31ed8c5702cb52b1
Gitweb: http://git.kernel.org/tip/22da956953f371c1ee7a578c31ed8c5702cb52b1
Author: Viresh Kumar 
AuthorDate: Tue, 4 Jun 2013 15:41:15 +0530
Committer:  Ingo Molnar 
CommitDate: Wed, 19 Jun 2013 12:58:43 +0200

sched: Optimize build_sched_domains() for saving first SD node for a cpu

We are saving first scheduling domain for a cpu in build_sched_domains() by
iterating over the nested sd->child list. We don't actually need to do it this
way.

tl will be equal to sched_domain_topology for the first iteration and so we can
set *per_cpu_ptr(d.sd, i) based on that.  So, save pointer to first SD while
running the iteration loop over tl's.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/fc473527cbc4dfa0b8eeef2a59db74684eb59a83.1370436120.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/core.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 342e744..137dcc0 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5985,16 +5985,13 @@ static int build_sched_domains(const struct cpumask 
*cpu_map,
sd = NULL;
for (tl = sched_domain_topology; tl->init; tl++) {
sd = build_sched_domain(tl, cpu_map, attr, sd, i);
+   if (tl == sched_domain_topology)
+   *per_cpu_ptr(d.sd, i) = sd;
if (tl->flags & SDTL_OVERLAP || 
sched_feat(FORCE_SD_OVERLAP))
sd->flags |= SD_OVERLAP;
if (cpumask_equal(cpu_map, sched_domain_span(sd)))
break;
}
-
-   while (sd->child)
-   sd = sd->child;
-
-   *per_cpu_ptr(d.sd, i) = sd;
}
 
/* Build the groups for the domains */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/core] sched: Remove WARN_ON(!sd) from init_sched_groups_power()

2013-06-19 Thread tip-bot for Viresh Kumar
Commit-ID:  94c95ba69f31e435416988ddb223c92e5b0e9e83
Gitweb: http://git.kernel.org/tip/94c95ba69f31e435416988ddb223c92e5b0e9e83
Author: Viresh Kumar 
AuthorDate: Tue, 11 Jun 2013 16:32:45 +0530
Committer:  Ingo Molnar 
CommitDate: Wed, 19 Jun 2013 12:58:47 +0200

sched: Remove WARN_ON(!sd) from init_sched_groups_power()

sd can't be NULL in init_sched_groups_power() and so checking it for NULL isn't
useful. In case it is required, then also we need to rearrange the code a bit as
we already accessed invalid pointer sd to get sg: sg = sd->groups.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/2bbe633cd74b431c05253a8ce61fdfd5066a531b.1370948150.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 014c97f..21b1403 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5400,7 +5400,7 @@ static void init_sched_groups_power(int cpu, struct 
sched_domain *sd)
 {
struct sched_group *sg = sd->groups;
 
-   WARN_ON(!sd || !sg);
+   WARN_ON(!sg);
 
do {
sg->group_weight = cpumask_weight(sched_group_cpus(sg));
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/core] sched: Fix memory leakage in build_sched_groups( )

2013-06-19 Thread tip-bot for Viresh Kumar
Commit-ID:  cd08e9234c987766ad077bba80eb5a07d0855525
Gitweb: http://git.kernel.org/tip/cd08e9234c987766ad077bba80eb5a07d0855525
Author: Viresh Kumar 
AuthorDate: Tue, 11 Jun 2013 16:32:44 +0530
Committer:  Ingo Molnar 
CommitDate: Wed, 19 Jun 2013 12:58:46 +0200

sched: Fix memory leakage in build_sched_groups()

In build_sched_groups() we don't need to call get_group() for cpus
which are already covered in previous iterations. Calling get_group()
would mark the group used and eventually leak it since we wouldn't
connect it and not find it again to free it.

This will happen only in cases where sg->cpumask contained more than
one cpu (For any topology level). This patch would free sg's memory
for all cpus leaving the group leader as the group isn't marked used
now.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/7a61e955abdcbb1dfa9fe493f11a5ec53a11ddd3.1370948150.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 3388387..014c97f 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5357,12 +5357,12 @@ build_sched_groups(struct sched_domain *sd, int cpu)
 
for_each_cpu(i, span) {
struct sched_group *sg;
-   int group = get_group(i, sdd, &sg);
-   int j;
+   int group, j;
 
if (cpumask_test_cpu(i, covered))
continue;
 
+   group = get_group(i, sdd, &sg);
cpumask_clear(sched_group_cpus(sg));
sg->sgp->power = 0;
cpumask_setall(sched_group_mask(sg));
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/core] sched: Rename sched.c as sched/ core.c in comments and Documentation

2013-06-19 Thread tip-bot for Viresh Kumar
Commit-ID:  0a0fca9d832b704f116a25badd1ca8c16771dcac
Gitweb: http://git.kernel.org/tip/0a0fca9d832b704f116a25badd1ca8c16771dcac
Author: Viresh Kumar 
AuthorDate: Tue, 4 Jun 2013 13:10:24 +0530
Committer:  Ingo Molnar 
CommitDate: Wed, 19 Jun 2013 12:58:42 +0200

sched: Rename sched.c as sched/core.c in comments and Documentation

Most of the stuff from kernel/sched.c was moved to kernel/sched/core.c long time
back and the comments/Documentation never got updated.

I figured it out when I was going through sched-domains.txt and so thought of
fixing it globally.

I haven't crossed check if the stuff that is referenced in sched/core.c by all
these files is still present and hasn't changed as that wasn't the motive behind
this patch.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/cdff76a265326ab8d71922a1db5be599f20aad45.1370329560.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 Documentation/cgroups/cpusets.txt | 2 +-
 Documentation/rt-mutex-design.txt | 2 +-
 Documentation/scheduler/sched-domains.txt | 4 ++--
 Documentation/spinlocks.txt   | 2 +-
 Documentation/virtual/uml/UserModeLinux-HOWTO.txt | 4 ++--
 arch/avr32/kernel/process.c   | 2 +-
 arch/cris/include/arch-v10/arch/bitops.h  | 2 +-
 arch/ia64/kernel/head.S   | 2 +-
 arch/mips/kernel/mips-mt-fpaff.c  | 4 ++--
 arch/mips/kernel/scall32-o32.S| 5 +++--
 arch/powerpc/include/asm/mmu_context.h| 2 +-
 arch/tile/include/asm/processor.h | 2 +-
 arch/tile/kernel/stack.c  | 2 +-
 arch/um/kernel/sysrq.c| 2 +-
 include/linux/completion.h| 2 +-
 include/linux/perf_event.h| 2 +-
 include/linux/spinlock_up.h   | 2 +-
 include/uapi/asm-generic/unistd.h | 2 +-
 kernel/cpuset.c   | 4 ++--
 kernel/time.c | 2 +-
 kernel/workqueue_internal.h   | 2 +-
 21 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/Documentation/cgroups/cpusets.txt 
b/Documentation/cgroups/cpusets.txt
index 12e01d4..7740038 100644
--- a/Documentation/cgroups/cpusets.txt
+++ b/Documentation/cgroups/cpusets.txt
@@ -373,7 +373,7 @@ can become very uneven.
 1.7 What is sched_load_balance ?
 
 
-The kernel scheduler (kernel/sched.c) automatically load balances
+The kernel scheduler (kernel/sched/core.c) automatically load balances
 tasks.  If one CPU is underutilized, kernel code running on that
 CPU will look for tasks on other more overloaded CPUs and move those
 tasks to itself, within the constraints of such placement mechanisms
diff --git a/Documentation/rt-mutex-design.txt 
b/Documentation/rt-mutex-design.txt
index 33ed800..a5bcd7f 100644
--- a/Documentation/rt-mutex-design.txt
+++ b/Documentation/rt-mutex-design.txt
@@ -384,7 +384,7 @@ priority back.
 __rt_mutex_adjust_prio examines the result of rt_mutex_getprio, and if the
 result does not equal the task's current priority, then rt_mutex_setprio
 is called to adjust the priority of the task to the new priority.
-Note that rt_mutex_setprio is defined in kernel/sched.c to implement the
+Note that rt_mutex_setprio is defined in kernel/sched/core.c to implement the
 actual change in priority.
 
 It is interesting to note that __rt_mutex_adjust_prio can either increase
diff --git a/Documentation/scheduler/sched-domains.txt 
b/Documentation/scheduler/sched-domains.txt
index 443f0c7..4af80b1 100644
--- a/Documentation/scheduler/sched-domains.txt
+++ b/Documentation/scheduler/sched-domains.txt
@@ -25,7 +25,7 @@ is treated as one entity. The load of a group is defined as 
the sum of the
 load of each of its member CPUs, and only when the load of a group becomes
 out of balance are tasks moved between groups.
 
-In kernel/sched.c, trigger_load_balance() is run periodically on each CPU
+In kernel/sched/core.c, trigger_load_balance() is run periodically on each CPU
 through scheduler_tick(). It raises a softirq after the next regularly 
scheduled
 rebalancing event for the current runqueue has arrived. The actual load
 balancing workhorse, run_rebalance_domains()->rebalance_domains(), is then run
@@ -62,7 +62,7 @@ struct sched_domain fields, SD_FLAG_*, SD_*_INIT to get an 
idea of
 the specifics and what to tune.
 
 Architectures may retain the regular override the default SD_*_INIT flags
-while using the generic domain builder in kernel/sched.c if they wish to
+while using the generic domain builder in kernel/sched/core.c if they wish to
 retain the traditional SMT->SMP->NUMA topology (or some subset of that). This
 can be done by #define'ing ARCH_HASH_SCHED_TUNE.
 
diff --git a/Documentation/spinlocks.txt b/Documentation/spinlocks.txt
index 9dbe885..97e

[tip:sched/core] sched: Create for_each_sd_topology()

2013-06-19 Thread tip-bot for Viresh Kumar
Commit-ID:  27723a68caf05381b0b0bc6e127da2c9e7bcb775
Gitweb: http://git.kernel.org/tip/27723a68caf05381b0b0bc6e127da2c9e7bcb775
Author: Viresh Kumar 
AuthorDate: Mon, 10 Jun 2013 16:27:20 +0530
Committer:  Ingo Molnar 
CommitDate: Wed, 19 Jun 2013 12:58:45 +0200

sched: Create for_each_sd_topology()

For loop for traversing sched_domain_topology was used at multiple placed in
core.c. This patch removes code redundancy by creating for_each_sd_topology().

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/e0e04542f54e9464bd9da54f5ccfe62ec6c4c0bc.1370861520.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/core.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 88c2c0e..547b7d3 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5565,6 +5565,9 @@ static struct sched_domain_topology_level 
default_topology[] = {
 
 static struct sched_domain_topology_level *sched_domain_topology = 
default_topology;
 
+#define for_each_sd_topology(tl)   \
+   for (tl = sched_domain_topology; tl->init; tl++)
+
 #ifdef CONFIG_NUMA
 
 static int sched_domains_numa_levels;
@@ -5862,7 +5865,7 @@ static int __sdt_alloc(const struct cpumask *cpu_map)
struct sched_domain_topology_level *tl;
int j;
 
-   for (tl = sched_domain_topology; tl->init; tl++) {
+   for_each_sd_topology(tl) {
struct sd_data *sdd = &tl->data;
 
sdd->sd = alloc_percpu(struct sched_domain *);
@@ -5915,7 +5918,7 @@ static void __sdt_free(const struct cpumask *cpu_map)
struct sched_domain_topology_level *tl;
int j;
 
-   for (tl = sched_domain_topology; tl->init; tl++) {
+   for_each_sd_topology(tl) {
struct sd_data *sdd = &tl->data;
 
for_each_cpu(j, cpu_map) {
@@ -5983,7 +5986,7 @@ static int build_sched_domains(const struct cpumask 
*cpu_map,
struct sched_domain_topology_level *tl;
 
sd = NULL;
-   for (tl = sched_domain_topology; tl->init; tl++) {
+   for_each_sd_topology(tl) {
sd = build_sched_domain(tl, cpu_map, attr, sd, i);
if (tl == sched_domain_topology)
*per_cpu_ptr(d.sd, i) = sd;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/core] sched: Remove unused params of build_sched_domain()

2013-06-19 Thread tip-bot for Viresh Kumar
Commit-ID:  4a850cbefa9592ddde3670a41c10c9576a657c43
Gitweb: http://git.kernel.org/tip/4a850cbefa9592ddde3670a41c10c9576a657c43
Author: Viresh Kumar 
AuthorDate: Tue, 4 Jun 2013 16:12:43 +0530
Committer:  Ingo Molnar 
CommitDate: Wed, 19 Jun 2013 12:58:42 +0200

sched: Remove unused params of build_sched_domain()

build_sched_domain() never uses parameter struct s_data *d and so passing it is
useless.

Remove it.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/545e0b4536166a15b4475abcafe5ed0db4ad4a2c.1370436120.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/core.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index d8f071c..342e744 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5943,9 +5943,8 @@ static void __sdt_free(const struct cpumask *cpu_map)
 }
 
 struct sched_domain *build_sched_domain(struct sched_domain_topology_level *tl,
-   struct s_data *d, const struct cpumask *cpu_map,
-   struct sched_domain_attr *attr, struct sched_domain *child,
-   int cpu)
+   const struct cpumask *cpu_map, struct sched_domain_attr *attr,
+   struct sched_domain *child, int cpu)
 {
struct sched_domain *sd = tl->init(tl, cpu);
if (!sd)
@@ -5985,7 +5984,7 @@ static int build_sched_domains(const struct cpumask 
*cpu_map,
 
sd = NULL;
for (tl = sched_domain_topology; tl->init; tl++) {
-   sd = build_sched_domain(tl, &d, cpu_map, attr, sd, i);
+   sd = build_sched_domain(tl, cpu_map, attr, sd, i);
if (tl->flags & SDTL_OVERLAP || 
sched_feat(FORCE_SD_OVERLAP))
sd->flags |= SD_OVERLAP;
if (cpumask_equal(cpu_map, sched_domain_span(sd)))
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/core] sched: Fix typo inside comment

2013-04-08 Thread tip-bot for Viresh Kumar
Commit-ID:  28b4a521f618d9722bc780ea38b44718ce0fe283
Gitweb: http://git.kernel.org/tip/28b4a521f618d9722bc780ea38b44718ce0fe283
Author: Viresh Kumar 
AuthorDate: Fri, 5 Apr 2013 16:26:46 +0530
Committer:  Ingo Molnar 
CommitDate: Mon, 8 Apr 2013 13:55:39 +0200

sched: Fix typo inside comment

Fix typo:

 sched_domains_nume_distance ->
 sched_domains_numa_distance

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: patc...@linaro.org
Cc: robin.randh...@arm.com
Cc: steve.bannis...@arm.com
Cc: liviu.du...@arm.com
Cc: charles.garcia-to...@arm.com
Cc: arvind.chau...@arm.com
Cc: pet...@infradead.org
Link: 
http://lkml.kernel.org/r/cd8084746ac932106d6fa6be388b8f2d6aa9617c.1365159023.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 849deb9..f5e1aa5 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6252,7 +6252,7 @@ static void sched_init_numa(void)
 * 'level' contains the number of unique distances, excluding the
 * identity distance node_distance(i,i).
 *
-* The sched_domains_nume_distance[] array includes the actual distance
+* The sched_domains_numa_distance[] array includes the actual distance
 * numbers.
 */
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/core] sched/cpufreq: Initialize sg_cpu->flags to 0

2018-01-10 Thread tip-bot for Viresh Kumar
Commit-ID:  6257e7047890084fbeeb84c641200b43f0668abc
Gitweb: https://git.kernel.org/tip/6257e7047890084fbeeb84c641200b43f0668abc
Author: Viresh Kumar 
AuthorDate: Wed, 13 Dec 2017 15:23:20 +0530
Committer:  Ingo Molnar 
CommitDate: Wed, 10 Jan 2018 11:30:29 +0100

sched/cpufreq: Initialize sg_cpu->flags to 0

Initializing sg_cpu->flags to SCHED_CPUFREQ_RT has no obvious benefit.
The flags field wouldn't be used until the utilization update handler is
called for the first time, and once that is called we will overwrite
flags anyway.

Initialize it to 0.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra (Intel) 
Reviewed-by: Juri Lelli 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Rafael Wysocki 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Cc: dietmar.eggem...@arm.com
Cc: joe...@google.com
Cc: morten.rasmus...@arm.com
Cc: tk...@android.com
Link: 
http://lkml.kernel.org/r/763feda6424ced8486b25a0c52979634e6104478.1513158452.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/cpufreq_schedutil.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index d6717a3..22d4630 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -655,7 +655,7 @@ static int sugov_start(struct cpufreq_policy *policy)
memset(sg_cpu, 0, sizeof(*sg_cpu));
sg_cpu->cpu = cpu;
sg_cpu->sg_policy = sg_policy;
-   sg_cpu->flags = SCHED_CPUFREQ_RT;
+   sg_cpu->flags = 0;
sg_cpu->iowait_boost_max = policy->cpuinfo.max_freq;
}
 


[tip:sched/core] sched/cpufreq: Don't pass flags to sugov_set_iowait_boost()

2018-01-10 Thread tip-bot for Viresh Kumar
Commit-ID:  5083452f8c7a11577e83842596f97625abbc9c8e
Gitweb: https://git.kernel.org/tip/5083452f8c7a11577e83842596f97625abbc9c8e
Author: Viresh Kumar 
AuthorDate: Wed, 13 Dec 2017 15:23:22 +0530
Committer:  Ingo Molnar 
CommitDate: Wed, 10 Jan 2018 11:30:29 +0100

sched/cpufreq: Don't pass flags to sugov_set_iowait_boost()

We are already passing sg_cpu as argument to sugov_set_iowait_boost()
helper and the same can be used to retrieve the flags value. Get rid of
the redundant argument.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Rafael Wysocki 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Cc: dietmar.eggem...@arm.com
Cc: joe...@google.com
Cc: juri.le...@redhat.com
Cc: morten.rasmus...@arm.com
Cc: tk...@android.com
Link: 
http://lkml.kernel.org/r/4ec5562b1a87e146ebab11fb5dde1ca9c763a7fb.1513158452.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/cpufreq_schedutil.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index 22d4630..6dd1ec9 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -187,10 +187,9 @@ static void sugov_get_util(unsigned long *util, unsigned 
long *max, int cpu)
*max = cfs_max;
 }
 
-static void sugov_set_iowait_boost(struct sugov_cpu *sg_cpu, u64 time,
-  unsigned int flags)
+static void sugov_set_iowait_boost(struct sugov_cpu *sg_cpu, u64 time)
 {
-   if (flags & SCHED_CPUFREQ_IOWAIT) {
+   if (sg_cpu->flags & SCHED_CPUFREQ_IOWAIT) {
if (sg_cpu->iowait_boost_pending)
return;
 
@@ -264,7 +263,7 @@ static void sugov_update_single(struct update_util_data 
*hook, u64 time,
unsigned int next_f;
bool busy;
 
-   sugov_set_iowait_boost(sg_cpu, time, flags);
+   sugov_set_iowait_boost(sg_cpu, time);
sg_cpu->last_update = time;
 
if (!sugov_should_update_freq(sg_policy, time))
@@ -349,7 +348,7 @@ static void sugov_update_shared(struct update_util_data 
*hook, u64 time,
sg_cpu->max = max;
sg_cpu->flags = flags;
 
-   sugov_set_iowait_boost(sg_cpu, time, flags);
+   sugov_set_iowait_boost(sg_cpu, time);
sg_cpu->last_update = time;
 
if (sugov_should_update_freq(sg_policy, time)) {


[tip:sched/core] sched/core: Create task_has_idle_policy() helper

2018-11-11 Thread tip-bot for Viresh Kumar
Commit-ID:  1da1843f9f0334e2428308945d396ffecc2acfe1
Gitweb: https://git.kernel.org/tip/1da1843f9f0334e2428308945d396ffecc2acfe1
Author: Viresh Kumar 
AuthorDate: Mon, 5 Nov 2018 16:51:55 +0530
Committer:  Ingo Molnar 
CommitDate: Mon, 12 Nov 2018 06:17:52 +0100

sched/core: Create task_has_idle_policy() helper

We already have task_has_rt_policy() and task_has_dl_policy() helpers,
create task_has_idle_policy() as well and update sched core to start
using it.

While at it, use task_has_dl_policy() at one more place.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra (Intel) 
Acked-by: Daniel Lezcano 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Link: 
http://lkml.kernel.org/r/ce3915d5b490fc81af926a3b6bfb775e7188e005.1541416894.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/core.c  |  4 ++--
 kernel/sched/debug.c |  2 +-
 kernel/sched/fair.c  | 10 +-
 kernel/sched/sched.h |  5 +
 4 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 02a20ef196a6..5afb868f7339 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -697,7 +697,7 @@ static void set_load_weight(struct task_struct *p, bool 
update_load)
/*
 * SCHED_IDLE tasks get minimal weight:
 */
-   if (idle_policy(p->policy)) {
+   if (task_has_idle_policy(p)) {
load->weight = scale_load(WEIGHT_IDLEPRIO);
load->inv_weight = WMULT_IDLEPRIO;
p->se.runnable_weight = load->weight;
@@ -4199,7 +4199,7 @@ recheck:
 * Treat SCHED_IDLE as nice 20. Only allow a switch to
 * SCHED_NORMAL if the RLIMIT_NICE would normally permit it.
 */
-   if (idle_policy(p->policy) && !idle_policy(policy)) {
+   if (task_has_idle_policy(p) && !idle_policy(policy)) {
if (!can_nice(p, task_nice(p)))
return -EPERM;
}
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 6383aa6a60ca..02bd5f969b21 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -974,7 +974,7 @@ void proc_sched_show_task(struct task_struct *p, struct 
pid_namespace *ns,
 #endif
P(policy);
P(prio);
-   if (p->policy == SCHED_DEADLINE) {
+   if (task_has_dl_policy(p)) {
P(dl.runtime);
P(dl.deadline);
}
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 2cac9a469df4..d1f91e6efe51 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6529,7 +6529,7 @@ wakeup_preempt_entity(struct sched_entity *curr, struct 
sched_entity *se)
 
 static void set_last_buddy(struct sched_entity *se)
 {
-   if (entity_is_task(se) && unlikely(task_of(se)->policy == SCHED_IDLE))
+   if (entity_is_task(se) && unlikely(task_has_idle_policy(task_of(se
return;
 
for_each_sched_entity(se) {
@@ -6541,7 +6541,7 @@ static void set_last_buddy(struct sched_entity *se)
 
 static void set_next_buddy(struct sched_entity *se)
 {
-   if (entity_is_task(se) && unlikely(task_of(se)->policy == SCHED_IDLE))
+   if (entity_is_task(se) && unlikely(task_has_idle_policy(task_of(se
return;
 
for_each_sched_entity(se) {
@@ -6599,8 +6599,8 @@ static void check_preempt_wakeup(struct rq *rq, struct 
task_struct *p, int wake_
return;
 
/* Idle tasks are by definition preempted by non-idle tasks. */
-   if (unlikely(curr->policy == SCHED_IDLE) &&
-   likely(p->policy != SCHED_IDLE))
+   if (unlikely(task_has_idle_policy(curr)) &&
+   likely(!task_has_idle_policy(p)))
goto preempt;
 
/*
@@ -7021,7 +7021,7 @@ static int task_hot(struct task_struct *p, struct lb_env 
*env)
if (p->sched_class != &fair_sched_class)
return 0;
 
-   if (unlikely(p->policy == SCHED_IDLE))
+   if (unlikely(task_has_idle_policy(p)))
return 0;
 
/*
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 618577fc9aa8..b7a3147874e3 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -176,6 +176,11 @@ static inline bool valid_policy(int policy)
rt_policy(policy) || dl_policy(policy);
 }
 
+static inline int task_has_idle_policy(struct task_struct *p)
+{
+   return idle_policy(p->policy);
+}
+
 static inline int task_has_rt_policy(struct task_struct *p)
 {
return rt_policy(p->policy);


[tip:sched/core] sched/core: Clean up the #ifdef block in add_nr_running()

2018-11-12 Thread tip-bot for Viresh Kumar
Commit-ID:  3e184501083c38fa091f640acb13af17a21fd228
Gitweb: https://git.kernel.org/tip/3e184501083c38fa091f640acb13af17a21fd228
Author: Viresh Kumar 
AuthorDate: Tue, 6 Nov 2018 11:12:57 +0530
Committer:  Ingo Molnar 
CommitDate: Mon, 12 Nov 2018 11:18:06 +0100

sched/core: Clean up the #ifdef block in add_nr_running()

There is no point in keeping the conditional statement of the #if block
outside of the #ifdef block, while all of its body is contained within
the #ifdef block.

Move the conditional statement under the #ifdef block as well.

Signed-off-by: Viresh Kumar 
Cc: Daniel Lezcano 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Link: 
http://lkml.kernel.org/r/78cbd78a615d6f9fdcd3327f1ead68470f92593e.1541482935.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/sched.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index b7a3147874e3..e0e052a50fcd 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1801,12 +1801,12 @@ static inline void add_nr_running(struct rq *rq, 
unsigned count)
 
rq->nr_running = prev_nr + count;
 
-   if (prev_nr < 2 && rq->nr_running >= 2) {
 #ifdef CONFIG_SMP
+   if (prev_nr < 2 && rq->nr_running >= 2) {
if (!READ_ONCE(rq->rd->overload))
WRITE_ONCE(rq->rd->overload, 1);
-#endif
}
+#endif
 
sched_update_tick_dependency(rq);
 }


[tip:timers/core] timer: Don't initialize 'tvec_base' on hotplug

2015-04-02 Thread tip-bot for Viresh Kumar
Commit-ID:  8def906044c02edcedac79aa3d6310ab4d90c4d8
Gitweb: http://git.kernel.org/tip/8def906044c02edcedac79aa3d6310ab4d90c4d8
Author: Viresh Kumar 
AuthorDate: Tue, 31 Mar 2015 20:49:01 +0530
Committer:  Ingo Molnar 
CommitDate: Thu, 2 Apr 2015 17:46:01 +0200

timer: Don't initialize 'tvec_base' on hotplug

There is no need to call init_timers_cpu() on every CPU hotplug event,
there is not much we need to reset.

 - Timer-lists are already empty at the end of migrate_timers().
 - timer_jiffies will be refreshed while adding a new timer, after the
   CPU is online again.
 - active_timers and all_timers can be reset from migrate_timers().

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/54a1c30ea7b805af55beb220cadf5a07a21b0a4d.1427814611.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/time/timer.c | 98 +++--
 1 file changed, 43 insertions(+), 55 deletions(-)

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index f3cc653..1feb9c7 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1543,43 +1543,6 @@ signed long __sched 
schedule_timeout_uninterruptible(signed long timeout)
 }
 EXPORT_SYMBOL(schedule_timeout_uninterruptible);
 
-static int init_timers_cpu(int cpu)
-{
-   struct tvec_base *base = per_cpu(tvec_bases, cpu);
-   static char tvec_base_done[NR_CPUS];
-   int j;
-
-   if (!tvec_base_done[cpu]) {
-   static char boot_cpu_skipped;
-
-   if (!boot_cpu_skipped) {
-   boot_cpu_skipped = 1; /* skip the boot cpu */
-   } else {
-   base = per_cpu_ptr(&__tvec_bases, cpu);
-   per_cpu(tvec_bases, cpu) = base;
-   }
-
-   spin_lock_init(&base->lock);
-   tvec_base_done[cpu] = 1;
-   base->cpu = cpu;
-   }
-
-   for (j = 0; j < TVN_SIZE; j++) {
-   INIT_LIST_HEAD(base->tv5.vec + j);
-   INIT_LIST_HEAD(base->tv4.vec + j);
-   INIT_LIST_HEAD(base->tv3.vec + j);
-   INIT_LIST_HEAD(base->tv2.vec + j);
-   }
-   for (j = 0; j < TVR_SIZE; j++)
-   INIT_LIST_HEAD(base->tv1.vec + j);
-
-   base->timer_jiffies = jiffies;
-   base->next_timer = base->timer_jiffies;
-   base->active_timers = 0;
-   base->all_timers = 0;
-   return 0;
-}
-
 #ifdef CONFIG_HOTPLUG_CPU
 static void migrate_timer_list(struct tvec_base *new_base, struct list_head 
*head)
 {
@@ -1621,6 +1584,9 @@ static void migrate_timers(int cpu)
migrate_timer_list(new_base, old_base->tv5.vec + i);
}
 
+   old_base->active_timers = 0;
+   old_base->all_timers = 0;
+
spin_unlock(&old_base->lock);
spin_unlock_irq(&new_base->lock);
put_cpu_var(tvec_bases);
@@ -1630,25 +1596,16 @@ static void migrate_timers(int cpu)
 static int timer_cpu_notify(struct notifier_block *self,
unsigned long action, void *hcpu)
 {
-   long cpu = (long)hcpu;
-   int err;
-
-   switch(action) {
-   case CPU_UP_PREPARE:
-   case CPU_UP_PREPARE_FROZEN:
-   err = init_timers_cpu(cpu);
-   if (err < 0)
-   return notifier_from_errno(err);
-   break;
 #ifdef CONFIG_HOTPLUG_CPU
+   switch (action) {
case CPU_DEAD:
case CPU_DEAD_FROZEN:
-   migrate_timers(cpu);
+   migrate_timers((long)hcpu);
break;
-#endif
default:
break;
}
+#endif
return NOTIFY_OK;
 }
 
@@ -1656,18 +1613,49 @@ static struct notifier_block timers_nb = {
.notifier_call  = timer_cpu_notify,
 };
 
+static void __init init_timer_cpu(struct tvec_base *base, int cpu)
+{
+   int j;
 
-void __init init_timers(void)
+   base->cpu = cpu;
+   per_cpu(tvec_bases, cpu) = base;
+   spin_lock_init(&base->lock);
+
+   for (j = 0; j < TVN_SIZE; j++) {
+   INIT_LIST_HEAD(base->tv5.vec + j);
+   INIT_LIST_HEAD(base->tv4.vec + j);
+   INIT_LIST_HEAD(base->tv3.vec + j);
+   INIT_LIST_HEAD(base->tv2.vec + j);
+   }
+   for (j = 0; j < TVR_SIZE; j++)
+   INIT_LIST_HEAD(base->tv1.vec + j);
+
+   base->timer_jiffies = jiffies;
+   base->next_timer = base->timer_jiffies;
+}
+
+static void __init init_timer_cpus(void)
 {
-   int err;
+   struct tvec_base *base;
+   int local_cpu = smp_processor_id();
+   int cpu;
+
+   for_each_possible_cpu(cpu) {
+   if (cpu == local_cpu)
+   base = &boot_tvec_bases;
+   else
+   base = per_cpu_ptr(&__tvec_bases, cpu);
+
+   init_timer_cpu(base, cpu);
+   }
+}
 
+void __init init_timers(void)
+{
/* ensure there are enough low bits for 

[tip:timers/core] hrtimer: Update active_bases before calling hrtimer_force_reprogram()

2015-04-22 Thread tip-bot for Viresh Kumar
Commit-ID:  d9f0acdeef48570c4e6159d3108f12b64571392e
Gitweb: http://git.kernel.org/tip/d9f0acdeef48570c4e6159d3108f12b64571392e
Author: Viresh Kumar 
AuthorDate: Tue, 14 Apr 2015 21:08:25 +
Committer:  Thomas Gleixner 
CommitDate: Wed, 22 Apr 2015 17:06:48 +0200

hrtimer: Update active_bases before calling hrtimer_force_reprogram()

'active_bases' indicates which clock-base have active timer. The
intention of this bit field was to avoid evaluating inactive bases. It
was introduced with the introduction of the BOOTTIME and TAI clock
bases, but it was never brought into full use.

We want to use it now, but in __remove_hrtimer() the update happens
after the calling hrtimer_force_reprogram() which has to evaluate all
clock bases for the next expiring timer. So in case the last timer of
a clock base got removed we still see the active bit and therefor
evaluate the clock base for no value. There are further optimizations
possible when active_bases is updated in the right place.

Move the update before the call to hrtimer_force_reprogram()

[ tglx: Massaged changelog ]

Signed-off-by: Viresh Kumar 
Reviewed-by: Preeti U Murthy 
Acked-by: Peter Zijlstra 
Cc: Marcelo Tosatti 
Cc: Frederic Weisbecker 
Cc: linaro-ker...@lists.linaro.org
Link: http://lkml.kernel.org/r/20150414203500.533438...@linutronix.de
Link: 
http://lkml.kernel.org/r/c7c8ebcd9ed88bb09d76059c745a1fafb48314e7.1428039899.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 kernel/time/hrtimer.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index b1a74ee..9abd50b 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -887,6 +887,9 @@ static void __remove_hrtimer(struct hrtimer *timer,
 
next_timer = timerqueue_getnext(&base->active);
timerqueue_del(&base->active, &timer->node);
+   if (!timerqueue_getnext(&base->active))
+   base->cpu_base->active_bases &= ~(1 << base->index);
+
if (&timer->node == next_timer) {
 #ifdef CONFIG_HIGH_RES_TIMERS
/* Reprogram the clock event device. if enabled */
@@ -900,8 +903,6 @@ static void __remove_hrtimer(struct hrtimer *timer,
}
 #endif
}
-   if (!timerqueue_getnext(&base->active))
-   base->cpu_base->active_bases &= ~(1 << base->index);
 out:
timer->state = newstate;
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/core] clocksource/drivers/efm32: Use CLOCK_EVT_FEAT_PERIODIC for defining features

2015-03-31 Thread tip-bot for Viresh Kumar
Commit-ID:  ad834a346853b7ee7c684efa56b1d415a850a710
Gitweb: http://git.kernel.org/tip/ad834a346853b7ee7c684efa56b1d415a850a710
Author: Viresh Kumar 
AuthorDate: Mon, 30 Mar 2015 22:17:13 +0200
Committer:  Ingo Molnar 
CommitDate: Tue, 31 Mar 2015 09:15:57 +0200

clocksource/drivers/efm32: Use CLOCK_EVT_FEAT_PERIODIC for defining features

We have used CLOCK_EVT_MODE_PERIODIC instead of
CLOCK_EVT_FEAT_PERIODIC while defining features. Fix it.

Signed-off-by: Viresh Kumar 
Signed-off-by: Daniel Lezcano 
Acked-by: Uwe Kleine-Koenig 
Cc: ben.do...@codethink.co.uk
Cc: dig...@gmail.com
Cc: hdego...@redhat.com
Cc: laurent.pinchart+rene...@ideasonboard.com
Cc: linux-arm-ker...@lists.infradead.org
Cc: maxime.rip...@free-electrons.com
Link: 
http://lkml.kernel.org/r/1427746633-9137-11-git-send-email-daniel.lezc...@linaro.org
Signed-off-by: Ingo Molnar 
---
 drivers/clocksource/time-efm32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/time-efm32.c b/drivers/clocksource/time-efm32.c
index ec57ba2..5b6e3d5 100644
--- a/drivers/clocksource/time-efm32.c
+++ b/drivers/clocksource/time-efm32.c
@@ -111,7 +111,7 @@ static irqreturn_t efm32_clock_event_handler(int irq, void 
*dev_id)
 static struct efm32_clock_event_ddata clock_event_ddata = {
.evtdev = {
.name = "efm32 clockevent",
-   .features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_MODE_PERIODIC,
+   .features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERIODIC,
.set_mode = efm32_clock_event_set_mode,
.set_next_event = efm32_clock_event_set_next_event,
.rating = 200,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/urgent] clockevents: Shutdown detached clockevent device

2015-04-24 Thread tip-bot for Viresh Kumar
Commit-ID:  149aabcc44e3e2c1f8fe4f0832be53d2db55b598
Gitweb: http://git.kernel.org/tip/149aabcc44e3e2c1f8fe4f0832be53d2db55b598
Author: Viresh Kumar 
AuthorDate: Fri, 10 Apr 2015 12:56:41 +0530
Committer:  Thomas Gleixner 
CommitDate: Fri, 24 Apr 2015 21:01:48 +0200

clockevents: Shutdown detached clockevent device

A clockevent device is marked DETACHED when it is replaced by another
clockevent device.

The device is shutdown properly for drivers that implement legacy
->set_mode() callback, as we call ->set_mode() for CLOCK_EVT_MODE_UNUSED
as well.

But for the new per-state callback interface, we skip shutting down the
device, as we thought its an internal state change. That wasn't correct.

The effect is that the device is left programmed in oneshot or periodic
mode.

Fall-back to 'case CLOCK_EVT_STATE_SHUTDOWN', to shutdown the device.

Fixes: bd624d75db21 "clockevents: Introduce mode specific callbacks"
Reported-by: Daniel Lezcano 
Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/eef0a91c51b74d4e52c8e5a95eca27b5a0563f07.1428650683.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 kernel/time/clockevents.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 25d942d..629be4e 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -117,11 +117,7 @@ static int __clockevents_set_state(struct 
clock_event_device *dev,
/* Transition with new state-specific callbacks */
switch (state) {
case CLOCK_EVT_STATE_DETACHED:
-   /*
-* This is an internal state, which is guaranteed to go from
-* SHUTDOWN to DETACHED. No driver interaction required.
-*/
-   return 0;
+   /* The clockevent device is getting replaced. Shut it down. */
 
case CLOCK_EVT_STATE_SHUTDOWN:
return dev->set_state_shutdown(dev);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/core] clockevents: Check state instead of mode in suspend/resume path

2015-06-18 Thread tip-bot for Viresh Kumar
Commit-ID:  a9d20988ac7db47fec4510cefc966e876a4ce674
Gitweb: http://git.kernel.org/tip/a9d20988ac7db47fec4510cefc966e876a4ce674
Author: Viresh Kumar 
AuthorDate: Wed, 17 Jun 2015 16:04:46 +0530
Committer:  Thomas Gleixner 
CommitDate: Thu, 18 Jun 2015 09:27:02 +0200

clockevents: Check state instead of mode in suspend/resume path

CLOCK_EVT_MODE_* macros are present for backward compatibility (as most
of the drivers are still using old ->set_mode() interface).

These macro's shouldn't be used anymore in code, that is common to both
driver interfaces, i.e. ->set_mode() and ->set_state_*().

Drivers implementing ->set_state_*() interface, which have their
clkevt->mode set to 0 (clkevt device structures are normally globally
defined), will not participate in suspend/resume as they will always be
marked as UNUSED.

Fix this by checking state of the clockevent device instead of mode,
which is updated for both the interfaces.

Fixes: ac34ad27fc16 ("clockevents: Do not suspend/resume if unused")
Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: alexandre.bell...@free-electrons.com
Cc: sylvain.roc...@finsecur.com
Link: 
http://lkml.kernel.org/r/a1964eef6e8a47d02b1ff9083c6c91f73f0ff643.1434537215.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 kernel/time/clockevents.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 2397b97..08ccc3d 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -639,7 +639,7 @@ void clockevents_suspend(void)
struct clock_event_device *dev;
 
list_for_each_entry_reverse(dev, &clockevent_devices, list)
-   if (dev->suspend && dev->mode != CLOCK_EVT_MODE_UNUSED)
+   if (dev->suspend && !clockevent_state_detached(dev))
dev->suspend(dev);
 }
 
@@ -651,7 +651,7 @@ void clockevents_resume(void)
struct clock_event_device *dev;
 
list_for_each_entry(dev, &clockevent_devices, list)
-   if (dev->resume && dev->mode != CLOCK_EVT_MODE_UNUSED)
+   if (dev->resume && !clockevent_state_detached(dev))
dev->resume(dev);
 }
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/core] clockevents: Add helpers to check the state of a clockevent device

2015-06-02 Thread tip-bot for Viresh Kumar
Commit-ID:  3434d23b694e5cb6e44e966914563406c31c4053
Gitweb: http://git.kernel.org/tip/3434d23b694e5cb6e44e966914563406c31c4053
Author: Viresh Kumar 
AuthorDate: Thu, 21 May 2015 13:33:45 +0530
Committer:  Thomas Gleixner 
CommitDate: Tue, 2 Jun 2015 14:40:47 +0200

clockevents: Add helpers to check the state of a clockevent device

Some clockevent drivers, once migrated to use per-state callbacks,
need to check the state of the clockevent device in their callbacks or
interrupt handler.

Add accessor functions clockevent_state_*() to get this information.

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/04a717d490335c688dd7af899fbcede97e1bb8ee.1432192527.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 include/linux/clockchips.h | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
index 271fa4c..64214ad 100644
--- a/include/linux/clockchips.h
+++ b/include/linux/clockchips.h
@@ -149,6 +149,32 @@ struct clock_event_device {
struct module   *owner;
 } cacheline_aligned;
 
+/* Helpers to verify state of a clockevent device */
+static inline bool clockevent_state_detached(struct clock_event_device *dev)
+{
+   return dev->state == CLOCK_EVT_STATE_DETACHED;
+}
+
+static inline bool clockevent_state_shutdown(struct clock_event_device *dev)
+{
+   return dev->state == CLOCK_EVT_STATE_SHUTDOWN;
+}
+
+static inline bool clockevent_state_periodic(struct clock_event_device *dev)
+{
+   return dev->state == CLOCK_EVT_STATE_PERIODIC;
+}
+
+static inline bool clockevent_state_oneshot(struct clock_event_device *dev)
+{
+   return dev->state == CLOCK_EVT_STATE_ONESHOT;
+}
+
+static inline bool clockevent_state_oneshot_stopped(struct clock_event_device 
*dev)
+{
+   return dev->state == CLOCK_EVT_STATE_ONESHOT_STOPPED;
+}
+
 /*
  * Calculate a multiplication factor for scaled math, which is used to convert
  * nanoseconds based values to clock ticks:
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/core] clockevents: Use helpers to check the state of a clockevent device

2015-06-02 Thread tip-bot for Viresh Kumar
Commit-ID:  472c4a9437d3c6a0b1e59df7c5aa14075946aa70
Gitweb: http://git.kernel.org/tip/472c4a9437d3c6a0b1e59df7c5aa14075946aa70
Author: Viresh Kumar 
AuthorDate: Thu, 21 May 2015 13:33:46 +0530
Committer:  Thomas Gleixner 
CommitDate: Tue, 2 Jun 2015 14:40:47 +0200

clockevents: Use helpers to check the state of a clockevent device

Use accessor functions to check the state of clockevent devices in
core code.

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/fa2b9869fd17f210eaa156ec2b594efd0230b6c7.1432192527.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 kernel/time/clockevents.c| 24 
 kernel/time/tick-broadcast.c |  6 +++---
 kernel/time/tick-common.c|  2 +-
 kernel/time/tick-oneshot.c   |  2 +-
 4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 2a5c369..e568ec8 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -136,7 +136,7 @@ static int __clockevents_set_state(struct 
clock_event_device *dev,
 
case CLOCK_EVT_STATE_ONESHOT_STOPPED:
/* Core internal bug */
-   if (WARN_ONCE(dev->state != CLOCK_EVT_STATE_ONESHOT,
+   if (WARN_ONCE(!clockevent_state_oneshot(dev),
  "Current state: %d\n", dev->state))
return -EINVAL;
 
@@ -170,7 +170,7 @@ void clockevents_set_state(struct clock_event_device *dev,
 * A nsec2cyc multiplicator of 0 is invalid and we'd crash
 * on it, so fix it up and emit a warning:
 */
-   if (state == CLOCK_EVT_STATE_ONESHOT) {
+   if (clockevent_state_oneshot(dev)) {
if (unlikely(!dev->mult)) {
dev->mult = 1;
WARN_ON(1);
@@ -259,7 +259,7 @@ static int clockevents_program_min_delta(struct 
clock_event_device *dev)
delta = dev->min_delta_ns;
dev->next_event = ktime_add_ns(ktime_get(), delta);
 
-   if (dev->state == CLOCK_EVT_STATE_SHUTDOWN)
+   if (clockevent_state_shutdown(dev))
return 0;
 
dev->retries++;
@@ -296,7 +296,7 @@ static int clockevents_program_min_delta(struct 
clock_event_device *dev)
delta = dev->min_delta_ns;
dev->next_event = ktime_add_ns(ktime_get(), delta);
 
-   if (dev->state == CLOCK_EVT_STATE_SHUTDOWN)
+   if (clockevent_state_shutdown(dev))
return 0;
 
dev->retries++;
@@ -328,11 +328,11 @@ int clockevents_program_event(struct clock_event_device 
*dev, ktime_t expires,
 
dev->next_event = expires;
 
-   if (dev->state == CLOCK_EVT_STATE_SHUTDOWN)
+   if (clockevent_state_shutdown(dev))
return 0;
 
/* We must be in ONESHOT state here */
-   WARN_ONCE(dev->state != CLOCK_EVT_STATE_ONESHOT, "Current state: %d\n",
+   WARN_ONCE(!clockevent_state_oneshot(dev), "Current state: %d\n",
  dev->state);
 
/* Shortcut for clockevent devices that can deal with ktime. */
@@ -377,7 +377,7 @@ static int clockevents_replace(struct clock_event_device 
*ced)
struct clock_event_device *dev, *newdev = NULL;
 
list_for_each_entry(dev, &clockevent_devices, list) {
-   if (dev == ced || dev->state != CLOCK_EVT_STATE_DETACHED)
+   if (dev == ced || !clockevent_state_detached(dev))
continue;
 
if (!tick_check_replacement(newdev, dev))
@@ -403,7 +403,7 @@ static int clockevents_replace(struct clock_event_device 
*ced)
 static int __clockevents_try_unbind(struct clock_event_device *ced, int cpu)
 {
/* Fast track. Device is unused */
-   if (ced->state == CLOCK_EVT_STATE_DETACHED) {
+   if (clockevent_state_detached(ced)) {
list_del_init(&ced->list);
return 0;
}
@@ -561,10 +561,10 @@ int __clockevents_update_freq(struct clock_event_device 
*dev, u32 freq)
 {
clockevents_config(dev, freq);
 
-   if (dev->state == CLOCK_EVT_STATE_ONESHOT)
+   if (clockevent_state_oneshot(dev))
return clockevents_program_event(dev, dev->next_event, false);
 
-   if (dev->state == CLOCK_EVT_STATE_PERIODIC)
+   if (clockevent_state_periodic(dev))
return __clockevents_set_state(dev, CLOCK_EVT_STATE_PERIODIC);
 
return 0;
@@ -625,7 +625,7 @@ void clockevents_exchange_device(struct clock_event_device 
*old,
}
 
if (new) {
-   BUG_ON(new->state != CLOCK_EVT_STATE_DETACHED);
+   BUG_ON(!clockevent_state_detached(new));
clockevents_shutdown(new);
}
 }
@@ -681,7 +681,7 @@ void tick_cleanup_dead_cpu(int cpu)
if (cpumask_test_cpu(cpu, dev->cpumask) &&
 

[tip:timers/core] timer: Spare IPI when deferrable timer is queued on idle remote targets

2014-02-26 Thread tip-bot for Viresh Kumar
Commit-ID:  8ba14654282ed6bb386d0a2f1ab329bfb293403f
Gitweb: http://git.kernel.org/tip/8ba14654282ed6bb386d0a2f1ab329bfb293403f
Author: Viresh Kumar 
AuthorDate: Mon, 10 Feb 2014 17:09:54 +0100
Committer:  Frederic Weisbecker 
CommitDate: Fri, 14 Feb 2014 17:59:14 +0100

timer: Spare IPI when deferrable timer is queued on idle remote targets

When a timer is enqueued or modified on a remote target, the latter is
expected to see and handle this timer on its next tick. However if the
target is idle and CONFIG_NO_HZ_IDLE=y, the CPU may be sleeping tickless
and the timer may be ignored.

wake_up_nohz_cpu() takes care of that by setting TIF_NEED_RESCHED and
sending an IPI to idle targets so that the tick is reevaluated on the
idle loop through the tick_nohz_idle_*() APIs.

Now this is all performed regardless of the power properties of the
timer. If the timer is deferrable, idle targets don't need to be woken
up. Only the next buzy tick needs to care about it, and no IPI kick
is needed for that to happen.

So lets spare the IPI on idle targets when the timer is deferrable.

Meanwhile we keep the current behaviour on full dynticks targets. We can
spare IPIs on idle full dynticks targets as well but some tricky races
against idle_cpu() must be dealt all along to make sure that the timer
is well handled after idle exit. We can deal with that later since
NO_HZ_FULL already has more important powersaving issues.

Reported-by: Thomas Gleixner 
Signed-off-by: Viresh Kumar 
Cc: Ingo Molnar 
Cc: Paul Gortmaker 
Cc: Paul E. McKenney 
Cc: Peter Zijlstra 
Cc: Steven Rostedt 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/cakohpommz0tan2e6n76_g4zrzxd5vz1xfuzfxrp7gmxftni...@mail.gmail.com
Signed-off-by: Frederic Weisbecker 
---
 kernel/timer.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/kernel/timer.c b/kernel/timer.c
index accfd24..b75e789 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -939,8 +939,15 @@ void add_timer_on(struct timer_list *timer, int cpu)
 * with the timer by holding the timer base lock. This also
 * makes sure that a CPU on the way to stop its tick can not
 * evaluate the timer wheel.
+*
+* Spare the IPI for deferrable timers on idle targets though.
+* The next busy ticks will take care of it. Except full dynticks
+* require special care against races with idle_cpu(), lets deal
+* with that later.
 */
-   wake_up_nohz_cpu(cpu);
+   if (!tbase_get_deferrable(timer->base) || tick_nohz_full_cpu(cpu))
+   wake_up_nohz_cpu(cpu);
+
spin_unlock_irqrestore(&base->lock, flags);
 }
 EXPORT_SYMBOL_GPL(add_timer_on);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/core] timer: Check failure of timer_cpu_notify() before calling init_timer_stats()

2014-03-04 Thread tip-bot for Viresh Kumar
Commit-ID:  c24a4a369419c360c323865b91198878275c1481
Gitweb: http://git.kernel.org/tip/c24a4a369419c360c323865b91198878275c1481
Author: Viresh Kumar 
AuthorDate: Fri, 28 Feb 2014 14:15:21 +0530
Committer:  Thomas Gleixner 
CommitDate: Tue, 4 Mar 2014 12:30:29 +0100

timer: Check failure of timer_cpu_notify() before calling init_timer_stats()

timer_cpu_notify() should return NOTIFY_OK and nothing else. Anything else would
trigger a BUG_ON(). Return value of this routine is already checked correctly
but is done after issuing a call to init_timer_stats(). The right order would be
to check the error case first and then call init_timer_stats(). Lets do it.

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: fweis...@gmail.com
Cc: t...@kernel.org
Cc: pet...@infradead.org
Link: 
http://lkml.kernel.org/r/c439f5b6bbc2047e1662f4d523350531425bcf9d.1393576981.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 kernel/timer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/timer.c b/kernel/timer.c
index a71bdfd..31824ef 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1681,9 +1681,9 @@ void __init init_timers(void)
 
err = timer_cpu_notify(&timers_nb, (unsigned long)CPU_UP_PREPARE,
   (void *)(long)smp_processor_id());
-   init_timer_stats();
-
BUG_ON(err != NOTIFY_OK);
+
+   init_timer_stats();
register_cpu_notifier(&timers_nb);
open_softirq(TIMER_SOFTIRQ, run_timer_softirq);
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/core] timer: Make sure TIMER_FLAG_MASK bits are free in allocated base

2014-03-04 Thread tip-bot for Viresh Kumar
Commit-ID:  38edbb0b913d73713c23dcc742669f7e78b52aa7
Gitweb: http://git.kernel.org/tip/38edbb0b913d73713c23dcc742669f7e78b52aa7
Author: Viresh Kumar 
AuthorDate: Fri, 28 Feb 2014 14:15:22 +0530
Committer:  Thomas Gleixner 
CommitDate: Tue, 4 Mar 2014 12:30:29 +0100

timer: Make sure TIMER_FLAG_MASK bits are free in allocated base

Currently we are using two lowest bit of base for internal purpose and
so they both should be zero in the allocated address. The code was
doing the right thing before this patch came in: commit c5f66e99b
(timer: Implement TIMER_IRQSAFE)

Tejun probably forgot to update this piece of code which checks if the
lowest 'n' bits are zero or not and so wasn't updated according to the
new flag. Lets use TIMER_FLAG_MASK in the calculations here.

[ tglx: Massaged changelog ]

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: fweis...@gmail.com
Cc: t...@kernel.org
Cc: pet...@infradead.org
Link: 
http://lkml.kernel.org/r/9144e10d7e854a0aa8a673332adec356d81a923c.1393576981.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 kernel/timer.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/timer.c b/kernel/timer.c
index 31824ef..949d74e 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1555,9 +1555,8 @@ static int init_timers_cpu(int cpu)
if (!base)
return -ENOMEM;
 
-   /* Make sure that tvec_base is 2 byte aligned */
-   if (tbase_get_deferrable(base)) {
-   WARN_ON(1);
+   /* Make sure tvec_base has TIMER_FLAG_MASK bits free */
+   if (WARN_ON(base != tbase_get_base(base))) {
kfree(base);
return -ENOMEM;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/core] timer: Use variable head instead of &work_list in __run_timers()

2014-03-20 Thread tip-bot for Viresh Kumar
Commit-ID:  c41eba7de133e43ea2c998ccd484059feab200f6
Gitweb: http://git.kernel.org/tip/c41eba7de133e43ea2c998ccd484059feab200f6
Author: Viresh Kumar 
AuthorDate: Tue, 18 Mar 2014 13:23:15 +0530
Committer:  Thomas Gleixner 
CommitDate: Thu, 20 Mar 2014 12:35:45 +0100

timer: Use variable head instead of &work_list in __run_timers()

We already have a variable 'head' that points to '&work_list', and so
we should use that instead wherever possible.

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Link: 
http://lkml.kernel.org/r/0d8645a6efc8360c4196c9797d59343abbfdcc5e.1395129136.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 kernel/timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/timer.c b/kernel/timer.c
index 949d74e..8e503fe 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1192,7 +1192,7 @@ static inline void __run_timers(struct tvec_base *base)
!cascade(base, &base->tv4, INDEX(2)))
cascade(base, &base->tv5, INDEX(3));
++base->timer_jiffies;
-   list_replace_init(base->tv1.vec + index, &work_list);
+   list_replace_init(base->tv1.vec + index, head);
while (!list_empty(head)) {
void (*fn)(unsigned long);
unsigned long data;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/core] hrtimer: Rearrange comments in the order struct members are declared

2014-03-20 Thread tip-bot for Viresh Kumar
Commit-ID:  e2e680fb7566880f7210cadf628c092c0433971c
Gitweb: http://git.kernel.org/tip/e2e680fb7566880f7210cadf628c092c0433971c
Author: Viresh Kumar 
AuthorDate: Wed, 19 Mar 2014 16:21:33 +0530
Committer:  Thomas Gleixner 
CommitDate: Thu, 20 Mar 2014 12:35:45 +0100

hrtimer: Rearrange comments in the order struct members are declared

Rearrange kernel doc comments in the order members of struct hrtimer are
declared.

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: fweis...@gmail.com
Cc: triv...@kernel.org
Link: 
http://lkml.kernel.org/r/1db1a3cfbe8a9ea49396af75c6ac04a2e67e3ab0.1395226248.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 include/linux/hrtimer.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index d19a5c2..e7a8d3f 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -96,12 +96,12 @@ enum hrtimer_restart {
  * @function:  timer expiry callback function
  * @base:  pointer to the timer base (per cpu and per clock)
  * @state: state information (See bit values above)
+ * @start_pid: timer statistics field to store the pid of the task which
+ * started the timer
  * @start_site:timer statistics field to store the site where the timer
  * was started
  * @start_comm: timer statistics field to store the name of the process which
  * started the timer
- * @start_pid: timer statistics field to store the pid of the task which
- * started the timer
  *
  * The hrtimer structure must be initialized by hrtimer_init()
  */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/core] timer: Remove code redundancy while calling get_nohz_timer_target()

2014-03-20 Thread tip-bot for Viresh Kumar
Commit-ID:  6201b4d61fbf194df6371fb3376c5026cb8f5eec
Gitweb: http://git.kernel.org/tip/6201b4d61fbf194df6371fb3376c5026cb8f5eec
Author: Viresh Kumar 
AuthorDate: Tue, 18 Mar 2014 16:26:07 +0530
Committer:  Thomas Gleixner 
CommitDate: Thu, 20 Mar 2014 12:35:46 +0100

timer: Remove code redundancy while calling get_nohz_timer_target()

There are only two users of get_nohz_timer_target(): timer and hrtimer. Both
call it under same circumstances, i.e.

#ifdef CONFIG_NO_HZ_COMMON
   if (!pinned && get_sysctl_timer_migration() && 
idle_cpu(this_cpu))
   return get_nohz_timer_target();
#endif

So, it makes more sense to get all this as part of get_nohz_timer_target()
instead of duplicating code at two places. For this another parameter is
required to be passed to this routine, pinned.

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: fweis...@gmail.com
Cc: pet...@infradead.org
Link: 
http://lkml.kernel.org/r/1e1b53537217d58d48c2d7a222a9c3ac47d5b64c.1395140107.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 include/linux/sched.h |  6 +-
 kernel/hrtimer.c  | 15 +--
 kernel/sched/core.c   |  5 -
 kernel/timer.c|  7 +--
 4 files changed, 11 insertions(+), 22 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 68a0e84..6f6c56f 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -291,10 +291,14 @@ extern int runqueue_is_locked(int cpu);
 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
 extern void nohz_balance_enter_idle(int cpu);
 extern void set_cpu_sd_state_idle(void);
-extern int get_nohz_timer_target(void);
+extern int get_nohz_timer_target(int pinned);
 #else
 static inline void nohz_balance_enter_idle(int cpu) { }
 static inline void set_cpu_sd_state_idle(void) { }
+static inline int get_nohz_timer_target(int pinned)
+{
+   return smp_processor_id();
+}
 #endif
 
 /*
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 0909436..d55092c 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -168,19 +168,6 @@ struct hrtimer_clock_base *lock_hrtimer_base(const struct 
hrtimer *timer,
}
 }
 
-
-/*
- * Get the preferred target CPU for NOHZ
- */
-static int hrtimer_get_target(int this_cpu, int pinned)
-{
-#ifdef CONFIG_NO_HZ_COMMON
-   if (!pinned && get_sysctl_timer_migration() && idle_cpu(this_cpu))
-   return get_nohz_timer_target();
-#endif
-   return this_cpu;
-}
-
 /*
  * With HIGHRES=y we do not migrate the timer when it is expiring
  * before the next event on the target cpu because we cannot reprogram
@@ -214,7 +201,7 @@ switch_hrtimer_base(struct hrtimer *timer, struct 
hrtimer_clock_base *base,
struct hrtimer_clock_base *new_base;
struct hrtimer_cpu_base *new_cpu_base;
int this_cpu = smp_processor_id();
-   int cpu = hrtimer_get_target(this_cpu, pinned);
+   int cpu = get_nohz_timer_target(pinned);
int basenum = base->index;
 
 again:
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b46131e..c0339e2 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -555,12 +555,15 @@ void resched_cpu(int cpu)
  * selecting an idle cpu will add more delays to the timers than intended
  * (as that cpu's timer base may not be uptodate wrt jiffies etc).
  */
-int get_nohz_timer_target(void)
+int get_nohz_timer_target(int pinned)
 {
int cpu = smp_processor_id();
int i;
struct sched_domain *sd;
 
+   if (pinned || !get_sysctl_timer_migration() || !idle_cpu(cpu))
+   return cpu;
+
rcu_read_lock();
for_each_domain(cpu, sd) {
for_each_cpu(i, sched_domain_span(sd)) {
diff --git a/kernel/timer.c b/kernel/timer.c
index 8e503fe..1d35dda 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -760,12 +760,7 @@ __mod_timer(struct timer_list *timer, unsigned long 
expires,
 
debug_activate(timer, expires);
 
-   cpu = smp_processor_id();
-
-#if defined(CONFIG_NO_HZ_COMMON) && defined(CONFIG_SMP)
-   if (!pinned && get_sysctl_timer_migration() && idle_cpu(cpu))
-   cpu = get_nohz_timer_target();
-#endif
+   cpu = get_nohz_timer_target(pinned);
new_base = per_cpu(tvec_bases, cpu);
 
if (base != new_base) {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/urgent] hrtimer: Set expiry time before switch_hrtimer_base()

2014-05-12 Thread tip-bot for Viresh Kumar
Commit-ID:  84ea7fe37908254c3bd90910921f6e1045c1747a
Gitweb: http://git.kernel.org/tip/84ea7fe37908254c3bd90910921f6e1045c1747a
Author: Viresh Kumar 
AuthorDate: Mon, 12 May 2014 13:42:29 +0530
Committer:  Thomas Gleixner 
CommitDate: Mon, 12 May 2014 10:47:39 +0200

hrtimer: Set expiry time before switch_hrtimer_base()

switch_hrtimer_base() calls hrtimer_check_target() which ensures that
we do not migrate a timer to a remote cpu if the timer expires before
the current programmed expiry time on that remote cpu.

But __hrtimer_start_range_ns() calls switch_hrtimer_base() before the
new expiry time is set. So the sanity check in hrtimer_check_target()
is operating on stale or even uninitialized data.

Update expiry time before calling switch_hrtimer_base().

[ tglx: Rewrote changelog once again ]

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: linaro-network...@linaro.org
Cc: fweis...@gmail.com
Cc: arvind.chau...@arm.com
Link: 
http://lkml.kernel.org/r/81999e148745fc51bbcd0615823fbab9b2e87e23.1399882253.git.viresh.ku...@linaro.org
Cc: sta...@vger.kernel.org
Signed-off-by: Thomas Gleixner 
---
 kernel/hrtimer.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 6b715c0..e0501fe 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -990,11 +990,8 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, 
ktime_t tim,
/* Remove an active timer from the queue: */
ret = remove_hrtimer(timer, base);
 
-   /* Switch the timer base, if necessary: */
-   new_base = switch_hrtimer_base(timer, base, mode & HRTIMER_MODE_PINNED);
-
if (mode & HRTIMER_MODE_REL) {
-   tim = ktime_add_safe(tim, new_base->get_time());
+   tim = ktime_add_safe(tim, base->get_time());
/*
 * CONFIG_TIME_LOW_RES is a temporary way for architectures
 * to signal that they simply return xtime in
@@ -1009,6 +1006,9 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, 
ktime_t tim,
 
hrtimer_set_expires_range_ns(timer, tim, delta_ns);
 
+   /* Switch the timer base, if necessary: */
+   new_base = switch_hrtimer_base(timer, base, mode & HRTIMER_MODE_PINNED);
+
timer_stats_hrtimer_set_start_info(timer);
 
leftmost = enqueue_hrtimer(timer, new_base);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/core] tick: Fix spelling mistake in tick_handle_periodic()

2014-03-25 Thread tip-bot for Viresh Kumar
Commit-ID:  cacb3c76c2012ade52124e8c6fdc5cb125625772
Gitweb: http://git.kernel.org/tip/cacb3c76c2012ade52124e8c6fdc5cb125625772
Author: Viresh Kumar 
AuthorDate: Tue, 25 Mar 2014 16:09:18 +0530
Committer:  Thomas Gleixner 
CommitDate: Wed, 26 Mar 2014 00:56:49 +0100

tick: Fix spelling mistake in tick_handle_periodic()

One of the comments in tick_handle_periodic() had 'when' instead of 'which' (My
guess :)). Fix it.

Also fix spelling mistake in 'Possible'.

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: skarafo...@gmail.com
Link: 
http://lkml.kernel.org/r/2b29ca4230c163e44179941d7c7a16c1474385c2.1395743878.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 kernel/time/tick-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
index 20b2fe3..0fec634 100644
--- a/kernel/time/tick-common.c
+++ b/kernel/time/tick-common.c
@@ -118,7 +118,7 @@ void tick_handle_periodic(struct clock_event_device *dev)
 * to be sure we're using a real hardware clocksource.
 * Otherwise we could get trapped in an infinite
 * loop, as the tick_periodic() increments jiffies,
-* when then will increment time, posibly causing
+* which then will increment time, possibly causing
 * the loop to trigger again and again.
 */
if (timekeeping_valid_for_hres())
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/core] tick: Remove code duplication in tick_handle_periodic()

2014-03-25 Thread tip-bot for Viresh Kumar
Commit-ID:  b97f0291a2504291aef850077f98cab68a5a2f33
Gitweb: http://git.kernel.org/tip/b97f0291a2504291aef850077f98cab68a5a2f33
Author: Viresh Kumar 
AuthorDate: Tue, 25 Mar 2014 13:56:23 +0530
Committer:  Thomas Gleixner 
CommitDate: Wed, 26 Mar 2014 00:56:49 +0100

tick: Remove code duplication in tick_handle_periodic()

tick_handle_periodic() is calling ktime_add() at two places, first before the
infinite loop and then at the end of infinite loop. We can rearrange code a bit
to fix code duplication here.

It looks quite simple and shouldn't break anything, I guess :)

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: fweis...@gmail.com
Link: 
http://lkml.kernel.org/r/be3481e8f3f71df694a4b43623254fc93ca51b59.1395735873.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 kernel/time/tick-common.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
index 0fec634..0156612 100644
--- a/kernel/time/tick-common.c
+++ b/kernel/time/tick-common.c
@@ -98,18 +98,19 @@ static void tick_periodic(int cpu)
 void tick_handle_periodic(struct clock_event_device *dev)
 {
int cpu = smp_processor_id();
-   ktime_t next;
+   ktime_t next = dev->next_event;
 
tick_periodic(cpu);
 
if (dev->mode != CLOCK_EVT_MODE_ONESHOT)
return;
-   /*
-* Setup the next period for devices, which do not have
-* periodic mode:
-*/
-   next = ktime_add(dev->next_event, tick_period);
for (;;) {
+   /*
+* Setup the next period for devices, which do not have
+* periodic mode:
+*/
+   next = ktime_add(next, tick_period);
+
if (!clockevents_program_event(dev, next, false))
return;
/*
@@ -123,7 +124,6 @@ void tick_handle_periodic(struct clock_event_device *dev)
 */
if (timekeeping_valid_for_hres())
tick_periodic(cpu);
-   next = ktime_add(next, tick_period);
}
 }
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/urgent] tick-sched: Don't call update_wall_time() when delta is lesser than tick_period

2014-04-15 Thread tip-bot for Viresh Kumar
Commit-ID:  03e6bdc5c4d0fc166bfd5d3cf749a5a0c1b5b1bd
Gitweb: http://git.kernel.org/tip/03e6bdc5c4d0fc166bfd5d3cf749a5a0c1b5b1bd
Author: Viresh Kumar 
AuthorDate: Tue, 15 Apr 2014 10:54:40 +0530
Committer:  Thomas Gleixner 
CommitDate: Tue, 15 Apr 2014 20:26:45 +0200

tick-sched: Don't call update_wall_time() when delta is lesser than tick_period

In tick_do_update_jiffies64() we are processing ticks only if delta is
greater than tick_period. This is what we are supposed to do here and
it broke a bit with this patch:

commit 47a1b796 (tick/timekeeping: Call update_wall_time outside the
jiffies lock)

With above patch, we might end up calling update_wall_time() even if
delta is found to be smaller that tick_period. Fix this by returning
when the delta is less than tick period.

[ tglx: Made it a 3 liner and massaged changelog ]

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: fweis...@gmail.com
Cc: arvind.chau...@arm.com
Cc: linaro-network...@linaro.org
Cc: John Stultz 
Cc:  # v3.14+
Link: 
http://lkml.kernel.org/r/80afb18a494b0bd9710975bcc4de134ae323c74f.1397537987.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 kernel/time/tick-sched.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 9f8af69..e947d96 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -84,6 +84,9 @@ static void tick_do_update_jiffies64(ktime_t now)
 
/* Keep the tick_next_period variable up to date */
tick_next_period = ktime_add(last_jiffies_update, tick_period);
+   } else {
+   write_sequnlock(&jiffies_lock);
+   return;
}
write_sequnlock(&jiffies_lock);
update_wall_time();
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/urgent] tick-sched: Check tick_nohz_enabled in tick_nohz_switch_to_nohz()

2014-04-15 Thread tip-bot for Viresh Kumar
Commit-ID:  27630532ef5ead28b98cfe28d8f95222ef91c2b7
Gitweb: http://git.kernel.org/tip/27630532ef5ead28b98cfe28d8f95222ef91c2b7
Author: Viresh Kumar 
AuthorDate: Tue, 15 Apr 2014 10:54:41 +0530
Committer:  Thomas Gleixner 
CommitDate: Tue, 15 Apr 2014 20:26:58 +0200

tick-sched: Check tick_nohz_enabled in tick_nohz_switch_to_nohz()

Since commit d689fe222 (NOHZ: Check for nohz active instead of nohz
enabled) the tick_nohz_switch_to_nohz() function returns because it
checks for the tick_nohz_active flag. This can't be set, because the
function itself sets it.

Undo the change in tick_nohz_switch_to_nohz().

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: fweis...@gmail.com
Cc: arvind.chau...@arm.com
Cc: linaro-network...@linaro.org
Cc:  # 3.13+
Link: 
http://lkml.kernel.org/r/40939c05f2d65d781b92b20302b02243d0654224.1397537987.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 kernel/time/tick-sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index e947d96..6558b7a 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -970,7 +970,7 @@ static void tick_nohz_switch_to_nohz(void)
struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
ktime_t next;
 
-   if (!tick_nohz_active)
+   if (!tick_nohz_enabled)
return;
 
local_irq_disable();
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/urgent] tick-common: Fix wrong check in tick_check_replacement()

2014-04-15 Thread tip-bot for Viresh Kumar
Commit-ID:  521c42990e9d561ed5ed9f501f07639d0512b3c9
Gitweb: http://git.kernel.org/tip/521c42990e9d561ed5ed9f501f07639d0512b3c9
Author: Viresh Kumar 
AuthorDate: Tue, 15 Apr 2014 10:54:37 +0530
Committer:  Thomas Gleixner 
CommitDate: Tue, 15 Apr 2014 20:26:44 +0200

tick-common: Fix wrong check in tick_check_replacement()

tick_check_replacement() returns if a replacement of clock_event_device is
possible or not. It does this as the first check:

if (tick_check_percpu(curdev, newdev, smp_processor_id()))
return false;

Thats wrong. tick_check_percpu() returns true when the device is
useable. Check for false instead.

[ tglx: Massaged changelog ]

Signed-off-by: Viresh Kumar 
Cc:  # v3.11+
Cc: linaro-ker...@lists.linaro.org
Cc: fweis...@gmail.com
Cc: arvind.chau...@arm.com
Cc: linaro-network...@linaro.org
Link: 
http://lkml.kernel.org/r/486a02efe0246635aaba786e24b42d316438bf3b.1397537987.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 kernel/time/tick-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
index 0156612..0a0608e 100644
--- a/kernel/time/tick-common.c
+++ b/kernel/time/tick-common.c
@@ -276,7 +276,7 @@ static bool tick_check_preferred(struct clock_event_device 
*curdev,
 bool tick_check_replacement(struct clock_event_device *curdev,
struct clock_event_device *newdev)
 {
-   if (tick_check_percpu(curdev, newdev, smp_processor_id()))
+   if (!tick_check_percpu(curdev, newdev, smp_processor_id()))
return false;
 
return tick_check_preferred(curdev, newdev);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/core] sched/core: Fix formatting issues in sched_can_stop_tick()

2014-07-05 Thread tip-bot for Viresh Kumar
Commit-ID:  541b82644d72c1ef4a0587515a619712c1c19bd3
Gitweb: http://git.kernel.org/tip/541b82644d72c1ef4a0587515a619712c1c19bd3
Author: Viresh Kumar 
AuthorDate: Tue, 24 Jun 2014 14:04:12 +0530
Committer:  Ingo Molnar 
CommitDate: Sat, 5 Jul 2014 11:17:28 +0200

sched/core: Fix formatting issues in sched_can_stop_tick()

sched_can_stop_tick() is using 7 spaces instead of 8 spaces or a 'tab' at the
beginning of few lines. Which doesn't align well with the Coding Guidelines.

Also remove local variable 'rq' as it is used at only one place and we can
directly use this_rq() instead.

Signed-off-by: Viresh Kumar 
Cc: fweis...@gmail.com
Signed-off-by: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/afb781733e4a9ffbced5eb9fd25cc0aa5c6ffd7a.1403596966.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/core.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 7f3063c..866d840 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -736,19 +736,15 @@ static inline bool got_nohz_idle_kick(void)
 #ifdef CONFIG_NO_HZ_FULL
 bool sched_can_stop_tick(void)
 {
-   struct rq *rq;
-
-   rq = this_rq();
-
/*
 * More than one running task need preemption.
 * nr_running update is assumed to be visible
 * after IPI is sent from wakers.
 */
-   if (rq->nr_running > 1)
-   return false;
+   if (this_rq()->nr_running > 1)
+   return false;
 
-   return true;
+   return true;
 }
 #endif /* CONFIG_NO_HZ_FULL */
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/core] sched/idle: Drop !! while calculating 'broadcast '

2014-07-05 Thread tip-bot for Viresh Kumar
Commit-ID:  89abb5ad10ae8ac3405e635ac80815f781c8b8e9
Gitweb: http://git.kernel.org/tip/89abb5ad10ae8ac3405e635ac80815f781c8b8e9
Author: Viresh Kumar 
AuthorDate: Tue, 24 Jun 2014 10:01:01 +0530
Committer:  Ingo Molnar 
CommitDate: Sat, 5 Jul 2014 11:17:31 +0200

sched/idle: Drop !! while calculating 'broadcast'

We don't need 'broadcast' to be set to 'zero or one', but to 'zero or non-zero'
and so the extra operation to convert it to 'zero or one' can be skipped.

Also change type of 'broadcast' to unsigned int, i.e. type of
drv->states[*].flags.

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Signed-off-by: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/0dfbe2976aa108c53e08d3477ea90f6360c1f54c.1403584026.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/idle.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
index cf009fb..9f1608f 100644
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -79,7 +79,7 @@ static void cpuidle_idle_call(void)
struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices);
struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
int next_state, entered_state;
-   bool broadcast;
+   unsigned int broadcast;
 
/*
 * Check if the idle task must be rescheduled. If it is the
@@ -135,7 +135,7 @@ use_default:
goto exit_idle;
}
 
-   broadcast = !!(drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP);
+   broadcast = drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP;
 
/*
 * Tell the time framework to switch to a broadcast timer
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/core] hrtimer: Remove hrtimer_enqueue_reprogram()

2014-06-23 Thread tip-bot for Viresh Kumar
Commit-ID:  9e1e01dd79ac4cf936623399abe57dfba4528ae6
Gitweb: http://git.kernel.org/tip/9e1e01dd79ac4cf936623399abe57dfba4528ae6
Author: Viresh Kumar 
AuthorDate: Sun, 22 Jun 2014 01:29:17 +0200
Committer:  Thomas Gleixner 
CommitDate: Mon, 23 Jun 2014 11:23:47 +0200

hrtimer: Remove hrtimer_enqueue_reprogram()

We call hrtimer_enqueue_reprogram() only when we are in high resolution
mode now so we don't need to check that again in hrtimer_enqueue_reprogram().

Once the check is removed, hrtimer_enqueue_reprogram() turns to be an
useless wrapper over hrtimer_reprogram() and can be dropped.

Signed-off-by: Viresh Kumar 
Signed-off-by: Frederic Weisbecker 
Link: 
http://lkml.kernel.org/r/1403393357-2070-6-git-send-email-fweis...@gmail.com
Signed-off-by: Thomas Gleixner 
---
 kernel/time/hrtimer.c | 23 ---
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index f900747..66a6dc1 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -602,6 +602,11 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, 
int skip_equal)
  * timers, we have to check, whether it expires earlier than the timer for
  * which the clock event device was armed.
  *
+ * Note, that in case the state has HRTIMER_STATE_CALLBACK set, no 
reprogramming
+ * and no expiry check happens. The timer gets enqueued into the rbtree. The
+ * reprogramming and expiry check is done in the hrtimer_interrupt or in the
+ * softirq.
+ *
  * Called with interrupts disabled and base->cpu_base.lock held
  */
 static int hrtimer_reprogram(struct hrtimer *timer,
@@ -662,18 +667,6 @@ static inline void hrtimer_init_hres(struct 
hrtimer_cpu_base *base)
base->hres_active = 0;
 }
 
-/*
- * When High resolution timers are active, try to reprogram. Note, that in case
- * the state has HRTIMER_STATE_CALLBACK set, no reprogramming and no expiry
- * check happens. The timer gets enqueued into the rbtree. The reprogramming
- * and expiry check is done in the hrtimer_interrupt or in the softirq.
- */
-static inline int hrtimer_enqueue_reprogram(struct hrtimer *timer,
-   struct hrtimer_clock_base *base)
-{
-   return base->cpu_base->hres_active && hrtimer_reprogram(timer, base);
-}
-
 static inline ktime_t hrtimer_update_base(struct hrtimer_cpu_base *base)
 {
ktime_t *offs_real = &base->clock_base[HRTIMER_BASE_REALTIME].offset;
@@ -755,8 +748,8 @@ static inline int hrtimer_is_hres_enabled(void) { return 0; 
}
 static inline int hrtimer_switch_to_hres(void) { return 0; }
 static inline void
 hrtimer_force_reprogram(struct hrtimer_cpu_base *base, int skip_equal) { }
-static inline int hrtimer_enqueue_reprogram(struct hrtimer *timer,
-   struct hrtimer_clock_base *base)
+static inline int hrtimer_reprogram(struct hrtimer *timer,
+   struct hrtimer_clock_base *base)
 {
return 0;
 }
@@ -1025,7 +1018,7 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, 
ktime_t tim,
 */
wake_up_nohz_cpu(new_base->cpu_base->cpu);
} else if (new_base->cpu_base == &__get_cpu_var(hrtimer_bases) &&
-   hrtimer_enqueue_reprogram(timer, new_base)) {
+   hrtimer_reprogram(timer, new_base)) {
/*
 * Only allow reprogramming if the new base is on this CPU.
 * (it might still be on another CPU if the timer was pending)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/core] timer: Kick dynticks targets on mod_timer*() calls

2014-06-23 Thread tip-bot for Viresh Kumar
Commit-ID:  9f6d9baaa8ca94b48aea495261cadaf2967c7784
Gitweb: http://git.kernel.org/tip/9f6d9baaa8ca94b48aea495261cadaf2967c7784
Author: Viresh Kumar 
AuthorDate: Sun, 22 Jun 2014 01:29:14 +0200
Committer:  Thomas Gleixner 
CommitDate: Mon, 23 Jun 2014 11:23:47 +0200

timer: Kick dynticks targets on mod_timer*() calls

When a timer is enqueued or modified on a dynticks target, that CPU
must re-evaluate the next tick to service that timer.

The tick re-evaluation is performed by an IPI kick on the target.
Now while we correctly call wake_up_nohz_cpu() from add_timer_on(), the
mod_timer*() API family doesn't support so well dynticks targets.

The reason for this is likely that __mod_timer() isn't supposed to
select an idle target for a timer, unless that target is the current
CPU, in which case a dynticks idle kick isn't actually needed.

But there is a small race window lurking behind that assumption: the
elected target has all the time to turn dynticks idle between the call
to get_nohz_timer_target() and the locking of its base. Hence a risk
that we enqueue a timer on a dynticks idle destination without kicking
it. As a result, the timer might be serviced too late in the future.

Also a target elected by __mod_timer() can be in full dynticks mode
and thus require to be kicked as well. And unlike idle dynticks, this
concern both local and remote targets.

To fix this whole issue, lets centralize the dynticks kick to
internal_add_timer() so that it is well handled for all sort of timer
enqueue. Even timer migration is concerned so that a full dynticks target
is correctly kicked as needed when timers are migrating to it.

Signed-off-by: Viresh Kumar 
Signed-off-by: Frederic Weisbecker 
Link: 
http://lkml.kernel.org/r/1403393357-2070-3-git-send-email-fweis...@gmail.com
Signed-off-by: Thomas Gleixner 
---
 kernel/time/timer.c | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 9e5f4f2..aca5dfe 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -410,6 +410,22 @@ static void internal_add_timer(struct tvec_base *base, 
struct timer_list *timer)
base->next_timer = timer->expires;
}
base->all_timers++;
+
+   /*
+* Check whether the other CPU is in dynticks mode and needs
+* to be triggered to reevaluate the timer wheel.
+* We are protected against the other CPU fiddling
+* with the timer by holding the timer base lock. This also
+* makes sure that a CPU on the way to stop its tick can not
+* evaluate the timer wheel.
+*
+* Spare the IPI for deferrable timers on idle targets though.
+* The next busy ticks will take care of it. Except full dynticks
+* require special care against races with idle_cpu(), lets deal
+* with that later.
+*/
+   if (!tbase_get_deferrable(base) || tick_nohz_full_cpu(base->cpu))
+   wake_up_nohz_cpu(base->cpu);
 }
 
 #ifdef CONFIG_TIMER_STATS
@@ -949,22 +965,6 @@ void add_timer_on(struct timer_list *timer, int cpu)
timer_set_base(timer, base);
debug_activate(timer, timer->expires);
internal_add_timer(base, timer);
-   /*
-* Check whether the other CPU is in dynticks mode and needs
-* to be triggered to reevaluate the timer wheel.
-* We are protected against the other CPU fiddling
-* with the timer by holding the timer base lock. This also
-* makes sure that a CPU on the way to stop its tick can not
-* evaluate the timer wheel.
-*
-* Spare the IPI for deferrable timers on idle targets though.
-* The next busy ticks will take care of it. Except full dynticks
-* require special care against races with idle_cpu(), lets deal
-* with that later.
-*/
-   if (!tbase_get_deferrable(timer->base) || tick_nohz_full_cpu(cpu))
-   wake_up_nohz_cpu(cpu);
-
spin_unlock_irqrestore(&base->lock, flags);
 }
 EXPORT_SYMBOL_GPL(add_timer_on);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/core] timer: Store cpu-number in struct tvec_base

2014-06-23 Thread tip-bot for Viresh Kumar
Commit-ID:  d6f93829811a3e74f58e3c3823d507411eed651a
Gitweb: http://git.kernel.org/tip/d6f93829811a3e74f58e3c3823d507411eed651a
Author: Viresh Kumar 
AuthorDate: Sun, 22 Jun 2014 01:29:13 +0200
Committer:  Thomas Gleixner 
CommitDate: Mon, 23 Jun 2014 11:23:46 +0200

timer: Store cpu-number in struct tvec_base

Timers are serviced by the tick. But when a timer is enqueued on a
dynticks target, we need to kick it in order to make it reconsider the
next tick to schedule to correctly handle the timer's expiring time.

Now while this kick is correctly performed for add_timer_on(), the
mod_timer*() family has been a bit neglected.

To prepare for fixing this, we need internal_add_timer() to be able to
resolve the CPU target associated to a timer's object 'base' so that the
kick can be centralized there.

This can't be passed as an argument as not all the callers know the CPU
number of a timer's base. So lets store it in the struct tvec_base to
resolve the CPU without much overhead. It is set once for good at every
CPU's first boot.

Signed-off-by: Viresh Kumar 
Signed-off-by: Frederic Weisbecker 
Link: 
http://lkml.kernel.org/r/1403393357-2070-2-git-send-email-fweis...@gmail.com
Signed-off-by: Thomas Gleixner 
---
 kernel/time/timer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 3bb01a3..9e5f4f2 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -82,6 +82,7 @@ struct tvec_base {
unsigned long next_timer;
unsigned long active_timers;
unsigned long all_timers;
+   int cpu;
struct tvec_root tv1;
struct tvec tv2;
struct tvec tv3;
@@ -1568,6 +1569,7 @@ static int init_timers_cpu(int cpu)
}
spin_lock_init(&base->lock);
tvec_base_done[cpu] = 1;
+   base->cpu = cpu;
} else {
base = per_cpu(tvec_bases, cpu);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/core] hrtimer: Kick lowres dynticks targets on timer enqueue

2014-06-23 Thread tip-bot for Viresh Kumar
Commit-ID:  49a2a07514a3a2ea4a02482fa60575e106d960f9
Gitweb: http://git.kernel.org/tip/49a2a07514a3a2ea4a02482fa60575e106d960f9
Author: Viresh Kumar 
AuthorDate: Mon, 23 Jun 2014 13:39:37 +0530
Committer:  Thomas Gleixner 
CommitDate: Mon, 23 Jun 2014 11:23:47 +0200

hrtimer: Kick lowres dynticks targets on timer enqueue

In lowres mode, hrtimers are serviced by the tick instead of a clock
event. It works well as long as the tick stays periodic but we must also
make sure that the hrtimers are serviced in dynticks mode targets,
pretty much like timer list timers do.

Note that all dynticks modes are concerned: get_nohz_timer_target()
tries not to return remote idle CPUs but there is nothing to prevent
the elected target from entering dynticks idle mode until we lock its
base. It's also prefectly legal to enqueue hrtimers on full dynticks CPU.

So there are two requirements to correctly handle dynticks:

1) On target's tick stop time, we must not delay the next tick further
   the next hrtimer.

2) On hrtimer queue time. If the tick of the target is stopped, we must
   wake up that CPU such that it sees the new hrtimer and recalculate
   the next tick accordingly.

The point 1 is well handled currently through get_nohz_timer_interrupt() and
cmp_next_hrtimer_event().

But the point 2 isn't handled at all.

Fixing this is easy though as we have the necessary API ready for that.
All we need is to call wake_up_nohz_cpu() on a target when a newly
enqueued hrtimer requires tick rescheduling, like timer list timer do.

Signed-off-by: Viresh Kumar 
Signed-off-by: Frederic Weisbecker 
Link: 
http://lkml.kernel.org/r/3d7ea08ce008698e26bd39fe10f55949391073ab.1403507178.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 kernel/time/hrtimer.c | 27 +++
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 0e32d4e..f900747 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1013,14 +1013,25 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, 
ktime_t tim,
 
leftmost = enqueue_hrtimer(timer, new_base);
 
-   /*
-* Only allow reprogramming if the new base is on this CPU.
-* (it might still be on another CPU if the timer was pending)
-*
-* XXX send_remote_softirq() ?
-*/
-   if (leftmost && new_base->cpu_base == &__get_cpu_var(hrtimer_bases)
-   && hrtimer_enqueue_reprogram(timer, new_base)) {
+   if (!leftmost) {
+   unlock_hrtimer_base(timer, &flags);
+   return ret;
+   }
+
+   if (!hrtimer_is_hres_active(timer)) {
+   /*
+* Kick to reschedule the next tick to handle the new timer
+* on dynticks target.
+*/
+   wake_up_nohz_cpu(new_base->cpu_base->cpu);
+   } else if (new_base->cpu_base == &__get_cpu_var(hrtimer_bases) &&
+   hrtimer_enqueue_reprogram(timer, new_base)) {
+   /*
+* Only allow reprogramming if the new base is on this CPU.
+* (it might still be on another CPU if the timer was pending)
+*
+* XXX send_remote_softirq() ?
+*/
if (wakeup) {
/*
 * We need to drop cpu_base->lock to avoid a
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/core] hrtimer: Store cpu-number in struct hrtimer_cpu_base

2014-06-23 Thread tip-bot for Viresh Kumar
Commit-ID:  cddd02489f52ccf635ed65931214729a23b93cd6
Gitweb: http://git.kernel.org/tip/cddd02489f52ccf635ed65931214729a23b93cd6
Author: Viresh Kumar 
AuthorDate: Sun, 22 Jun 2014 01:29:15 +0200
Committer:  Thomas Gleixner 
CommitDate: Mon, 23 Jun 2014 11:23:47 +0200

hrtimer: Store cpu-number in struct hrtimer_cpu_base

In lowres mode, hrtimers are serviced by the tick instead of a clock
event. Now it works well as long as the tick stays periodic but we
must also make sure that the hrtimers are serviced in dynticks mode.

Part of that job consist in kicking a dynticks hrtimer target in order
to make it reconsider the next tick to schedule to correctly handle the
hrtimer's expiring time. And that part isn't handled by the hrtimers
subsystem.

To prepare for fixing this, we need __hrtimer_start_range_ns() to be
able to resolve the CPU target associated to a hrtimer's object
'cpu_base' so that the kick can be centralized there.

So lets store it in the 'struct hrtimer_cpu_base' to resolve the CPU
without overhead. It is set once at CPU's online notification.

Signed-off-by: Viresh Kumar 
Signed-off-by: Frederic Weisbecker 
Link: 
http://lkml.kernel.org/r/1403393357-2070-4-git-send-email-fweis...@gmail.com
Signed-off-by: Thomas Gleixner 
---
 include/linux/hrtimer.h | 2 ++
 kernel/time/hrtimer.c   | 1 +
 2 files changed, 3 insertions(+)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index e7a8d3f..bb4 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -165,6 +165,7 @@ enum  hrtimer_base_type {
  * struct hrtimer_cpu_base - the per cpu clock bases
  * @lock:  lock protecting the base and associated clock bases
  * and timers
+ * @cpu:   cpu number
  * @active_bases:  Bitfield to mark bases with active timers
  * @clock_was_set: Indicates that clock was set from irq context.
  * @expires_next:  absolute time of the next event which was scheduled
@@ -179,6 +180,7 @@ enum  hrtimer_base_type {
  */
 struct hrtimer_cpu_base {
raw_spinlock_t  lock;
+   unsigned intcpu;
unsigned intactive_bases;
unsigned intclock_was_set;
 #ifdef CONFIG_HIGH_RES_TIMERS
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 3ab2899..0e32d4e 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1680,6 +1680,7 @@ static void init_hrtimers_cpu(int cpu)
timerqueue_init_head(&cpu_base->clock_base[i].active);
}
 
+   cpu_base->cpu = cpu;
hrtimer_init_hres(cpu_base);
 }
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/apic] x86/apic: Migrate apic timer to new set_state interface

2015-07-30 Thread tip-bot for Viresh Kumar
Commit-ID:  b23d8e527815954768861bb20d2b224009fff7cd
Gitweb: http://git.kernel.org/tip/b23d8e527815954768861bb20d2b224009fff7cd
Author: Viresh Kumar 
AuthorDate: Thu, 16 Jul 2015 16:28:44 +0530
Committer:  Thomas Gleixner 
CommitDate: Thu, 30 Jul 2015 00:51:47 +0200

x86/apic: Migrate apic timer to new set_state interface

Migrate apic driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

We weren't doing anything while switching to resume mode and so that
callback isn't implemented.

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: Jiang Liu 
Cc: Borislav Petkov 
Cc: David Rientjes 
Cc: Bandan Das 
Link: 
http://lkml.kernel.org/r/1896ac5989d27f2ac37f4786af9bd537e1921b83.1437042675.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 arch/x86/kernel/apic/apic.c | 86 +++--
 1 file changed, 51 insertions(+), 35 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index dcb5285..ecd6705 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -462,40 +462,53 @@ static int lapic_next_deadline(unsigned long delta,
return 0;
 }
 
-/*
- * Setup the lapic timer in periodic or oneshot mode
- */
-static void lapic_timer_setup(enum clock_event_mode mode,
- struct clock_event_device *evt)
+static int lapic_timer_shutdown(struct clock_event_device *evt)
 {
unsigned long flags;
unsigned int v;
 
/* Lapic used as dummy for broadcast ? */
if (evt->features & CLOCK_EVT_FEAT_DUMMY)
-   return;
+   return 0;
 
local_irq_save(flags);
 
-   switch (mode) {
-   case CLOCK_EVT_MODE_PERIODIC:
-   case CLOCK_EVT_MODE_ONESHOT:
-   __setup_APIC_LVTT(lapic_timer_frequency,
- mode != CLOCK_EVT_MODE_PERIODIC, 1);
-   break;
-   case CLOCK_EVT_MODE_UNUSED:
-   case CLOCK_EVT_MODE_SHUTDOWN:
-   v = apic_read(APIC_LVTT);
-   v |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR);
-   apic_write(APIC_LVTT, v);
-   apic_write(APIC_TMICT, 0);
-   break;
-   case CLOCK_EVT_MODE_RESUME:
-   /* Nothing to do here */
-   break;
-   }
+   v = apic_read(APIC_LVTT);
+   v |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR);
+   apic_write(APIC_LVTT, v);
+   apic_write(APIC_TMICT, 0);
+
+   local_irq_restore(flags);
+
+   return 0;
+}
+
+static inline int
+lapic_timer_set_periodic_oneshot(struct clock_event_device *evt, bool oneshot)
+{
+   unsigned long flags;
+
+   /* Lapic used as dummy for broadcast ? */
+   if (evt->features & CLOCK_EVT_FEAT_DUMMY)
+   return 0;
+
+   local_irq_save(flags);
+
+   __setup_APIC_LVTT(lapic_timer_frequency, oneshot, 1);
 
local_irq_restore(flags);
+
+   return 0;
+}
+
+static int lapic_timer_set_periodic(struct clock_event_device *evt)
+{
+   return lapic_timer_set_periodic_oneshot(evt, false);
+}
+
+static int lapic_timer_set_oneshot(struct clock_event_device *evt)
+{
+   return lapic_timer_set_periodic_oneshot(evt, true);
 }
 
 /*
@@ -513,15 +526,18 @@ static void lapic_timer_broadcast(const struct cpumask 
*mask)
  * The local apic timer can be used for any function which is CPU local.
  */
 static struct clock_event_device lapic_clockevent = {
-   .name   = "lapic",
-   .features   = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT
-   | CLOCK_EVT_FEAT_C3STOP | CLOCK_EVT_FEAT_DUMMY,
-   .shift  = 32,
-   .set_mode   = lapic_timer_setup,
-   .set_next_event = lapic_next_event,
-   .broadcast  = lapic_timer_broadcast,
-   .rating = 100,
-   .irq= -1,
+   .name   = "lapic",
+   .features   = CLOCK_EVT_FEAT_PERIODIC |
+ CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP
+ | CLOCK_EVT_FEAT_DUMMY,
+   .shift  = 32,
+   .set_state_shutdown = lapic_timer_shutdown,
+   .set_state_periodic = lapic_timer_set_periodic,
+   .set_state_oneshot  = lapic_timer_set_oneshot,
+   .set_next_event = lapic_next_event,
+   .broadcast  = lapic_timer_broadcast,
+   .rating = 100,
+   .irq= -1,
 };
 static DEFINE_PER_CPU(struct clock_event_device, lapic_events);
 
@@ -778,7 +794,7 @@ static int __init calibrate_APIC_clock(void)
 * Setup the apic timer manually
 */
levt->event_handler = lapic_cal_handler;
-   lapic_timer_setup(CLOCK_EVT_MODE_P

[tip:x86/platform] x86/uv/time: Migrate to new set-state interface

2015-07-30 Thread tip-bot for Viresh Kumar
Commit-ID:  ca53d434f7e63352c9edd1ad8cde4dfe11da44aa
Gitweb: http://git.kernel.org/tip/ca53d434f7e63352c9edd1ad8cde4dfe11da44aa
Author: Viresh Kumar 
AuthorDate: Thu, 16 Jul 2015 16:28:47 +0530
Committer:  Thomas Gleixner 
CommitDate: Thu, 30 Jul 2015 21:25:38 +0200

x86/uv/time: Migrate to new set-state interface

Migrate uv driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

We weren't doing anything while switching modes other than in shutdown
mode and so those are not implemented.

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: Christoph Lameter 
Cc: Tejun Heo 
Link: 
http://lkml.kernel.org/r/52e04139746222a2e82a96d13953cbc306cfb59b.1437042675.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 arch/x86/platform/uv/uv_time.c | 37 +
 1 file changed, 13 insertions(+), 24 deletions(-)

diff --git a/arch/x86/platform/uv/uv_time.c b/arch/x86/platform/uv/uv_time.c
index a244237..2b158a9 100644
--- a/arch/x86/platform/uv/uv_time.c
+++ b/arch/x86/platform/uv/uv_time.c
@@ -32,8 +32,7 @@
 
 static cycle_t uv_read_rtc(struct clocksource *cs);
 static int uv_rtc_next_event(unsigned long, struct clock_event_device *);
-static void uv_rtc_timer_setup(enum clock_event_mode,
-   struct clock_event_device *);
+static int uv_rtc_shutdown(struct clock_event_device *evt);
 
 static struct clocksource clocksource_uv = {
.name   = RTC_NAME,
@@ -44,14 +43,14 @@ static struct clocksource clocksource_uv = {
 };
 
 static struct clock_event_device clock_event_device_uv = {
-   .name   = RTC_NAME,
-   .features   = CLOCK_EVT_FEAT_ONESHOT,
-   .shift  = 20,
-   .rating = 400,
-   .irq= -1,
-   .set_next_event = uv_rtc_next_event,
-   .set_mode   = uv_rtc_timer_setup,
-   .event_handler  = NULL,
+   .name   = RTC_NAME,
+   .features   = CLOCK_EVT_FEAT_ONESHOT,
+   .shift  = 20,
+   .rating = 400,
+   .irq= -1,
+   .set_next_event = uv_rtc_next_event,
+   .set_state_shutdown = uv_rtc_shutdown,
+   .event_handler  = NULL,
 };
 
 static DEFINE_PER_CPU(struct clock_event_device, cpu_ced);
@@ -321,24 +320,14 @@ static int uv_rtc_next_event(unsigned long delta,
 }
 
 /*
- * Setup the RTC timer in oneshot mode
+ * Shutdown the RTC timer
  */
-static void uv_rtc_timer_setup(enum clock_event_mode mode,
-  struct clock_event_device *evt)
+static int uv_rtc_shutdown(struct clock_event_device *evt)
 {
int ced_cpu = cpumask_first(evt->cpumask);
 
-   switch (mode) {
-   case CLOCK_EVT_MODE_PERIODIC:
-   case CLOCK_EVT_MODE_ONESHOT:
-   case CLOCK_EVT_MODE_RESUME:
-   /* Nothing to do here yet */
-   break;
-   case CLOCK_EVT_MODE_UNUSED:
-   case CLOCK_EVT_MODE_SHUTDOWN:
-   uv_rtc_unset_timer(ced_cpu, 1);
-   break;
-   }
+   uv_rtc_unset_timer(ced_cpu, 1);
+   return 0;
 }
 
 static void uv_rtc_interrupt(void)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/platform] x86/lguest/timer: Migrate to new set-state interface

2015-07-30 Thread tip-bot for Viresh Kumar
Commit-ID:  c2e13cc2cea64385043fa9afaaf91a74ec438467
Gitweb: http://git.kernel.org/tip/c2e13cc2cea64385043fa9afaaf91a74ec438467
Author: Viresh Kumar 
AuthorDate: Thu, 16 Jul 2015 16:28:46 +0530
Committer:  Thomas Gleixner 
CommitDate: Thu, 30 Jul 2015 21:25:38 +0200

x86/lguest/timer: Migrate to new set-state interface

Migrate lguest driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

We weren't doing anything while switching modes other than in shutdown
mode and so those are not implemented.

Signed-off-by: Viresh Kumar 
Acked-and-tested-by: Rusty Russell 
Cc: linaro-ker...@lists.linaro.org
Cc: Alexander Kuleshov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: Jan Beulich 
Cc: Andy Lutomirski 
Cc: lgu...@lists.ozlabs.org (open list:LGUEST)
Link: 
http://lkml.kernel.org/r/b96f1c308f4523255c5394a4e6e13f2b67685402.1437042675.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 arch/x86/lguest/boot.c | 24 ++--
 1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index f2dc08c..433e5a7 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -985,23 +985,11 @@ static int lguest_clockevent_set_next_event(unsigned long 
delta,
return 0;
 }
 
-static void lguest_clockevent_set_mode(enum clock_event_mode mode,
-  struct clock_event_device *evt)
-{
-   switch (mode) {
-   case CLOCK_EVT_MODE_UNUSED:
-   case CLOCK_EVT_MODE_SHUTDOWN:
-   /* A 0 argument shuts the clock down. */
-   hcall(LHCALL_SET_CLOCKEVENT, 0, 0, 0, 0);
-   break;
-   case CLOCK_EVT_MODE_ONESHOT:
-   /* This is what we expect. */
-   break;
-   case CLOCK_EVT_MODE_PERIODIC:
-   BUG();
-   case CLOCK_EVT_MODE_RESUME:
-   break;
-   }
+static int lguest_clockevent_shutdown(struct clock_event_device *evt)
+{
+   /* A 0 argument shuts the clock down. */
+   hcall(LHCALL_SET_CLOCKEVENT, 0, 0, 0, 0);
+   return 0;
 }
 
 /* This describes our primitive timer chip. */
@@ -1009,7 +997,7 @@ static struct clock_event_device lguest_clockevent = {
.name   = "lguest",
.features   = CLOCK_EVT_FEAT_ONESHOT,
.set_next_event = lguest_clockevent_set_next_event,
-   .set_mode   = lguest_clockevent_set_mode,
+   .set_state_shutdown = lguest_clockevent_shutdown,
.rating = INT_MAX,
.mult   = 1,
.shift  = 0,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/platform] x86/xen/time: Migrate to new set-state interface

2015-07-30 Thread tip-bot for Viresh Kumar
Commit-ID:  955381dd65654bd6f066408823691db8fa7d05bb
Gitweb: http://git.kernel.org/tip/955381dd65654bd6f066408823691db8fa7d05bb
Author: Viresh Kumar 
AuthorDate: Thu, 16 Jul 2015 16:28:48 +0530
Committer:  Thomas Gleixner 
CommitDate: Thu, 30 Jul 2015 21:25:38 +0200

x86/xen/time: Migrate to new set-state interface

Migrate xen driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

Callbacks aren't implemented for modes where we weren't doing anything.

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: Konrad Rzeszutek Wilk 
Cc: Boris Ostrovsky 
Cc: David Vrabel 
Cc: xen-de...@lists.xenproject.org (moderated list:XEN HYPERVISOR INTERFACE)
Link: 
http://lkml.kernel.org/r/881eea6e1a3d483cd33e044cd34827cce26a57fd.1437042675.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 arch/x86/xen/time.c | 80 +
 1 file changed, 31 insertions(+), 49 deletions(-)

diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 55da33b..f1ba6a0 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -274,30 +274,18 @@ static s64 get_abs_timeout(unsigned long delta)
return xen_clocksource_read() + delta;
 }
 
-static void xen_timerop_set_mode(enum clock_event_mode mode,
-struct clock_event_device *evt)
+static int xen_timerop_shutdown(struct clock_event_device *evt)
 {
-   switch (mode) {
-   case CLOCK_EVT_MODE_PERIODIC:
-   /* unsupported */
-   WARN_ON(1);
-   break;
-
-   case CLOCK_EVT_MODE_ONESHOT:
-   case CLOCK_EVT_MODE_RESUME:
-   break;
-
-   case CLOCK_EVT_MODE_UNUSED:
-   case CLOCK_EVT_MODE_SHUTDOWN:
-   HYPERVISOR_set_timer_op(0);  /* cancel timeout */
-   break;
-   }
+   /* cancel timeout */
+   HYPERVISOR_set_timer_op(0);
+
+   return 0;
 }
 
 static int xen_timerop_set_next_event(unsigned long delta,
  struct clock_event_device *evt)
 {
-   WARN_ON(evt->mode != CLOCK_EVT_MODE_ONESHOT);
+   WARN_ON(!clockevent_state_oneshot(evt));
 
if (HYPERVISOR_set_timer_op(get_abs_timeout(delta)) < 0)
BUG();
@@ -310,46 +298,39 @@ static int xen_timerop_set_next_event(unsigned long delta,
 }
 
 static const struct clock_event_device xen_timerop_clockevent = {
-   .name = "xen",
-   .features = CLOCK_EVT_FEAT_ONESHOT,
+   .name   = "xen",
+   .features   = CLOCK_EVT_FEAT_ONESHOT,
 
-   .max_delta_ns = 0x,
-   .min_delta_ns = TIMER_SLOP,
+   .max_delta_ns   = 0x,
+   .min_delta_ns   = TIMER_SLOP,
 
-   .mult = 1,
-   .shift = 0,
-   .rating = 500,
+   .mult   = 1,
+   .shift  = 0,
+   .rating = 500,
 
-   .set_mode = xen_timerop_set_mode,
-   .set_next_event = xen_timerop_set_next_event,
+   .set_state_shutdown = xen_timerop_shutdown,
+   .set_next_event = xen_timerop_set_next_event,
 };
 
+static int xen_vcpuop_shutdown(struct clock_event_device *evt)
+{
+   int cpu = smp_processor_id();
 
+   if (HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, cpu, NULL) ||
+   HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
+   BUG();
+
+   return 0;
+}
 
-static void xen_vcpuop_set_mode(enum clock_event_mode mode,
-   struct clock_event_device *evt)
+static int xen_vcpuop_set_oneshot(struct clock_event_device *evt)
 {
int cpu = smp_processor_id();
 
-   switch (mode) {
-   case CLOCK_EVT_MODE_PERIODIC:
-   WARN_ON(1); /* unsupported */
-   break;
-
-   case CLOCK_EVT_MODE_ONESHOT:
-   if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
-   BUG();
-   break;
+   if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
+   BUG();
 
-   case CLOCK_EVT_MODE_UNUSED:
-   case CLOCK_EVT_MODE_SHUTDOWN:
-   if (HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, cpu, NULL) 
||
-   HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
-   BUG();
-   break;
-   case CLOCK_EVT_MODE_RESUME:
-   break;
-   }
+   return 0;
 }
 
 static int xen_vcpuop_set_next_event(unsigned long delta,
@@ -359,7 +340,7 @@ static int xen_vcpuop_set_next_event(unsigned long delta,
struct vcpu_set_singleshot_timer single;
int ret;
 
-   WARN_ON(evt->mode != CLOCK_EVT_MODE_ONESHOT);
+   WARN_ON(!clockevent_state_oneshot(evt));
 
single.timeout_abs_ns = get_abs_timeout(delta)

[tip:x86/core] x86/hpet: Migrate to new set_state interface

2015-07-30 Thread tip-bot for Viresh Kumar
Commit-ID:  c8b5db7de66b75330a96f9f1ad7376b89646c953
Gitweb: http://git.kernel.org/tip/c8b5db7de66b75330a96f9f1ad7376b89646c953
Author: Viresh Kumar 
AuthorDate: Thu, 16 Jul 2015 16:28:45 +0530
Committer:  Thomas Gleixner 
CommitDate: Thu, 30 Jul 2015 21:28:25 +0200

x86/hpet: Migrate to new set_state interface

Migrate hpet driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

Forward definition of 'hpet_clockevent' wasn't required and so it is
placed after all the callback are defined, to avoid forward declaring
all the callbacks.

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: Jiang Liu 
Cc: Rasmus Villemoes 
Link: 
http://lkml.kernel.org/r/8cc9864b6d6342dfac28f270cf69f4cba46fffae.1437042675.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 arch/x86/kernel/hpet.c | 198 +++--
 1 file changed, 124 insertions(+), 74 deletions(-)

diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 10757d0..437297a 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -226,22 +226,7 @@ static void hpet_reserve_platform_timers(unsigned int id) 
{ }
  */
 static unsigned long hpet_freq;
 
-static void hpet_legacy_set_mode(enum clock_event_mode mode,
- struct clock_event_device *evt);
-static int hpet_legacy_next_event(unsigned long delta,
-  struct clock_event_device *evt);
-
-/*
- * The hpet clock event device
- */
-static struct clock_event_device hpet_clockevent = {
-   .name   = "hpet",
-   .features   = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
-   .set_mode   = hpet_legacy_set_mode,
-   .set_next_event = hpet_legacy_next_event,
-   .irq= 0,
-   .rating = 50,
-};
+static struct clock_event_device hpet_clockevent;
 
 static void hpet_stop_counter(void)
 {
@@ -306,64 +291,74 @@ static void hpet_legacy_clockevent_register(void)
printk(KERN_DEBUG "hpet clockevent registered\n");
 }
 
-static void hpet_set_mode(enum clock_event_mode mode,
- struct clock_event_device *evt, int timer)
+static int hpet_set_periodic(struct clock_event_device *evt, int timer)
 {
unsigned int cfg, cmp, now;
uint64_t delta;
 
-   switch (mode) {
-   case CLOCK_EVT_MODE_PERIODIC:
-   hpet_stop_counter();
-   delta = ((uint64_t)(NSEC_PER_SEC/HZ)) * evt->mult;
-   delta >>= evt->shift;
-   now = hpet_readl(HPET_COUNTER);
-   cmp = now + (unsigned int) delta;
-   cfg = hpet_readl(HPET_Tn_CFG(timer));
-   cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC |
-  HPET_TN_SETVAL | HPET_TN_32BIT;
-   hpet_writel(cfg, HPET_Tn_CFG(timer));
-   hpet_writel(cmp, HPET_Tn_CMP(timer));
-   udelay(1);
-   /*
-* HPET on AMD 81xx needs a second write (with HPET_TN_SETVAL
-* cleared) to T0_CMP to set the period. The HPET_TN_SETVAL
-* bit is automatically cleared after the first write.
-* (See AMD-8111 HyperTransport I/O Hub Data Sheet,
-* Publication # 24674)
-*/
-   hpet_writel((unsigned int) delta, HPET_Tn_CMP(timer));
-   hpet_start_counter();
-   hpet_print_config();
-   break;
+   hpet_stop_counter();
+   delta = ((uint64_t)(NSEC_PER_SEC / HZ)) * evt->mult;
+   delta >>= evt->shift;
+   now = hpet_readl(HPET_COUNTER);
+   cmp = now + (unsigned int)delta;
+   cfg = hpet_readl(HPET_Tn_CFG(timer));
+   cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC | HPET_TN_SETVAL |
+  HPET_TN_32BIT;
+   hpet_writel(cfg, HPET_Tn_CFG(timer));
+   hpet_writel(cmp, HPET_Tn_CMP(timer));
+   udelay(1);
+   /*
+* HPET on AMD 81xx needs a second write (with HPET_TN_SETVAL
+* cleared) to T0_CMP to set the period. The HPET_TN_SETVAL
+* bit is automatically cleared after the first write.
+* (See AMD-8111 HyperTransport I/O Hub Data Sheet,
+* Publication # 24674)
+*/
+   hpet_writel((unsigned int)delta, HPET_Tn_CMP(timer));
+   hpet_start_counter();
+   hpet_print_config();
 
-   case CLOCK_EVT_MODE_ONESHOT:
-   cfg = hpet_readl(HPET_Tn_CFG(timer));
-   cfg &= ~HPET_TN_PERIODIC;
-   cfg |= HPET_TN_ENABLE | HPET_TN_32BIT;
-   hpet_writel(cfg, HPET_Tn_CFG(timer));
-   break;
+   return 0;
+}
 
-   case CLOCK_EVT_MODE_UNUSED:
-   case CLOCK_EVT_MODE_SHUTDOWN:
-   cfg = hpet_readl(HPET_Tn_CFG(timer));
-   cfg &= ~HPET_TN_ENABLE;
-   

[tip:timers/urgent] clockevents: Remvoe unused set_mode() callback

2015-09-14 Thread tip-bot for Viresh Kumar
Commit-ID:  1803118b4f5a7eeb49805ba0493dfaf72ae9c50b
Gitweb: http://git.kernel.org/tip/1803118b4f5a7eeb49805ba0493dfaf72ae9c50b
Author: Viresh Kumar 
AuthorDate: Fri, 11 Sep 2015 09:34:26 +0530
Committer:  Thomas Gleixner 
CommitDate: Mon, 14 Sep 2015 09:52:03 +0200

clockevents: Remvoe unused set_mode() callback

All users are migrated to the per-state callbacks, get rid of the
unused interface and the core support code.

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: John Stultz 
Link: 
http://lkml.kernel.org/r/fd60de14cf6d125489c031207567bb255ad946f6.1441943991.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 include/linux/clockchips.h | 29 +
 kernel/time/clockevents.c  | 42 +---
 kernel/time/tick-common.c  |  1 -
 kernel/time/timer_list.c   | 54 +-
 4 files changed, 30 insertions(+), 96 deletions(-)

diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
index 31ce435..bdcf358 100644
--- a/include/linux/clockchips.h
+++ b/include/linux/clockchips.h
@@ -18,15 +18,6 @@
 struct clock_event_device;
 struct module;
 
-/* Clock event mode commands for legacy ->set_mode(): OBSOLETE */
-enum clock_event_mode {
-   CLOCK_EVT_MODE_UNUSED,
-   CLOCK_EVT_MODE_SHUTDOWN,
-   CLOCK_EVT_MODE_PERIODIC,
-   CLOCK_EVT_MODE_ONESHOT,
-   CLOCK_EVT_MODE_RESUME,
-};
-
 /*
  * Possible states of a clock event device.
  *
@@ -86,16 +77,14 @@ enum clock_event_state {
  * @min_delta_ns:  minimum delta value in ns
  * @mult:  nanosecond to cycles multiplier
  * @shift: nanoseconds to cycles divisor (power of two)
- * @mode:  operating mode, relevant only to ->set_mode(), OBSOLETE
  * @state_use_accessors:current state of the device, assigned by the core code
  * @features:  features
  * @retries:   number of forced programming retries
- * @set_mode:  legacy set mode function, only for modes <= 
CLOCK_EVT_MODE_RESUME.
- * @set_state_periodic:switch state to periodic, if !set_mode
- * @set_state_oneshot: switch state to oneshot, if !set_mode
- * @set_state_oneshot_stopped: switch state to oneshot_stopped, if !set_mode
- * @set_state_shutdown:switch state to shutdown, if !set_mode
- * @tick_resume:   resume clkevt device, if !set_mode
+ * @set_state_periodic:switch state to periodic
+ * @set_state_oneshot: switch state to oneshot
+ * @set_state_oneshot_stopped: switch state to oneshot_stopped
+ * @set_state_shutdown:switch state to shutdown
+ * @tick_resume:   resume clkevt device
  * @broadcast: function to broadcast events
  * @min_delta_ticks:   minimum delta value in ticks stored for reconfiguration
  * @max_delta_ticks:   maximum delta value in ticks stored for reconfiguration
@@ -116,18 +105,10 @@ struct clock_event_device {
u64 min_delta_ns;
u32 mult;
u32 shift;
-   enum clock_event_mode   mode;
enum clock_event_state  state_use_accessors;
unsigned intfeatures;
unsigned long   retries;
 
-   /*
-* State transition callback(s): Only one of the two groups should be
-* defined:
-* - set_mode(), only for modes <= CLOCK_EVT_MODE_RESUME.
-* - set_state_{shutdown|periodic|oneshot|oneshot_stopped}(), 
tick_resume().
-*/
-   void(*set_mode)(enum clock_event_mode mode, struct 
clock_event_device *);
int (*set_state_periodic)(struct clock_event_device 
*);
int (*set_state_oneshot)(struct clock_event_device 
*);
int (*set_state_oneshot_stopped)(struct 
clock_event_device *);
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 50eb107..a9b76a4 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -97,20 +97,6 @@ EXPORT_SYMBOL_GPL(clockevent_delta2ns);
 static int __clockevents_switch_state(struct clock_event_device *dev,
  enum clock_event_state state)
 {
-   /* Transition with legacy set_mode() callback */
-   if (dev->set_mode) {
-   /* Legacy callback doesn't support new modes */
-   if (state > CLOCK_EVT_STATE_ONESHOT)
-   return -ENOSYS;
-   /*
-* 'clock_event_state' and 'clock_event_mode' have 1-to-1
-* mapping until *_ONESHOT, and so a simple cast will work.
-*/
-   dev->set_mode((enum clock_event_mode)state, dev);
-   dev->mode = (enum clock_event_mode)state;
-   return 0;
-   }
-
if (dev->features & CLOCK_EVT_FEAT_DUMMY)
return 0;
 
@@ -204,12 +190,8 @@ int clockevents_tick_resume(struct clock_event_device *dev)
 {
  

[tip:timers/urgent] clockevents: Remove unused set_mode() callback

2015-09-14 Thread tip-bot for Viresh Kumar
Commit-ID:  eef7635a22f6b144206b5ca2f1398f637acffc4d
Gitweb: http://git.kernel.org/tip/eef7635a22f6b144206b5ca2f1398f637acffc4d
Author: Viresh Kumar 
AuthorDate: Fri, 11 Sep 2015 09:34:26 +0530
Committer:  Ingo Molnar 
CommitDate: Mon, 14 Sep 2015 11:00:55 +0200

clockevents: Remove unused set_mode() callback

All users are migrated to the per-state callbacks, get rid of the
unused interface and the core support code.

Signed-off-by: Viresh Kumar 
Signed-off-by: Thomas Gleixner 
Cc: linaro-ker...@lists.linaro.org
Cc: John Stultz 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/fd60de14cf6d125489c031207567bb255ad946f6.1441943991.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 include/linux/clockchips.h | 29 +
 kernel/time/clockevents.c  | 42 +---
 kernel/time/tick-common.c  |  1 -
 kernel/time/timer_list.c   | 54 +-
 4 files changed, 30 insertions(+), 96 deletions(-)

diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
index 31ce435..bdcf358 100644
--- a/include/linux/clockchips.h
+++ b/include/linux/clockchips.h
@@ -18,15 +18,6 @@
 struct clock_event_device;
 struct module;
 
-/* Clock event mode commands for legacy ->set_mode(): OBSOLETE */
-enum clock_event_mode {
-   CLOCK_EVT_MODE_UNUSED,
-   CLOCK_EVT_MODE_SHUTDOWN,
-   CLOCK_EVT_MODE_PERIODIC,
-   CLOCK_EVT_MODE_ONESHOT,
-   CLOCK_EVT_MODE_RESUME,
-};
-
 /*
  * Possible states of a clock event device.
  *
@@ -86,16 +77,14 @@ enum clock_event_state {
  * @min_delta_ns:  minimum delta value in ns
  * @mult:  nanosecond to cycles multiplier
  * @shift: nanoseconds to cycles divisor (power of two)
- * @mode:  operating mode, relevant only to ->set_mode(), OBSOLETE
  * @state_use_accessors:current state of the device, assigned by the core code
  * @features:  features
  * @retries:   number of forced programming retries
- * @set_mode:  legacy set mode function, only for modes <= 
CLOCK_EVT_MODE_RESUME.
- * @set_state_periodic:switch state to periodic, if !set_mode
- * @set_state_oneshot: switch state to oneshot, if !set_mode
- * @set_state_oneshot_stopped: switch state to oneshot_stopped, if !set_mode
- * @set_state_shutdown:switch state to shutdown, if !set_mode
- * @tick_resume:   resume clkevt device, if !set_mode
+ * @set_state_periodic:switch state to periodic
+ * @set_state_oneshot: switch state to oneshot
+ * @set_state_oneshot_stopped: switch state to oneshot_stopped
+ * @set_state_shutdown:switch state to shutdown
+ * @tick_resume:   resume clkevt device
  * @broadcast: function to broadcast events
  * @min_delta_ticks:   minimum delta value in ticks stored for reconfiguration
  * @max_delta_ticks:   maximum delta value in ticks stored for reconfiguration
@@ -116,18 +105,10 @@ struct clock_event_device {
u64 min_delta_ns;
u32 mult;
u32 shift;
-   enum clock_event_mode   mode;
enum clock_event_state  state_use_accessors;
unsigned intfeatures;
unsigned long   retries;
 
-   /*
-* State transition callback(s): Only one of the two groups should be
-* defined:
-* - set_mode(), only for modes <= CLOCK_EVT_MODE_RESUME.
-* - set_state_{shutdown|periodic|oneshot|oneshot_stopped}(), 
tick_resume().
-*/
-   void(*set_mode)(enum clock_event_mode mode, struct 
clock_event_device *);
int (*set_state_periodic)(struct clock_event_device 
*);
int (*set_state_oneshot)(struct clock_event_device 
*);
int (*set_state_oneshot_stopped)(struct 
clock_event_device *);
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 50eb107..a9b76a4 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -97,20 +97,6 @@ EXPORT_SYMBOL_GPL(clockevent_delta2ns);
 static int __clockevents_switch_state(struct clock_event_device *dev,
  enum clock_event_state state)
 {
-   /* Transition with legacy set_mode() callback */
-   if (dev->set_mode) {
-   /* Legacy callback doesn't support new modes */
-   if (state > CLOCK_EVT_STATE_ONESHOT)
-   return -ENOSYS;
-   /*
-* 'clock_event_state' and 'clock_event_mode' have 1-to-1
-* mapping until *_ONESHOT, and so a simple cast will work.
-*/
-   dev->set_mode((enum clock_event_mode)state, dev);
-   dev->mode = (enum clock_event_mode)state;
-   return 0;
-   }
-
if (dev->features & CLOCK_EVT_FEAT_DUMMY)
return 0;
 
@@ -204,12 +190,8 @@ int clockevents_tick_

[tip:timers/core] clockevents: Stop unused clockevent devices

2015-05-19 Thread tip-bot for Viresh Kumar
Commit-ID:  d25408756accbd2171abaa0678f986adae139e6f
Gitweb: http://git.kernel.org/tip/d25408756accbd2171abaa0678f986adae139e6f
Author: Viresh Kumar 
AuthorDate: Fri, 3 Apr 2015 09:04:05 +0530
Committer:  Thomas Gleixner 
CommitDate: Tue, 19 May 2015 16:18:11 +0200

clockevents: Stop unused clockevent devices

To avoid getting spurious interrupts on a tickless CPU, clockevent
device can now be stopped by switching to ONESHOT_STOPPED state.

The natural place for handling this transition is tick_program_event().

On 'expires == KTIME_MAX', we skip programming the event and so we need
to fix such call sites as well, to always call tick_program_event()
irrespective of the expires value.

Once the clockevent device is required again, check if it was earlier
put into ONESHOT_STOPPED state. If yes, switch its state to ONESHOT
before programming its event.

To make sure we haven't missed any corner case, add a WARN() for the
case where we try to reprogram clockevent device while we aren't
configured in ONESHOT_STOPPED state.

Signed-off-by: Viresh Kumar 
Cc: linaro-ker...@lists.linaro.org
Cc: Frederic Weisbecker 
Cc: Kevin Hilman 
Cc: Daniel Lezcano 
Cc: Preeti U Murthy 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/5146b07be7f0bc497e0ebae036590ec2fa73e540.1428031396.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 kernel/time/clockevents.c  |  4 
 kernel/time/hrtimer.c  |  6 ++
 kernel/time/tick-oneshot.c | 16 
 3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index dc6afb4..4922f1b 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -331,6 +331,10 @@ int clockevents_program_event(struct clock_event_device 
*dev, ktime_t expires,
if (dev->state == CLOCK_EVT_STATE_SHUTDOWN)
return 0;
 
+   /* We must be in ONESHOT state here */
+   WARN_ONCE(dev->state != CLOCK_EVT_STATE_ONESHOT, "Current state: %d\n",
+ dev->state);
+
/* Shortcut for clockevent devices that can deal with ktime. */
if (dev->features & CLOCK_EVT_FEAT_KTIME)
return dev->set_next_ktime(expires, dev);
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 4adf320..278d4b3 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -550,8 +550,7 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, 
int skip_equal)
if (cpu_base->hang_detected)
return;
 
-   if (cpu_base->expires_next.tv64 != KTIME_MAX)
-   tick_program_event(cpu_base->expires_next, 1);
+   tick_program_event(cpu_base->expires_next, 1);
 }
 
 /*
@@ -1237,8 +1236,7 @@ retry:
raw_spin_unlock(&cpu_base->lock);
 
/* Reprogramming necessary ? */
-   if (expires_next.tv64 == KTIME_MAX ||
-   !tick_program_event(expires_next, 0)) {
+   if (!tick_program_event(expires_next, 0)) {
cpu_base->hang_detected = 0;
return;
}
diff --git a/kernel/time/tick-oneshot.c b/kernel/time/tick-oneshot.c
index 67a64b1..f8de757 100644
--- a/kernel/time/tick-oneshot.c
+++ b/kernel/time/tick-oneshot.c
@@ -28,6 +28,22 @@ int tick_program_event(ktime_t expires, int force)
 {
struct clock_event_device *dev = 
__this_cpu_read(tick_cpu_device.evtdev);
 
+   if (unlikely(expires.tv64 == KTIME_MAX)) {
+   /*
+* We don't need the clock event device any more, stop it.
+*/
+   clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT_STOPPED);
+   return 0;
+   }
+
+   if (unlikely(dev->state == CLOCK_EVT_STATE_ONESHOT_STOPPED)) {
+   /*
+* We need the clock event again, configure it in ONESHOT mode
+* before using it.
+*/
+   clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT);
+   }
+
return clockevents_program_event(dev, expires, force);
 }
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/core] clockevents: Introduce CLOCK_EVT_STATE_ONESHOT_STOPPED state

2015-05-19 Thread tip-bot for Viresh Kumar
Commit-ID:  8fff52fd50934580c5108afed12043a774edf728
Gitweb: http://git.kernel.org/tip/8fff52fd50934580c5108afed12043a774edf728
Author: Viresh Kumar 
AuthorDate: Fri, 3 Apr 2015 09:04:04 +0530
Committer:  Thomas Gleixner 
CommitDate: Tue, 19 May 2015 16:18:02 +0200

clockevents: Introduce CLOCK_EVT_STATE_ONESHOT_STOPPED state

When no timers/hrtimers are pending, the expiry time is set to a
special value: 'KTIME_MAX'. This normally happens with
NO_HZ_{IDLE|FULL} in both LOWRES/HIGHRES modes.

When 'expiry == KTIME_MAX', we either cancel the 'tick-sched' hrtimer
(NOHZ_MODE_HIGHRES) or skip reprogramming clockevent device
(NOHZ_MODE_LOWRES).  But, the clockevent device is already
reprogrammed from the tick-handler for next tick.

As the clock event device is programmed in ONESHOT mode it will at
least fire one more time (unnecessarily). Timers on few
implementations (like arm_arch_timer, etc.) only support PERIODIC mode
and their drivers emulate ONESHOT over that. Which means that on these
platforms we will get spurious interrupts periodically (at last
programmed interval rate, normally tick rate).

In order to avoid spurious interrupts, the clockevent device should be
stopped or its interrupts should be masked.

A simple (yet hacky) solution to get this fixed could be: update
hrtimer_force_reprogram() to always reprogram clockevent device and
update clockevent drivers to STOP generating events (or delay it to
max time) when 'expires' is set to KTIME_MAX. But the drawback here is
that every clockevent driver has to be hacked for this particular case
and its very easy for new ones to miss this.

However, Thomas suggested to add an optional state ONESHOT_STOPPED to
solve this problem: lkml.org/lkml/2014/5/9/508.

This patch adds support for ONESHOT_STOPPED state in clockevents
core. It will only be available to drivers that implement the
state-specific callbacks instead of the legacy ->set_mode() callback.

Signed-off-by: Viresh Kumar 
Reviewed-by: Preeti U. Murthy 
Cc: linaro-ker...@lists.linaro.org
Cc: Frederic Weisbecker 
Cc: Kevin Hilman 
Cc: Daniel Lezcano 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/b8b383a03ac07b13312c16850b5106b82e4245b5.1428031396.git.viresh.ku...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 include/linux/clockchips.h |  7 ++-
 kernel/time/clockevents.c  | 14 +-
 kernel/time/timer_list.c   |  6 ++
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
index 96c280b..271fa4c 100644
--- a/include/linux/clockchips.h
+++ b/include/linux/clockchips.h
@@ -37,12 +37,15 @@ enum clock_event_mode {
  * reached from DETACHED or SHUTDOWN.
  * ONESHOT:Device is programmed to generate event only once. Can be reached
  * from DETACHED or SHUTDOWN.
+ * ONESHOT_STOPPED: Device was programmed in ONESHOT mode and is temporarily
+ * stopped.
  */
 enum clock_event_state {
CLOCK_EVT_STATE_DETACHED,
CLOCK_EVT_STATE_SHUTDOWN,
CLOCK_EVT_STATE_PERIODIC,
CLOCK_EVT_STATE_ONESHOT,
+   CLOCK_EVT_STATE_ONESHOT_STOPPED,
 };
 
 /*
@@ -90,6 +93,7 @@ enum clock_event_state {
  * @set_mode:  legacy set mode function, only for modes <= 
CLOCK_EVT_MODE_RESUME.
  * @set_state_periodic:switch state to periodic, if !set_mode
  * @set_state_oneshot: switch state to oneshot, if !set_mode
+ * @set_state_oneshot_stopped: switch state to oneshot_stopped, if !set_mode
  * @set_state_shutdown:switch state to shutdown, if !set_mode
  * @tick_resume:   resume clkevt device, if !set_mode
  * @broadcast: function to broadcast events
@@ -121,11 +125,12 @@ struct clock_event_device {
 * State transition callback(s): Only one of the two groups should be
 * defined:
 * - set_mode(), only for modes <= CLOCK_EVT_MODE_RESUME.
-* - set_state_{shutdown|periodic|oneshot}(), tick_resume().
+* - set_state_{shutdown|periodic|oneshot|oneshot_stopped}(), 
tick_resume().
 */
void(*set_mode)(enum clock_event_mode mode, struct 
clock_event_device *);
int (*set_state_periodic)(struct clock_event_device 
*);
int (*set_state_oneshot)(struct clock_event_device 
*);
+   int (*set_state_oneshot_stopped)(struct 
clock_event_device *);
int (*set_state_shutdown)(struct clock_event_device 
*);
int (*tick_resume)(struct clock_event_device *);
 
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 637a094..dc6afb4 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -134,6 +134,17 @@ static int __clockevents_set_state(struct 
clock_event_device *dev,
return -ENOSYS;
return dev->set_state_oneshot(dev);
 
+   case CLOCK_EVT_STATE_ONESHOT_STOPPED:
+  

[tip:timers/core] clockevents: Handle tick device' s resume separately

2015-03-27 Thread tip-bot for Viresh Kumar
Commit-ID:  554ef3876c6acdff1331feab10275e9e9e0adb84
Gitweb: http://git.kernel.org/tip/554ef3876c6acdff1331feab10275e9e9e0adb84
Author: Viresh Kumar 
AuthorDate: Fri, 27 Feb 2015 17:21:32 +0530
Committer:  Ingo Molnar 
CommitDate: Fri, 27 Mar 2015 10:26:19 +0100

clockevents: Handle tick device's resume separately

Upcoming patch will redefine possible states of a clockevent
device. The RESUME mode is a special case only for tick's
clockevent devices. In future it can be replaced by ->resume()
callback already available for clockevent devices.

Lets handle it separately so that clockevents_set_mode() only
handles states valid across all devices. This also renames
set_mode_resume() to tick_resume() to make it more explicit.

Signed-off-by: Viresh Kumar 
Acked-by: Peter Zijlstra 
Cc: Daniel Lezcano 
Cc: Frederic Weisbecker 
Cc: Kevin Hilman 
Cc: Peter Zijlstra 
Cc: Preeti U Murthy 
Cc: linaro-ker...@lists.linaro.org
Cc: linaro-network...@linaro.org
Cc: linux-arm-ker...@lists.infradead.org
Link: 
http://lkml.kernel.org/r/c1b0112410870f49e7bf06958e1483eac6c15e20.1425037853.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 include/linux/clockchips.h   |  4 ++--
 kernel/time/clockevents.c| 30 +-
 kernel/time/tick-broadcast.c |  2 +-
 kernel/time/tick-common.c|  2 +-
 kernel/time/tick-internal.h  |  1 +
 kernel/time/timer_list.c |  4 ++--
 6 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
index 59af26b..a417495 100644
--- a/include/linux/clockchips.h
+++ b/include/linux/clockchips.h
@@ -87,7 +87,7 @@ enum clock_event_mode {
  * @set_mode_periodic: switch mode to periodic, if !set_mode
  * @set_mode_oneshot:  switch mode to oneshot, if !set_mode
  * @set_mode_shutdown: switch mode to shutdown, if !set_mode
- * @set_mode_resume:   resume clkevt device, if !set_mode
+ * @tick_resume:   resume clkevt device, if !set_mode
  * @broadcast: function to broadcast events
  * @min_delta_ticks:   minimum delta value in ticks stored for reconfiguration
  * @max_delta_ticks:   maximum delta value in ticks stored for reconfiguration
@@ -125,7 +125,7 @@ struct clock_event_device {
int (*set_mode_periodic)(struct clock_event_device 
*);
int (*set_mode_oneshot)(struct clock_event_device 
*);
int (*set_mode_shutdown)(struct clock_event_device 
*);
-   int (*set_mode_resume)(struct clock_event_device *);
+   int (*tick_resume)(struct clock_event_device *);
 
void(*broadcast)(const struct cpumask *mask);
void(*suspend)(struct clock_event_device *);
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 489642b..1b0ea63 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -100,7 +100,7 @@ static int __clockevents_set_mode(struct clock_event_device 
*dev,
/* Transition with legacy set_mode() callback */
if (dev->set_mode) {
/* Legacy callback doesn't support new modes */
-   if (mode > CLOCK_EVT_MODE_RESUME)
+   if (mode > CLOCK_EVT_MODE_ONESHOT)
return -ENOSYS;
dev->set_mode(mode, dev);
return 0;
@@ -133,13 +133,6 @@ static int __clockevents_set_mode(struct 
clock_event_device *dev,
return -ENOSYS;
return dev->set_mode_oneshot(dev);
 
-   case CLOCK_EVT_MODE_RESUME:
-   /* Optional callback */
-   if (dev->set_mode_resume)
-   return dev->set_mode_resume(dev);
-   else
-   return 0;
-
default:
return -ENOSYS;
}
@@ -184,6 +177,25 @@ void clockevents_shutdown(struct clock_event_device *dev)
dev->next_event.tv64 = KTIME_MAX;
 }
 
+/**
+ * clockevents_tick_resume -   Resume the tick device before using it again
+ * @dev:   device to resume
+ */
+int clockevents_tick_resume(struct clock_event_device *dev)
+{
+   int ret = 0;
+
+   if (dev->set_mode)
+   dev->set_mode(CLOCK_EVT_MODE_RESUME, dev);
+   else if (dev->tick_resume)
+   ret = dev->tick_resume(dev);
+
+   if (likely(!ret))
+   dev->mode = CLOCK_EVT_MODE_RESUME;
+
+   return ret;
+}
+
 #ifdef CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST
 
 /* Limit min_delta to a jiffie */
@@ -433,7 +445,7 @@ static int clockevents_sanity_check(struct 
clock_event_device *dev)
if (dev->set_mode) {
/* We shouldn't be supporting new modes now */
WARN_ON(dev->set_mode_periodic || dev->set_mode_oneshot ||
-   dev->set_mode_shutdown || dev->set_mode_resume);
+   dev->set_mode_shutdown || dev->tick_resume);
return

[tip:timers/core] clockevents: Don't validate dev-> mode against CLOCK_EVT_MODE_UNUSED for new interface

2015-03-27 Thread tip-bot for Viresh Kumar
Commit-ID:  de81e64b250d3865a75d221a80b4311e3273670a
Gitweb: http://git.kernel.org/tip/de81e64b250d3865a75d221a80b4311e3273670a
Author: Viresh Kumar 
AuthorDate: Fri, 27 Feb 2015 17:21:34 +0530
Committer:  Ingo Molnar 
CommitDate: Fri, 27 Mar 2015 10:26:20 +0100

clockevents: Don't validate dev->mode against CLOCK_EVT_MODE_UNUSED for new 
interface

It was a requirement in the legacy interface that drivers must
initialize ->mode field to 'CLOCK_EVT_MODE_UNUSED'. This field
isn't used anymore by the new interface and so should be only
checked for the legacy interface.

Probably it can be dropped as well as core doesn't rely on it
anymore, but lets keep it to support legacy interface.

Signed-off-by: Viresh Kumar 
Acked-by: Peter Zijlstra 
Cc: Daniel Lezcano 
Cc: Frederic Weisbecker 
Cc: Kevin Hilman 
Cc: Peter Zijlstra 
Cc: Preeti U Murthy 
Cc: linaro-ker...@lists.linaro.org
Cc: linaro-network...@linaro.org
Cc: linux-arm-ker...@lists.infradead.org
Link: 
http://lkml.kernel.org/r/c6604fa1a77fe1fc8dcab87769857228fb1dadd5.1425037853.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/time/clockevents.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 6e53e9a..73689df 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -450,6 +450,8 @@ static int clockevents_sanity_check(struct 
clock_event_device *dev)
/* We shouldn't be supporting new modes now */
WARN_ON(dev->set_state_periodic || dev->set_state_oneshot ||
dev->set_state_shutdown || dev->tick_resume);
+
+   BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED);
return 0;
}
 
@@ -479,7 +481,6 @@ void clockevents_register_device(struct clock_event_device 
*dev)
 {
unsigned long flags;
 
-   BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED);
BUG_ON(clockevents_sanity_check(dev));
 
/* Initialize state to DETACHED */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:timers/core] clockevents: Manage device' s state separately for the core

2015-03-27 Thread tip-bot for Viresh Kumar
Commit-ID:  77e32c89a7117614ab3d66d20c1088de721abfaa
Gitweb: http://git.kernel.org/tip/77e32c89a7117614ab3d66d20c1088de721abfaa
Author: Viresh Kumar 
AuthorDate: Fri, 27 Feb 2015 17:21:33 +0530
Committer:  Ingo Molnar 
CommitDate: Fri, 27 Mar 2015 10:26:19 +0100

clockevents: Manage device's state separately for the core

'enum clock_event_mode' is used for two purposes today:

 - to pass mode to the driver of clockevent device::set_mode().

 - for managing state of the device for clockevents core.

For supporting new modes/states we have moved away from the
legacy set_mode() callback to new per-mode/state callbacks. New
modes/states shouldn't be exposed to the legacy (now OBSOLOTE)
callbacks and so we shouldn't add new states to 'enum
clock_event_mode'.

Lets have separate enums for the two use cases mentioned above.
Keep using the earlier enum for legacy set_mode() callback and
mark it OBSOLETE. And add another enum to clearly specify the
possible states of a clockevent device.

This also renames the newly added per-mode callbacks to reflect
state changes.

We haven't got rid of 'mode' member of 'struct
clock_event_device' as it is used by some of the clockevent
drivers and it would automatically die down once we migrate
those drivers to the new interface. It ('mode') is only updated
now for the drivers using the legacy interface.

Suggested-by: Peter Zijlstra 
Suggested-by: Ingo Molnar 
Signed-off-by: Viresh Kumar 
Acked-by: Peter Zijlstra 
Cc: Daniel Lezcano 
Cc: Frederic Weisbecker 
Cc: Kevin Hilman 
Cc: Preeti U Murthy 
Cc: linaro-ker...@lists.linaro.org
Cc: linaro-network...@linaro.org
Cc: linux-arm-ker...@lists.infradead.org
Link: 
http://lkml.kernel.org/r/b6b0143a8a57bd58352ad35e08c25424c879c0cb.1425037853.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 arch/arm/common/bL_switcher.c |  8 ++--
 include/linux/clockchips.h| 44 +--
 kernel/time/clockevents.c | 99 +++
 kernel/time/tick-broadcast.c  | 20 -
 kernel/time/tick-common.c |  7 +--
 kernel/time/tick-oneshot.c|  6 +--
 kernel/time/timer_list.c  | 12 +++---
 7 files changed, 111 insertions(+), 85 deletions(-)

diff --git a/arch/arm/common/bL_switcher.c b/arch/arm/common/bL_switcher.c
index 6eaddc4..d4f970a 100644
--- a/arch/arm/common/bL_switcher.c
+++ b/arch/arm/common/bL_switcher.c
@@ -152,7 +152,7 @@ static int bL_switch_to(unsigned int new_cluster_id)
unsigned int ob_mpidr, ob_cpu, ob_cluster, ib_mpidr, ib_cpu, ib_cluster;
struct completion inbound_alive;
struct tick_device *tdev;
-   enum clock_event_mode tdev_mode;
+   enum clock_event_state tdev_state;
long volatile *handshake_ptr;
int ipi_nr, ret;
 
@@ -223,8 +223,8 @@ static int bL_switch_to(unsigned int new_cluster_id)
if (tdev && !cpumask_equal(tdev->evtdev->cpumask, cpumask_of(this_cpu)))
tdev = NULL;
if (tdev) {
-   tdev_mode = tdev->evtdev->mode;
-   clockevents_set_mode(tdev->evtdev, CLOCK_EVT_MODE_SHUTDOWN);
+   tdev_state = tdev->evtdev->state;
+   clockevents_set_state(tdev->evtdev, CLOCK_EVT_STATE_SHUTDOWN);
}
 
ret = cpu_pm_enter();
@@ -252,7 +252,7 @@ static int bL_switch_to(unsigned int new_cluster_id)
ret = cpu_pm_exit();
 
if (tdev) {
-   clockevents_set_mode(tdev->evtdev, tdev_mode);
+   clockevents_set_state(tdev->evtdev, tdev_state);
clockevents_program_event(tdev->evtdev,
  tdev->evtdev->next_event, 1);
}
diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
index a417495..e20232c 100644
--- a/include/linux/clockchips.h
+++ b/include/linux/clockchips.h
@@ -32,15 +32,31 @@ enum clock_event_nofitiers {
 struct clock_event_device;
 struct module;
 
-/* Clock event mode commands */
+/* Clock event mode commands for legacy ->set_mode(): OBSOLETE */
 enum clock_event_mode {
CLOCK_EVT_MODE_UNUSED = 0,
CLOCK_EVT_MODE_SHUTDOWN,
CLOCK_EVT_MODE_PERIODIC,
CLOCK_EVT_MODE_ONESHOT,
CLOCK_EVT_MODE_RESUME,
+};
 
-   /* Legacy ->set_mode() callback doesn't support below modes */
+/*
+ * Possible states of a clock event device.
+ *
+ * DETACHED:   Device is not used by clockevents core. Initial state or can be
+ * reached from SHUTDOWN.
+ * SHUTDOWN:   Device is powered-off. Can be reached from PERIODIC or ONESHOT.
+ * PERIODIC:   Device is programmed to generate events periodically. Can be
+ * reached from DETACHED or SHUTDOWN.
+ * ONESHOT:Device is programmed to generate event only once. Can be reached
+ * from DETACHED or SHUTDOWN.
+ */
+enum clock_event_state {
+   CLOCK_EVT_STATE_DETACHED = 0,
+   CLOCK_EVT_STATE_SHUTDOWN,
+   CLOCK_EVT_STATE_PERIODIC,
+   CLOCK_EVT_STATE_ONESHOT,
 };
 
 /*
@@ -80,13 +96,14 @@ enum clock_e

[tip:timers/core] clockevents: Introduce mode specific callbacks

2015-02-18 Thread tip-bot for Viresh Kumar
Commit-ID:  bd624d75db21ea5402f9ecf4450b311794d80352
Gitweb: http://git.kernel.org/tip/bd624d75db21ea5402f9ecf4450b311794d80352
Author: Viresh Kumar 
AuthorDate: Fri, 13 Feb 2015 08:54:56 +0800
Committer:  Ingo Molnar 
CommitDate: Wed, 18 Feb 2015 15:16:23 +0100

clockevents: Introduce mode specific callbacks

It is not possible for the clockevents core to know which modes (other than
those with a corresponding feature flag) are supported by a particular
implementation. And drivers are expected to handle transition to all modes
elegantly, as ->set_mode() would be issued for them unconditionally.

Now, adding support for a new mode complicates things a bit if we want to use
the legacy ->set_mode() callback. We need to closely review all clockevents
drivers to see if they would break on addition of a new mode. And after such
reviews, it is found that we have to do non-trivial changes to most of the
drivers [1].

Introduce mode-specific set_mode_*() callbacks, some of which the drivers may or
may not implement. A missing callback would clearly convey the message that the
corresponding mode isn't supported.

A driver may still choose to keep supporting the legacy ->set_mode() callback,
but ->set_mode() wouldn't be supporting any new modes beyond RESUME. If a driver
wants to benefit from using a new mode, it would be required to migrate to
the mode specific callbacks.

The legacy ->set_mode() callback and the newly introduced mode-specific
callbacks are mutually exclusive. Only one of them should be supported by the
driver.

Sanity check is done at the time of registration to distinguish between optional
and required callbacks and to make error recovery and handling simpler. If the
legacy ->set_mode() callback is provided, all mode specific ones would be
ignored by the core but a warning is thrown if they are present.

Call sites calling ->set_mode() directly are also updated to use
__clockevents_set_mode() instead, as ->set_mode() may not be available anymore
for few drivers.

 [1] https://lkml.org/lkml/2014/12/9/605
 [2] https://lkml.org/lkml/2015/1/23/255

Suggested-by: Thomas Gleixner  [2]
Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Daniel Lezcano 
Cc: Frederic Weisbecker 
Cc: John Stultz 
Cc: Kevin Hilman 
Cc: Linus Torvalds 
Cc: Preeti U Murthy 
Cc: linaro-ker...@lists.linaro.org
Cc: linaro-network...@linaro.org
Link: 
http://lkml.kernel.org/r/792d59a40423f0acffc9bb0bec9de1341a06fa02.1423788565.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 include/linux/clockchips.h | 21 +--
 kernel/time/clockevents.c  | 88 --
 kernel/time/timer_list.c   | 32 +++--
 3 files changed, 134 insertions(+), 7 deletions(-)

diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
index 2e4cb67..59af26b 100644
--- a/include/linux/clockchips.h
+++ b/include/linux/clockchips.h
@@ -39,6 +39,8 @@ enum clock_event_mode {
CLOCK_EVT_MODE_PERIODIC,
CLOCK_EVT_MODE_ONESHOT,
CLOCK_EVT_MODE_RESUME,
+
+   /* Legacy ->set_mode() callback doesn't support below modes */
 };
 
 /*
@@ -81,7 +83,11 @@ enum clock_event_mode {
  * @mode:  operating mode assigned by the management code
  * @features:  features
  * @retries:   number of forced programming retries
- * @set_mode:  set mode function
+ * @set_mode:  legacy set mode function, only for modes <= 
CLOCK_EVT_MODE_RESUME.
+ * @set_mode_periodic: switch mode to periodic, if !set_mode
+ * @set_mode_oneshot:  switch mode to oneshot, if !set_mode
+ * @set_mode_shutdown: switch mode to shutdown, if !set_mode
+ * @set_mode_resume:   resume clkevt device, if !set_mode
  * @broadcast: function to broadcast events
  * @min_delta_ticks:   minimum delta value in ticks stored for reconfiguration
  * @max_delta_ticks:   maximum delta value in ticks stored for reconfiguration
@@ -108,9 +114,20 @@ struct clock_event_device {
unsigned intfeatures;
unsigned long   retries;
 
-   void(*broadcast)(const struct cpumask *mask);
+   /*
+* Mode transition callback(s): Only one of the two groups should be
+* defined:
+* - set_mode(), only for modes <= CLOCK_EVT_MODE_RESUME.
+* - set_mode_{shutdown|periodic|oneshot|resume}().
+*/
void(*set_mode)(enum clock_event_mode mode,
struct clock_event_device *);
+   int (*set_mode_periodic)(struct clock_event_device 
*);
+   int (*set_mode_oneshot)(struct clock_event_device 
*);
+   int (*set_mode_shutdown)(struct clock_event_device 
*);
+   int (*set_mode_resume)(struct clock_event_device *);
+
+   void(*broadcast)(const struct cpumask *mask);
void(*suspend)

[tip:sched/core] sched/fair: Remove unused 'sd' parameter from select_idle_smt()

2019-02-11 Thread tip-bot for Viresh Kumar
Commit-ID:  1b5500d73466c62fe048153f0cea1610d2543c7f
Gitweb: https://git.kernel.org/tip/1b5500d73466c62fe048153f0cea1610d2543c7f
Author: Viresh Kumar 
AuthorDate: Thu, 7 Feb 2019 16:16:05 +0530
Committer:  Ingo Molnar 
CommitDate: Mon, 11 Feb 2019 08:48:27 +0100

sched/fair: Remove unused 'sd' parameter from select_idle_smt()

The 'sd' parameter isn't getting used in select_idle_smt(), drop it.

Signed-off-by: Viresh Kumar 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Link: 
http://lkml.kernel.org/r/f91c5e118183e79d4a982e9ac4ce5e47948f6c1b.1549536337.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/fair.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index f44da9b491ff..8abd1c271499 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6117,7 +6117,7 @@ static int select_idle_core(struct task_struct *p, struct 
sched_domain *sd, int
 /*
  * Scan the local SMT mask for idle CPUs.
  */
-static int select_idle_smt(struct task_struct *p, struct sched_domain *sd, int 
target)
+static int select_idle_smt(struct task_struct *p, int target)
 {
int cpu;
 
@@ -6141,7 +6141,7 @@ static inline int select_idle_core(struct task_struct *p, 
struct sched_domain *s
return -1;
 }
 
-static inline int select_idle_smt(struct task_struct *p, struct sched_domain 
*sd, int target)
+static inline int select_idle_smt(struct task_struct *p, int target)
 {
return -1;
 }
@@ -6246,7 +6246,7 @@ static int select_idle_sibling(struct task_struct *p, int 
prev, int target)
if ((unsigned)i < nr_cpumask_bits)
return i;
 
-   i = select_idle_smt(p, sd, target);
+   i = select_idle_smt(p, target);
if ((unsigned)i < nr_cpumask_bits)
return i;
 


[tip:sched/core] sched/fair: Start tracking SCHED_IDLE tasks count in cfs_rq

2019-07-25 Thread tip-bot for Viresh Kumar
Commit-ID:  43e9f7f231e40e4534fc3a735da152911a085c16
Gitweb: https://git.kernel.org/tip/43e9f7f231e40e4534fc3a735da152911a085c16
Author: Viresh Kumar 
AuthorDate: Wed, 26 Jun 2019 10:36:29 +0530
Committer:  Ingo Molnar 
CommitDate: Thu, 25 Jul 2019 15:51:53 +0200

sched/fair: Start tracking SCHED_IDLE tasks count in cfs_rq

Track how many tasks are present with SCHED_IDLE policy in each cfs_rq.
This will be used by later commits.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Daniel Lezcano 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Cc: chris.redp...@arm.com
Cc: quentin.per...@linaro.org
Cc: songliubrav...@fb.com
Cc: steven.sist...@oracle.com
Cc: subhra.mazum...@oracle.com
Cc: tk...@google.com
Link: 
https://lkml.kernel.org/r/0d3cdc427fc68808ad5bccc40e86ed0bf9da8bb4.1561523542.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/fair.c  | 14 --
 kernel/sched/sched.h |  3 ++-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 9be36ffb5689..9ed5ab53872f 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4555,7 +4555,7 @@ static void throttle_cfs_rq(struct cfs_rq *cfs_rq)
struct rq *rq = rq_of(cfs_rq);
struct cfs_bandwidth *cfs_b = tg_cfs_bandwidth(cfs_rq->tg);
struct sched_entity *se;
-   long task_delta, dequeue = 1;
+   long task_delta, idle_task_delta, dequeue = 1;
bool empty;
 
se = cfs_rq->tg->se[cpu_of(rq_of(cfs_rq))];
@@ -4566,6 +4566,7 @@ static void throttle_cfs_rq(struct cfs_rq *cfs_rq)
rcu_read_unlock();
 
task_delta = cfs_rq->h_nr_running;
+   idle_task_delta = cfs_rq->idle_h_nr_running;
for_each_sched_entity(se) {
struct cfs_rq *qcfs_rq = cfs_rq_of(se);
/* throttled entity or throttle-on-deactivate */
@@ -4575,6 +4576,7 @@ static void throttle_cfs_rq(struct cfs_rq *cfs_rq)
if (dequeue)
dequeue_entity(qcfs_rq, se, DEQUEUE_SLEEP);
qcfs_rq->h_nr_running -= task_delta;
+   qcfs_rq->idle_h_nr_running -= idle_task_delta;
 
if (qcfs_rq->load.weight)
dequeue = 0;
@@ -4614,7 +4616,7 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq)
struct cfs_bandwidth *cfs_b = tg_cfs_bandwidth(cfs_rq->tg);
struct sched_entity *se;
int enqueue = 1;
-   long task_delta;
+   long task_delta, idle_task_delta;
 
se = cfs_rq->tg->se[cpu_of(rq)];
 
@@ -4634,6 +4636,7 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq)
return;
 
task_delta = cfs_rq->h_nr_running;
+   idle_task_delta = cfs_rq->idle_h_nr_running;
for_each_sched_entity(se) {
if (se->on_rq)
enqueue = 0;
@@ -4642,6 +4645,7 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq)
if (enqueue)
enqueue_entity(cfs_rq, se, ENQUEUE_WAKEUP);
cfs_rq->h_nr_running += task_delta;
+   cfs_rq->idle_h_nr_running += idle_task_delta;
 
if (cfs_rq_throttled(cfs_rq))
break;
@@ -5255,6 +5259,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, 
int flags)
 {
struct cfs_rq *cfs_rq;
struct sched_entity *se = &p->se;
+   int idle_h_nr_running = task_has_idle_policy(p);
 
/*
 * The code below (indirectly) updates schedutil which looks at
@@ -5287,6 +5292,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, 
int flags)
if (cfs_rq_throttled(cfs_rq))
break;
cfs_rq->h_nr_running++;
+   cfs_rq->idle_h_nr_running += idle_h_nr_running;
 
flags = ENQUEUE_WAKEUP;
}
@@ -5294,6 +5300,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, 
int flags)
for_each_sched_entity(se) {
cfs_rq = cfs_rq_of(se);
cfs_rq->h_nr_running++;
+   cfs_rq->idle_h_nr_running += idle_h_nr_running;
 
if (cfs_rq_throttled(cfs_rq))
break;
@@ -5355,6 +5362,7 @@ static void dequeue_task_fair(struct rq *rq, struct 
task_struct *p, int flags)
struct cfs_rq *cfs_rq;
struct sched_entity *se = &p->se;
int task_sleep = flags & DEQUEUE_SLEEP;
+   int idle_h_nr_running = task_has_idle_policy(p);
 
for_each_sched_entity(se) {
cfs_rq = cfs_rq_of(se);
@@ -5369,6 +5377,7 @@ static void dequeue_task_fair(struct rq *rq, struct 
task_struct *p, int flags)
if (cfs_rq_throttled(cfs_rq))
break;
cfs_rq->h_nr_running--;
+   cfs_rq->idle_h_nr_running -= idle_h_nr_running;
 
/* Don't dequeue parent if it has other entities besides us */
if (cfs_rq->load.weight) {

[tip:sched/core] sched/fair: Fall back to sched-idle CPU if idle CPU isn't found

2019-07-25 Thread tip-bot for Viresh Kumar
Commit-ID:  3c29e651e16dd3b3179cfb2d055ee9538e37515c
Gitweb: https://git.kernel.org/tip/3c29e651e16dd3b3179cfb2d055ee9538e37515c
Author: Viresh Kumar 
AuthorDate: Wed, 26 Jun 2019 10:36:30 +0530
Committer:  Ingo Molnar 
CommitDate: Thu, 25 Jul 2019 15:51:54 +0200

sched/fair: Fall back to sched-idle CPU if idle CPU isn't found

We try to find an idle CPU to run the next task, but in case we don't
find an idle CPU it is better to pick a CPU which will run the task the
soonest, for performance reason.

A CPU which isn't idle but has only SCHED_IDLE activity queued on it
should be a good target based on this criteria as any normal fair task
will most likely preempt the currently running SCHED_IDLE task
immediately. In fact, choosing a SCHED_IDLE CPU over a fully idle one
shall give better results as it should be able to run the task sooner
than an idle CPU (which requires to be woken up from an idle state).

This patch updates both fast and slow paths with this optimization.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Daniel Lezcano 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Cc: chris.redp...@arm.com
Cc: quentin.per...@linaro.org
Cc: songliubrav...@fb.com
Cc: steven.sist...@oracle.com
Cc: subhra.mazum...@oracle.com
Cc: tk...@google.com
Link: 
https://lkml.kernel.org/r/eeafa25fdeb6f6edd5b2da716bc8f0ba7708cbcf.1561523542.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/fair.c | 43 +--
 1 file changed, 33 insertions(+), 10 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 9ed5ab53872f..52564e050062 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5431,6 +5431,15 @@ static struct {
 
 #endif /* CONFIG_NO_HZ_COMMON */
 
+/* CPU only has SCHED_IDLE tasks enqueued */
+static int sched_idle_cpu(int cpu)
+{
+   struct rq *rq = cpu_rq(cpu);
+
+   return unlikely(rq->nr_running == rq->cfs.idle_h_nr_running &&
+   rq->nr_running);
+}
+
 static unsigned long cpu_runnable_load(struct rq *rq)
 {
return cfs_rq_runnable_load_avg(&rq->cfs);
@@ -5753,7 +5762,7 @@ find_idlest_group_cpu(struct sched_group *group, struct 
task_struct *p, int this
unsigned int min_exit_latency = UINT_MAX;
u64 latest_idle_timestamp = 0;
int least_loaded_cpu = this_cpu;
-   int shallowest_idle_cpu = -1;
+   int shallowest_idle_cpu = -1, si_cpu = -1;
int i;
 
/* Check if we have any choice: */
@@ -5784,7 +5793,12 @@ find_idlest_group_cpu(struct sched_group *group, struct 
task_struct *p, int this
latest_idle_timestamp = rq->idle_stamp;
shallowest_idle_cpu = i;
}
-   } else if (shallowest_idle_cpu == -1) {
+   } else if (shallowest_idle_cpu == -1 && si_cpu == -1) {
+   if (sched_idle_cpu(i)) {
+   si_cpu = i;
+   continue;
+   }
+
load = cpu_runnable_load(cpu_rq(i));
if (load < min_load) {
min_load = load;
@@ -5793,7 +5807,11 @@ find_idlest_group_cpu(struct sched_group *group, struct 
task_struct *p, int this
}
}
 
-   return shallowest_idle_cpu != -1 ? shallowest_idle_cpu : 
least_loaded_cpu;
+   if (shallowest_idle_cpu != -1)
+   return shallowest_idle_cpu;
+   if (si_cpu != -1)
+   return si_cpu;
+   return least_loaded_cpu;
 }
 
 static inline int find_idlest_cpu(struct sched_domain *sd, struct task_struct 
*p,
@@ -5946,7 +5964,7 @@ static int select_idle_core(struct task_struct *p, struct 
sched_domain *sd, int
  */
 static int select_idle_smt(struct task_struct *p, int target)
 {
-   int cpu;
+   int cpu, si_cpu = -1;
 
if (!static_branch_likely(&sched_smt_present))
return -1;
@@ -5956,9 +5974,11 @@ static int select_idle_smt(struct task_struct *p, int 
target)
continue;
if (available_idle_cpu(cpu))
return cpu;
+   if (si_cpu == -1 && sched_idle_cpu(cpu))
+   si_cpu = cpu;
}
 
-   return -1;
+   return si_cpu;
 }
 
 #else /* CONFIG_SCHED_SMT */
@@ -5986,8 +6006,8 @@ static int select_idle_cpu(struct task_struct *p, struct 
sched_domain *sd, int t
u64 avg_cost, avg_idle;
u64 time, cost;
s64 delta;
-   int cpu, nr = INT_MAX;
int this = smp_processor_id();
+   int cpu, nr = INT_MAX, si_cpu = -1;
 
this_sd = rcu_dereference(*this_cpu_ptr(&sd_llc));
if (!this_sd)
@@ -6015,11 +6035,13 @@ static int select_idle_cpu(struct task_struct *p, 
struct sched_domain *sd, int t
 
for_each_cpu_wrap(cpu, sched_domain_span(sd), target) {
if

[tip:sched/core] sched/fair: Introduce fits_capacity()

2019-07-25 Thread tip-bot for Viresh Kumar
Commit-ID:  60e17f5cef838e9ca7946ced208ceddcec6c315d
Gitweb: https://git.kernel.org/tip/60e17f5cef838e9ca7946ced208ceddcec6c315d
Author: Viresh Kumar 
AuthorDate: Tue, 4 Jun 2019 12:31:52 +0530
Committer:  Ingo Molnar 
CommitDate: Thu, 25 Jul 2019 15:51:56 +0200

sched/fair: Introduce fits_capacity()

The same formula to check utilization against capacity (after
considering capacity_margin) is already used at 5 different locations.

This patch creates a new macro, fits_capacity(), which can be used from
all these locations without exposing the details of it and hence
simplify code.

All the 5 code locations are updated as well to use it..

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Link: 
https://lkml.kernel.org/r/b477ac75a2b163048bdaeb37f57b4c3f04f75a31.1559631700.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/fair.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 52564e050062..fb75c0bea80f 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -96,12 +96,12 @@ int __weak arch_asym_cpu_priority(int cpu)
 }
 
 /*
- * The margin used when comparing utilization with CPU capacity:
- * util * margin < capacity * 1024
+ * The margin used when comparing utilization with CPU capacity.
  *
  * (default: ~20%)
  */
-static unsigned int capacity_margin= 1280;
+#define fits_capacity(cap, max)((cap) * 1280 < (max) * 1024)
+
 #endif
 
 #ifdef CONFIG_CFS_BANDWIDTH
@@ -3808,7 +3808,7 @@ util_est_dequeue(struct cfs_rq *cfs_rq, struct 
task_struct *p, bool task_sleep)
 
 static inline int task_fits_capacity(struct task_struct *p, long capacity)
 {
-   return capacity * 1024 > task_util_est(p) * capacity_margin;
+   return fits_capacity(task_util_est(p), capacity);
 }
 
 static inline void update_misfit_status(struct task_struct *p, struct rq *rq)
@@ -5235,7 +5235,7 @@ static inline unsigned long cpu_util(int cpu);
 
 static inline bool cpu_overutilized(int cpu)
 {
-   return (capacity_of(cpu) * 1024) < (cpu_util(cpu) * capacity_margin);
+   return !fits_capacity(cpu_util(cpu), capacity_of(cpu));
 }
 
 static inline void update_overutilized_status(struct rq *rq)
@@ -6456,7 +6456,7 @@ static int find_energy_efficient_cpu(struct task_struct 
*p, int prev_cpu)
/* Skip CPUs that will be overutilized. */
util = cpu_util_next(cpu, p, cpu);
cpu_cap = capacity_of(cpu);
-   if (cpu_cap * 1024 < util * capacity_margin)
+   if (!fits_capacity(util, cpu_cap))
continue;
 
/* Always use prev_cpu as a candidate. */
@@ -8011,8 +8011,7 @@ group_is_overloaded(struct lb_env *env, struct 
sg_lb_stats *sgs)
 static inline bool
 group_smaller_min_cpu_capacity(struct sched_group *sg, struct sched_group *ref)
 {
-   return sg->sgc->min_capacity * capacity_margin <
-   ref->sgc->min_capacity * 1024;
+   return fits_capacity(sg->sgc->min_capacity, ref->sgc->min_capacity);
 }
 
 /*
@@ -8022,8 +8021,7 @@ group_smaller_min_cpu_capacity(struct sched_group *sg, 
struct sched_group *ref)
 static inline bool
 group_smaller_max_cpu_capacity(struct sched_group *sg, struct sched_group *ref)
 {
-   return sg->sgc->max_capacity * capacity_margin <
-   ref->sgc->max_capacity * 1024;
+   return fits_capacity(sg->sgc->max_capacity, ref->sgc->max_capacity);
 }
 
 static inline enum


[tip:sched/core] sched/fair: Use non-atomic cpumask_{set,clear}_cpu()

2019-02-13 Thread tip-bot for Viresh Kumar
Commit-ID:  c89d92eddfad11e912fb506f85e1796064a9f9d2
Gitweb: https://git.kernel.org/tip/c89d92eddfad11e912fb506f85e1796064a9f9d2
Author: Viresh Kumar 
AuthorDate: Tue, 12 Feb 2019 14:57:01 +0530
Committer:  Ingo Molnar 
CommitDate: Wed, 13 Feb 2019 08:34:13 +0100

sched/fair: Use non-atomic cpumask_{set,clear}_cpu()

The cpumasks updated here are not subject to concurrency and using
atomic bitops for them is pointless and expensive. Use the non-atomic
variants instead.

Suggested-by: Peter Zijlstra 
Signed-off-by: Viresh Kumar 
Cc: Linus Torvalds 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Link: 
http://lkml.kernel.org/r/2e2a10f84b9049a81eef94ed6d5989447c21e34a.1549963617.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/fair.c  | 6 +++---
 kernel/sched/isolation.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 8abd1c271499..8213ff6e365d 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6097,7 +6097,7 @@ static int select_idle_core(struct task_struct *p, struct 
sched_domain *sd, int
bool idle = true;
 
for_each_cpu(cpu, cpu_smt_mask(core)) {
-   cpumask_clear_cpu(cpu, cpus);
+   __cpumask_clear_cpu(cpu, cpus);
if (!available_idle_cpu(cpu))
idle = false;
}
@@ -9105,7 +9105,7 @@ more_balance:
if ((env.flags & LBF_DST_PINNED) && env.imbalance > 0) {
 
/* Prevent to re-select dst_cpu via env's CPUs */
-   cpumask_clear_cpu(env.dst_cpu, env.cpus);
+   __cpumask_clear_cpu(env.dst_cpu, env.cpus);
 
env.dst_rq   = cpu_rq(env.new_dst_cpu);
env.dst_cpu  = env.new_dst_cpu;
@@ -9132,7 +9132,7 @@ more_balance:
 
/* All tasks on this runqueue were pinned by CPU affinity */
if (unlikely(env.flags & LBF_ALL_PINNED)) {
-   cpumask_clear_cpu(cpu_of(busiest), cpus);
+   __cpumask_clear_cpu(cpu_of(busiest), cpus);
/*
 * Attempting to continue load balancing at the current
 * sched_domain level only makes sense if there are
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index 81faddba9e20..b02d148e7672 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -80,7 +80,7 @@ static int __init housekeeping_setup(char *str, enum hk_flags 
flags)
cpumask_andnot(housekeeping_mask,
   cpu_possible_mask, non_housekeeping_mask);
if (cpumask_empty(housekeeping_mask))
-   cpumask_set_cpu(smp_processor_id(), housekeeping_mask);
+   __cpumask_set_cpu(smp_processor_id(), 
housekeeping_mask);
} else {
cpumask_var_t tmp;
 


[tip:sched/core] sched/fair: Rearrange select_task_rq_fair() to optimize it

2018-05-04 Thread tip-bot for Viresh Kumar
Commit-ID:  f1d88b4468188ddcd2620b8d612068faf6662a62
Gitweb: https://git.kernel.org/tip/f1d88b4468188ddcd2620b8d612068faf6662a62
Author: Viresh Kumar 
AuthorDate: Thu, 26 Apr 2018 16:00:50 +0530
Committer:  Ingo Molnar 
CommitDate: Fri, 4 May 2018 10:00:07 +0200

sched/fair: Rearrange select_task_rq_fair() to optimize it

Rearrange select_task_rq_fair() a bit to avoid executing some
conditional statements in few specific code-paths. That gets rid of the
goto as well.

This shouldn't result in any functional changes.

Tested-by: Rohit Jain 
Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra (Intel) 
Reviewed-by: Valentin Schneider 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Link: 
http://lkml.kernel.org/r/20831b8d237bf3a20e4e328286f678b425ff04c9.1524738578.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/fair.c | 37 -
 1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index e3002e5ada31..4b346f358005 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6613,7 +6613,7 @@ static int wake_cap(struct task_struct *p, int cpu, int 
prev_cpu)
 static int
 select_task_rq_fair(struct task_struct *p, int prev_cpu, int sd_flag, int 
wake_flags)
 {
-   struct sched_domain *tmp, *affine_sd = NULL, *sd = NULL;
+   struct sched_domain *tmp, *sd = NULL;
int cpu = smp_processor_id();
int new_cpu = prev_cpu;
int want_affine = 0;
@@ -6636,7 +6636,10 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, 
int sd_flag, int wake_f
 */
if (want_affine && (tmp->flags & SD_WAKE_AFFINE) &&
cpumask_test_cpu(prev_cpu, sched_domain_span(tmp))) {
-   affine_sd = tmp;
+   if (cpu != prev_cpu)
+   new_cpu = wake_affine(tmp, p, cpu, prev_cpu, 
sync);
+
+   sd = NULL; /* Prefer wake_affine over balance flags */
break;
}
 
@@ -6646,33 +6649,25 @@ select_task_rq_fair(struct task_struct *p, int 
prev_cpu, int sd_flag, int wake_f
break;
}
 
-   if (affine_sd) {
-   sd = NULL; /* Prefer wake_affine over balance flags */
-   if (cpu == prev_cpu)
-   goto pick_cpu;
-
-   new_cpu = wake_affine(affine_sd, p, cpu, prev_cpu, sync);
-   }
+   if (unlikely(sd)) {
+   /* Slow path */
 
-   if (sd && !(sd_flag & SD_BALANCE_FORK)) {
/*
 * We're going to need the task's util for capacity_spare_wake
 * in find_idlest_group. Sync it up to prev_cpu's
 * last_update_time.
 */
-   sync_entity_load_avg(&p->se);
-   }
-
-   if (!sd) {
-pick_cpu:
-   if (sd_flag & SD_BALANCE_WAKE) { /* XXX always ? */
-   new_cpu = select_idle_sibling(p, prev_cpu, new_cpu);
+   if (!(sd_flag & SD_BALANCE_FORK))
+   sync_entity_load_avg(&p->se);
 
-   if (want_affine)
-   current->recent_used_cpu = cpu;
-   }
-   } else {
new_cpu = find_idlest_cpu(sd, p, cpu, prev_cpu, sd_flag);
+   } else if (sd_flag & SD_BALANCE_WAKE) { /* XXX always ? */
+   /* Fast path */
+
+   new_cpu = select_idle_sibling(p, prev_cpu, new_cpu);
+
+   if (want_affine)
+   current->recent_used_cpu = cpu;
}
rcu_read_unlock();
 


[tip:sched/core] sched/fair: Avoid calling sync_entity_load_avg() unnecessarily

2018-05-04 Thread tip-bot for Viresh Kumar
Commit-ID:  c976a862ba4869c1e75c39b9b8f1e9ebfe90cdfc
Gitweb: https://git.kernel.org/tip/c976a862ba4869c1e75c39b9b8f1e9ebfe90cdfc
Author: Viresh Kumar 
AuthorDate: Thu, 26 Apr 2018 16:00:51 +0530
Committer:  Ingo Molnar 
CommitDate: Fri, 4 May 2018 10:00:08 +0200

sched/fair: Avoid calling sync_entity_load_avg() unnecessarily

Call sync_entity_load_avg() directly from find_idlest_cpu() instead of
select_task_rq_fair(), as that's where we need to use task's utilization
value. And call sync_entity_load_avg() only after making sure sched
domain spans over one of the allowed CPUs for the task.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Link: 
http://lkml.kernel.org/r/cd019d1753824c81130eae7b43e2bbcec47cc1ad.1524738578.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/fair.c | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 4b346f358005..1f6a23a5b451 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6199,6 +6199,13 @@ static inline int find_idlest_cpu(struct sched_domain 
*sd, struct task_struct *p
if (!cpumask_intersects(sched_domain_span(sd), &p->cpus_allowed))
return prev_cpu;
 
+   /*
+* We need task's util for capacity_spare_wake, sync it up to prev_cpu's
+* last_update_time.
+*/
+   if (!(sd_flag & SD_BALANCE_FORK))
+   sync_entity_load_avg(&p->se);
+
while (sd) {
struct sched_group *group;
struct sched_domain *tmp;
@@ -6651,15 +6658,6 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, 
int sd_flag, int wake_f
 
if (unlikely(sd)) {
/* Slow path */
-
-   /*
-* We're going to need the task's util for capacity_spare_wake
-* in find_idlest_group. Sync it up to prev_cpu's
-* last_update_time.
-*/
-   if (!(sd_flag & SD_BALANCE_FORK))
-   sync_entity_load_avg(&p->se);
-
new_cpu = find_idlest_cpu(sd, p, cpu, prev_cpu, sd_flag);
} else if (sd_flag & SD_BALANCE_WAKE) { /* XXX always ? */
/* Fast path */


[tip:timers/urgent] clockevents: Allow set-state callbacks to be optional

2015-07-07 Thread tip-bot for Viresh Kumar
Commit-ID:  7c4a976cd55972b68c75a978f171b6db5df4ce66
Gitweb: http://git.kernel.org/tip/7c4a976cd55972b68c75a978f171b6db5df4ce66
Author: Viresh Kumar 
AuthorDate: Tue, 7 Jul 2015 10:14:35 +0200
Committer:  Thomas Gleixner 
CommitDate: Tue, 7 Jul 2015 10:44:45 +0200

clockevents: Allow set-state callbacks to be optional

Its mandatory for the drivers to provide set_state_{oneshot|periodic}()
(only if related modes are supported) and set_state_shutdown() callbacks
today, if they are implementing the new set-state interface.

But this leads to unnecessary noop callbacks for drivers which don't
want to implement them. Over that, it will lead to a full function call
for nothing really useful.

Lets make all set-state callbacks optional.

Suggested-by: Daniel Lezcano 
Signed-off-by: Viresh Kumar 
Signed-off-by: Daniel Lezcano 
Link: 
http://lkml.kernel.org/r/1436256875-15562-1-git-send-email-daniel.lezc...@linaro.org
Signed-off-by: Thomas Gleixner 
---
 kernel/time/clockevents.c | 24 +---
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 08ccc3d..50eb107 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -120,19 +120,25 @@ static int __clockevents_switch_state(struct 
clock_event_device *dev,
/* The clockevent device is getting replaced. Shut it down. */
 
case CLOCK_EVT_STATE_SHUTDOWN:
-   return dev->set_state_shutdown(dev);
+   if (dev->set_state_shutdown)
+   return dev->set_state_shutdown(dev);
+   return 0;
 
case CLOCK_EVT_STATE_PERIODIC:
/* Core internal bug */
if (!(dev->features & CLOCK_EVT_FEAT_PERIODIC))
return -ENOSYS;
-   return dev->set_state_periodic(dev);
+   if (dev->set_state_periodic)
+   return dev->set_state_periodic(dev);
+   return 0;
 
case CLOCK_EVT_STATE_ONESHOT:
/* Core internal bug */
if (!(dev->features & CLOCK_EVT_FEAT_ONESHOT))
return -ENOSYS;
-   return dev->set_state_oneshot(dev);
+   if (dev->set_state_oneshot)
+   return dev->set_state_oneshot(dev);
+   return 0;
 
case CLOCK_EVT_STATE_ONESHOT_STOPPED:
/* Core internal bug */
@@ -471,18 +477,6 @@ static int clockevents_sanity_check(struct 
clock_event_device *dev)
if (dev->features & CLOCK_EVT_FEAT_DUMMY)
return 0;
 
-   /* New state-specific callbacks */
-   if (!dev->set_state_shutdown)
-   return -EINVAL;
-
-   if ((dev->features & CLOCK_EVT_FEAT_PERIODIC) &&
-   !dev->set_state_periodic)
-   return -EINVAL;
-
-   if ((dev->features & CLOCK_EVT_FEAT_ONESHOT) &&
-   !dev->set_state_oneshot)
-   return -EINVAL;
-
return 0;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/core] sched/fair: Call cpufreq update util handlers less frequently on UP

2017-08-10 Thread tip-bot for Viresh Kumar
Commit-ID:  a030d7381d8b3adabde724e3077bb6cb32d1b3ee
Gitweb: http://git.kernel.org/tip/a030d7381d8b3adabde724e3077bb6cb32d1b3ee
Author: Viresh Kumar 
AuthorDate: Wed, 24 May 2017 10:59:52 +0530
Committer:  Ingo Molnar 
CommitDate: Thu, 10 Aug 2017 12:18:09 +0200

sched/fair: Call cpufreq update util handlers less frequently on UP

For SMP systems, update_load_avg() calls the cpufreq update util
handlers only for the top level cfs_rq (i.e. rq->cfs).

But that is not the case for UP systems. update_load_avg() calls util
handler for any cfs_rq for which it is called. This would result in way
too many calls from the scheduler to the cpufreq governors when
CONFIG_FAIR_GROUP_SCHED is enabled.

Reduce the frequency of these calls by copying the behavior from the SMP
case, i.e. Only call util handlers for the top level cfs_rq.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Cc: linaro-ker...@lists.linaro.org
Fixes: 536bd00cdbb7 ("sched/fair: Fix !CONFIG_SMP kernel cpufreq governor 
breakage")
Link: 
http://lkml.kernel.org/r/6abf69a2107525885b616a2c1ec03d9c0946171c.1495603536.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/fair.c | 48 
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index c95880e..139abf2 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2790,6 +2790,29 @@ static inline void update_cfs_shares(struct sched_entity 
*se)
 }
 #endif /* CONFIG_FAIR_GROUP_SCHED */
 
+static inline void cfs_rq_util_change(struct cfs_rq *cfs_rq)
+{
+   if (&this_rq()->cfs == cfs_rq) {
+   /*
+* There are a few boundary cases this might miss but it should
+* get called often enough that that should (hopefully) not be
+* a real problem -- added to that it only calls on the local
+* CPU, so if we enqueue remotely we'll miss an update, but
+* the next tick/schedule should update.
+*
+* It will not get called when we go idle, because the idle
+* thread is a different class (!fair), nor will the utilization
+* number include things like RT tasks.
+*
+* As is, the util number is not freq-invariant (we'd have to
+* implement arch_scale_freq_capacity() for that).
+*
+* See cpu_util().
+*/
+   cpufreq_update_util(rq_of(cfs_rq), 0);
+   }
+}
+
 #ifdef CONFIG_SMP
 /*
  * Approximate:
@@ -3276,29 +3299,6 @@ static inline void set_tg_cfs_propagate(struct cfs_rq 
*cfs_rq) {}
 
 #endif /* CONFIG_FAIR_GROUP_SCHED */
 
-static inline void cfs_rq_util_change(struct cfs_rq *cfs_rq)
-{
-   if (&this_rq()->cfs == cfs_rq) {
-   /*
-* There are a few boundary cases this might miss but it should
-* get called often enough that that should (hopefully) not be
-* a real problem -- added to that it only calls on the local
-* CPU, so if we enqueue remotely we'll miss an update, but
-* the next tick/schedule should update.
-*
-* It will not get called when we go idle, because the idle
-* thread is a different class (!fair), nor will the utilization
-* number include things like RT tasks.
-*
-* As is, the util number is not freq-invariant (we'd have to
-* implement arch_scale_freq_capacity() for that).
-*
-* See cpu_util().
-*/
-   cpufreq_update_util(rq_of(cfs_rq), 0);
-   }
-}
-
 /*
  * Unsigned subtract and clamp on underflow.
  *
@@ -3544,7 +3544,7 @@ update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq, 
bool update_freq)
 
 static inline void update_load_avg(struct sched_entity *se, int not_used1)
 {
-   cpufreq_update_util(rq_of(cfs_rq_of(se)), 0);
+   cfs_rq_util_change(cfs_rq_of(se));
 }
 
 static inline void


[tip:sched/core] sched/core: Reuse put_prev_task()

2017-08-10 Thread tip-bot for Viresh Kumar
Commit-ID:  5b713a3d949bd7f8c615a335a8c40297586bc1b1
Gitweb: http://git.kernel.org/tip/5b713a3d949bd7f8c615a335a8c40297586bc1b1
Author: Viresh Kumar 
AuthorDate: Wed, 24 May 2017 10:59:53 +0530
Committer:  Ingo Molnar 
CommitDate: Thu, 10 Aug 2017 12:18:10 +0200

sched/core: Reuse put_prev_task()

Reuse put_prev_task() instead of copying its implementation.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Cc: linaro-ker...@lists.linaro.org
Link: 
http://lkml.kernel.org/r/e2e50578223d05c5e90a9feb964fe1ec5d09a052.1495603536.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 0869b20..835a234 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5438,7 +5438,7 @@ static void migrate_tasks(struct rq *dead_rq, struct 
rq_flags *rf)
 */
next = pick_next_task(rq, &fake_task, rf);
BUG_ON(!next);
-   next->sched_class->put_prev_task(rq, next);
+   put_prev_task(rq, next);
 
/*
 * Rules for changing task_struct::cpus_allowed are holding


[tip:sched/core] sched/fair: Pass 'rq' to weighted_cpuload()

2017-08-10 Thread tip-bot for Viresh Kumar
Commit-ID:  c7132dd6f0e3b07bd4541cda9040897cc460d855
Gitweb: http://git.kernel.org/tip/c7132dd6f0e3b07bd4541cda9040897cc460d855
Author: Viresh Kumar 
AuthorDate: Wed, 24 May 2017 10:59:54 +0530
Committer:  Ingo Molnar 
CommitDate: Thu, 10 Aug 2017 12:18:11 +0200

sched/fair: Pass 'rq' to weighted_cpuload()

weighted_cpuload() uses the cpu number passed to it get pointer to the
runqueue. Almost all callers of weighted_cpuload() already have the rq
pointer with them and can send that directly to weighted_cpuload(). In
some cases the callers actually get the CPU number by doing cpu_of(rq).

It would be simpler to pass rq to weighted_cpuload().

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Cc: linaro-ker...@lists.linaro.org
Link: 
http://lkml.kernel.org/r/b7720627e0576dc29b4ba3f9b6edbc913bb4f684.1495603536.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/fair.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 139abf2..27d425e 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1378,7 +1378,7 @@ bool should_numa_migrate_memory(struct task_struct *p, 
struct page * page,
   group_faults_cpu(ng, src_nid) * group_faults(p, dst_nid) * 4;
 }
 
-static unsigned long weighted_cpuload(const int cpu);
+static unsigned long weighted_cpuload(struct rq *rq);
 static unsigned long source_load(int cpu, int type);
 static unsigned long target_load(int cpu, int type);
 static unsigned long capacity_of(int cpu);
@@ -1409,7 +1409,7 @@ static void update_numa_stats(struct numa_stats *ns, int 
nid)
struct rq *rq = cpu_rq(cpu);
 
ns->nr_running += rq->nr_running;
-   ns->load += weighted_cpuload(cpu);
+   ns->load += weighted_cpuload(rq);
ns->compute_capacity += capacity_of(cpu);
 
cpus++;
@@ -5125,9 +5125,9 @@ static void cpu_load_update(struct rq *this_rq, unsigned 
long this_load,
 }
 
 /* Used instead of source_load when we know the type == 0 */
-static unsigned long weighted_cpuload(const int cpu)
+static unsigned long weighted_cpuload(struct rq *rq)
 {
-   return cfs_rq_runnable_load_avg(&cpu_rq(cpu)->cfs);
+   return cfs_rq_runnable_load_avg(&rq->cfs);
 }
 
 #ifdef CONFIG_NO_HZ_COMMON
@@ -5172,7 +5172,7 @@ static void cpu_load_update_idle(struct rq *this_rq)
/*
 * bail if there's load or we're actually up-to-date.
 */
-   if (weighted_cpuload(cpu_of(this_rq)))
+   if (weighted_cpuload(this_rq))
return;
 
cpu_load_update_nohz(this_rq, READ_ONCE(jiffies), 0);
@@ -5193,7 +5193,7 @@ void cpu_load_update_nohz_start(void)
 * concurrently we'll exit nohz. And cpu_load write can race with
 * cpu_load_update_idle() but both updater would be writing the same.
 */
-   this_rq->cpu_load[0] = weighted_cpuload(cpu_of(this_rq));
+   this_rq->cpu_load[0] = weighted_cpuload(this_rq);
 }
 
 /*
@@ -5209,7 +5209,7 @@ void cpu_load_update_nohz_stop(void)
if (curr_jiffies == this_rq->last_load_update_tick)
return;
 
-   load = weighted_cpuload(cpu_of(this_rq));
+   load = weighted_cpuload(this_rq);
rq_lock(this_rq, &rf);
update_rq_clock(this_rq);
cpu_load_update_nohz(this_rq, curr_jiffies, load);
@@ -5235,7 +5235,7 @@ static void cpu_load_update_periodic(struct rq *this_rq, 
unsigned long load)
  */
 void cpu_load_update_active(struct rq *this_rq)
 {
-   unsigned long load = weighted_cpuload(cpu_of(this_rq));
+   unsigned long load = weighted_cpuload(this_rq);
 
if (tick_nohz_tick_stopped())
cpu_load_update_nohz(this_rq, READ_ONCE(jiffies), load);
@@ -5253,7 +5253,7 @@ void cpu_load_update_active(struct rq *this_rq)
 static unsigned long source_load(int cpu, int type)
 {
struct rq *rq = cpu_rq(cpu);
-   unsigned long total = weighted_cpuload(cpu);
+   unsigned long total = weighted_cpuload(rq);
 
if (type == 0 || !sched_feat(LB_BIAS))
return total;
@@ -5268,7 +5268,7 @@ static unsigned long source_load(int cpu, int type)
 static unsigned long target_load(int cpu, int type)
 {
struct rq *rq = cpu_rq(cpu);
-   unsigned long total = weighted_cpuload(cpu);
+   unsigned long total = weighted_cpuload(rq);
 
if (type == 0 || !sched_feat(LB_BIAS))
return total;
@@ -5290,7 +5290,7 @@ static unsigned long cpu_avg_load_per_task(int cpu)
 {
struct rq *rq = cpu_rq(cpu);
unsigned long nr_running = READ_ONCE(rq->cfs.h_nr_running);
-   unsigned long load_avg = weighted_cpuload(cpu);
+   unsigned long load_avg = weighted_cpuload(rq);
 
if (nr_running)
return load_avg / nr_running;
@@ -5550,7 +5550,7 @@ find_idlest_cp

[tip:sched/core] sched/fair: Avoid checking cfs_rq->nr_running twice

2017-08-10 Thread tip-bot for Viresh Kumar
Commit-ID:  9674f5cad22a590c865a330ce333026b9f9c078b
Gitweb: http://git.kernel.org/tip/9674f5cad22a590c865a330ce333026b9f9c078b
Author: Viresh Kumar 
AuthorDate: Wed, 24 May 2017 10:59:55 +0530
Committer:  Ingo Molnar 
CommitDate: Thu, 10 Aug 2017 12:18:11 +0200

sched/fair: Avoid checking cfs_rq->nr_running twice

Rearrange pick_next_task_fair() a bit to avoid checking
cfs_rq->nr_running twice for the case where FAIR_GROUP_SCHED is enabled
and the previous task doesn't belong to the fair class.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Cc: linaro-ker...@lists.linaro.org
Link: 
http://lkml.kernel.org/r/000903ab3df3350943d3271c53615893a230dc95.1495603536.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/fair.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 27d425e..30fd196 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6187,10 +6187,10 @@ pick_next_task_fair(struct rq *rq, struct task_struct 
*prev, struct rq_flags *rf
int new_tasks;
 
 again:
-#ifdef CONFIG_FAIR_GROUP_SCHED
if (!cfs_rq->nr_running)
goto idle;
 
+#ifdef CONFIG_FAIR_GROUP_SCHED
if (prev->sched_class != &fair_sched_class)
goto simple;
 
@@ -6220,11 +6220,17 @@ again:
/*
 * This call to check_cfs_rq_runtime() will do the
 * throttle and dequeue its entity in the parent(s).
-* Therefore the 'simple' nr_running test will indeed
+* Therefore the nr_running test will indeed
 * be correct.
 */
-   if (unlikely(check_cfs_rq_runtime(cfs_rq)))
+   if (unlikely(check_cfs_rq_runtime(cfs_rq))) {
+   cfs_rq = &rq->cfs;
+
+   if (!cfs_rq->nr_running)
+   goto idle;
+
goto simple;
+   }
}
 
se = pick_next_entity(cfs_rq, curr);
@@ -6264,12 +6270,8 @@ again:
 
return p;
 simple:
-   cfs_rq = &rq->cfs;
 #endif
 
-   if (!cfs_rq->nr_running)
-   goto idle;
-
put_prev_task(rq, prev);
 
do {


[tip:sched/core] sched/fair: Drop always true parameter of update_cfs_rq_load_avg()

2017-08-10 Thread tip-bot for Viresh Kumar
Commit-ID:  3a12310d54dbdde6ccbbd519c74c91ba2f52
Gitweb: http://git.kernel.org/tip/3a12310d54dbdde6ccbbd519c74c91ba2f52
Author: Viresh Kumar 
AuthorDate: Wed, 24 May 2017 10:59:56 +0530
Committer:  Ingo Molnar 
CommitDate: Thu, 10 Aug 2017 12:18:12 +0200

sched/fair: Drop always true parameter of update_cfs_rq_load_avg()

update_freq is always true and there is no need to pass it to
update_cfs_rq_load_avg(). Remove it.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Cc: linaro-ker...@lists.linaro.org
Link: 
http://lkml.kernel.org/r/2d28d295f3f591ede7e931462bce1bda5aaa4896.1495603536.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/fair.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 30fd196..75c58c7 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -806,7 +806,7 @@ void post_init_entity_util_avg(struct sched_entity *se)
/*
 * For !fair tasks do:
 *
-   update_cfs_rq_load_avg(now, cfs_rq, false);
+   update_cfs_rq_load_avg(now, cfs_rq);
attach_entity_load_avg(cfs_rq, se);
switched_from_fair(rq, p);
 *
@@ -3320,7 +3320,6 @@ static inline void set_tg_cfs_propagate(struct cfs_rq 
*cfs_rq) {}
  * update_cfs_rq_load_avg - update the cfs_rq's load/util averages
  * @now: current time, as per cfs_rq_clock_task()
  * @cfs_rq: cfs_rq to update
- * @update_freq: should we call cfs_rq_util_change() or will the call do so
  *
  * The cfs_rq avg is the direct sum of all its entities (blocked and runnable)
  * avg. The immediate corollary is that all (fair) tasks must be attached, see
@@ -3334,7 +,7 @@ static inline void set_tg_cfs_propagate(struct cfs_rq 
*cfs_rq) {}
  * call update_tg_load_avg() when this function returns true.
  */
 static inline int
-update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq, bool update_freq)
+update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq)
 {
struct sched_avg *sa = &cfs_rq->avg;
int decayed, removed_load = 0, removed_util = 0;
@@ -3362,7 +3361,7 @@ update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq, 
bool update_freq)
cfs_rq->load_last_update_time_copy = sa->last_update_time;
 #endif
 
-   if (update_freq && (decayed || removed_util))
+   if (decayed || removed_util)
cfs_rq_util_change(cfs_rq);
 
return decayed || removed_load;
@@ -3390,7 +3389,7 @@ static inline void update_load_avg(struct sched_entity 
*se, int flags)
if (se->avg.last_update_time && !(flags & SKIP_AGE_LOAD))
__update_load_avg_se(now, cpu, cfs_rq, se);
 
-   decayed  = update_cfs_rq_load_avg(now, cfs_rq, true);
+   decayed  = update_cfs_rq_load_avg(now, cfs_rq);
decayed |= propagate_entity_load_avg(se);
 
if (decayed && (flags & UPDATE_TG))
@@ -3534,7 +3533,7 @@ static int idle_balance(struct rq *this_rq, struct 
rq_flags *rf);
 #else /* CONFIG_SMP */
 
 static inline int
-update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq, bool update_freq)
+update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq)
 {
return 0;
 }
@@ -6919,7 +6918,7 @@ static void update_blocked_averages(int cpu)
if (throttled_hierarchy(cfs_rq))
continue;
 
-   if (update_cfs_rq_load_avg(cfs_rq_clock_task(cfs_rq), cfs_rq, 
true))
+   if (update_cfs_rq_load_avg(cfs_rq_clock_task(cfs_rq), cfs_rq))
update_tg_load_avg(cfs_rq, 0);
 
/* Propagate pending load changes to the parent, if any: */
@@ -6992,7 +6991,7 @@ static inline void update_blocked_averages(int cpu)
 
rq_lock_irqsave(rq, &rf);
update_rq_clock(rq);
-   update_cfs_rq_load_avg(cfs_rq_clock_task(cfs_rq), cfs_rq, true);
+   update_cfs_rq_load_avg(cfs_rq_clock_task(cfs_rq), cfs_rq);
rq_unlock_irqrestore(rq, &rf);
 }
 


[tip:sched/core] sched/deadline: Don't re-initialize 'struct cpudl'

2017-08-10 Thread tip-bot for Viresh Kumar
Commit-ID:  42d394d41ab90f4ed9d7a7403ed22e8f7590948a
Gitweb: http://git.kernel.org/tip/42d394d41ab90f4ed9d7a7403ed22e8f7590948a
Author: Viresh Kumar 
AuthorDate: Thu, 13 Apr 2017 14:45:49 +0530
Committer:  Ingo Molnar 
CommitDate: Thu, 10 Aug 2017 12:18:13 +0200

sched/deadline: Don't re-initialize 'struct cpudl'

The 'struct cpudl' passed to cpudl_init() is already initialized to zero.
Don't do that again.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Cc: linaro-ker...@lists.linaro.org
Link: 
http://lkml.kernel.org/r/bd4c229806bc96694b15546207afcc221387d2f5.1492065513.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/cpudeadline.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
index fba235c..bdf448b 100644
--- a/kernel/sched/cpudeadline.c
+++ b/kernel/sched/cpudeadline.c
@@ -246,7 +246,6 @@ int cpudl_init(struct cpudl *cp)
 {
int i;
 
-   memset(cp, 0, sizeof(*cp));
raw_spin_lock_init(&cp->lock);
cp->size = 0;
 


[tip:sched/core] sched/topology: Drop memset() from init_rootdomain()

2017-08-10 Thread tip-bot for Viresh Kumar
Commit-ID:  4d13a06d54c415238325b0fe2c14f1052da4512f
Gitweb: http://git.kernel.org/tip/4d13a06d54c415238325b0fe2c14f1052da4512f
Author: Viresh Kumar 
AuthorDate: Thu, 13 Apr 2017 14:45:48 +0530
Committer:  Ingo Molnar 
CommitDate: Thu, 10 Aug 2017 12:18:13 +0200

sched/topology: Drop memset() from init_rootdomain()

There are only two callers of init_rootdomain(). One of them passes a
global to it and another one sends dynamically allocated root-domain.

There is no need to memset the root-domain in the first case as the
structure is already reset.

Update alloc_rootdomain() to allocate the memory with kzalloc() and
remove the memset() call from init_rootdomain().

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Cc: linaro-ker...@lists.linaro.org
Link: 
http://lkml.kernel.org/r/fc2f6cc90b098040970c85a97046512572d765bc.1492065513.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/topology.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 79895ae..216fee0 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -261,8 +261,6 @@ void rq_attach_root(struct rq *rq, struct root_domain *rd)
 
 static int init_rootdomain(struct root_domain *rd)
 {
-   memset(rd, 0, sizeof(*rd));
-
if (!zalloc_cpumask_var(&rd->span, GFP_KERNEL))
goto out;
if (!zalloc_cpumask_var(&rd->online, GFP_KERNEL))
@@ -311,7 +309,7 @@ static struct root_domain *alloc_rootdomain(void)
 {
struct root_domain *rd;
 
-   rd = kmalloc(sizeof(*rd), GFP_KERNEL);
+   rd = kzalloc(sizeof(*rd), GFP_KERNEL);
if (!rd)
return NULL;
 


[tip:sched/core] sched/cpupri: Don't re-initialize 'struct cpupri'

2017-08-10 Thread tip-bot for Viresh Kumar
Commit-ID:  1c2a4861dbfca373fea1ff2cf9e9793933d024ce
Gitweb: http://git.kernel.org/tip/1c2a4861dbfca373fea1ff2cf9e9793933d024ce
Author: Viresh Kumar 
AuthorDate: Thu, 13 Apr 2017 14:45:50 +0530
Committer:  Ingo Molnar 
CommitDate: Thu, 10 Aug 2017 12:18:14 +0200

sched/cpupri: Don't re-initialize 'struct cpupri'

The 'struct cpupri' passed to cpupri_init() is already initialized to
zero. Don't do that again.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Cc: linaro-ker...@lists.linaro.org
Link: 
http://lkml.kernel.org/r/8a71d48c5a077500b6ddc1a41484c0ac8d3aad94.1492065513.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/cpupri.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/sched/cpupri.c b/kernel/sched/cpupri.c
index 981fcd7..2511aba 100644
--- a/kernel/sched/cpupri.c
+++ b/kernel/sched/cpupri.c
@@ -209,8 +209,6 @@ int cpupri_init(struct cpupri *cp)
 {
int i;
 
-   memset(cp, 0, sizeof(*cp));
-
for (i = 0; i < CPUPRI_NR_PRIORITIES; i++) {
struct cpupri_vec *vec = &cp->pri_to_cpu[i];
 


[tip:sched/core] sched: Mark pick_next_task_dl() and build_sched_domain() as static

2017-08-10 Thread tip-bot for Viresh Kumar
Commit-ID:  181a80d1f7f453f58c4b47f89084d0849632858c
Gitweb: http://git.kernel.org/tip/181a80d1f7f453f58c4b47f89084d0849632858c
Author: Viresh Kumar 
AuthorDate: Thu, 27 Apr 2017 13:58:59 +0530
Committer:  Ingo Molnar 
CommitDate: Thu, 10 Aug 2017 12:18:14 +0200

sched: Mark pick_next_task_dl() and build_sched_domain() as static

pick_next_task_dl() and build_sched_domain() aren't used outside
deadline.c and topology.c.

Make them static.

Signed-off-by: Viresh Kumar 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vincent Guittot 
Cc: linaro-ker...@lists.linaro.org
Link: 
http://lkml.kernel.org/r/36e4cbb6210002cadae89920ae97e19e7e513008.1493281605.git.viresh.ku...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/deadline.c | 2 +-
 kernel/sched/topology.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 755bd3f..a205ac7 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1655,7 +1655,7 @@ static struct sched_dl_entity *pick_next_dl_entity(struct 
rq *rq,
return rb_entry(left, struct sched_dl_entity, rb_node);
 }
 
-struct task_struct *
+static struct task_struct *
 pick_next_task_dl(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
 {
struct sched_dl_entity *dl_se;
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 216fee0..bd8b6d6 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -1593,7 +1593,7 @@ static void __sdt_free(const struct cpumask *cpu_map)
}
 }
 
-struct sched_domain *build_sched_domain(struct sched_domain_topology_level *tl,
+static struct sched_domain *build_sched_domain(struct 
sched_domain_topology_level *tl,
const struct cpumask *cpu_map, struct sched_domain_attr *attr,
struct sched_domain *child, int cpu)
 {