diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/cpu.c | 38 | ||||
-rw-r--r-- | kernel/events/core.c | 14 | ||||
-rw-r--r-- | kernel/exit.c | 12 | ||||
-rw-r--r-- | kernel/relay.c | 4 | ||||
-rw-r--r-- | kernel/sched/fair.c | 1 | ||||
-rw-r--r-- | kernel/sched/psi.c | 21 | ||||
-rw-r--r-- | kernel/smp.c | 2 | ||||
-rw-r--r-- | kernel/trace/trace_uprobe.c | 9 | ||||
-rw-r--r-- | kernel/workqueue.c | 23 | ||||
-rw-r--r-- | kernel/workqueue_internal.h | 6 |
10 files changed, 79 insertions, 51 deletions
diff --git a/kernel/cpu.c b/kernel/cpu.c index 91d5c38eb7e5..d1c6d152da89 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c | |||
@@ -376,9 +376,6 @@ void __weak arch_smt_update(void) { } | |||
376 | 376 | ||
377 | #ifdef CONFIG_HOTPLUG_SMT | 377 | #ifdef CONFIG_HOTPLUG_SMT |
378 | enum cpuhp_smt_control cpu_smt_control __read_mostly = CPU_SMT_ENABLED; | 378 | enum cpuhp_smt_control cpu_smt_control __read_mostly = CPU_SMT_ENABLED; |
379 | EXPORT_SYMBOL_GPL(cpu_smt_control); | ||
380 | |||
381 | static bool cpu_smt_available __read_mostly; | ||
382 | 379 | ||
383 | void __init cpu_smt_disable(bool force) | 380 | void __init cpu_smt_disable(bool force) |
384 | { | 381 | { |
@@ -397,25 +394,11 @@ void __init cpu_smt_disable(bool force) | |||
397 | 394 | ||
398 | /* | 395 | /* |
399 | * The decision whether SMT is supported can only be done after the full | 396 | * The decision whether SMT is supported can only be done after the full |
400 | * CPU identification. Called from architecture code before non boot CPUs | 397 | * CPU identification. Called from architecture code. |
401 | * are brought up. | ||
402 | */ | ||
403 | void __init cpu_smt_check_topology_early(void) | ||
404 | { | ||
405 | if (!topology_smt_supported()) | ||
406 | cpu_smt_control = CPU_SMT_NOT_SUPPORTED; | ||
407 | } | ||
408 | |||
409 | /* | ||
410 | * If SMT was disabled by BIOS, detect it here, after the CPUs have been | ||
411 | * brought online. This ensures the smt/l1tf sysfs entries are consistent | ||
412 | * with reality. cpu_smt_available is set to true during the bringup of non | ||
413 | * boot CPUs when a SMT sibling is detected. Note, this may overwrite | ||
414 | * cpu_smt_control's previous setting. | ||
415 | */ | 398 | */ |
416 | void __init cpu_smt_check_topology(void) | 399 | void __init cpu_smt_check_topology(void) |
417 | { | 400 | { |
418 | if (!cpu_smt_available) | 401 | if (!topology_smt_supported()) |
419 | cpu_smt_control = CPU_SMT_NOT_SUPPORTED; | 402 | cpu_smt_control = CPU_SMT_NOT_SUPPORTED; |
420 | } | 403 | } |
421 | 404 | ||
@@ -428,18 +411,10 @@ early_param("nosmt", smt_cmdline_disable); | |||
428 | 411 | ||
429 | static inline bool cpu_smt_allowed(unsigned int cpu) | 412 | static inline bool cpu_smt_allowed(unsigned int cpu) |
430 | { | 413 | { |
431 | if (topology_is_primary_thread(cpu)) | 414 | if (cpu_smt_control == CPU_SMT_ENABLED) |
432 | return true; | 415 | return true; |
433 | 416 | ||
434 | /* | 417 | if (topology_is_primary_thread(cpu)) |
435 | * If the CPU is not a 'primary' thread and the booted_once bit is | ||
436 | * set then the processor has SMT support. Store this information | ||
437 | * for the late check of SMT support in cpu_smt_check_topology(). | ||
438 | */ | ||
439 | if (per_cpu(cpuhp_state, cpu).booted_once) | ||
440 | cpu_smt_available = true; | ||
441 | |||
442 | if (cpu_smt_control == CPU_SMT_ENABLED) | ||
443 | return true; | 418 | return true; |
444 | 419 | ||
445 | /* | 420 | /* |
@@ -2090,10 +2065,8 @@ static int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval) | |||
2090 | */ | 2065 | */ |
2091 | cpuhp_offline_cpu_device(cpu); | 2066 | cpuhp_offline_cpu_device(cpu); |
2092 | } | 2067 | } |
2093 | if (!ret) { | 2068 | if (!ret) |
2094 | cpu_smt_control = ctrlval; | 2069 | cpu_smt_control = ctrlval; |
2095 | arch_smt_update(); | ||
2096 | } | ||
2097 | cpu_maps_update_done(); | 2070 | cpu_maps_update_done(); |
2098 | return ret; | 2071 | return ret; |
2099 | } | 2072 | } |
@@ -2104,7 +2077,6 @@ static int cpuhp_smt_enable(void) | |||
2104 | 2077 | ||
2105 | cpu_maps_update_begin(); | 2078 | cpu_maps_update_begin(); |
2106 | cpu_smt_control = CPU_SMT_ENABLED; | 2079 | cpu_smt_control = CPU_SMT_ENABLED; |
2107 | arch_smt_update(); | ||
2108 | for_each_present_cpu(cpu) { | 2080 | for_each_present_cpu(cpu) { |
2109 | /* Skip online CPUs and CPUs on offline nodes */ | 2081 | /* Skip online CPUs and CPUs on offline nodes */ |
2110 | if (cpu_online(cpu) || !node_online(cpu_to_node(cpu))) | 2082 | if (cpu_online(cpu) || !node_online(cpu_to_node(cpu))) |
diff --git a/kernel/events/core.c b/kernel/events/core.c index 3cd13a30f732..e5ede6918050 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -436,18 +436,18 @@ int perf_proc_update_handler(struct ctl_table *table, int write, | |||
436 | void __user *buffer, size_t *lenp, | 436 | void __user *buffer, size_t *lenp, |
437 | loff_t *ppos) | 437 | loff_t *ppos) |
438 | { | 438 | { |
439 | int ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); | 439 | int ret; |
440 | 440 | int perf_cpu = sysctl_perf_cpu_time_max_percent; | |
441 | if (ret || !write) | ||
442 | return ret; | ||
443 | |||
444 | /* | 441 | /* |
445 | * If throttling is disabled don't allow the write: | 442 | * If throttling is disabled don't allow the write: |
446 | */ | 443 | */ |
447 | if (sysctl_perf_cpu_time_max_percent == 100 || | 444 | if (write && (perf_cpu == 100 || perf_cpu == 0)) |
448 | sysctl_perf_cpu_time_max_percent == 0) | ||
449 | return -EINVAL; | 445 | return -EINVAL; |
450 | 446 | ||
447 | ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); | ||
448 | if (ret || !write) | ||
449 | return ret; | ||
450 | |||
451 | max_samples_per_tick = DIV_ROUND_UP(sysctl_perf_event_sample_rate, HZ); | 451 | max_samples_per_tick = DIV_ROUND_UP(sysctl_perf_event_sample_rate, HZ); |
452 | perf_sample_period_ns = NSEC_PER_SEC / sysctl_perf_event_sample_rate; | 452 | perf_sample_period_ns = NSEC_PER_SEC / sysctl_perf_event_sample_rate; |
453 | update_perf_cpu_limits(); | 453 | update_perf_cpu_limits(); |
diff --git a/kernel/exit.c b/kernel/exit.c index 3fb7be001964..2639a30a8aa5 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -558,12 +558,14 @@ static struct task_struct *find_alive_thread(struct task_struct *p) | |||
558 | return NULL; | 558 | return NULL; |
559 | } | 559 | } |
560 | 560 | ||
561 | static struct task_struct *find_child_reaper(struct task_struct *father) | 561 | static struct task_struct *find_child_reaper(struct task_struct *father, |
562 | struct list_head *dead) | ||
562 | __releases(&tasklist_lock) | 563 | __releases(&tasklist_lock) |
563 | __acquires(&tasklist_lock) | 564 | __acquires(&tasklist_lock) |
564 | { | 565 | { |
565 | struct pid_namespace *pid_ns = task_active_pid_ns(father); | 566 | struct pid_namespace *pid_ns = task_active_pid_ns(father); |
566 | struct task_struct *reaper = pid_ns->child_reaper; | 567 | struct task_struct *reaper = pid_ns->child_reaper; |
568 | struct task_struct *p, *n; | ||
567 | 569 | ||
568 | if (likely(reaper != father)) | 570 | if (likely(reaper != father)) |
569 | return reaper; | 571 | return reaper; |
@@ -579,6 +581,12 @@ static struct task_struct *find_child_reaper(struct task_struct *father) | |||
579 | panic("Attempted to kill init! exitcode=0x%08x\n", | 581 | panic("Attempted to kill init! exitcode=0x%08x\n", |
580 | father->signal->group_exit_code ?: father->exit_code); | 582 | father->signal->group_exit_code ?: father->exit_code); |
581 | } | 583 | } |
584 | |||
585 | list_for_each_entry_safe(p, n, dead, ptrace_entry) { | ||
586 | list_del_init(&p->ptrace_entry); | ||
587 | release_task(p); | ||
588 | } | ||
589 | |||
582 | zap_pid_ns_processes(pid_ns); | 590 | zap_pid_ns_processes(pid_ns); |
583 | write_lock_irq(&tasklist_lock); | 591 | write_lock_irq(&tasklist_lock); |
584 | 592 | ||
@@ -668,7 +676,7 @@ static void forget_original_parent(struct task_struct *father, | |||
668 | exit_ptrace(father, dead); | 676 | exit_ptrace(father, dead); |
669 | 677 | ||
670 | /* Can drop and reacquire tasklist_lock */ | 678 | /* Can drop and reacquire tasklist_lock */ |
671 | reaper = find_child_reaper(father); | 679 | reaper = find_child_reaper(father, dead); |
672 | if (list_empty(&father->children)) | 680 | if (list_empty(&father->children)) |
673 | return; | 681 | return; |
674 | 682 | ||
diff --git a/kernel/relay.c b/kernel/relay.c index 04f248644e06..9e0f52375487 100644 --- a/kernel/relay.c +++ b/kernel/relay.c | |||
@@ -428,6 +428,8 @@ static struct dentry *relay_create_buf_file(struct rchan *chan, | |||
428 | dentry = chan->cb->create_buf_file(tmpname, chan->parent, | 428 | dentry = chan->cb->create_buf_file(tmpname, chan->parent, |
429 | S_IRUSR, buf, | 429 | S_IRUSR, buf, |
430 | &chan->is_global); | 430 | &chan->is_global); |
431 | if (IS_ERR(dentry)) | ||
432 | dentry = NULL; | ||
431 | 433 | ||
432 | kfree(tmpname); | 434 | kfree(tmpname); |
433 | 435 | ||
@@ -461,7 +463,7 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu) | |||
461 | dentry = chan->cb->create_buf_file(NULL, NULL, | 463 | dentry = chan->cb->create_buf_file(NULL, NULL, |
462 | S_IRUSR, buf, | 464 | S_IRUSR, buf, |
463 | &chan->is_global); | 465 | &chan->is_global); |
464 | if (WARN_ON(dentry)) | 466 | if (IS_ERR_OR_NULL(dentry)) |
465 | goto free_buf; | 467 | goto free_buf; |
466 | } | 468 | } |
467 | 469 | ||
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 50aa2aba69bd..310d0637fe4b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c | |||
@@ -5980,6 +5980,7 @@ static inline int find_idlest_cpu(struct sched_domain *sd, struct task_struct *p | |||
5980 | 5980 | ||
5981 | #ifdef CONFIG_SCHED_SMT | 5981 | #ifdef CONFIG_SCHED_SMT |
5982 | DEFINE_STATIC_KEY_FALSE(sched_smt_present); | 5982 | DEFINE_STATIC_KEY_FALSE(sched_smt_present); |
5983 | EXPORT_SYMBOL_GPL(sched_smt_present); | ||
5983 | 5984 | ||
5984 | static inline void set_idle_cores(int cpu, int val) | 5985 | static inline void set_idle_cores(int cpu, int val) |
5985 | { | 5986 | { |
diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index fe24de3fbc93..c3484785b179 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c | |||
@@ -124,6 +124,7 @@ | |||
124 | * sampling of the aggregate task states would be. | 124 | * sampling of the aggregate task states would be. |
125 | */ | 125 | */ |
126 | 126 | ||
127 | #include "../workqueue_internal.h" | ||
127 | #include <linux/sched/loadavg.h> | 128 | #include <linux/sched/loadavg.h> |
128 | #include <linux/seq_file.h> | 129 | #include <linux/seq_file.h> |
129 | #include <linux/proc_fs.h> | 130 | #include <linux/proc_fs.h> |
@@ -480,9 +481,6 @@ static void psi_group_change(struct psi_group *group, int cpu, | |||
480 | groupc->tasks[t]++; | 481 | groupc->tasks[t]++; |
481 | 482 | ||
482 | write_seqcount_end(&groupc->seq); | 483 | write_seqcount_end(&groupc->seq); |
483 | |||
484 | if (!delayed_work_pending(&group->clock_work)) | ||
485 | schedule_delayed_work(&group->clock_work, PSI_FREQ); | ||
486 | } | 484 | } |
487 | 485 | ||
488 | static struct psi_group *iterate_groups(struct task_struct *task, void **iter) | 486 | static struct psi_group *iterate_groups(struct task_struct *task, void **iter) |
@@ -513,6 +511,7 @@ void psi_task_change(struct task_struct *task, int clear, int set) | |||
513 | { | 511 | { |
514 | int cpu = task_cpu(task); | 512 | int cpu = task_cpu(task); |
515 | struct psi_group *group; | 513 | struct psi_group *group; |
514 | bool wake_clock = true; | ||
516 | void *iter = NULL; | 515 | void *iter = NULL; |
517 | 516 | ||
518 | if (!task->pid) | 517 | if (!task->pid) |
@@ -530,8 +529,22 @@ void psi_task_change(struct task_struct *task, int clear, int set) | |||
530 | task->psi_flags &= ~clear; | 529 | task->psi_flags &= ~clear; |
531 | task->psi_flags |= set; | 530 | task->psi_flags |= set; |
532 | 531 | ||
533 | while ((group = iterate_groups(task, &iter))) | 532 | /* |
533 | * Periodic aggregation shuts off if there is a period of no | ||
534 | * task changes, so we wake it back up if necessary. However, | ||
535 | * don't do this if the task change is the aggregation worker | ||
536 | * itself going to sleep, or we'll ping-pong forever. | ||
537 | */ | ||
538 | if (unlikely((clear & TSK_RUNNING) && | ||
539 | (task->flags & PF_WQ_WORKER) && | ||
540 | wq_worker_last_func(task) == psi_update_work)) | ||
541 | wake_clock = false; | ||
542 | |||
543 | while ((group = iterate_groups(task, &iter))) { | ||
534 | psi_group_change(group, cpu, clear, set); | 544 | psi_group_change(group, cpu, clear, set); |
545 | if (wake_clock && !delayed_work_pending(&group->clock_work)) | ||
546 | schedule_delayed_work(&group->clock_work, PSI_FREQ); | ||
547 | } | ||
535 | } | 548 | } |
536 | 549 | ||
537 | void psi_memstall_tick(struct task_struct *task, int cpu) | 550 | void psi_memstall_tick(struct task_struct *task, int cpu) |
diff --git a/kernel/smp.c b/kernel/smp.c index 163c451af42e..f4cf1b0bb3b8 100644 --- a/kernel/smp.c +++ b/kernel/smp.c | |||
@@ -584,8 +584,6 @@ void __init smp_init(void) | |||
584 | num_nodes, (num_nodes > 1 ? "s" : ""), | 584 | num_nodes, (num_nodes > 1 ? "s" : ""), |
585 | num_cpus, (num_cpus > 1 ? "s" : "")); | 585 | num_cpus, (num_cpus > 1 ? "s" : "")); |
586 | 586 | ||
587 | /* Final decision about SMT support */ | ||
588 | cpu_smt_check_topology(); | ||
589 | /* Any cleanup work */ | 587 | /* Any cleanup work */ |
590 | smp_cpus_done(setup_max_cpus); | 588 | smp_cpus_done(setup_max_cpus); |
591 | } | 589 | } |
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c index e335576b9411..9bde07c06362 100644 --- a/kernel/trace/trace_uprobe.c +++ b/kernel/trace/trace_uprobe.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * Copyright (C) IBM Corporation, 2010-2012 | 5 | * Copyright (C) IBM Corporation, 2010-2012 |
6 | * Author: Srikar Dronamraju <srikar@linux.vnet.ibm.com> | 6 | * Author: Srikar Dronamraju <srikar@linux.vnet.ibm.com> |
7 | */ | 7 | */ |
8 | #define pr_fmt(fmt) "trace_kprobe: " fmt | 8 | #define pr_fmt(fmt) "trace_uprobe: " fmt |
9 | 9 | ||
10 | #include <linux/ctype.h> | 10 | #include <linux/ctype.h> |
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
@@ -160,6 +160,13 @@ fetch_store_string(unsigned long addr, void *dest, void *base) | |||
160 | if (ret >= 0) { | 160 | if (ret >= 0) { |
161 | if (ret == maxlen) | 161 | if (ret == maxlen) |
162 | dst[ret - 1] = '\0'; | 162 | dst[ret - 1] = '\0'; |
163 | else | ||
164 | /* | ||
165 | * Include the terminating null byte. In this case it | ||
166 | * was copied by strncpy_from_user but not accounted | ||
167 | * for in ret. | ||
168 | */ | ||
169 | ret++; | ||
163 | *(u32 *)dest = make_data_loc(ret, (void *)dst - base); | 170 | *(u32 *)dest = make_data_loc(ret, (void *)dst - base); |
164 | } | 171 | } |
165 | 172 | ||
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 392be4b252f6..fc5d23d752a5 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -910,6 +910,26 @@ struct task_struct *wq_worker_sleeping(struct task_struct *task) | |||
910 | } | 910 | } |
911 | 911 | ||
912 | /** | 912 | /** |
913 | * wq_worker_last_func - retrieve worker's last work function | ||
914 | * | ||
915 | * Determine the last function a worker executed. This is called from | ||
916 | * the scheduler to get a worker's last known identity. | ||
917 | * | ||
918 | * CONTEXT: | ||
919 | * spin_lock_irq(rq->lock) | ||
920 | * | ||
921 | * Return: | ||
922 | * The last work function %current executed as a worker, NULL if it | ||
923 | * hasn't executed any work yet. | ||
924 | */ | ||
925 | work_func_t wq_worker_last_func(struct task_struct *task) | ||
926 | { | ||
927 | struct worker *worker = kthread_data(task); | ||
928 | |||
929 | return worker->last_func; | ||
930 | } | ||
931 | |||
932 | /** | ||
913 | * worker_set_flags - set worker flags and adjust nr_running accordingly | 933 | * worker_set_flags - set worker flags and adjust nr_running accordingly |
914 | * @worker: self | 934 | * @worker: self |
915 | * @flags: flags to set | 935 | * @flags: flags to set |
@@ -2184,6 +2204,9 @@ __acquires(&pool->lock) | |||
2184 | if (unlikely(cpu_intensive)) | 2204 | if (unlikely(cpu_intensive)) |
2185 | worker_clr_flags(worker, WORKER_CPU_INTENSIVE); | 2205 | worker_clr_flags(worker, WORKER_CPU_INTENSIVE); |
2186 | 2206 | ||
2207 | /* tag the worker for identification in schedule() */ | ||
2208 | worker->last_func = worker->current_func; | ||
2209 | |||
2187 | /* we're done with it, release */ | 2210 | /* we're done with it, release */ |
2188 | hash_del(&worker->hentry); | 2211 | hash_del(&worker->hentry); |
2189 | worker->current_work = NULL; | 2212 | worker->current_work = NULL; |
diff --git a/kernel/workqueue_internal.h b/kernel/workqueue_internal.h index 66fbb5a9e633..cb68b03ca89a 100644 --- a/kernel/workqueue_internal.h +++ b/kernel/workqueue_internal.h | |||
@@ -53,6 +53,9 @@ struct worker { | |||
53 | 53 | ||
54 | /* used only by rescuers to point to the target workqueue */ | 54 | /* used only by rescuers to point to the target workqueue */ |
55 | struct workqueue_struct *rescue_wq; /* I: the workqueue to rescue */ | 55 | struct workqueue_struct *rescue_wq; /* I: the workqueue to rescue */ |
56 | |||
57 | /* used by the scheduler to determine a worker's last known identity */ | ||
58 | work_func_t last_func; | ||
56 | }; | 59 | }; |
57 | 60 | ||
58 | /** | 61 | /** |
@@ -67,9 +70,10 @@ static inline struct worker *current_wq_worker(void) | |||
67 | 70 | ||
68 | /* | 71 | /* |
69 | * Scheduler hooks for concurrency managed workqueue. Only to be used from | 72 | * Scheduler hooks for concurrency managed workqueue. Only to be used from |
70 | * sched/core.c and workqueue.c. | 73 | * sched/ and workqueue.c. |
71 | */ | 74 | */ |
72 | void wq_worker_waking_up(struct task_struct *task, int cpu); | 75 | void wq_worker_waking_up(struct task_struct *task, int cpu); |
73 | struct task_struct *wq_worker_sleeping(struct task_struct *task); | 76 | struct task_struct *wq_worker_sleeping(struct task_struct *task); |
77 | work_func_t wq_worker_last_func(struct task_struct *task); | ||
74 | 78 | ||
75 | #endif /* _KERNEL_WORKQUEUE_INTERNAL_H */ | 79 | #endif /* _KERNEL_WORKQUEUE_INTERNAL_H */ |