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 14:07:57 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-04-16 22:20:36 +00: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 10:45:48 +00:00
|
|
|
* CPUs are exported via sysfs in the devices/system/cpu
|
2005-04-16 22:20:36 +00:00
|
|
|
* directory.
|
|
|
|
*/
|
|
|
|
#ifndef _LINUX_CPU_H_
|
|
|
|
#define _LINUX_CPU_H_
|
|
|
|
|
|
|
|
#include <linux/node.h>
|
|
|
|
#include <linux/compiler.h>
|
2016-02-26 18:43:28 +00:00
|
|
|
#include <linux/cpuhotplug.h>
|
2024-06-10 00:39:24 +00:00
|
|
|
#include <linux/cpuhplock.h>
|
2023-07-05 14:51:35 +00:00
|
|
|
#include <linux/cpu_smt.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-01-30 16:46:54 +00:00
|
|
|
struct device;
|
2013-10-03 21:24:51 +00:00
|
|
|
struct device_node;
|
2014-09-30 13:48:24 +00:00
|
|
|
struct attribute_group;
|
2012-01-30 16:46:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
struct cpu {
|
|
|
|
int node_id; /* The node which contains the CPU */
|
2006-12-07 01:14:10 +00:00
|
|
|
int hotpluggable; /* creates sysfs control file if hotpluggable */
|
2011-12-21 22:29:42 +00:00
|
|
|
struct device dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2016-02-26 18:43:28 +00: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-12 19:19:42 +00:00
|
|
|
extern void boot_cpu_hotplug_init(void);
|
2017-02-05 13:47:12 +00:00
|
|
|
extern void cpu_init(void);
|
|
|
|
extern void trap_init(void);
|
2016-02-26 18:43:28 +00: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 09:53:41 +00:00
|
|
|
extern int register_cpu(struct cpu *cpu, int num);
|
2011-12-21 22:29:42 +00:00
|
|
|
extern struct device *get_cpu_device(unsigned cpu);
|
2011-12-03 21:06:50 +00:00
|
|
|
extern bool cpu_is_hotpluggable(unsigned cpu);
|
2013-08-15 13:01:40 +00:00
|
|
|
extern bool arch_match_cpu_phys_id(int cpu, u64 phys_id);
|
2013-10-03 21:24:51 +00:00
|
|
|
extern bool arch_find_n_match_cpu_physical_id(struct device_node *cpun,
|
|
|
|
int cpu, unsigned int *thread);
|
2006-10-24 16:31:24 +00:00
|
|
|
|
2011-12-21 22:29:42 +00:00
|
|
|
extern int cpu_add_dev_attr(struct device_attribute *attr);
|
|
|
|
extern void cpu_remove_dev_attr(struct device_attribute *attr);
|
2006-10-24 16:31:24 +00:00
|
|
|
|
2011-12-21 22:29:42 +00: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-24 16:31:24 +00:00
|
|
|
|
2018-01-07 21:48:00 +00: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 02:04:20 +00:00
|
|
|
extern ssize_t cpu_show_spec_store_bypass(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf);
|
2018-06-13 22:48:26 +00:00
|
|
|
extern ssize_t cpu_show_l1tf(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf);
|
2019-02-18 21:51:43 +00:00
|
|
|
extern ssize_t cpu_show_mds(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf);
|
2019-10-23 10:19:51 +00:00
|
|
|
extern ssize_t cpu_show_tsx_async_abort(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf);
|
2019-11-04 11:22:01 +00:00
|
|
|
extern ssize_t cpu_show_itlb_multihit(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf);
|
2020-06-17 14:14:10 +00:00
|
|
|
extern ssize_t cpu_show_srbds(struct device *dev, struct device_attribute *attr, char *buf);
|
2022-05-20 03:32:13 +00:00
|
|
|
extern ssize_t cpu_show_mmio_stale_data(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf);
|
2022-06-14 21:15:49 +00:00
|
|
|
extern ssize_t cpu_show_retbleed(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf);
|
2023-06-28 09:02:39 +00:00
|
|
|
extern ssize_t cpu_show_spec_rstack_overflow(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf);
|
2023-08-09 13:04:59 +00:00
|
|
|
extern ssize_t cpu_show_gds(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf);
|
2024-03-11 19:29:43 +00:00
|
|
|
extern ssize_t cpu_show_reg_file_data_sampling(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf);
|
2018-01-07 21:48:00 +00:00
|
|
|
|
2015-07-17 23:23:42 +00:00
|
|
|
extern __printf(4, 5)
|
|
|
|
struct device *cpu_device_create(struct device *parent, void *drvdata,
|
|
|
|
const struct attribute_group **groups,
|
|
|
|
const char *fmt, ...);
|
2023-11-21 13:44:36 +00:00
|
|
|
extern bool arch_cpu_is_hotpluggable(int cpu);
|
2023-09-25 16:28:39 +00:00
|
|
|
extern int arch_register_cpu(int cpu);
|
|
|
|
extern void arch_unregister_cpu(int cpu);
|
2005-04-16 22:20:36 +00: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 09:53:41 +00:00
|
|
|
extern void unregister_cpu(struct cpu *cpu);
|
2009-11-25 17:23:25 +00:00
|
|
|
extern ssize_t arch_cpu_probe(const char *, size_t);
|
|
|
|
extern ssize_t arch_cpu_release(const char *, size_t);
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
|
2023-11-21 13:44:25 +00:00
|
|
|
#ifdef CONFIG_GENERIC_CPU_DEVICES
|
|
|
|
DECLARE_PER_CPU(struct cpu, cpu_devices);
|
|
|
|
#endif
|
|
|
|
|
2017-11-13 08:39:01 +00: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 00:13:08 +00:00
|
|
|
*/
|
2017-11-13 08:39:01 +00: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 00:13:08 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef CONFIG_SMP
|
2016-02-26 18:43:23 +00:00
|
|
|
extern bool cpuhp_tasks_frozen;
|
2020-03-23 13:50:54 +00:00
|
|
|
int add_cpu(unsigned int cpu);
|
2020-03-23 13:51:10 +00:00
|
|
|
int cpu_device_up(struct device *dev);
|
2008-09-07 14:57:22 +00:00
|
|
|
void notify_cpu_starting(unsigned int cpu);
|
2008-07-25 08:47:50 +00:00
|
|
|
extern void cpu_maps_update_begin(void);
|
|
|
|
extern void cpu_maps_update_done(void);
|
2020-03-23 13:51:01 +00:00
|
|
|
int bringup_hibernate_cpu(unsigned int sleep_cpu);
|
2024-02-27 08:58:15 +00:00
|
|
|
void bringup_nonboot_cpus(unsigned int max_cpus);
|
2008-01-25 20:08:02 +00:00
|
|
|
|
2008-07-25 08:47:50 +00:00
|
|
|
#else /* CONFIG_SMP */
|
2016-02-26 18:43:23 +00:00
|
|
|
#define cpuhp_tasks_frozen 0
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-07-25 08:47:50 +00:00
|
|
|
static inline void cpu_maps_update_begin(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void cpu_maps_update_done(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-02-21 13:43:38 +00:00
|
|
|
static inline int add_cpu(unsigned int cpu) { return 0;}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif /* CONFIG_SMP */
|
2024-01-05 10:26:48 +00:00
|
|
|
extern const struct bus_type cpu_subsys;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-08-31 06:56:29 +00:00
|
|
|
#ifdef CONFIG_PM_SLEEP_SMP
|
2020-04-30 11:40:04 +00:00
|
|
|
extern int freeze_secondary_cpus(int primary);
|
2020-04-30 11:40:03 +00:00
|
|
|
extern void thaw_secondary_cpus(void);
|
2019-04-11 03:34:45 +00:00
|
|
|
|
|
|
|
static inline int suspend_disable_secondary_cpus(void)
|
|
|
|
{
|
2019-04-11 03:34:46 +00:00
|
|
|
int cpu = 0;
|
|
|
|
|
|
|
|
if (IS_ENABLED(CONFIG_PM_SLEEP_SMP_NONZERO_CPU))
|
|
|
|
cpu = -1;
|
|
|
|
|
|
|
|
return freeze_secondary_cpus(cpu);
|
2019-04-11 03:34:45 +00:00
|
|
|
}
|
|
|
|
static inline void suspend_enable_secondary_cpus(void)
|
|
|
|
{
|
2020-04-30 11:40:03 +00:00
|
|
|
return thaw_secondary_cpus();
|
2019-04-11 03:34:45 +00:00
|
|
|
}
|
|
|
|
|
2007-08-31 06:56:29 +00:00
|
|
|
#else /* !CONFIG_PM_SLEEP_SMP */
|
2020-04-30 11:40:03 +00:00
|
|
|
static inline void thaw_secondary_cpus(void) {}
|
2019-04-11 03:34:45 +00:00
|
|
|
static inline int suspend_disable_secondary_cpus(void) { return 0; }
|
|
|
|
static inline void suspend_enable_secondary_cpus(void) { }
|
2007-08-31 06:56:29 +00:00
|
|
|
#endif /* !CONFIG_PM_SLEEP_SMP */
|
2006-09-26 06:32:48 +00:00
|
|
|
|
2022-04-08 09:45:55 +00:00
|
|
|
void __noreturn cpu_startup_entry(enum cpuhp_state state);
|
2013-03-21 21:49:34 +00:00
|
|
|
|
2013-03-21 21:49:35 +00:00
|
|
|
void cpu_idle_poll_ctrl(bool enable);
|
|
|
|
|
2016-10-08 00:02:55 +00:00
|
|
|
bool cpu_in_idle(unsigned long pc);
|
|
|
|
|
2013-03-21 21:49:35 +00:00
|
|
|
void arch_cpu_idle(void);
|
|
|
|
void arch_cpu_idle_prepare(void);
|
|
|
|
void arch_cpu_idle_enter(void);
|
|
|
|
void arch_cpu_idle_exit(void);
|
2024-02-29 14:23:36 +00:00
|
|
|
void arch_tick_broadcast_enter(void);
|
|
|
|
void arch_tick_broadcast_exit(void);
|
2023-02-14 07:05:58 +00:00
|
|
|
void __noreturn arch_cpu_idle_dead(void);
|
2013-03-21 21:49:35 +00:00
|
|
|
|
2023-06-13 23:39:22 +00:00
|
|
|
#ifdef CONFIG_ARCH_HAS_CPU_FINALIZE_INIT
|
|
|
|
void arch_cpu_finalize_init(void);
|
|
|
|
#else
|
|
|
|
static inline void arch_cpu_finalize_init(void) { }
|
|
|
|
#endif
|
|
|
|
|
cpuidle: Allow idle injection to apply exit latency limit
In some cases it may be useful to specify an exit latency limit for
the idle state to be used during CPU idle time injection.
Instead of duplicating the information in struct cpuidle_device
or propagating the latency limit in the call stack, replace the
use_deepest_state field with forced_latency_limit_ns to represent
that limit, so that the deepest idle state with exit latency within
that limit is forced (i.e. no governors) when it is set.
A zero exit latency limit for forced idle means to use governors in
the usual way (analogous to use_deepest_state equal to "false" before
this change).
Additionally, add play_idle_precise() taking two arguments, the
duration of forced idle and the idle state exit latency limit, both
in nanoseconds, and redefine play_idle() as a wrapper around that
new function.
This change is preparatory, no functional impact is expected.
Suggested-by: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
[ rjw: Subject, changelog, cpuidle_use_deepest_state() kerneldoc, whitespace ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-11-16 13:16:12 +00:00
|
|
|
void play_idle_precise(u64 duration_ns, u64 latency_ns);
|
|
|
|
|
|
|
|
static inline void play_idle(unsigned long duration_us)
|
|
|
|
{
|
|
|
|
play_idle_precise(duration_us * NSEC_PER_USEC, U64_MAX);
|
|
|
|
}
|
2016-11-29 07:03:05 +00:00
|
|
|
|
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-25 18:34:39 +00:00
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
2016-02-26 18:43:43 +00: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-25 18:34:39 +00:00
|
|
|
#endif /* #ifdef CONFIG_HOTPLUG_CPU */
|
|
|
|
|
2024-04-20 00:05:55 +00:00
|
|
|
#ifdef CONFIG_CPU_MITIGATIONS
|
2019-11-04 11:22:02 +00:00
|
|
|
extern bool cpu_mitigations_off(void);
|
|
|
|
extern bool cpu_mitigations_auto_nosmt(void);
|
2024-04-20 00:05:55 +00:00
|
|
|
#else
|
|
|
|
static inline bool cpu_mitigations_off(void)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
static inline bool cpu_mitigations_auto_nosmt(void)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
2019-04-12 20:39:28 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif /* _LINUX_CPU_H_ */
|