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
|
2008-10-04 20:01:56 +00:00
|
|
|
#include <linux/cpumask.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/kernel_stat.h>
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/sched.h>
|
2017-02-08 17:51:35 +00:00
|
|
|
#include <linux/sched/stat.h>
|
2008-10-04 20:01:56 +00:00
|
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/time.h>
|
2020-10-27 20:42:57 +00:00
|
|
|
#include <linux/time_namespace.h>
|
2008-12-26 05:24:10 +00:00
|
|
|
#include <linux/irqnr.h>
|
2017-02-05 10:48:36 +00:00
|
|
|
#include <linux/sched/cputime.h>
|
2011-08-24 07:40:25 +00:00
|
|
|
#include <linux/tick.h>
|
2008-10-04 20:01:56 +00:00
|
|
|
|
|
|
|
#ifndef arch_irq_stat_cpu
|
|
|
|
#define arch_irq_stat_cpu(cpu) 0
|
|
|
|
#endif
|
|
|
|
#ifndef arch_irq_stat
|
|
|
|
#define arch_irq_stat() 0
|
|
|
|
#endif
|
2012-03-30 10:23:08 +00:00
|
|
|
|
|
|
|
#ifdef arch_idle_time
|
|
|
|
|
2019-03-05 23:50:32 +00:00
|
|
|
static u64 get_idle_time(struct kernel_cpustat *kcs, int cpu)
|
2012-03-30 10:23:08 +00:00
|
|
|
{
|
2017-01-31 03:09:19 +00:00
|
|
|
u64 idle;
|
2012-03-30 10:23:08 +00:00
|
|
|
|
2019-03-05 23:50:32 +00:00
|
|
|
idle = kcs->cpustat[CPUTIME_IDLE];
|
2012-03-30 10:23:08 +00:00
|
|
|
if (cpu_online(cpu) && !nr_iowait_cpu(cpu))
|
2017-01-31 03:09:47 +00:00
|
|
|
idle += arch_idle_time(cpu);
|
2012-03-30 10:23:08 +00:00
|
|
|
return idle;
|
|
|
|
}
|
|
|
|
|
2019-03-05 23:50:32 +00:00
|
|
|
static u64 get_iowait_time(struct kernel_cpustat *kcs, int cpu)
|
2012-03-30 10:23:08 +00:00
|
|
|
{
|
2017-01-31 03:09:19 +00:00
|
|
|
u64 iowait;
|
2012-03-30 10:23:08 +00:00
|
|
|
|
2019-03-05 23:50:32 +00:00
|
|
|
iowait = kcs->cpustat[CPUTIME_IOWAIT];
|
2012-03-30 10:23:08 +00:00
|
|
|
if (cpu_online(cpu) && nr_iowait_cpu(cpu))
|
2017-01-31 03:09:47 +00:00
|
|
|
iowait += arch_idle_time(cpu);
|
2012-03-30 10:23:08 +00:00
|
|
|
return iowait;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
2008-10-04 20:01:56 +00:00
|
|
|
|
2019-03-05 23:50:32 +00:00
|
|
|
static u64 get_idle_time(struct kernel_cpustat *kcs, int cpu)
|
2011-08-24 07:40:25 +00:00
|
|
|
{
|
2017-01-31 03:09:19 +00:00
|
|
|
u64 idle, idle_usecs = -1ULL;
|
2012-10-10 06:21:09 +00:00
|
|
|
|
|
|
|
if (cpu_online(cpu))
|
2017-01-31 03:09:19 +00:00
|
|
|
idle_usecs = get_cpu_idle_time_us(cpu, NULL);
|
2011-08-24 07:40:25 +00:00
|
|
|
|
2017-01-31 03:09:19 +00:00
|
|
|
if (idle_usecs == -1ULL)
|
2012-10-10 06:21:09 +00:00
|
|
|
/* !NO_HZ or cpu offline so we can rely on cpustat.idle */
|
2019-03-05 23:50:32 +00:00
|
|
|
idle = kcs->cpustat[CPUTIME_IDLE];
|
2012-03-30 10:23:08 +00:00
|
|
|
else
|
2017-01-31 03:09:19 +00:00
|
|
|
idle = idle_usecs * NSEC_PER_USEC;
|
2011-08-24 07:40:25 +00:00
|
|
|
|
|
|
|
return idle;
|
|
|
|
}
|
|
|
|
|
2019-03-05 23:50:32 +00:00
|
|
|
static u64 get_iowait_time(struct kernel_cpustat *kcs, int cpu)
|
2011-08-24 07:40:25 +00:00
|
|
|
{
|
2017-01-31 03:09:19 +00:00
|
|
|
u64 iowait, iowait_usecs = -1ULL;
|
2012-10-10 06:21:09 +00:00
|
|
|
|
|
|
|
if (cpu_online(cpu))
|
2017-01-31 03:09:19 +00:00
|
|
|
iowait_usecs = get_cpu_iowait_time_us(cpu, NULL);
|
2011-08-24 07:40:25 +00:00
|
|
|
|
2017-01-31 03:09:19 +00:00
|
|
|
if (iowait_usecs == -1ULL)
|
2012-10-10 06:21:09 +00:00
|
|
|
/* !NO_HZ or cpu offline so we can rely on cpustat.iowait */
|
2019-03-05 23:50:32 +00:00
|
|
|
iowait = kcs->cpustat[CPUTIME_IOWAIT];
|
2011-08-24 07:40:25 +00:00
|
|
|
else
|
2017-01-31 03:09:19 +00:00
|
|
|
iowait = iowait_usecs * NSEC_PER_USEC;
|
2011-08-24 07:40:25 +00:00
|
|
|
|
|
|
|
return iowait;
|
|
|
|
}
|
|
|
|
|
2012-03-30 10:23:08 +00:00
|
|
|
#endif
|
|
|
|
|
2019-02-08 13:48:04 +00:00
|
|
|
static void show_irq_gap(struct seq_file *p, unsigned int gap)
|
|
|
|
{
|
|
|
|
static const char zeros[] = " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0";
|
|
|
|
|
|
|
|
while (gap > 0) {
|
|
|
|
unsigned int inc;
|
|
|
|
|
|
|
|
inc = min_t(unsigned int, gap, ARRAY_SIZE(zeros) / 2);
|
|
|
|
seq_write(p, zeros, 2 * inc);
|
|
|
|
gap -= inc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void show_all_irqs(struct seq_file *p)
|
|
|
|
{
|
|
|
|
unsigned int i, next = 0;
|
|
|
|
|
|
|
|
for_each_active_irq(i) {
|
|
|
|
show_irq_gap(p, i - next);
|
|
|
|
seq_put_decimal_ull(p, " ", kstat_irqs_usr(i));
|
|
|
|
next = i + 1;
|
|
|
|
}
|
|
|
|
show_irq_gap(p, nr_irqs - next);
|
|
|
|
}
|
|
|
|
|
2008-10-04 20:01:56 +00:00
|
|
|
static int show_stat(struct seq_file *p, void *v)
|
|
|
|
{
|
|
|
|
int i, j;
|
2011-11-28 16:45:17 +00:00
|
|
|
u64 user, nice, system, idle, iowait, irq, softirq, steal;
|
|
|
|
u64 guest, guest_nice;
|
2008-10-04 20:01:56 +00:00
|
|
|
u64 sum = 0;
|
2009-06-17 23:25:55 +00:00
|
|
|
u64 sum_softirq = 0;
|
|
|
|
unsigned int per_softirq_sums[NR_SOFTIRQS] = {0};
|
2016-08-02 21:03:22 +00:00
|
|
|
struct timespec64 boottime;
|
2008-10-04 20:01:56 +00:00
|
|
|
|
|
|
|
user = nice = system = idle = iowait =
|
2011-11-28 16:45:17 +00:00
|
|
|
irq = softirq = steal = 0;
|
|
|
|
guest = guest_nice = 0;
|
2016-08-02 21:03:22 +00:00
|
|
|
getboottime64(&boottime);
|
2020-10-27 20:42:57 +00:00
|
|
|
/* shift boot timestamp according to the timens offset */
|
|
|
|
timens_sub_boottime(&boottime);
|
2008-10-04 20:01:56 +00:00
|
|
|
|
|
|
|
for_each_possible_cpu(i) {
|
2019-11-21 02:44:27 +00:00
|
|
|
struct kernel_cpustat kcpustat;
|
|
|
|
u64 *cpustat = kcpustat.cpustat;
|
|
|
|
|
|
|
|
kcpustat_cpu_fetch(&kcpustat, i);
|
|
|
|
|
|
|
|
user += cpustat[CPUTIME_USER];
|
|
|
|
nice += cpustat[CPUTIME_NICE];
|
|
|
|
system += cpustat[CPUTIME_SYSTEM];
|
|
|
|
idle += get_idle_time(&kcpustat, i);
|
|
|
|
iowait += get_iowait_time(&kcpustat, i);
|
|
|
|
irq += cpustat[CPUTIME_IRQ];
|
|
|
|
softirq += cpustat[CPUTIME_SOFTIRQ];
|
|
|
|
steal += cpustat[CPUTIME_STEAL];
|
|
|
|
guest += cpustat[CPUTIME_GUEST];
|
2019-12-05 02:03:44 +00:00
|
|
|
guest_nice += cpustat[CPUTIME_GUEST_NICE];
|
2019-11-21 02:44:27 +00:00
|
|
|
sum += kstat_cpu_irqs_sum(i);
|
|
|
|
sum += arch_irq_stat_cpu(i);
|
2009-06-17 23:25:55 +00:00
|
|
|
|
|
|
|
for (j = 0; j < NR_SOFTIRQS; j++) {
|
|
|
|
unsigned int softirq_stat = kstat_softirqs_cpu(j, i);
|
|
|
|
|
|
|
|
per_softirq_sums[j] += softirq_stat;
|
|
|
|
sum_softirq += softirq_stat;
|
|
|
|
}
|
2008-10-04 20:01:56 +00:00
|
|
|
}
|
|
|
|
sum += arch_irq_stat();
|
|
|
|
|
2017-01-31 03:09:19 +00:00
|
|
|
seq_put_decimal_ull(p, "cpu ", nsec_to_clock_t(user));
|
|
|
|
seq_put_decimal_ull(p, " ", nsec_to_clock_t(nice));
|
|
|
|
seq_put_decimal_ull(p, " ", nsec_to_clock_t(system));
|
|
|
|
seq_put_decimal_ull(p, " ", nsec_to_clock_t(idle));
|
|
|
|
seq_put_decimal_ull(p, " ", nsec_to_clock_t(iowait));
|
|
|
|
seq_put_decimal_ull(p, " ", nsec_to_clock_t(irq));
|
|
|
|
seq_put_decimal_ull(p, " ", nsec_to_clock_t(softirq));
|
|
|
|
seq_put_decimal_ull(p, " ", nsec_to_clock_t(steal));
|
|
|
|
seq_put_decimal_ull(p, " ", nsec_to_clock_t(guest));
|
|
|
|
seq_put_decimal_ull(p, " ", nsec_to_clock_t(guest_nice));
|
2012-03-23 22:02:54 +00:00
|
|
|
seq_putc(p, '\n');
|
|
|
|
|
2008-10-04 20:01:56 +00:00
|
|
|
for_each_online_cpu(i) {
|
2019-11-21 02:44:27 +00:00
|
|
|
struct kernel_cpustat kcpustat;
|
|
|
|
u64 *cpustat = kcpustat.cpustat;
|
|
|
|
|
|
|
|
kcpustat_cpu_fetch(&kcpustat, i);
|
2019-03-05 23:50:32 +00:00
|
|
|
|
2008-10-04 20:01:56 +00:00
|
|
|
/* Copy values here to work around gcc-2.95.3, gcc-2.96 */
|
2019-11-21 02:44:27 +00:00
|
|
|
user = cpustat[CPUTIME_USER];
|
|
|
|
nice = cpustat[CPUTIME_NICE];
|
|
|
|
system = cpustat[CPUTIME_SYSTEM];
|
|
|
|
idle = get_idle_time(&kcpustat, i);
|
|
|
|
iowait = get_iowait_time(&kcpustat, i);
|
|
|
|
irq = cpustat[CPUTIME_IRQ];
|
|
|
|
softirq = cpustat[CPUTIME_SOFTIRQ];
|
|
|
|
steal = cpustat[CPUTIME_STEAL];
|
|
|
|
guest = cpustat[CPUTIME_GUEST];
|
2019-12-05 02:03:44 +00:00
|
|
|
guest_nice = cpustat[CPUTIME_GUEST_NICE];
|
2012-03-23 22:02:54 +00:00
|
|
|
seq_printf(p, "cpu%d", i);
|
2017-01-31 03:09:19 +00:00
|
|
|
seq_put_decimal_ull(p, " ", nsec_to_clock_t(user));
|
|
|
|
seq_put_decimal_ull(p, " ", nsec_to_clock_t(nice));
|
|
|
|
seq_put_decimal_ull(p, " ", nsec_to_clock_t(system));
|
|
|
|
seq_put_decimal_ull(p, " ", nsec_to_clock_t(idle));
|
|
|
|
seq_put_decimal_ull(p, " ", nsec_to_clock_t(iowait));
|
|
|
|
seq_put_decimal_ull(p, " ", nsec_to_clock_t(irq));
|
|
|
|
seq_put_decimal_ull(p, " ", nsec_to_clock_t(softirq));
|
|
|
|
seq_put_decimal_ull(p, " ", nsec_to_clock_t(steal));
|
|
|
|
seq_put_decimal_ull(p, " ", nsec_to_clock_t(guest));
|
|
|
|
seq_put_decimal_ull(p, " ", nsec_to_clock_t(guest_nice));
|
2012-03-23 22:02:54 +00:00
|
|
|
seq_putc(p, '\n');
|
2008-10-04 20:01:56 +00:00
|
|
|
}
|
2016-10-08 00:02:20 +00:00
|
|
|
seq_put_decimal_ull(p, "intr ", (unsigned long long)sum);
|
2008-10-04 20:01:56 +00:00
|
|
|
|
2019-02-08 13:48:04 +00:00
|
|
|
show_all_irqs(p);
|
2008-10-04 20:01:56 +00:00
|
|
|
|
|
|
|
seq_printf(p,
|
|
|
|
"\nctxt %llu\n"
|
2016-08-02 21:03:22 +00:00
|
|
|
"btime %llu\n"
|
2008-10-04 20:01:56 +00:00
|
|
|
"processes %lu\n"
|
|
|
|
"procs_running %lu\n"
|
|
|
|
"procs_blocked %lu\n",
|
|
|
|
nr_context_switches(),
|
2016-08-02 21:03:22 +00:00
|
|
|
(unsigned long long)boottime.tv_sec,
|
2008-10-04 20:01:56 +00:00
|
|
|
total_forks,
|
|
|
|
nr_running(),
|
|
|
|
nr_iowait());
|
|
|
|
|
2016-10-08 00:02:20 +00:00
|
|
|
seq_put_decimal_ull(p, "softirq ", (unsigned long long)sum_softirq);
|
2009-06-17 23:25:55 +00:00
|
|
|
|
|
|
|
for (i = 0; i < NR_SOFTIRQS; i++)
|
2016-10-08 00:02:20 +00:00
|
|
|
seq_put_decimal_ull(p, " ", per_softirq_sums[i]);
|
2011-01-13 01:00:32 +00:00
|
|
|
seq_putc(p, '\n');
|
2009-06-17 23:25:55 +00:00
|
|
|
|
2008-10-04 20:01:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int stat_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
2018-08-22 04:54:41 +00:00
|
|
|
unsigned int size = 1024 + 128 * num_online_cpus();
|
2008-10-04 20:01:56 +00:00
|
|
|
|
2012-03-23 22:02:53 +00:00
|
|
|
/* minimum size to display an interrupt count : 2 bytes */
|
|
|
|
size += 2 * nr_irqs;
|
2014-07-02 22:22:37 +00:00
|
|
|
return single_open_size(file, show_stat, NULL, size);
|
2008-10-04 20:01:56 +00:00
|
|
|
}
|
|
|
|
|
2020-02-04 01:37:17 +00:00
|
|
|
static const struct proc_ops stat_proc_ops = {
|
proc: faster open/read/close with "permanent" files
Now that "struct proc_ops" exist we can start putting there stuff which
could not fly with VFS "struct file_operations"...
Most of fs/proc/inode.c file is dedicated to make open/read/.../close
reliable in the event of disappearing /proc entries which usually happens
if module is getting removed. Files like /proc/cpuinfo which never
disappear simply do not need such protection.
Save 2 atomic ops, 1 allocation, 1 free per open/read/close sequence for such
"permanent" files.
Enable "permanent" flag for
/proc/cpuinfo
/proc/kmsg
/proc/modules
/proc/slabinfo
/proc/stat
/proc/sysvipc/*
/proc/swaps
More will come once I figure out foolproof way to prevent out module
authors from marking their stuff "permanent" for performance reasons
when it is not.
This should help with scalability: benchmark is "read /proc/cpuinfo R times
by N threads scattered over the system".
N R t, s (before) t, s (after)
-----------------------------------------------------
64 4096 1.582458 1.530502 -3.2%
256 4096 6.371926 6.125168 -3.9%
1024 4096 25.64888 24.47528 -4.6%
Benchmark source:
#include <chrono>
#include <iostream>
#include <thread>
#include <vector>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
const int NR_CPUS = sysconf(_SC_NPROCESSORS_ONLN);
int N;
const char *filename;
int R;
int xxx = 0;
int glue(int n)
{
cpu_set_t m;
CPU_ZERO(&m);
CPU_SET(n, &m);
return sched_setaffinity(0, sizeof(cpu_set_t), &m);
}
void f(int n)
{
glue(n % NR_CPUS);
while (*(volatile int *)&xxx == 0) {
}
for (int i = 0; i < R; i++) {
int fd = open(filename, O_RDONLY);
char buf[4096];
ssize_t rv = read(fd, buf, sizeof(buf));
asm volatile ("" :: "g" (rv));
close(fd);
}
}
int main(int argc, char *argv[])
{
if (argc < 4) {
std::cerr << "usage: " << argv[0] << ' ' << "N /proc/filename R
";
return 1;
}
N = atoi(argv[1]);
filename = argv[2];
R = atoi(argv[3]);
for (int i = 0; i < NR_CPUS; i++) {
if (glue(i) == 0)
break;
}
std::vector<std::thread> T;
T.reserve(N);
for (int i = 0; i < N; i++) {
T.emplace_back(f, i);
}
auto t0 = std::chrono::system_clock::now();
{
*(volatile int *)&xxx = 1;
for (auto& t: T) {
t.join();
}
}
auto t1 = std::chrono::system_clock::now();
std::chrono::duration<double> dt = t1 - t0;
std::cout << dt.count() << '
';
return 0;
}
P.S.:
Explicit randomization marker is added because adding non-function pointer
will silently disable structure layout randomization.
[akpm@linux-foundation.org: coding style fixes]
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Joe Perches <joe@perches.com>
Link: http://lkml.kernel.org/r/20200222201539.GA22576@avx2
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-04-07 03:09:01 +00:00
|
|
|
.proc_flags = PROC_ENTRY_PERMANENT,
|
2020-02-04 01:37:17 +00:00
|
|
|
.proc_open = stat_open,
|
2020-11-04 08:27:36 +00:00
|
|
|
.proc_read_iter = seq_read_iter,
|
2020-02-04 01:37:17 +00:00
|
|
|
.proc_lseek = seq_lseek,
|
|
|
|
.proc_release = single_release,
|
2008-10-04 20:01:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init proc_stat_init(void)
|
|
|
|
{
|
2020-02-04 01:37:17 +00:00
|
|
|
proc_create("stat", 0, NULL, &stat_proc_ops);
|
2008-10-04 20:01:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2014-01-23 23:55:45 +00:00
|
|
|
fs_initcall(proc_stat_init);
|