Skip to content

Commit

Permalink
Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/kernel/git/tip/tip

Pull scheduler updates from Ingo Molnar:
 "The main changes in this cycle were:

   - Make nohz housekeeping processing more permissive and less
     intrusive to isolated CPUs

   - Decouple CPU-bound workqueue acconting from the scheduler and move
     it into the workqueue code.

   - Optimize topology building

   - Better handle quota and period overflows

   - Add more RCU annotations

   - Comment updates, misc cleanups"

* 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (25 commits)
  nohz_full: Allow the boot CPU to be nohz_full
  sched/isolation: Require a present CPU in housekeeping mask
  kernel/cpu: Allow non-zero CPU to be primary for suspend / kexec freeze
  power/suspend: Add function to disable secondaries for suspend
  sched/core: Allow the remote scheduler tick to be started on CPU0
  sched/nohz: Run NOHZ idle load balancer on HK_FLAG_MISC CPUs
  sched/debug: Fix spelling mistake "logaritmic" -> "logarithmic"
  sched/topology: Update init_sched_domains() comment
  cgroup/cpuset: Update stale generate_sched_domains() comments
  sched/core: Check quota and period overflow at usec to nsec conversion
  sched/core: Handle overflow in cpu_shares_write_u64
  sched/rt: Check integer overflow at usec to nsec conversion
  sched/core: Fix typo in comment
  sched/core: Make some functions static
  sched/core: Unify p->on_rq updates
  sched/core: Remove ttwu_activate()
  sched/core, workqueues: Distangle worker accounting from rq lock
  sched/fair: Remove unneeded prototype of capacity_of()
  sched/topology: Skip duplicate group rewrites in build_sched_groups()
  sched/topology: Fix build_sched_groups() comment
  ...
  • Loading branch information
torvalds committed May 6, 2019
2 parents 90489a7 + 08ae95f commit e00d413
Show file tree
Hide file tree
Showing 22 changed files with 255 additions and 193 deletions.
4 changes: 4 additions & 0 deletions arch/powerpc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ config ARCH_SUSPEND_POSSIBLE
(PPC_85xx && !PPC_E500MC) || PPC_86xx || PPC_PSERIES \
|| 44x || 40x

config ARCH_SUSPEND_NONZERO_CPU
def_bool y
depends on PPC_POWERNV || PPC_PSERIES

config PPC_DCR_NATIVE
bool

Expand Down
17 changes: 17 additions & 0 deletions include/linux/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,26 @@ static inline int disable_nonboot_cpus(void)
return freeze_secondary_cpus(0);
}
extern void enable_nonboot_cpus(void);

static inline int suspend_disable_secondary_cpus(void)
{
int cpu = 0;

if (IS_ENABLED(CONFIG_PM_SLEEP_SMP_NONZERO_CPU))
cpu = -1;

return freeze_secondary_cpus(cpu);
}
static inline void suspend_enable_secondary_cpus(void)
{
return enable_nonboot_cpus();
}

#else /* !CONFIG_PM_SLEEP_SMP */
static inline int disable_nonboot_cpus(void) { return 0; }
static inline void enable_nonboot_cpus(void) {}
static inline int suspend_disable_secondary_cpus(void) { return 0; }
static inline void suspend_enable_secondary_cpus(void) { }
#endif /* !CONFIG_PM_SLEEP_SMP */

void cpu_startup_entry(enum cpuhp_state state);
Expand Down
2 changes: 1 addition & 1 deletion include/linux/rcuwait.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* awoken.
*/
struct rcuwait {
struct task_struct *task;
struct task_struct __rcu *task;
};

#define __RCUWAIT_INITIALIZER(name) \
Expand Down
4 changes: 2 additions & 2 deletions include/linux/sched/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ struct sched_domain_shared {

struct sched_domain {
/* These fields must be setup */
struct sched_domain *parent; /* top domain must be null terminated */
struct sched_domain *child; /* bottom domain must be null terminated */
struct sched_domain __rcu *parent; /* top domain must be null terminated */
struct sched_domain __rcu *child; /* bottom domain must be null terminated */
struct sched_group *groups; /* the balancing groups of the domain */
unsigned long min_interval; /* Minimum balance interval ms */
unsigned long max_interval; /* Maximum balance interval ms */
Expand Down
11 changes: 5 additions & 6 deletions kernel/cgroup/cpuset.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,11 +740,10 @@ static inline int nr_cpusets(void)
* Must be called with cpuset_mutex held.
*
* The three key local variables below are:
* q - a linked-list queue of cpuset pointers, used to implement a
* top-down scan of all cpusets. This scan loads a pointer
* to each cpuset marked is_sched_load_balance into the
* array 'csa'. For our purposes, rebuilding the schedulers
* sched domains, we can ignore !is_sched_load_balance cpusets.
* cp - cpuset pointer, used (together with pos_css) to perform a
* top-down scan of all cpusets. For our purposes, rebuilding
* the schedulers sched domains, we can ignore !is_sched_load_
* balance cpusets.
* csa - (for CpuSet Array) Array of pointers to all the cpusets
* that need to be load balanced, for convenient iterative
* access by the subsequent code that finds the best partition,
Expand Down Expand Up @@ -775,7 +774,7 @@ static inline int nr_cpusets(void)
static int generate_sched_domains(cpumask_var_t **domains,
struct sched_domain_attr **attributes)
{
struct cpuset *cp; /* scans q */
struct cpuset *cp; /* top-down scan of cpusets */
struct cpuset **csa; /* array of all cpuset ptrs */
int csn; /* how many cpuset ptrs in csa so far */
int i, j, k; /* indices for partition finding loops */
Expand Down
10 changes: 9 additions & 1 deletion kernel/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/notifier.h>
#include <linux/sched/signal.h>
#include <linux/sched/hotplug.h>
#include <linux/sched/isolation.h>
#include <linux/sched/task.h>
#include <linux/sched/smt.h>
#include <linux/unistd.h>
Expand Down Expand Up @@ -1199,8 +1200,15 @@ int freeze_secondary_cpus(int primary)
int cpu, error = 0;

cpu_maps_update_begin();
if (!cpu_online(primary))
if (primary == -1) {
primary = cpumask_first(cpu_online_mask);
if (!housekeeping_cpu(primary, HK_FLAG_TIMER))
primary = housekeeping_any_cpu(HK_FLAG_TIMER);
} else {
if (!cpu_online(primary))
primary = cpumask_first(cpu_online_mask);
}

/*
* We take down all of the non-boot CPUs in one shot to avoid races
* with the userspace trying to use the CPU hotplug at the same time
Expand Down
4 changes: 2 additions & 2 deletions kernel/kexec_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ int kernel_kexec(void)
error = dpm_suspend_end(PMSG_FREEZE);
if (error)
goto Resume_devices;
error = disable_nonboot_cpus();
error = suspend_disable_secondary_cpus();
if (error)
goto Enable_cpus;
local_irq_disable();
Expand Down Expand Up @@ -1183,7 +1183,7 @@ int kernel_kexec(void)
Enable_irqs:
local_irq_enable();
Enable_cpus:
enable_nonboot_cpus();
suspend_enable_secondary_cpus();
dpm_resume_start(PMSG_RESTORE);
Resume_devices:
dpm_resume_end(PMSG_RESTORE);
Expand Down
9 changes: 9 additions & 0 deletions kernel/power/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ config PM_SLEEP_SMP
depends on PM_SLEEP
select HOTPLUG_CPU

config PM_SLEEP_SMP_NONZERO_CPU
def_bool y
depends on PM_SLEEP_SMP
depends on ARCH_SUSPEND_NONZERO_CPU
---help---
If an arch can suspend (for suspend, hibernate, kexec, etc) on a
non-zero numbered CPU, it may define ARCH_SUSPEND_NONZERO_CPU. This
will allow nohz_full mask to include CPU0.

config PM_AUTOSLEEP
bool "Opportunistic sleep"
depends on PM_SLEEP
Expand Down
12 changes: 6 additions & 6 deletions kernel/power/hibernate.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ static int create_image(int platform_mode)
if (error || hibernation_test(TEST_PLATFORM))
goto Platform_finish;

error = disable_nonboot_cpus();
error = suspend_disable_secondary_cpus();
if (error || hibernation_test(TEST_CPUS))
goto Enable_cpus;

Expand Down Expand Up @@ -323,7 +323,7 @@ static int create_image(int platform_mode)
local_irq_enable();

Enable_cpus:
enable_nonboot_cpus();
suspend_enable_secondary_cpus();

Platform_finish:
platform_finish(platform_mode);
Expand Down Expand Up @@ -417,7 +417,7 @@ int hibernation_snapshot(int platform_mode)

int __weak hibernate_resume_nonboot_cpu_disable(void)
{
return disable_nonboot_cpus();
return suspend_disable_secondary_cpus();
}

/**
Expand Down Expand Up @@ -486,7 +486,7 @@ static int resume_target_kernel(bool platform_mode)
local_irq_enable();

Enable_cpus:
enable_nonboot_cpus();
suspend_enable_secondary_cpus();

Cleanup:
platform_restore_cleanup(platform_mode);
Expand Down Expand Up @@ -564,7 +564,7 @@ int hibernation_platform_enter(void)
if (error)
goto Platform_finish;

error = disable_nonboot_cpus();
error = suspend_disable_secondary_cpus();
if (error)
goto Enable_cpus;

Expand All @@ -586,7 +586,7 @@ int hibernation_platform_enter(void)
local_irq_enable();

Enable_cpus:
enable_nonboot_cpus();
suspend_enable_secondary_cpus();

Platform_finish:
hibernation_ops->finish();
Expand Down
4 changes: 2 additions & 2 deletions kernel/power/suspend.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
if (suspend_test(TEST_PLATFORM))
goto Platform_wake;

error = disable_nonboot_cpus();
error = suspend_disable_secondary_cpus();
if (error || suspend_test(TEST_CPUS))
goto Enable_cpus;

Expand Down Expand Up @@ -458,7 +458,7 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
BUG_ON(irqs_disabled());

Enable_cpus:
enable_nonboot_cpus();
suspend_enable_secondary_cpus();

Platform_wake:
platform_resume_noirq(state);
Expand Down
Loading

0 comments on commit e00d413

Please sign in to comment.