License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* include/linux/cpu.h - generic cpu definition
|
|
|
|
*
|
|
|
|
* This is mainly for topological representation. We define the
|
|
|
|
* basic 'struct cpu' here, which can be embedded in per-arch
|
|
|
|
* definitions of processors.
|
|
|
|
*
|
|
|
|
* Basic handling of the devices is done in drivers/base/cpu.c
|
|
|
|
*
|
2013-05-03 18:45:48 +08:00
|
|
|
* CPUs are exported via sysfs in the devices/system/cpu
|
2005-04-17 06:20:36 +08:00
|
|
|
* directory.
|
|
|
|
*/
|
|
|
|
#ifndef _LINUX_CPU_H_
|
|
|
|
#define _LINUX_CPU_H_
|
|
|
|
|
|
|
|
#include <linux/node.h>
|
|
|
|
#include <linux/compiler.h>
|
|
|
|
#include <linux/cpumask.h>
|
2016-02-27 02:43:28 +08:00
|
|
|
#include <linux/cpuhotplug.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-01-31 00:46:54 +08:00
|
|
|
struct device;
|
2013-10-04 05:24:51 +08:00
|
|
|
struct device_node;
|
2014-09-30 21:48:24 +08:00
|
|
|
struct attribute_group;
|
2012-01-31 00:46:54 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
struct cpu {
|
|
|
|
int node_id; /* The node which contains the CPU */
|
2006-12-07 09:14:10 +08:00
|
|
|
int hotpluggable; /* creates sysfs control file if hotpluggable */
|
2011-12-22 06:29:42 +08:00
|
|
|
struct device dev;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2016-02-27 02:43:28 +08:00
|
|
|
extern void boot_cpu_init(void);
|
init: rename and re-order boot_cpu_state_init()
This is purely a preparatory patch for upcoming changes during the 4.19
merge window.
We have a function called "boot_cpu_state_init()" that isn't really
about the bootup cpu state: that is done much earlier by the similarly
named "boot_cpu_init()" (note lack of "state" in name).
This function initializes some hotplug CPU state, and needs to run after
the percpu data has been properly initialized. It even has a comment to
that effect.
Except it _doesn't_ actually run after the percpu data has been properly
initialized. On x86 it happens to do that, but on at least arm and
arm64, the percpu base pointers are initialized by the arch-specific
'smp_prepare_boot_cpu()' hook, which ran _after_ boot_cpu_state_init().
This had some unexpected results, and in particular we have a patch
pending for the merge window that did the obvious cleanup of using
'this_cpu_write()' in the cpu hotplug init code:
- per_cpu_ptr(&cpuhp_state, smp_processor_id())->state = CPUHP_ONLINE;
+ this_cpu_write(cpuhp_state.state, CPUHP_ONLINE);
which is obviously the right thing to do. Except because of the
ordering issue, it actually failed miserably and unexpectedly on arm64.
So this just fixes the ordering, and changes the name of the function to
be 'boot_cpu_hotplug_init()' to make it obvious that it's about cpu
hotplug state, because the core CPU state was supposed to have already
been done earlier.
Marked for stable, since the (not yet merged) patch that will show this
problem is marked for stable.
Reported-by: Vlastimil Babka <vbabka@suse.cz>
Reported-by: Mian Yousaf Kaukab <yousaf.kaukab@suse.com>
Suggested-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-13 03:19:42 +08:00
|
|
|
extern void boot_cpu_hotplug_init(void);
|
2017-02-05 21:47:12 +08:00
|
|
|
extern void cpu_init(void);
|
|
|
|
extern void trap_init(void);
|
2016-02-27 02:43:28 +08:00
|
|
|
|
[PATCH] node hotplug: register cpu: remove node struct
With Goto-san's patch, we can add new pgdat/node at runtime. I'm now
considering node-hot-add with cpu + memory on ACPI.
I found acpi container, which describes node, could evaluate cpu before
memory. This means cpu-hot-add occurs before memory hot add.
In most part, cpu-hot-add doesn't depend on node hot add. But register_cpu(),
which creates symbolic link from node to cpu, requires that node should be
onlined before register_cpu(). When a node is onlined, its pgdat should be
there.
This patch-set holds off creating symbolic link from node to cpu
until node is onlined.
This removes node arguments from register_cpu().
Now, register_cpu() requires 'struct node' as its argument. But the array of
struct node is now unified in driver/base/node.c now (By Goto's node hotplug
patch). We can get struct node in generic way. So, this argument is not
necessary now.
This patch also guarantees add cpu under node only when node is onlined. It
is necessary for node-hot-add vs. cpu-hot-add patch following this.
Moreover, register_cpu calculates cpu->node_id by cpu_to_node() without regard
to its 'struct node *root' argument. This patch removes it.
Also modify callers of register_cpu()/unregister_cpu, whose args are changed
by register-cpu-remove-node-struct patch.
[Brice.Goglin@ens-lyon.org: fix it]
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: Ashok Raj <ashok.raj@intel.com>
Cc: Dave Hansen <haveblue@us.ibm.com>
Signed-off-by: Brice Goglin <Brice.Goglin@ens-lyon.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-27 17:53:41 +08:00
|
|
|
extern int register_cpu(struct cpu *cpu, int num);
|
2011-12-22 06:29:42 +08:00
|
|
|
extern struct device *get_cpu_device(unsigned cpu);
|
2011-12-04 05:06:50 +08:00
|
|
|
extern bool cpu_is_hotpluggable(unsigned cpu);
|
2013-08-15 21:01:40 +08:00
|
|
|
extern bool arch_match_cpu_phys_id(int cpu, u64 phys_id);
|
2013-10-04 05:24:51 +08:00
|
|
|
extern bool arch_find_n_match_cpu_physical_id(struct device_node *cpun,
|
|
|
|
int cpu, unsigned int *thread);
|
2006-10-25 00:31:24 +08:00
|
|
|
|
2011-12-22 06:29:42 +08:00
|
|
|
extern int cpu_add_dev_attr(struct device_attribute *attr);
|
|
|
|
extern void cpu_remove_dev_attr(struct device_attribute *attr);
|
2006-10-25 00:31:24 +08:00
|
|
|
|
2011-12-22 06:29:42 +08:00
|
|
|
extern int cpu_add_dev_attr_group(struct attribute_group *attrs);
|
|
|
|
extern void cpu_remove_dev_attr_group(struct attribute_group *attrs);
|
2006-10-25 00:31:24 +08:00
|
|
|
|
2018-01-08 05:48:00 +08:00
|
|
|
extern ssize_t cpu_show_meltdown(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf);
|
|
|
|
extern ssize_t cpu_show_spectre_v1(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf);
|
|
|
|
extern ssize_t cpu_show_spectre_v2(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf);
|
2018-04-26 10:04:20 +08:00
|
|
|
extern ssize_t cpu_show_spec_store_bypass(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf);
|
2018-06-14 06:48:26 +08:00
|
|
|
extern ssize_t cpu_show_l1tf(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf);
|
2018-01-08 05:48:00 +08:00
|
|
|
|
2015-07-18 07:23:42 +08:00
|
|
|
extern __printf(4, 5)
|
|
|
|
struct device *cpu_device_create(struct device *parent, void *drvdata,
|
|
|
|
const struct attribute_group **groups,
|
|
|
|
const char *fmt, ...);
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
[PATCH] node hotplug: register cpu: remove node struct
With Goto-san's patch, we can add new pgdat/node at runtime. I'm now
considering node-hot-add with cpu + memory on ACPI.
I found acpi container, which describes node, could evaluate cpu before
memory. This means cpu-hot-add occurs before memory hot add.
In most part, cpu-hot-add doesn't depend on node hot add. But register_cpu(),
which creates symbolic link from node to cpu, requires that node should be
onlined before register_cpu(). When a node is onlined, its pgdat should be
there.
This patch-set holds off creating symbolic link from node to cpu
until node is onlined.
This removes node arguments from register_cpu().
Now, register_cpu() requires 'struct node' as its argument. But the array of
struct node is now unified in driver/base/node.c now (By Goto's node hotplug
patch). We can get struct node in generic way. So, this argument is not
necessary now.
This patch also guarantees add cpu under node only when node is onlined. It
is necessary for node-hot-add vs. cpu-hot-add patch following this.
Moreover, register_cpu calculates cpu->node_id by cpu_to_node() without regard
to its 'struct node *root' argument. This patch removes it.
Also modify callers of register_cpu()/unregister_cpu, whose args are changed
by register-cpu-remove-node-struct patch.
[Brice.Goglin@ens-lyon.org: fix it]
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: Ashok Raj <ashok.raj@intel.com>
Cc: Dave Hansen <haveblue@us.ibm.com>
Signed-off-by: Brice Goglin <Brice.Goglin@ens-lyon.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-27 17:53:41 +08:00
|
|
|
extern void unregister_cpu(struct cpu *cpu);
|
2009-11-26 01:23:25 +08:00
|
|
|
extern ssize_t arch_cpu_probe(const char *, size_t);
|
|
|
|
extern ssize_t arch_cpu_release(const char *, size_t);
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
|
2017-11-13 16:39:01 +08:00
|
|
|
/*
|
|
|
|
* These states are not related to the core CPU hotplug mechanism. They are
|
|
|
|
* used by various (sub)architectures to track internal state
|
2011-07-26 08:13:08 +08:00
|
|
|
*/
|
2017-11-13 16:39:01 +08:00
|
|
|
#define CPU_ONLINE 0x0002 /* CPU is up */
|
|
|
|
#define CPU_UP_PREPARE 0x0003 /* CPU coming up */
|
|
|
|
#define CPU_DEAD 0x0007 /* CPU dead */
|
|
|
|
#define CPU_DEAD_FROZEN 0x0008 /* CPU timed out on unplug */
|
|
|
|
#define CPU_POST_DEAD 0x0009 /* CPU successfully unplugged */
|
|
|
|
#define CPU_BROKEN 0x000B /* CPU did not die properly */
|
2011-07-26 08:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef CONFIG_SMP
|
2016-02-27 02:43:23 +08:00
|
|
|
extern bool cpuhp_tasks_frozen;
|
2005-04-17 06:20:36 +08:00
|
|
|
int cpu_up(unsigned int cpu);
|
2008-09-07 22:57:22 +08:00
|
|
|
void notify_cpu_starting(unsigned int cpu);
|
2008-07-25 16:47:50 +08:00
|
|
|
extern void cpu_maps_update_begin(void);
|
|
|
|
extern void cpu_maps_update_done(void);
|
2008-01-26 04:08:02 +08:00
|
|
|
|
2008-07-25 16:47:50 +08:00
|
|
|
#else /* CONFIG_SMP */
|
2016-02-27 02:43:23 +08:00
|
|
|
#define cpuhp_tasks_frozen 0
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-25 16:47:50 +08:00
|
|
|
static inline void cpu_maps_update_begin(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void cpu_maps_update_done(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* CONFIG_SMP */
|
2011-12-22 06:29:42 +08:00
|
|
|
extern struct bus_type cpu_subsys;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
2017-05-24 16:15:12 +08:00
|
|
|
extern void cpus_write_lock(void);
|
|
|
|
extern void cpus_write_unlock(void);
|
|
|
|
extern void cpus_read_lock(void);
|
|
|
|
extern void cpus_read_unlock(void);
|
2018-07-25 02:26:04 +08:00
|
|
|
extern int cpus_read_trylock(void);
|
2017-05-24 16:15:40 +08:00
|
|
|
extern void lockdep_assert_cpus_held(void);
|
2013-06-13 05:04:36 +08:00
|
|
|
extern void cpu_hotplug_disable(void);
|
|
|
|
extern void cpu_hotplug_enable(void);
|
cpu: introduce clear_tasks_mm_cpumask() helper
Many architectures clear tasks' mm_cpumask like this:
read_lock(&tasklist_lock);
for_each_process(p) {
if (p->mm)
cpumask_clear_cpu(cpu, mm_cpumask(p->mm));
}
read_unlock(&tasklist_lock);
Depending on the context, the code above may have several problems,
such as:
1. Working with task->mm w/o getting mm or grabing the task lock is
dangerous as ->mm might disappear (exit_mm() assigns NULL under
task_lock(), so tasklist lock is not enough).
2. Checking for process->mm is not enough because process' main
thread may exit or detach its mm via use_mm(), but other threads
may still have a valid mm.
This patch implements a small helper function that does things
correctly, i.e.:
1. We take the task's lock while whe handle its mm (we can't use
get_task_mm()/mmput() pair as mmput() might sleep);
2. To catch exited main thread case, we use find_lock_task_mm(),
which walks up all threads and returns an appropriate task
(with task lock held).
Also, Per Peter Zijlstra's idea, now we don't grab tasklist_lock in
the new helper, instead we take the rcu read lock. We can do this
because the function is called after the cpu is taken down and marked
offline, so no new tasks will get this cpu set in their mm mask.
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-06-01 07:26:22 +08:00
|
|
|
void clear_tasks_mm_cpumask(int cpu);
|
2005-04-17 06:20:36 +08:00
|
|
|
int cpu_down(unsigned int cpu);
|
2006-12-07 12:38:58 +08:00
|
|
|
|
2017-05-24 16:15:12 +08:00
|
|
|
#else /* CONFIG_HOTPLUG_CPU */
|
|
|
|
|
|
|
|
static inline void cpus_write_lock(void) { }
|
|
|
|
static inline void cpus_write_unlock(void) { }
|
|
|
|
static inline void cpus_read_lock(void) { }
|
|
|
|
static inline void cpus_read_unlock(void) { }
|
2018-07-25 02:26:04 +08:00
|
|
|
static inline int cpus_read_trylock(void) { return true; }
|
2017-05-24 16:15:13 +08:00
|
|
|
static inline void lockdep_assert_cpus_held(void) { }
|
2017-05-24 16:15:12 +08:00
|
|
|
static inline void cpu_hotplug_disable(void) { }
|
|
|
|
static inline void cpu_hotplug_enable(void) { }
|
|
|
|
#endif /* !CONFIG_HOTPLUG_CPU */
|
|
|
|
|
|
|
|
/* Wrappers which go away once all code is converted */
|
|
|
|
static inline void cpu_hotplug_begin(void) { cpus_write_lock(); }
|
|
|
|
static inline void cpu_hotplug_done(void) { cpus_write_unlock(); }
|
|
|
|
static inline void get_online_cpus(void) { cpus_read_lock(); }
|
|
|
|
static inline void put_online_cpus(void) { cpus_read_unlock(); }
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-08-31 14:56:29 +08:00
|
|
|
#ifdef CONFIG_PM_SLEEP_SMP
|
2016-08-17 20:50:25 +08:00
|
|
|
extern int freeze_secondary_cpus(int primary);
|
|
|
|
static inline int disable_nonboot_cpus(void)
|
|
|
|
{
|
|
|
|
return freeze_secondary_cpus(0);
|
|
|
|
}
|
2006-09-26 14:32:48 +08:00
|
|
|
extern void enable_nonboot_cpus(void);
|
2007-08-31 14:56:29 +08:00
|
|
|
#else /* !CONFIG_PM_SLEEP_SMP */
|
2006-09-26 14:32:48 +08:00
|
|
|
static inline int disable_nonboot_cpus(void) { return 0; }
|
|
|
|
static inline void enable_nonboot_cpus(void) {}
|
2007-08-31 14:56:29 +08:00
|
|
|
#endif /* !CONFIG_PM_SLEEP_SMP */
|
2006-09-26 14:32:48 +08:00
|
|
|
|
2013-03-22 05:49:34 +08:00
|
|
|
void cpu_startup_entry(enum cpuhp_state state);
|
|
|
|
|
2013-03-22 05:49:35 +08:00
|
|
|
void cpu_idle_poll_ctrl(bool enable);
|
|
|
|
|
2016-10-08 08:02:55 +08:00
|
|
|
/* Attach to any functions which should be considered cpuidle. */
|
|
|
|
#define __cpuidle __attribute__((__section__(".cpuidle.text")))
|
|
|
|
|
|
|
|
bool cpu_in_idle(unsigned long pc);
|
|
|
|
|
2013-03-22 05:49:35 +08:00
|
|
|
void arch_cpu_idle(void);
|
|
|
|
void arch_cpu_idle_prepare(void);
|
|
|
|
void arch_cpu_idle_enter(void);
|
|
|
|
void arch_cpu_idle_exit(void);
|
|
|
|
void arch_cpu_idle_dead(void);
|
|
|
|
|
smpboot: Add common code for notification from dying CPU
RCU ignores offlined CPUs, so they cannot safely run RCU read-side code.
(They -can- use SRCU, but not RCU.) This means that any use of RCU
during or after the call to arch_cpu_idle_dead(). Unfortunately,
commit 2ed53c0d6cc99 added a complete() call, which will contain RCU
read-side critical sections if there is a task waiting to be awakened.
Which, as it turns out, there almost never is. In my qemu/KVM testing,
the to-be-awakened task is not yet asleep more than 99.5% of the time.
In current mainline, failure is even harder to reproduce, requiring a
virtualized environment that delays the outgoing CPU by at least three
jiffies between the time it exits its stop_machine() task at CPU_DYING
time and the time it calls arch_cpu_idle_dead() from the idle loop.
However, this problem really can occur, especially in virtualized
environments, and therefore really does need to be fixed
This suggests moving back to the polling loop, but using a much shorter
wait, with gentle exponential backoff instead of the old 100-millisecond
wait. Most of the time, the loop will exit without waiting at all,
and almost all of the remaining uses will wait only five microseconds.
If the outgoing CPU is preempted, a loop will wait one jiffy, then
increase the wait by a factor of 11/10ths, rounding up. As before, there
is a five-second timeout.
This commit therefore provides common-code infrastructure to do the
dying-to-surviving CPU handoff in a safe manner. This code also
provides an indication at CPU-online of whether the CPU to be onlined
previously timed out on offline. The new cpu_check_up_prepare() function
returns -EBUSY if this CPU previously took more than five seconds to
go offline, or -EAGAIN if it has not yet managed to go offline. The
rationale for -EAGAIN is that it might still be preempted, so an additional
wait might well find it correctly offlined. Architecture-specific code
can decide how to handle these conditions. Systems in which CPUs take
themselves completely offline might respond to an -EBUSY return as if
it was a zero (success) return. Systems in which the surviving CPU must
take some action might take it at this time, or might simply mark the
other CPU as unusable.
Note that architectures that take the easy way out and simply pass the
-EBUSY and -EAGAIN upwards will change the sysfs API.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: <linux-api@vger.kernel.org>
Cc: <linux-arch@vger.kernel.org>
[ paulmck: Fixed state machine for architectures that don't check earlier
CPU-hotplug results as suggested by James Hogan. ]
2015-02-26 02:34:39 +08:00
|
|
|
int cpu_report_state(int cpu);
|
|
|
|
int cpu_check_up_prepare(int cpu);
|
|
|
|
void cpu_set_state_online(int cpu);
|
2016-11-29 15:03:05 +08:00
|
|
|
void play_idle(unsigned long duration_ms);
|
|
|
|
|
smpboot: Add common code for notification from dying CPU
RCU ignores offlined CPUs, so they cannot safely run RCU read-side code.
(They -can- use SRCU, but not RCU.) This means that any use of RCU
during or after the call to arch_cpu_idle_dead(). Unfortunately,
commit 2ed53c0d6cc99 added a complete() call, which will contain RCU
read-side critical sections if there is a task waiting to be awakened.
Which, as it turns out, there almost never is. In my qemu/KVM testing,
the to-be-awakened task is not yet asleep more than 99.5% of the time.
In current mainline, failure is even harder to reproduce, requiring a
virtualized environment that delays the outgoing CPU by at least three
jiffies between the time it exits its stop_machine() task at CPU_DYING
time and the time it calls arch_cpu_idle_dead() from the idle loop.
However, this problem really can occur, especially in virtualized
environments, and therefore really does need to be fixed
This suggests moving back to the polling loop, but using a much shorter
wait, with gentle exponential backoff instead of the old 100-millisecond
wait. Most of the time, the loop will exit without waiting at all,
and almost all of the remaining uses will wait only five microseconds.
If the outgoing CPU is preempted, a loop will wait one jiffy, then
increase the wait by a factor of 11/10ths, rounding up. As before, there
is a five-second timeout.
This commit therefore provides common-code infrastructure to do the
dying-to-surviving CPU handoff in a safe manner. This code also
provides an indication at CPU-online of whether the CPU to be onlined
previously timed out on offline. The new cpu_check_up_prepare() function
returns -EBUSY if this CPU previously took more than five seconds to
go offline, or -EAGAIN if it has not yet managed to go offline. The
rationale for -EAGAIN is that it might still be preempted, so an additional
wait might well find it correctly offlined. Architecture-specific code
can decide how to handle these conditions. Systems in which CPUs take
themselves completely offline might respond to an -EBUSY return as if
it was a zero (success) return. Systems in which the surviving CPU must
take some action might take it at this time, or might simply mark the
other CPU as unusable.
Note that architectures that take the easy way out and simply pass the
-EBUSY and -EAGAIN upwards will change the sysfs API.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: <linux-api@vger.kernel.org>
Cc: <linux-arch@vger.kernel.org>
[ paulmck: Fixed state machine for architectures that don't check earlier
CPU-hotplug results as suggested by James Hogan. ]
2015-02-26 02:34:39 +08:00
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
|
|
bool cpu_wait_death(unsigned int cpu, int seconds);
|
|
|
|
bool cpu_report_death(void);
|
2016-02-27 02:43:43 +08:00
|
|
|
void cpuhp_report_idle_dead(void);
|
|
|
|
#else
|
|
|
|
static inline void cpuhp_report_idle_dead(void) { }
|
smpboot: Add common code for notification from dying CPU
RCU ignores offlined CPUs, so they cannot safely run RCU read-side code.
(They -can- use SRCU, but not RCU.) This means that any use of RCU
during or after the call to arch_cpu_idle_dead(). Unfortunately,
commit 2ed53c0d6cc99 added a complete() call, which will contain RCU
read-side critical sections if there is a task waiting to be awakened.
Which, as it turns out, there almost never is. In my qemu/KVM testing,
the to-be-awakened task is not yet asleep more than 99.5% of the time.
In current mainline, failure is even harder to reproduce, requiring a
virtualized environment that delays the outgoing CPU by at least three
jiffies between the time it exits its stop_machine() task at CPU_DYING
time and the time it calls arch_cpu_idle_dead() from the idle loop.
However, this problem really can occur, especially in virtualized
environments, and therefore really does need to be fixed
This suggests moving back to the polling loop, but using a much shorter
wait, with gentle exponential backoff instead of the old 100-millisecond
wait. Most of the time, the loop will exit without waiting at all,
and almost all of the remaining uses will wait only five microseconds.
If the outgoing CPU is preempted, a loop will wait one jiffy, then
increase the wait by a factor of 11/10ths, rounding up. As before, there
is a five-second timeout.
This commit therefore provides common-code infrastructure to do the
dying-to-surviving CPU handoff in a safe manner. This code also
provides an indication at CPU-online of whether the CPU to be onlined
previously timed out on offline. The new cpu_check_up_prepare() function
returns -EBUSY if this CPU previously took more than five seconds to
go offline, or -EAGAIN if it has not yet managed to go offline. The
rationale for -EAGAIN is that it might still be preempted, so an additional
wait might well find it correctly offlined. Architecture-specific code
can decide how to handle these conditions. Systems in which CPUs take
themselves completely offline might respond to an -EBUSY return as if
it was a zero (success) return. Systems in which the surviving CPU must
take some action might take it at this time, or might simply mark the
other CPU as unusable.
Note that architectures that take the easy way out and simply pass the
-EBUSY and -EAGAIN upwards will change the sysfs API.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: <linux-api@vger.kernel.org>
Cc: <linux-arch@vger.kernel.org>
[ paulmck: Fixed state machine for architectures that don't check earlier
CPU-hotplug results as suggested by James Hogan. ]
2015-02-26 02:34:39 +08:00
|
|
|
#endif /* #ifdef CONFIG_HOTPLUG_CPU */
|
|
|
|
|
2018-05-29 23:48:27 +08:00
|
|
|
enum cpuhp_smt_control {
|
|
|
|
CPU_SMT_ENABLED,
|
|
|
|
CPU_SMT_DISABLED,
|
|
|
|
CPU_SMT_FORCE_DISABLED,
|
|
|
|
CPU_SMT_NOT_SUPPORTED,
|
|
|
|
};
|
|
|
|
|
|
|
|
#if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_SMT)
|
|
|
|
extern enum cpuhp_smt_control cpu_smt_control;
|
2018-07-13 22:23:23 +08:00
|
|
|
extern void cpu_smt_disable(bool force);
|
2018-07-13 22:23:24 +08:00
|
|
|
extern void cpu_smt_check_topology(void);
|
2018-05-29 23:48:27 +08:00
|
|
|
#else
|
|
|
|
# define cpu_smt_control (CPU_SMT_ENABLED)
|
2018-07-13 22:23:23 +08:00
|
|
|
static inline void cpu_smt_disable(bool force) { }
|
2018-07-13 22:23:24 +08:00
|
|
|
static inline void cpu_smt_check_topology(void) { }
|
2018-05-29 23:48:27 +08:00
|
|
|
#endif
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* _LINUX_CPU_H_ */
|