New conflicts in sched/core due to the following upstream fixes: 44585f7bc0cb ("psi: fix "defined but not used" warnings when CONFIG_PROC_FS=n") a06247c6804f ("psi: Fix uaf issue when psi trigger is destroyed while being polled") Conflicts: include/linux/psi_types.h kernel/sched/psi.c
Showing the changes to kernel (37 of 1212 files). Show all
Unified · Split
| @@ -205,9 +205,6 @@ async_cookie_t async_schedule_node_domain(async_func_t func, void *data, · 204 unmodified lines | |||
| 205 | atomic_inc(&entry_count); | 205 | atomic_inc(&entry_count); |
| 206 | spin_unlock_irqrestore(&async_lock, flags); | 206 | spin_unlock_irqrestore(&async_lock, flags); |
| 207 | 207 | ||
| 208 | /* mark that this task has queued an async job, used by module init */ | ||
| 209 | current->flags |= PF_USED_ASYNC; | ||
| 210 | |||
| 211 | /* schedule for execution */ | 208 | /* schedule for execution */ |
| 212 | queue_work_node(node, system_unbound_wq, &entry->work); | 209 | queue_work_node(node, system_unbound_wq, &entry->work); |
| 213 | 210 | ||
| @@ -541,20 +541,22 @@ static void kauditd_printk_skb(struct sk_buff *skb) · 540 unmodified lines | |||
| 541 | /** | 541 | /** |
| 542 | * kauditd_rehold_skb - Handle a audit record send failure in the hold queue | 542 | * kauditd_rehold_skb - Handle a audit record send failure in the hold queue |
| 543 | * @skb: audit record | 543 | * @skb: audit record |
| 544 | * @error: error code (unused) | ||
| 544 | * | 545 | * |
| 545 | * Description: | 546 | * Description: |
| 546 | * This should only be used by the kauditd_thread when it fails to flush the | 547 | * This should only be used by the kauditd_thread when it fails to flush the |
| 547 | * hold queue. | 548 | * hold queue. |
| 548 | */ | 549 | */ |
| 549 | static void kauditd_rehold_skb(struct sk_buff *skb) | 550 | static void kauditd_rehold_skb(struct sk_buff *skb, __always_unused int error) |
| 550 | { | 551 | { |
| 551 | /* put the record back in the queue at the same place */ | 552 | /* put the record back in the queue */ |
| 552 | skb_queue_head(&audit_hold_queue, skb); | 553 | skb_queue_tail(&audit_hold_queue, skb); |
| 553 | } | 554 | } |
| 554 | 555 | ||
| 555 | /** | 556 | /** |
| 556 | * kauditd_hold_skb - Queue an audit record, waiting for auditd | 557 | * kauditd_hold_skb - Queue an audit record, waiting for auditd |
| 557 | * @skb: audit record | 558 | * @skb: audit record |
| 559 | * @error: error code | ||
| 558 | * | 560 | * |
| 559 | * Description: | 561 | * Description: |
| 560 | * Queue the audit record, waiting for an instance of auditd. When this | 562 | * Queue the audit record, waiting for an instance of auditd. When this |
| @@ -564,19 +566,31 @@ static void kauditd_rehold_skb(struct sk_buff *skb) · 3 unmodified lines | |||
| 564 | * and queue it, if we have room. If we want to hold on to the record, but we | 566 | * and queue it, if we have room. If we want to hold on to the record, but we |
| 565 | * don't have room, record a record lost message. | 567 | * don't have room, record a record lost message. |
| 566 | */ | 568 | */ |
| 567 | static void kauditd_hold_skb(struct sk_buff *skb) | 569 | static void kauditd_hold_skb(struct sk_buff *skb, int error) |
| 568 | { | 570 | { |
| 569 | /* at this point it is uncertain if we will ever send this to auditd so | 571 | /* at this point it is uncertain if we will ever send this to auditd so |
| 570 | * try to send the message via printk before we go any further */ | 572 | * try to send the message via printk before we go any further */ |
| 571 | kauditd_printk_skb(skb); | 573 | kauditd_printk_skb(skb); |
| 572 | 574 | ||
| 573 | /* can we just silently drop the message? */ | 575 | /* can we just silently drop the message? */ |
| 574 | if (!audit_default) { | 576 | if (!audit_default) |
| 575 | kfree_skb(skb); | 577 | goto drop; |
| 576 | return; | 578 | |
| 579 | /* the hold queue is only for when the daemon goes away completely, | ||
| 580 | * not -EAGAIN failures; if we are in a -EAGAIN state requeue the | ||
| 581 | * record on the retry queue unless it's full, in which case drop it | ||
| 582 | */ | ||
| 583 | if (error == -EAGAIN) { | ||
| 584 | if (!audit_backlog_limit || | ||
| 585 | skb_queue_len(&audit_retry_queue) < audit_backlog_limit) { | ||
| 586 | skb_queue_tail(&audit_retry_queue, skb); | ||
| 587 | return; | ||
| 588 | } | ||
| 589 | audit_log_lost("kauditd retry queue overflow"); | ||
| 590 | goto drop; | ||
| 577 | } | 591 | } |
| 578 | 592 | ||
| 579 | /* if we have room, queue the message */ | 593 | /* if we have room in the hold queue, queue the message */ |
| 580 | if (!audit_backlog_limit || | 594 | if (!audit_backlog_limit || |
| 581 | skb_queue_len(&audit_hold_queue) < audit_backlog_limit) { | 595 | skb_queue_len(&audit_hold_queue) < audit_backlog_limit) { |
| 582 | skb_queue_tail(&audit_hold_queue, skb); | 596 | skb_queue_tail(&audit_hold_queue, skb); |
| @@ -585,24 +599,32 @@ static void kauditd_hold_skb(struct sk_buff *skb) · 2 unmodified lines | |||
| 585 | 599 | ||
| 586 | /* we have no other options - drop the message */ | 600 | /* we have no other options - drop the message */ |
| 587 | audit_log_lost("kauditd hold queue overflow"); | 601 | audit_log_lost("kauditd hold queue overflow"); |
| 602 | drop: | ||
| 588 | kfree_skb(skb); | 603 | kfree_skb(skb); |
| 589 | } | 604 | } |
| 590 | 605 | ||
| 591 | /** | 606 | /** |
| 592 | * kauditd_retry_skb - Queue an audit record, attempt to send again to auditd | 607 | * kauditd_retry_skb - Queue an audit record, attempt to send again to auditd |
| 593 | * @skb: audit record | 608 | * @skb: audit record |
| 609 | * @error: error code (unused) | ||
| 594 | * | 610 | * |
| 595 | * Description: | 611 | * Description: |
| 596 | * Not as serious as kauditd_hold_skb() as we still have a connected auditd, | 612 | * Not as serious as kauditd_hold_skb() as we still have a connected auditd, |
| 597 | * but for some reason we are having problems sending it audit records so | 613 | * but for some reason we are having problems sending it audit records so |
| 598 | * queue the given record and attempt to resend. | 614 | * queue the given record and attempt to resend. |
| 599 | */ | 615 | */ |
| 600 | static void kauditd_retry_skb(struct sk_buff *skb) | 616 | static void kauditd_retry_skb(struct sk_buff *skb, __always_unused int error) |
| 601 | { | 617 | { |
| 602 | /* NOTE: because records should only live in the retry queue for a | 618 | if (!audit_backlog_limit || |
| 603 | * short period of time, before either being sent or moved to the hold | 619 | skb_queue_len(&audit_retry_queue) < audit_backlog_limit) { |
| 604 | * queue, we don't currently enforce a limit on this queue */ | 620 | skb_queue_tail(&audit_retry_queue, skb); |
| 605 | skb_queue_tail(&audit_retry_queue, skb); | 621 | return; |
| 622 | } | ||
| 623 | |||
| 624 | /* we have to drop the record, send it via printk as a last effort */ | ||
| 625 | kauditd_printk_skb(skb); | ||
| 626 | audit_log_lost("kauditd retry queue overflow"); | ||
| 627 | kfree_skb(skb); | ||
| 606 | } | 628 | } |
| 607 | 629 | ||
| 608 | /** | 630 | /** |
| @@ -640,7 +662,7 @@ static void auditd_reset(const struct auditd_connection *ac) · 31 unmodified lines | |||
| 640 | /* flush the retry queue to the hold queue, but don't touch the main | 662 | /* flush the retry queue to the hold queue, but don't touch the main |
| 641 | * queue since we need to process that normally for multicast */ | 663 | * queue since we need to process that normally for multicast */ |
| 642 | while ((skb = skb_dequeue(&audit_retry_queue))) | 664 | while ((skb = skb_dequeue(&audit_retry_queue))) |
| 643 | kauditd_hold_skb(skb); | 665 | kauditd_hold_skb(skb, -ECONNREFUSED); |
| 644 | } | 666 | } |
| 645 | 667 | ||
| 646 | /** | 668 | /** |
| @@ -714,16 +736,18 @@ static int kauditd_send_queue(struct sock *sk, u32 portid, · 67 unmodified lines | |||
| 714 | struct sk_buff_head *queue, | 736 | struct sk_buff_head *queue, |
| 715 | unsigned int retry_limit, | 737 | unsigned int retry_limit, |
| 716 | void (*skb_hook)(struct sk_buff *skb), | 738 | void (*skb_hook)(struct sk_buff *skb), |
| 717 | void (*err_hook)(struct sk_buff *skb)) | 739 | void (*err_hook)(struct sk_buff *skb, int error)) |
| 718 | { | 740 | { |
| 719 | int rc = 0; | 741 | int rc = 0; |
| 720 | struct sk_buff *skb; | 742 | struct sk_buff *skb = NULL; |
| 743 | struct sk_buff *skb_tail; | ||
| 721 | unsigned int failed = 0; | 744 | unsigned int failed = 0; |
| 722 | 745 | ||
| 723 | /* NOTE: kauditd_thread takes care of all our locking, we just use | 746 | /* NOTE: kauditd_thread takes care of all our locking, we just use |
| 724 | * the netlink info passed to us (e.g. sk and portid) */ | 747 | * the netlink info passed to us (e.g. sk and portid) */ |
| 725 | 748 | ||
| 726 | while ((skb = skb_dequeue(queue))) { | 749 | skb_tail = skb_peek_tail(queue); |
| 750 | while ((skb != skb_tail) && (skb = skb_dequeue(queue))) { | ||
| 727 | /* call the skb_hook for each skb we touch */ | 751 | /* call the skb_hook for each skb we touch */ |
| 728 | if (skb_hook) | 752 | if (skb_hook) |
| 729 | (*skb_hook)(skb); | 753 | (*skb_hook)(skb); |
| @@ -731,7 +755,7 @@ static int kauditd_send_queue(struct sock *sk, u32 portid, · 1 unmodified line | |||
| 731 | /* can we send to anyone via unicast? */ | 755 | /* can we send to anyone via unicast? */ |
| 732 | if (!sk) { | 756 | if (!sk) { |
| 733 | if (err_hook) | 757 | if (err_hook) |
| 734 | (*err_hook)(skb); | 758 | (*err_hook)(skb, -ECONNREFUSED); |
| 735 | continue; | 759 | continue; |
| 736 | } | 760 | } |
| 737 | 761 | ||
| @@ -745,7 +769,7 @@ retry: · 7 unmodified lines | |||
| 745 | rc == -ECONNREFUSED || rc == -EPERM) { | 769 | rc == -ECONNREFUSED || rc == -EPERM) { |
| 746 | sk = NULL; | 770 | sk = NULL; |
| 747 | if (err_hook) | 771 | if (err_hook) |
| 748 | (*err_hook)(skb); | 772 | (*err_hook)(skb, rc); |
| 749 | if (rc == -EAGAIN) | 773 | if (rc == -EAGAIN) |
| 750 | rc = 0; | 774 | rc = 0; |
| 751 | /* continue to drain the queue */ | 775 | /* continue to drain the queue */ |
| @@ -185,7 +185,7 @@ static int audit_match_perm(struct audit_context *ctx, int mask) · 184 unmodified lines | |||
| 185 | case AUDITSC_EXECVE: | 185 | case AUDITSC_EXECVE: |
| 186 | return mask & AUDIT_PERM_EXEC; | 186 | return mask & AUDIT_PERM_EXEC; |
| 187 | case AUDITSC_OPENAT2: | 187 | case AUDITSC_OPENAT2: |
| 188 | return mask & ACC_MODE((u32)((struct open_how *)ctx->argv[2])->flags); | 188 | return mask & ACC_MODE((u32)ctx->openat2.flags); |
| 189 | default: | 189 | default: |
| 190 | return 0; | 190 | return 0; |
| 191 | } | 191 | } |
| @@ -207,7 +207,7 @@ BTF_ID(func, bpf_lsm_socket_socketpair) · 206 unmodified lines | |||
| 207 | 207 | ||
| 208 | BTF_ID(func, bpf_lsm_syslog) | 208 | BTF_ID(func, bpf_lsm_syslog) |
| 209 | BTF_ID(func, bpf_lsm_task_alloc) | 209 | BTF_ID(func, bpf_lsm_task_alloc) |
| 210 | BTF_ID(func, bpf_lsm_task_getsecid_subj) | 210 | BTF_ID(func, bpf_lsm_current_getsecid_subj) |
| 211 | BTF_ID(func, bpf_lsm_task_getsecid_obj) | 211 | BTF_ID(func, bpf_lsm_task_getsecid_obj) |
| 212 | BTF_ID(func, bpf_lsm_task_prctl) | 212 | BTF_ID(func, bpf_lsm_task_prctl) |
| 213 | BTF_ID(func, bpf_lsm_task_setscheduler) | 213 | BTF_ID(func, bpf_lsm_task_setscheduler) |
| @@ -104,7 +104,7 @@ static struct bpf_ringbuf *bpf_ringbuf_area_alloc(size_t data_sz, int numa_node) · 103 unmodified lines | |||
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | rb = vmap(pages, nr_meta_pages + 2 * nr_data_pages, | 106 | rb = vmap(pages, nr_meta_pages + 2 * nr_data_pages, |
| 107 | VM_ALLOC | VM_USERMAP, PAGE_KERNEL); | 107 | VM_MAP | VM_USERMAP, PAGE_KERNEL); |
| 108 | if (rb) { | 108 | if (rb) { |
| 109 | kmemleak_not_leak(pages); | 109 | kmemleak_not_leak(pages); |
| 110 | rb->pages = pages; | 110 | rb->pages = pages; |
| @@ -472,13 +472,14 @@ BPF_CALL_4(bpf_get_task_stack, struct task_struct *, task, void *, buf, · 471 unmodified lines | |||
| 472 | u32, size, u64, flags) | 472 | u32, size, u64, flags) |
| 473 | { | 473 | { |
| 474 | struct pt_regs *regs; | 474 | struct pt_regs *regs; |
| 475 | long res; | 475 | long res = -EINVAL; |
| 476 | 476 | ||
| 477 | if (!try_get_task_stack(task)) | 477 | if (!try_get_task_stack(task)) |
| 478 | return -EFAULT; | 478 | return -EFAULT; |
| 479 | 479 | ||
| 480 | regs = task_pt_regs(task); | 480 | regs = task_pt_regs(task); |
| 481 | res = __bpf_get_stack(regs, task, NULL, buf, size, flags); | 481 | if (regs) |
| 482 | res = __bpf_get_stack(regs, task, NULL, buf, size, flags); | ||
| 482 | put_task_stack(task); | 483 | put_task_stack(task); |
| 483 | 484 | ||
| 484 | return res; | 485 | return res; |
| @@ -550,11 +550,12 @@ static __always_inline u64 notrace bpf_prog_start_time(void) · 549 unmodified lines | |||
| 550 | static void notrace inc_misses_counter(struct bpf_prog *prog) | 550 | static void notrace inc_misses_counter(struct bpf_prog *prog) |
| 551 | { | 551 | { |
| 552 | struct bpf_prog_stats *stats; | 552 | struct bpf_prog_stats *stats; |
| 553 | unsigned int flags; | ||
| 553 | 554 | ||
| 554 | stats = this_cpu_ptr(prog->stats); | 555 | stats = this_cpu_ptr(prog->stats); |
| 555 | u64_stats_update_begin(&stats->syncp); | 556 | flags = u64_stats_update_begin_irqsave(&stats->syncp); |
| 556 | u64_stats_inc(&stats->misses); | 557 | u64_stats_inc(&stats->misses); |
| 557 | u64_stats_update_end(&stats->syncp); | 558 | u64_stats_update_end_irqrestore(&stats->syncp, flags); |
| 558 | } | 559 | } |
| 559 | 560 | ||
| 560 | /* The logic is similar to bpf_prog_run(), but with an explicit | 561 | /* The logic is similar to bpf_prog_run(), but with an explicit |
| @@ -549,6 +549,14 @@ static ssize_t cgroup_release_agent_write(struct kernfs_open_file *of, · 548 unmodified lines | |||
| 549 | 549 | ||
| 550 | BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX); | 550 | BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX); |
| 551 | 551 | ||
| 552 | /* | ||
| 553 | * Release agent gets called with all capabilities, | ||
| 554 | * require capabilities to set release agent. | ||
| 555 | */ | ||
| 556 | if ((of->file->f_cred->user_ns != &init_user_ns) || | ||
| 557 | !capable(CAP_SYS_ADMIN)) | ||
| 558 | return -EPERM; | ||
| 559 | |||
| 552 | cgrp = cgroup_kn_lock_live(of->kn, false); | 560 | cgrp = cgroup_kn_lock_live(of->kn, false); |
| 553 | if (!cgrp) | 561 | if (!cgrp) |
| 554 | return -ENODEV; | 562 | return -ENODEV; |
| @@ -954,6 +962,12 @@ int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param) · 399 unmodified lines | |||
| 954 | /* Specifying two release agents is forbidden */ | 962 | /* Specifying two release agents is forbidden */ |
| 955 | if (ctx->release_agent) | 963 | if (ctx->release_agent) |
| 956 | return invalfc(fc, "release_agent respecified"); | 964 | return invalfc(fc, "release_agent respecified"); |
| 965 | /* | ||
| 966 | * Release agent gets called with all capabilities, | ||
| 967 | * require capabilities to set release agent. | ||
| 968 | */ | ||
| 969 | if ((fc->user_ns != &init_user_ns) || !capable(CAP_SYS_ADMIN)) | ||
| 970 | return invalfc(fc, "Setting release_agent not allowed"); | ||
| 957 | ctx->release_agent = param->string; | 971 | ctx->release_agent = param->string; |
| 958 | param->string = NULL; | 972 | param->string = NULL; |
| 959 | break; | 973 | break; |
| @@ -3643,6 +3643,12 @@ static ssize_t cgroup_pressure_write(struct kernfs_open_file *of, char *buf, · 3642 unmodified lines | |||
| 3643 | cgroup_get(cgrp); | 3643 | cgroup_get(cgrp); |
| 3644 | cgroup_kn_unlock(of->kn); | 3644 | cgroup_kn_unlock(of->kn); |
| 3645 | 3645 | ||
| 3646 | /* Allow only one trigger per file descriptor */ | ||
| 3647 | if (ctx->psi.trigger) { | ||
| 3648 | cgroup_put(cgrp); | ||
| 3649 | return -EBUSY; | ||
| 3650 | } | ||
| 3651 | |||
| 3646 | psi = cgroup_ino(cgrp) == 1 ? &psi_system : &cgrp->psi; | 3652 | psi = cgroup_ino(cgrp) == 1 ? &psi_system : &cgrp->psi; |
| 3647 | new = psi_trigger_create(psi, buf, nbytes, res); | 3653 | new = psi_trigger_create(psi, buf, nbytes, res); |
| 3648 | if (IS_ERR(new)) { | 3654 | if (IS_ERR(new)) { |
| @@ -3650,8 +3656,7 @@ static ssize_t cgroup_pressure_write(struct kernfs_open_file *of, char *buf, · 1 unmodified line | |||
| 3650 | return PTR_ERR(new); | 3656 | return PTR_ERR(new); |
| 3651 | } | 3657 | } |
| 3652 | 3658 | ||
| 3653 | psi_trigger_replace(&ctx->psi.trigger, new); | 3659 | smp_store_release(&ctx->psi.trigger, new); |
| 3654 | |||
| 3655 | cgroup_put(cgrp); | 3660 | cgroup_put(cgrp); |
| 3656 | 3661 | ||
| 3657 | return nbytes; | 3662 | return nbytes; |
| @@ -3690,7 +3695,7 @@ static void cgroup_pressure_release(struct kernfs_open_file *of) · 32 unmodified lines | |||
| 3690 | { | 3695 | { |
| 3691 | struct cgroup_file_ctx *ctx = of->priv; | 3696 | struct cgroup_file_ctx *ctx = of->priv; |
| 3692 | 3697 | ||
| 3693 | psi_trigger_replace(&ctx->psi.trigger, NULL); | 3698 | psi_trigger_destroy(ctx->psi.trigger); |
| 3694 | } | 3699 | } |
| 3695 | 3700 | ||
| 3696 | bool cgroup_psi_enabled(void) | 3701 | bool cgroup_psi_enabled(void) |
| @@ -590,6 +590,35 @@ static inline void free_cpuset(struct cpuset *cs) · 589 unmodified lines | |||
| 590 | kfree(cs); | 590 | kfree(cs); |
| 591 | } | 591 | } |
| 592 | 592 | ||
| 593 | /* | ||
| 594 | * validate_change_legacy() - Validate conditions specific to legacy (v1) | ||
| 595 | * behavior. | ||
| 596 | */ | ||
| 597 | static int validate_change_legacy(struct cpuset *cur, struct cpuset *trial) | ||
| 598 | { | ||
| 599 | struct cgroup_subsys_state *css; | ||
| 600 | struct cpuset *c, *par; | ||
| 601 | int ret; | ||
| 602 | |||
| 603 | WARN_ON_ONCE(!rcu_read_lock_held()); | ||
| 604 | |||
| 605 | /* Each of our child cpusets must be a subset of us */ | ||
| 606 | ret = -EBUSY; | ||
| 607 | cpuset_for_each_child(c, css, cur) | ||
| 608 | if (!is_cpuset_subset(c, trial)) | ||
| 609 | goto out; | ||
| 610 | |||
| 611 | /* On legacy hierarchy, we must be a subset of our parent cpuset. */ | ||
| 612 | ret = -EACCES; | ||
| 613 | par = parent_cs(cur); | ||
| 614 | if (par && !is_cpuset_subset(trial, par)) | ||
| 615 | goto out; | ||
| 616 | |||
| 617 | ret = 0; | ||
| 618 | out: | ||
| 619 | return ret; | ||
| 620 | } | ||
| 621 | |||
| 593 | /* | 622 | /* |
| 594 | * validate_change() - Used to validate that any proposed cpuset change | 623 | * validate_change() - Used to validate that any proposed cpuset change |
| 595 | * follows the structural rules for cpusets. | 624 | * follows the structural rules for cpusets. |
| @@ -614,20 +643,21 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial) · 18 unmodified lines | |||
| 614 | { | 643 | { |
| 615 | struct cgroup_subsys_state *css; | 644 | struct cgroup_subsys_state *css; |
| 616 | struct cpuset *c, *par; | 645 | struct cpuset *c, *par; |
| 617 | int ret; | 646 | int ret = 0; |
| 618 | |||
| 619 | /* The checks don't apply to root cpuset */ | ||
| 620 | if (cur == &top_cpuset) | ||
| 621 | return 0; | ||
| 622 | 647 | ||
| 623 | rcu_read_lock(); | 648 | rcu_read_lock(); |
| 624 | par = parent_cs(cur); | ||
| 625 | 649 | ||
| 626 | /* On legacy hierarchy, we must be a subset of our parent cpuset. */ | 650 | if (!is_in_v2_mode()) |
| 627 | ret = -EACCES; | 651 | ret = validate_change_legacy(cur, trial); |
| 628 | if (!is_in_v2_mode() && !is_cpuset_subset(trial, par)) | 652 | if (ret) |
| 653 | goto out; | ||
| 654 | |||
| 655 | /* Remaining checks don't apply to root cpuset */ | ||
| 656 | if (cur == &top_cpuset) | ||
| 629 | goto out; | 657 | goto out; |
| 630 | 658 | ||
| 659 | par = parent_cs(cur); | ||
| 660 | |||
| 631 | /* | 661 | /* |
| 632 | * If either I or some sibling (!= me) is exclusive, we can't | 662 | * If either I or some sibling (!= me) is exclusive, we can't |
| 633 | * overlap | 663 | * overlap |
| @@ -1175,9 +1205,7 @@ enum subparts_cmd { · 541 unmodified lines | |||
| 1175 | * | 1205 | * |
| 1176 | * Because of the implicit cpu exclusive nature of a partition root, | 1206 | * Because of the implicit cpu exclusive nature of a partition root, |
| 1177 | * cpumask changes that violates the cpu exclusivity rule will not be | 1207 | * cpumask changes that violates the cpu exclusivity rule will not be |
| 1178 | * permitted when checked by validate_change(). The validate_change() | 1208 | * permitted when checked by validate_change(). |
| 1179 | * function will also prevent any changes to the cpu list if it is not | ||
| 1180 | * a superset of children's cpu lists. | ||
| 1181 | */ | 1209 | */ |
| 1182 | static int update_parent_subparts_cpumask(struct cpuset *cpuset, int cmd, | 1210 | static int update_parent_subparts_cpumask(struct cpuset *cpuset, int cmd, |
| 1183 | struct cpumask *newmask, | 1211 | struct cpumask *newmask, |
| @@ -1522,10 +1550,15 @@ static void update_sibling_cpumasks(struct cpuset *parent, struct cpuset *cs, · 338 unmodified lines | |||
| 1522 | struct cpuset *sibling; | 1550 | struct cpuset *sibling; |
| 1523 | struct cgroup_subsys_state *pos_css; | 1551 | struct cgroup_subsys_state *pos_css; |
| 1524 | 1552 | ||
| 1553 | percpu_rwsem_assert_held(&cpuset_rwsem); | ||
| 1554 | |||
| 1525 | /* | 1555 | /* |
| 1526 | * Check all its siblings and call update_cpumasks_hier() | 1556 | * Check all its siblings and call update_cpumasks_hier() |
| 1527 | * if their use_parent_ecpus flag is set in order for them | 1557 | * if their use_parent_ecpus flag is set in order for them |
| 1528 | * to use the right effective_cpus value. | 1558 | * to use the right effective_cpus value. |
| 1559 | * | ||
| 1560 | * The update_cpumasks_hier() function may sleep. So we have to | ||
| 1561 | * release the RCU read lock before calling it. | ||
| 1529 | */ | 1562 | */ |
| 1530 | rcu_read_lock(); | 1563 | rcu_read_lock(); |
| 1531 | cpuset_for_each_child(sibling, pos_css, parent) { | 1564 | cpuset_for_each_child(sibling, pos_css, parent) { |
| @@ -1533,8 +1566,13 @@ static void update_sibling_cpumasks(struct cpuset *parent, struct cpuset *cs, · 1 unmodified line | |||
| 1533 | continue; | 1566 | continue; |
| 1534 | if (!sibling->use_parent_ecpus) | 1567 | if (!sibling->use_parent_ecpus) |
| 1535 | continue; | 1568 | continue; |
| 1569 | if (!css_tryget_online(&sibling->css)) | ||
| 1570 | continue; | ||
| 1536 | 1571 | ||
| 1572 | rcu_read_unlock(); | ||
| 1537 | update_cpumasks_hier(sibling, tmp); | 1573 | update_cpumasks_hier(sibling, tmp); |
| 1574 | rcu_read_lock(); | ||
| 1575 | css_put(&sibling->css); | ||
| 1538 | } | 1576 | } |
| 1539 | rcu_read_unlock(); | 1577 | rcu_read_unlock(); |
| 1540 | } | 1578 | } |
| @@ -1607,8 +1645,7 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs, · 66 unmodified lines | |||
| 1607 | * Make sure that subparts_cpus is a subset of cpus_allowed. | 1645 | * Make sure that subparts_cpus is a subset of cpus_allowed. |
| 1608 | */ | 1646 | */ |
| 1609 | if (cs->nr_subparts_cpus) { | 1647 | if (cs->nr_subparts_cpus) { |
| 1610 | cpumask_andnot(cs->subparts_cpus, cs->subparts_cpus, | 1648 | cpumask_and(cs->subparts_cpus, cs->subparts_cpus, cs->cpus_allowed); |
| 1611 | cs->cpus_allowed); | ||
| 1612 | cs->nr_subparts_cpus = cpumask_weight(cs->subparts_cpus); | 1649 | cs->nr_subparts_cpus = cpumask_weight(cs->subparts_cpus); |
| 1613 | } | 1650 | } |
| 1614 | spin_unlock_irq(&callback_lock); | 1651 | spin_unlock_irq(&callback_lock); |
| @@ -665,21 +665,16 @@ EXPORT_SYMBOL(cred_fscmp); · 664 unmodified lines | |||
| 665 | 665 | ||
| 666 | int set_cred_ucounts(struct cred *new) | 666 | int set_cred_ucounts(struct cred *new) |
| 667 | { | 667 | { |
| 668 | struct task_struct *task = current; | ||
| 669 | const struct cred *old = task->real_cred; | ||
| 670 | struct ucounts *new_ucounts, *old_ucounts = new->ucounts; | 668 | struct ucounts *new_ucounts, *old_ucounts = new->ucounts; |
| 671 | 669 | ||
| 672 | if (new->user == old->user && new->user_ns == old->user_ns) | ||
| 673 | return 0; | ||
| 674 | |||
| 675 | /* | 670 | /* |
| 676 | * This optimization is needed because alloc_ucounts() uses locks | 671 | * This optimization is needed because alloc_ucounts() uses locks |
| 677 | * for table lookups. | 672 | * for table lookups. |
| 678 | */ | 673 | */ |
| 679 | if (old_ucounts->ns == new->user_ns && uid_eq(old_ucounts->uid, new->euid)) | 674 | if (old_ucounts->ns == new->user_ns && uid_eq(old_ucounts->uid, new->uid)) |
| 680 | return 0; | 675 | return 0; |
| 681 | 676 | ||
| 682 | if (!(new_ucounts = alloc_ucounts(new->user_ns, new->euid))) | 677 | if (!(new_ucounts = alloc_ucounts(new->user_ns, new->uid))) |
| 683 | return -EAGAIN; | 678 | return -EAGAIN; |
| 684 | 679 | ||
| 685 | new->ucounts = new_ucounts; | 680 | new->ucounts = new_ucounts; |
| @@ -674,6 +674,23 @@ perf_event_set_state(struct perf_event *event, enum perf_event_state state) · 673 unmodified lines | |||
| 674 | WRITE_ONCE(event->state, state); | 674 | WRITE_ONCE(event->state, state); |
| 675 | } | 675 | } |
| 676 | 676 | ||
| 677 | /* | ||
| 678 | * UP store-release, load-acquire | ||
| 679 | */ | ||
| 680 | |||
| 681 | #define __store_release(ptr, val) \ | ||
| 682 | do { \ | ||
| 683 | barrier(); \ | ||
| 684 | WRITE_ONCE(*(ptr), (val)); \ | ||
| 685 | } while (0) | ||
| 686 | |||
| 687 | #define __load_acquire(ptr) \ | ||
| 688 | ({ \ | ||
| 689 | __unqual_scalar_typeof(*(ptr)) ___p = READ_ONCE(*(ptr)); \ | ||
| 690 | barrier(); \ | ||
| 691 | ___p; \ | ||
| 692 | }) | ||
| 693 | |||
| 677 | #ifdef CONFIG_CGROUP_PERF | 694 | #ifdef CONFIG_CGROUP_PERF |
| 678 | 695 | ||
| 679 | static inline bool | 696 | static inline bool |
| @@ -719,34 +736,51 @@ static inline u64 perf_cgroup_event_time(struct perf_event *event) · 39 unmodified lines | |||
| 719 | return t->time; | 736 | return t->time; |
| 720 | } | 737 | } |
| 721 | 738 | ||
| 722 | static inline void __update_cgrp_time(struct perf_cgroup *cgrp) | 739 | static inline u64 perf_cgroup_event_time_now(struct perf_event *event, u64 now) |
| 723 | { | 740 | { |
| 724 | struct perf_cgroup_info *info; | 741 | struct perf_cgroup_info *t; |
| 725 | u64 now; | ||
| 726 | |||
| 727 | now = perf_clock(); | ||
| 728 | 742 | ||
| 729 | info = this_cpu_ptr(cgrp->info); | 743 | t = per_cpu_ptr(event->cgrp->info, event->cpu); |
| 744 | if (!__load_acquire(&t->active)) | ||
| 745 | return t->time; | ||
| 746 | now += READ_ONCE(t->timeoffset); | ||
| 747 | return now; | ||
| 748 | } | ||
| 730 | 749 | ||
| 731 | info->time += now - info->timestamp; | 750 | static inline void __update_cgrp_time(struct perf_cgroup_info *info, u64 now, bool adv) |
| 751 | { | ||
| 752 | if (adv) | ||
| 753 | info->time += now - info->timestamp; | ||
| 732 | info->timestamp = now; | 754 | info->timestamp = now; |
| 755 | /* | ||
| 756 | * see update_context_time() | ||
| 757 | */ | ||
| 758 | WRITE_ONCE(info->timeoffset, info->time - info->timestamp); | ||
| 733 | } | 759 | } |
| 734 | 760 | ||
| 735 | static inline void update_cgrp_time_from_cpuctx(struct perf_cpu_context *cpuctx) | 761 | static inline void update_cgrp_time_from_cpuctx(struct perf_cpu_context *cpuctx, bool final) |
| 736 | { | 762 | { |
| 737 | struct perf_cgroup *cgrp = cpuctx->cgrp; | 763 | struct perf_cgroup *cgrp = cpuctx->cgrp; |
| 738 | struct cgroup_subsys_state *css; | 764 | struct cgroup_subsys_state *css; |
| 765 | struct perf_cgroup_info *info; | ||
| 739 | 766 | ||
| 740 | if (cgrp) { | 767 | if (cgrp) { |
| 768 | u64 now = perf_clock(); | ||
| 769 | |||
| 741 | for (css = &cgrp->css; css; css = css->parent) { | 770 | for (css = &cgrp->css; css; css = css->parent) { |
| 742 | cgrp = container_of(css, struct perf_cgroup, css); | 771 | cgrp = container_of(css, struct perf_cgroup, css); |
| 743 | __update_cgrp_time(cgrp); | 772 | info = this_cpu_ptr(cgrp->info); |
| 773 | |||
| 774 | __update_cgrp_time(info, now, true); | ||
| 775 | if (final) | ||
| 776 | __store_release(&info->active, 0); | ||
| 744 | } | 777 | } |
| 745 | } | 778 | } |
| 746 | } | 779 | } |
| 747 | 780 | ||
| 748 | static inline void update_cgrp_time_from_event(struct perf_event *event) | 781 | static inline void update_cgrp_time_from_event(struct perf_event *event) |
| 749 | { | 782 | { |
| 783 | struct perf_cgroup_info *info; | ||
| 750 | struct perf_cgroup *cgrp; | 784 | struct perf_cgroup *cgrp; |
| 751 | 785 | ||
| 752 | /* | 786 | /* |
| @@ -760,8 +794,10 @@ static inline void update_cgrp_time_from_event(struct perf_event *event) · 7 unmodified lines | |||
| 760 | /* | 794 | /* |
| 761 | * Do not update time when cgroup is not active | 795 | * Do not update time when cgroup is not active |
| 762 | */ | 796 | */ |
| 763 | if (cgroup_is_descendant(cgrp->css.cgroup, event->cgrp->css.cgroup)) | 797 | if (cgroup_is_descendant(cgrp->css.cgroup, event->cgrp->css.cgroup)) { |
| 764 | __update_cgrp_time(event->cgrp); | 798 | info = this_cpu_ptr(event->cgrp->info); |
| 799 | __update_cgrp_time(info, perf_clock(), true); | ||
| 800 | } | ||
| 765 | } | 801 | } |
| 766 | 802 | ||
| 767 | static inline void | 803 | static inline void |
| @@ -785,7 +821,8 @@ perf_cgroup_set_timestamp(struct task_struct *task, · 17 unmodified lines | |||
| 785 | for (css = &cgrp->css; css; css = css->parent) { | 821 | for (css = &cgrp->css; css; css = css->parent) { |
| 786 | cgrp = container_of(css, struct perf_cgroup, css); | 822 | cgrp = container_of(css, struct perf_cgroup, css); |
| 787 | info = this_cpu_ptr(cgrp->info); | 823 | info = this_cpu_ptr(cgrp->info); |
| 788 | info->timestamp = ctx->timestamp; | 824 | __update_cgrp_time(info, ctx->timestamp, false); |
| 825 | __store_release(&info->active, 1); | ||
| 789 | } | 826 | } |
| 790 | } | 827 | } |
| 791 | 828 | ||
| @@ -802,7 +839,7 @@ static DEFINE_PER_CPU(struct list_head, cgrp_cpuctx_list); · 10 unmodified lines | |||
| 802 | */ | 839 | */ |
| 803 | static void perf_cgroup_switch(struct task_struct *task, int mode) | 840 | static void perf_cgroup_switch(struct task_struct *task, int mode) |
| 804 | { | 841 | { |
| 805 | struct perf_cpu_context *cpuctx; | 842 | struct perf_cpu_context *cpuctx, *tmp; |
| 806 | struct list_head *list; | 843 | struct list_head *list; |
| 807 | unsigned long flags; | 844 | unsigned long flags; |
| 808 | 845 | ||
| @@ -813,7 +850,7 @@ static void perf_cgroup_switch(struct task_struct *task, int mode) · 4 unmodified lines | |||
| 813 | local_irq_save(flags); | 850 | local_irq_save(flags); |
| 814 | 851 | ||
| 815 | list = this_cpu_ptr(&cgrp_cpuctx_list); | 852 | list = this_cpu_ptr(&cgrp_cpuctx_list); |
| 816 | list_for_each_entry(cpuctx, list, cgrp_cpuctx_entry) { | 853 | list_for_each_entry_safe(cpuctx, tmp, list, cgrp_cpuctx_entry) { |
| 817 | WARN_ON_ONCE(cpuctx->ctx.nr_cgroups == 0); | 854 | WARN_ON_ONCE(cpuctx->ctx.nr_cgroups == 0); |
| 818 | 855 | ||
| 819 | perf_ctx_lock(cpuctx, cpuctx->task_ctx); | 856 | perf_ctx_lock(cpuctx, cpuctx->task_ctx); |
| @@ -981,14 +1018,6 @@ out: · 161 unmodified lines | |||
| 981 | return ret; | 1018 | return ret; |
| 982 | } | 1019 | } |
| 983 | 1020 | ||
| 984 | static inline void | ||
| 985 | perf_cgroup_set_shadow_time(struct perf_event *event, u64 now) | ||
| 986 | { | ||
| 987 | struct perf_cgroup_info *t; | ||
| 988 | t = per_cpu_ptr(event->cgrp->info, event->cpu); | ||
| 989 | event->shadow_ctx_time = now - t->timestamp; | ||
| 990 | } | ||
| 991 | |||
| 992 | static inline void | 1021 | static inline void |
| 993 | perf_cgroup_event_enable(struct perf_event *event, struct perf_event_context *ctx) | 1022 | perf_cgroup_event_enable(struct perf_event *event, struct perf_event_context *ctx) |
| 994 | { | 1023 | { |
| @@ -1066,7 +1095,8 @@ static inline void update_cgrp_time_from_event(struct perf_event *event) · 71 unmodified lines | |||
| 1066 | { | 1095 | { |
| 1067 | } | 1096 | } |
| 1068 | 1097 | ||
| 1069 | static inline void update_cgrp_time_from_cpuctx(struct perf_cpu_context *cpuctx) | 1098 | static inline void update_cgrp_time_from_cpuctx(struct perf_cpu_context *cpuctx, |
| 1099 | bool final) | ||
| 1070 | { | 1100 | { |
| 1071 | } | 1101 | } |
| 1072 | 1102 | ||
| @@ -1098,12 +1128,12 @@ perf_cgroup_switch(struct task_struct *task, struct task_struct *next) · 25 unmodified lines | |||
| 1098 | { | 1128 | { |
| 1099 | } | 1129 | } |
| 1100 | 1130 | ||
| 1101 | static inline void | 1131 | static inline u64 perf_cgroup_event_time(struct perf_event *event) |
| 1102 | perf_cgroup_set_shadow_time(struct perf_event *event, u64 now) | ||
| 1103 | { | 1132 | { |
| 1133 | return 0; | ||
| 1104 | } | 1134 | } |
| 1105 | 1135 | ||
| 1106 | static inline u64 perf_cgroup_event_time(struct perf_event *event) | 1136 | static inline u64 perf_cgroup_event_time_now(struct perf_event *event, u64 now) |
| 1107 | { | 1137 | { |
| 1108 | return 0; | 1138 | return 0; |
| 1109 | } | 1139 | } |
| @@ -1525,22 +1555,59 @@ static void perf_unpin_context(struct perf_event_context *ctx) · 415 unmodified lines | |||
| 1525 | /* | 1555 | /* |
| 1526 | * Update the record of the current time in a context. | 1556 | * Update the record of the current time in a context. |
| 1527 | */ | 1557 | */ |
| 1528 | static void update_context_time(struct perf_event_context *ctx) | 1558 | static void __update_context_time(struct perf_event_context *ctx, bool adv) |
| 1529 | { | 1559 | { |
| 1530 | u64 now = perf_clock(); | 1560 | u64 now = perf_clock(); |
| 1531 | 1561 | ||
| 1532 | ctx->time += now - ctx->timestamp; | 1562 | if (adv) |
| 1563 | ctx->time += now - ctx->timestamp; | ||
| 1533 | ctx->timestamp = now; | 1564 | ctx->timestamp = now; |
| 1565 | |||
| 1566 | /* | ||
| 1567 | * The above: time' = time + (now - timestamp), can be re-arranged | ||
| 1568 | * into: time` = now + (time - timestamp), which gives a single value | ||
| 1569 | * offset to compute future time without locks on. | ||
| 1570 | * | ||
| 1571 | * See perf_event_time_now(), which can be used from NMI context where | ||
| 1572 | * it's (obviously) not possible to acquire ctx->lock in order to read | ||
| 1573 | * both the above values in a consistent manner. | ||
| 1574 | */ | ||
| 1575 | WRITE_ONCE(ctx->timeoffset, ctx->time - ctx->timestamp); | ||
| 1576 | } | ||
| 1577 | |||
| 1578 | static void update_context_time(struct perf_event_context *ctx) | ||
| 1579 | { | ||
| 1580 | __update_context_time(ctx, true); | ||
| 1534 | } | 1581 | } |
| 1535 | 1582 | ||
| 1536 | static u64 perf_event_time(struct perf_event *event) | 1583 | static u64 perf_event_time(struct perf_event *event) |
| 1537 | { | 1584 | { |
| 1538 | struct perf_event_context *ctx = event->ctx; | 1585 | struct perf_event_context *ctx = event->ctx; |
| 1539 | 1586 | ||
| 1587 | if (unlikely(!ctx)) | ||
| 1588 | return 0; | ||
| 1589 | |||
| 1540 | if (is_cgroup_event(event)) | 1590 | if (is_cgroup_event(event)) |
| 1541 | return perf_cgroup_event_time(event); | 1591 | return perf_cgroup_event_time(event); |
| 1542 | 1592 | ||
| 1543 | return ctx ? ctx->time : 0; | 1593 | return ctx->time; |
| 1594 | } | ||
| 1595 | |||
| 1596 | static u64 perf_event_time_now(struct perf_event *event, u64 now) | ||
| 1597 | { | ||
| 1598 | struct perf_event_context *ctx = event->ctx; | ||
| 1599 | |||
| 1600 | if (unlikely(!ctx)) | ||
| 1601 | return 0; | ||
| 1602 | |||
| 1603 | if (is_cgroup_event(event)) | ||
| 1604 | return perf_cgroup_event_time_now(event, now); | ||
| 1605 | |||
| 1606 | if (!(__load_acquire(&ctx->is_active) & EVENT_TIME)) | ||
| 1607 | return ctx->time; | ||
| 1608 | |||
| 1609 | now += READ_ONCE(ctx->timeoffset); | ||
| 1610 | return now; | ||
| 1544 | } | 1611 | } |
| 1545 | 1612 | ||
| 1546 | static enum event_type_t get_event_type(struct perf_event *event) | 1613 | static enum event_type_t get_event_type(struct perf_event *event) |
| @@ -2350,7 +2417,7 @@ __perf_remove_from_context(struct perf_event *event, · 803 unmodified lines | |||
| 2350 | 2417 | ||
| 2351 | if (ctx->is_active & EVENT_TIME) { | 2418 | if (ctx->is_active & EVENT_TIME) { |
| 2352 | update_context_time(ctx); | 2419 | update_context_time(ctx); |
| 2353 | update_cgrp_time_from_cpuctx(cpuctx); | 2420 | update_cgrp_time_from_cpuctx(cpuctx, false); |
| 2354 | } | 2421 | } |
| 2355 | 2422 | ||
| 2356 | event_sched_out(event, cpuctx, ctx); | 2423 | event_sched_out(event, cpuctx, ctx); |
| @@ -2361,6 +2428,9 @@ __perf_remove_from_context(struct perf_event *event, · 4 unmodified lines | |||
| 2361 | list_del_event(event, ctx); | 2428 | list_del_event(event, ctx); |
| 2362 | 2429 | ||
| 2363 | if (!ctx->nr_events && ctx->is_active) { | 2430 | if (!ctx->nr_events && ctx->is_active) { |
| 2431 | if (ctx == &cpuctx->ctx) | ||
| 2432 | update_cgrp_time_from_cpuctx(cpuctx, true); | ||
| 2433 | |||
| 2364 | ctx->is_active = 0; | 2434 | ctx->is_active = 0; |
| 2365 | ctx->rotate_necessary = 0; | 2435 | ctx->rotate_necessary = 0; |
| 2366 | if (ctx->task) { | 2436 | if (ctx->task) { |
| @@ -2392,7 +2462,11 @@ static void perf_remove_from_context(struct perf_event *event, unsigned long fla · 25 unmodified lines | |||
| 2392 | * event_function_call() user. | 2462 | * event_function_call() user. |
| 2393 | */ | 2463 | */ |
| 2394 | raw_spin_lock_irq(&ctx->lock); | 2464 | raw_spin_lock_irq(&ctx->lock); |
| 2395 | if (!ctx->is_active) { | 2465 | /* |
| 2466 | * Cgroup events are per-cpu events, and must IPI because of | ||
| 2467 | * cgrp_cpuctx_list. | ||
| 2468 | */ | ||
| 2469 | if (!ctx->is_active && !is_cgroup_event(event)) { | ||
| 2396 | __perf_remove_from_context(event, __get_cpu_context(ctx), | 2470 | __perf_remove_from_context(event, __get_cpu_context(ctx), |
| 2397 | ctx, (void *)flags); | 2471 | ctx, (void *)flags); |
| 2398 | raw_spin_unlock_irq(&ctx->lock); | 2472 | raw_spin_unlock_irq(&ctx->lock); |
| @@ -2482,40 +2556,6 @@ void perf_event_disable_inatomic(struct perf_event *event) · 83 unmodified lines | |||
| 2482 | irq_work_queue(&event->pending); | 2556 | irq_work_queue(&event->pending); |
| 2483 | } | 2557 | } |
| 2484 | 2558 | ||
| 2485 | static void perf_set_shadow_time(struct perf_event *event, | ||
| 2486 | struct perf_event_context *ctx) | ||
| 2487 | { | ||
| 2488 | /* | ||
| 2489 | * use the correct time source for the time snapshot | ||
| 2490 | * | ||
| 2491 | * We could get by without this by leveraging the | ||
| 2492 | * fact that to get to this function, the caller | ||
| 2493 | * has most likely already called update_context_time() | ||
| 2494 | * and update_cgrp_time_xx() and thus both timestamp | ||
| 2495 | * are identical (or very close). Given that tstamp is, | ||
| 2496 | * already adjusted for cgroup, we could say that: | ||
| 2497 | * tstamp - ctx->timestamp | ||
| 2498 | * is equivalent to | ||
| 2499 | * tstamp - cgrp->timestamp. | ||
| 2500 | * | ||
| 2501 | * Then, in perf_output_read(), the calculation would | ||
| 2502 | * work with no changes because: | ||
| 2503 | * - event is guaranteed scheduled in | ||
| 2504 | * - no scheduled out in between | ||
| 2505 | * - thus the timestamp would be the same | ||
| 2506 | * | ||
| 2507 | * But this is a bit hairy. | ||
| 2508 | * | ||
| 2509 | * So instead, we have an explicit cgroup call to remain | ||
| 2510 | * within the time source all along. We believe it | ||
| 2511 | * is cleaner and simpler to understand. | ||
| 2512 | */ | ||
| 2513 | if (is_cgroup_event(event)) | ||
| 2514 | perf_cgroup_set_shadow_time(event, event->tstamp); | ||
| 2515 | else | ||
| 2516 | event->shadow_ctx_time = event->tstamp - ctx->timestamp; | ||
| 2517 | } | ||
| 2518 | |||
| 2519 | #define MAX_INTERRUPTS (~0ULL) | 2559 | #define MAX_INTERRUPTS (~0ULL) |
| 2520 | 2560 | ||
| 2521 | static void perf_log_throttle(struct perf_event *event, int enable); | 2561 | static void perf_log_throttle(struct perf_event *event, int enable); |
| @@ -2556,8 +2596,6 @@ event_sched_in(struct perf_event *event, · 34 unmodified lines | |||
| 2556 | 2596 | ||
| 2557 | perf_pmu_disable(event->pmu); | 2597 | perf_pmu_disable(event->pmu); |
| 2558 | 2598 | ||
| 2559 | perf_set_shadow_time(event, ctx); | ||
| 2560 | |||
| 2561 | perf_log_itrace_start(event); | 2599 | perf_log_itrace_start(event); |
| 2562 | 2600 | ||
| 2563 | if (event->pmu->add(event, PERF_EF_START)) { | 2601 | if (event->pmu->add(event, PERF_EF_START)) { |
| @@ -2861,11 +2899,14 @@ perf_install_in_context(struct perf_event_context *ctx, · 297 unmodified lines | |||
| 2861 | * perf_event_attr::disabled events will not run and can be initialized | 2899 | * perf_event_attr::disabled events will not run and can be initialized |
| 2862 | * without IPI. Except when this is the first event for the context, in | 2900 | * without IPI. Except when this is the first event for the context, in |
| 2863 | * that case we need the magic of the IPI to set ctx->is_active. | 2901 | * that case we need the magic of the IPI to set ctx->is_active. |
| 2902 | * Similarly, cgroup events for the context also needs the IPI to | ||
| 2903 | * manipulate the cgrp_cpuctx_list. | ||
| 2864 | * | 2904 | * |
| 2865 | * The IOC_ENABLE that is sure to follow the creation of a disabled | 2905 | * The IOC_ENABLE that is sure to follow the creation of a disabled |
| 2866 | * event will issue the IPI and reprogram the hardware. | 2906 | * event will issue the IPI and reprogram the hardware. |
| 2867 | */ | 2907 | */ |
| 2868 | if (__perf_effective_state(event) == PERF_EVENT_STATE_OFF && ctx->nr_events) { | 2908 | if (__perf_effective_state(event) == PERF_EVENT_STATE_OFF && |
| 2909 | ctx->nr_events && !is_cgroup_event(event)) { | ||
| 2869 | raw_spin_lock_irq(&ctx->lock); | 2910 | raw_spin_lock_irq(&ctx->lock); |
| 2870 | if (ctx->task == TASK_TOMBSTONE) { | 2911 | if (ctx->task == TASK_TOMBSTONE) { |
| 2871 | raw_spin_unlock_irq(&ctx->lock); | 2912 | raw_spin_unlock_irq(&ctx->lock); |
| @@ -3197,6 +3238,15 @@ static int perf_event_modify_breakpoint(struct perf_event *bp, · 325 unmodified lines | |||
| 3197 | return err; | 3238 | return err; |
| 3198 | } | 3239 | } |
| 3199 | 3240 | ||
| 3241 | /* | ||
| 3242 | * Copy event-type-independent attributes that may be modified. | ||
| 3243 | */ | ||
| 3244 | static void perf_event_modify_copy_attr(struct perf_event_attr *to, | ||
| 3245 | const struct perf_event_attr *from) | ||
| 3246 | { | ||
| 3247 | to->sig_data = from->sig_data; | ||
| 3248 | } | ||
| 3249 | |||
| 3200 | static int perf_event_modify_attr(struct perf_event *event, | 3250 | static int perf_event_modify_attr(struct perf_event *event, |
| 3201 | struct perf_event_attr *attr) | 3251 | struct perf_event_attr *attr) |
| 3202 | { | 3252 | { |
| @@ -3219,10 +3269,17 @@ static int perf_event_modify_attr(struct perf_event *event, · 16 unmodified lines | |||
| 3219 | WARN_ON_ONCE(event->ctx->parent_ctx); | 3269 | WARN_ON_ONCE(event->ctx->parent_ctx); |
| 3220 | 3270 | ||
| 3221 | mutex_lock(&event->child_mutex); | 3271 | mutex_lock(&event->child_mutex); |
| 3272 | /* | ||
| 3273 | * Event-type-independent attributes must be copied before event-type | ||
| 3274 | * modification, which will validate that final attributes match the | ||
| 3275 | * source attributes after all relevant attributes have been copied. | ||
| 3276 | */ | ||
| 3277 | perf_event_modify_copy_attr(&event->attr, attr); | ||
| 3222 | err = func(event, attr); | 3278 | err = func(event, attr); |
| 3223 | if (err) | 3279 | if (err) |
| 3224 | goto out; | 3280 | goto out; |
| 3225 | list_for_each_entry(child, &event->child_list, child_list) { | 3281 | list_for_each_entry(child, &event->child_list, child_list) { |
| 3282 | perf_event_modify_copy_attr(&child->attr, attr); | ||
| 3226 | err = func(child, attr); | 3283 | err = func(child, attr); |
| 3227 | if (err) | 3284 | if (err) |
| 3228 | goto out; | 3285 | goto out; |
| @@ -3251,16 +3308,6 @@ static void ctx_sched_out(struct perf_event_context *ctx, · 22 unmodified lines | |||
| 3251 | return; | 3308 | return; |
| 3252 | } | 3309 | } |
| 3253 | 3310 | ||
| 3254 | ctx->is_active &= ~event_type; | ||
| 3255 | if (!(ctx->is_active & EVENT_ALL)) | ||
| 3256 | ctx->is_active = 0; | ||
| 3257 | |||
| 3258 | if (ctx->task) { | ||
| 3259 | WARN_ON_ONCE(cpuctx->task_ctx != ctx); | ||
| 3260 | if (!ctx->is_active) | ||
| 3261 | cpuctx->task_ctx = NULL; | ||
| 3262 | } | ||
| 3263 | |||
| 3264 | /* | 3311 | /* |
| 3265 | * Always update time if it was set; not only when it changes. | 3312 | * Always update time if it was set; not only when it changes. |
| 3266 | * Otherwise we can 'forget' to update time for any but the last | 3313 | * Otherwise we can 'forget' to update time for any but the last |
| @@ -3274,7 +3321,22 @@ static void ctx_sched_out(struct perf_event_context *ctx, · 7 unmodified lines | |||
| 3274 | if (is_active & EVENT_TIME) { | 3321 | if (is_active & EVENT_TIME) { |
| 3275 | /* update (and stop) ctx time */ | 3322 | /* update (and stop) ctx time */ |
| 3276 | update_context_time(ctx); | 3323 | update_context_time(ctx); |
| 3277 | update_cgrp_time_from_cpuctx(cpuctx); | 3324 | update_cgrp_time_from_cpuctx(cpuctx, ctx == &cpuctx->ctx); |
| 3325 | /* | ||
| 3326 | * CPU-release for the below ->is_active store, | ||
| 3327 | * see __load_acquire() in perf_event_time_now() | ||
| 3328 | */ | ||
| 3329 | barrier(); | ||
| 3330 | } | ||
| 3331 | |||
| 3332 | ctx->is_active &= ~event_type; | ||
| 3333 | if (!(ctx->is_active & EVENT_ALL)) | ||
| 3334 | ctx->is_active = 0; | ||
| 3335 | |||
| 3336 | if (ctx->task) { | ||
| 3337 | WARN_ON_ONCE(cpuctx->task_ctx != ctx); | ||
| 3338 | if (!ctx->is_active) | ||
| 3339 | cpuctx->task_ctx = NULL; | ||
| 3278 | } | 3340 | } |
| 3279 | 3341 | ||
| 3280 | is_active ^= ctx->is_active; /* changed bits */ | 3342 | is_active ^= ctx->is_active; /* changed bits */ |
| @@ -3711,13 +3773,19 @@ static noinline int visit_groups_merge(struct perf_cpu_context *cpuctx, · 430 unmodified lines | |||
| 3711 | return 0; | 3773 | return 0; |
| 3712 | } | 3774 | } |
| 3713 | 3775 | ||
| 3776 | /* | ||
| 3777 | * Because the userpage is strictly per-event (there is no concept of context, | ||
| 3778 | * so there cannot be a context indirection), every userpage must be updated | ||
| 3779 | * when context time starts :-( | ||
| 3780 | * | ||
| 3781 | * IOW, we must not miss EVENT_TIME edges. | ||
| 3782 | */ | ||
| 3714 | static inline bool event_update_userpage(struct perf_event *event) | 3783 | static inline bool event_update_userpage(struct perf_event *event) |
| 3715 | { | 3784 | { |
| 3716 | if (likely(!atomic_read(&event->mmap_count))) | 3785 | if (likely(!atomic_read(&event->mmap_count))) |
| 3717 | return false; | 3786 | return false; |
| 3718 | 3787 | ||
| 3719 | perf_event_update_time(event); | 3788 | perf_event_update_time(event); |
| 3720 | perf_set_shadow_time(event, event->ctx); | ||
| 3721 | perf_event_update_userpage(event); | 3789 | perf_event_update_userpage(event); |
| 3722 | 3790 | ||
| 3723 | return true; | 3791 | return true; |
| @@ -3801,13 +3869,23 @@ ctx_sched_in(struct perf_event_context *ctx, · 77 unmodified lines | |||
| 3801 | struct task_struct *task) | 3869 | struct task_struct *task) |
| 3802 | { | 3870 | { |
| 3803 | int is_active = ctx->is_active; | 3871 | int is_active = ctx->is_active; |
| 3804 | u64 now; | ||
| 3805 | 3872 | ||
| 3806 | lockdep_assert_held(&ctx->lock); | 3873 | lockdep_assert_held(&ctx->lock); |
| 3807 | 3874 | ||
| 3808 | if (likely(!ctx->nr_events)) | 3875 | if (likely(!ctx->nr_events)) |
| 3809 | return; | 3876 | return; |
| 3810 | 3877 | ||
| 3878 | if (is_active ^ EVENT_TIME) { | ||
| 3879 | /* start ctx time */ | ||
| 3880 | __update_context_time(ctx, false); | ||
| 3881 | perf_cgroup_set_timestamp(task, ctx); | ||
| 3882 | /* | ||
| 3883 | * CPU-release for the below ->is_active store, | ||
| 3884 | * see __load_acquire() in perf_event_time_now() | ||
| 3885 | */ | ||
| 3886 | barrier(); | ||
| 3887 | } | ||
| 3888 | |||
| 3811 | ctx->is_active |= (event_type | EVENT_TIME); | 3889 | ctx->is_active |= (event_type | EVENT_TIME); |
| 3812 | if (ctx->task) { | 3890 | if (ctx->task) { |
| 3813 | if (!is_active) | 3891 | if (!is_active) |
| @@ -3818,13 +3896,6 @@ ctx_sched_in(struct perf_event_context *ctx, · 4 unmodified lines | |||
| 3818 | 3896 | ||
| 3819 | is_active ^= ctx->is_active; /* changed bits */ | 3897 | is_active ^= ctx->is_active; /* changed bits */ |
| 3820 | 3898 | ||
| 3821 | if (is_active & EVENT_TIME) { | ||
| 3822 | /* start ctx time */ | ||
| 3823 | now = perf_clock(); | ||
| 3824 | ctx->timestamp = now; | ||
| 3825 | perf_cgroup_set_timestamp(task, ctx); | ||
| 3826 | } | ||
| 3827 | |||
| 3828 | /* | 3899 | /* |
| 3829 | * First go through the list and put on any pinned groups | 3900 | * First go through the list and put on any pinned groups |
| 3830 | * in order to give them the best chance of going on. | 3901 | * in order to give them the best chance of going on. |
| @@ -4418,6 +4489,18 @@ static inline u64 perf_event_count(struct perf_event *event) · 587 unmodified lines | |||
| 4418 | return local64_read(&event->count) + atomic64_read(&event->child_count); | 4489 | return local64_read(&event->count) + atomic64_read(&event->child_count); |
| 4419 | } | 4490 | } |
| 4420 | 4491 | ||
| 4492 | static void calc_timer_values(struct perf_event *event, | ||
| 4493 | u64 *now, | ||
| 4494 | u64 *enabled, | ||
| 4495 | u64 *running) | ||
| 4496 | { | ||
| 4497 | u64 ctx_time; | ||
| 4498 | |||
| 4499 | *now = perf_clock(); | ||
| 4500 | ctx_time = perf_event_time_now(event, *now); | ||
| 4501 | __perf_update_times(event, ctx_time, enabled, running); | ||
| 4502 | } | ||
| 4503 | |||
| 4421 | /* | 4504 | /* |
| 4422 | * NMI-safe method to read a local event, that is an event that | 4505 | * NMI-safe method to read a local event, that is an event that |
| 4423 | * is: | 4506 | * is: |
| @@ -4477,10 +4560,9 @@ int perf_event_read_local(struct perf_event *event, u64 *value, · 53 unmodified lines | |||
| 4477 | 4560 | ||
| 4478 | *value = local64_read(&event->count); | 4561 | *value = local64_read(&event->count); |
| 4479 | if (enabled || running) { | 4562 | if (enabled || running) { |
| 4480 | u64 now = event->shadow_ctx_time + perf_clock(); | 4563 | u64 __enabled, __running, __now;; |
| 4481 | u64 __enabled, __running; | ||
| 4482 | 4564 | ||
| 4483 | __perf_update_times(event, now, &__enabled, &__running); | 4565 | calc_timer_values(event, &__now, &__enabled, &__running); |
| 4484 | if (enabled) | 4566 | if (enabled) |
| 4485 | *enabled = __enabled; | 4567 | *enabled = __enabled; |
| 4486 | if (running) | 4568 | if (running) |
| @@ -5802,18 +5884,6 @@ static int perf_event_index(struct perf_event *event) · 1315 unmodified lines | |||
| 5802 | return event->pmu->event_idx(event); | 5884 | return event->pmu->event_idx(event); |
| 5803 | } | 5885 | } |
| 5804 | 5886 | ||
| 5805 | static void calc_timer_values(struct perf_event *event, | ||
| 5806 | u64 *now, | ||
| 5807 | u64 *enabled, | ||
| 5808 | u64 *running) | ||
| 5809 | { | ||
| 5810 | u64 ctx_time; | ||
| 5811 | |||
| 5812 | *now = perf_clock(); | ||
| 5813 | ctx_time = event->shadow_ctx_time + *now; | ||
| 5814 | __perf_update_times(event, ctx_time, enabled, running); | ||
| 5815 | } | ||
| 5816 | |||
| 5817 | static void perf_event_init_userpage(struct perf_event *event) | 5887 | static void perf_event_init_userpage(struct perf_event *event) |
| 5818 | { | 5888 | { |
| 5819 | struct perf_event_mmap_page *userpg; | 5889 | struct perf_event_mmap_page *userpg; |
| @@ -5938,6 +6008,8 @@ static void ring_buffer_attach(struct perf_event *event, · 118 unmodified lines | |||
| 5938 | struct perf_buffer *old_rb = NULL; | 6008 | struct perf_buffer *old_rb = NULL; |
| 5939 | unsigned long flags; | 6009 | unsigned long flags; |
| 5940 | 6010 | ||
| 6011 | WARN_ON_ONCE(event->parent); | ||
| 6012 | |||
| 5941 | if (event->rb) { | 6013 | if (event->rb) { |
| 5942 | /* | 6014 | /* |
| 5943 | * Should be impossible, we set this when removing | 6015 | * Should be impossible, we set this when removing |
| @@ -5995,6 +6067,9 @@ static void ring_buffer_wakeup(struct perf_event *event) · 51 unmodified lines | |||
| 5995 | { | 6067 | { |
| 5996 | struct perf_buffer *rb; | 6068 | struct perf_buffer *rb; |
| 5997 | 6069 | ||
| 6070 | if (event->parent) | ||
| 6071 | event = event->parent; | ||
| 6072 | |||
| 5998 | rcu_read_lock(); | 6073 | rcu_read_lock(); |
| 5999 | rb = rcu_dereference(event->rb); | 6074 | rb = rcu_dereference(event->rb); |
| 6000 | if (rb) { | 6075 | if (rb) { |
| @@ -6008,6 +6083,9 @@ struct perf_buffer *ring_buffer_get(struct perf_event *event) · 7 unmodified lines | |||
| 6008 | { | 6083 | { |
| 6009 | struct perf_buffer *rb; | 6084 | struct perf_buffer *rb; |
| 6010 | 6085 | ||
| 6086 | if (event->parent) | ||
| 6087 | event = event->parent; | ||
| 6088 | |||
| 6011 | rcu_read_lock(); | 6089 | rcu_read_lock(); |
| 6012 | rb = rcu_dereference(event->rb); | 6090 | rb = rcu_dereference(event->rb); |
| 6013 | if (rb) { | 6091 | if (rb) { |
| @@ -6353,7 +6431,6 @@ accounting: · 339 unmodified lines | |||
| 6353 | ring_buffer_attach(event, rb); | 6431 | ring_buffer_attach(event, rb); |
| 6354 | 6432 | ||
| 6355 | perf_event_update_time(event); | 6433 | perf_event_update_time(event); |
| 6356 | perf_set_shadow_time(event, event->ctx); | ||
| 6357 | perf_event_init_userpage(event); | 6434 | perf_event_init_userpage(event); |
| 6358 | perf_event_update_userpage(event); | 6435 | perf_event_update_userpage(event); |
| 6359 | } else { | 6436 | } else { |
| @@ -6717,7 +6794,7 @@ static unsigned long perf_prepare_sample_aux(struct perf_event *event, · 357 unmodified lines | |||
| 6717 | if (WARN_ON_ONCE(READ_ONCE(sampler->oncpu) != smp_processor_id())) | 6794 | if (WARN_ON_ONCE(READ_ONCE(sampler->oncpu) != smp_processor_id())) |
| 6718 | goto out; | 6795 | goto out; |
| 6719 | 6796 | ||
| 6720 | rb = ring_buffer_get(sampler->parent ? sampler->parent : sampler); | 6797 | rb = ring_buffer_get(sampler); |
| 6721 | if (!rb) | 6798 | if (!rb) |
| 6722 | goto out; | 6799 | goto out; |
| 6723 | 6800 | ||
| @@ -6783,7 +6860,7 @@ static void perf_aux_sample_output(struct perf_event *event, · 59 unmodified lines | |||
| 6783 | if (WARN_ON_ONCE(!sampler || !data->aux_size)) | 6860 | if (WARN_ON_ONCE(!sampler || !data->aux_size)) |
| 6784 | return; | 6861 | return; |
| 6785 | 6862 | ||
| 6786 | rb = ring_buffer_get(sampler->parent ? sampler->parent : sampler); | 6863 | rb = ring_buffer_get(sampler); |
| 6787 | if (!rb) | 6864 | if (!rb) |
| 6788 | return; | 6865 | return; |
| 6789 | 6866 | ||
| @@ -2021,18 +2021,18 @@ static __latent_entropy struct task_struct *copy_process( · 2020 unmodified lines | |||
| 2021 | #ifdef CONFIG_PROVE_LOCKING | 2021 | #ifdef CONFIG_PROVE_LOCKING |
| 2022 | DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled); | 2022 | DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled); |
| 2023 | #endif | 2023 | #endif |
| 2024 | retval = copy_creds(p, clone_flags); | ||
| 2025 | if (retval < 0) | ||
| 2026 | goto bad_fork_free; | ||
| 2027 | |||
| 2024 | retval = -EAGAIN; | 2028 | retval = -EAGAIN; |
| 2025 | if (is_ucounts_overlimit(task_ucounts(p), UCOUNT_RLIMIT_NPROC, rlimit(RLIMIT_NPROC))) { | 2029 | if (is_ucounts_overlimit(task_ucounts(p), UCOUNT_RLIMIT_NPROC, rlimit(RLIMIT_NPROC))) { |
| 2026 | if (p->real_cred->user != INIT_USER && | 2030 | if (p->real_cred->user != INIT_USER && |
| 2027 | !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN)) | 2031 | !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN)) |
| 2028 | goto bad_fork_free; | 2032 | goto bad_fork_cleanup_count; |
| 2029 | } | 2033 | } |
| 2030 | current->flags &= ~PF_NPROC_EXCEEDED; | 2034 | current->flags &= ~PF_NPROC_EXCEEDED; |
| 2031 | 2035 | ||
| 2032 | retval = copy_creds(p, clone_flags); | ||
| 2033 | if (retval < 0) | ||
| 2034 | goto bad_fork_free; | ||
| 2035 | |||
| 2036 | /* | 2036 | /* |
| 2037 | * If multiple threads are within copy_process(), then this check | 2037 | * If multiple threads are within copy_process(), then this check |
| 2038 | * triggers too late. This doesn't hurt, the check is only there | 2038 | * triggers too late. This doesn't hurt, the check is only there |
| @@ -2266,6 +2266,17 @@ static __latent_entropy struct task_struct *copy_process( · 227 unmodified lines | |||
| 2266 | if (retval) | 2266 | if (retval) |
| 2267 | goto bad_fork_put_pidfd; | 2267 | goto bad_fork_put_pidfd; |
| 2268 | 2268 | ||
| 2269 | /* | ||
| 2270 | * Now that the cgroups are pinned, re-clone the parent cgroup and put | ||
| 2271 | * the new task on the correct runqueue. All this *before* the task | ||
| 2272 | * becomes visible. | ||
| 2273 | * | ||
| 2274 | * This isn't part of ->can_fork() because while the re-cloning is | ||
| 2275 | * cgroup specific, it unconditionally needs to place the task on a | ||
| 2276 | * runqueue. | ||
| 2277 | */ | ||
| 2278 | sched_cgroup_fork(p, args); | ||
| 2279 | |||
| 2269 | /* | 2280 | /* |
| 2270 | * From this point on we must avoid any synchronous user-space | 2281 | * From this point on we must avoid any synchronous user-space |
| 2271 | * communication until we take the tasklist-lock. In particular, we do | 2282 | * communication until we take the tasklist-lock. In particular, we do |
| @@ -2323,10 +2334,6 @@ static __latent_entropy struct task_struct *copy_process( · 51 unmodified lines | |||
| 2323 | goto bad_fork_cancel_cgroup; | 2334 | goto bad_fork_cancel_cgroup; |
| 2324 | } | 2335 | } |
| 2325 | 2336 | ||
| 2326 | /* past the last point of failure */ | ||
| 2327 | if (pidfile) | ||
| 2328 | fd_install(pidfd, pidfile); | ||
| 2329 | |||
| 2330 | init_task_pid_links(p); | 2337 | init_task_pid_links(p); |
| 2331 | if (likely(p->pid)) { | 2338 | if (likely(p->pid)) { |
| 2332 | ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace); | 2339 | ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace); |
| @@ -2375,8 +2382,11 @@ static __latent_entropy struct task_struct *copy_process( · 42 unmodified lines | |||
| 2375 | syscall_tracepoint_update(p); | 2382 | syscall_tracepoint_update(p); |
| 2376 | write_unlock_irq(&tasklist_lock); | 2383 | write_unlock_irq(&tasklist_lock); |
| 2377 | 2384 | ||
| 2385 | if (pidfile) | ||
| 2386 | fd_install(pidfd, pidfile); | ||
| 2387 | |||
| 2378 | proc_fork_connector(p); | 2388 | proc_fork_connector(p); |
| 2379 | sched_post_fork(p, args); | 2389 | sched_post_fork(p); |
| 2380 | cgroup_post_fork(p, args); | 2390 | cgroup_post_fork(p, args); |
| 2381 | perf_event_fork(p); | 2391 | perf_event_fork(p); |
| 2382 | 2392 | ||
| @@ -3462,7 +3462,7 @@ struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i) · 3461 unmodified lines | |||
| 3462 | u16 chain_hlock = chain_hlocks[chain->base + i]; | 3462 | u16 chain_hlock = chain_hlocks[chain->base + i]; |
| 3463 | unsigned int class_idx = chain_hlock_class_idx(chain_hlock); | 3463 | unsigned int class_idx = chain_hlock_class_idx(chain_hlock); |
| 3464 | 3464 | ||
| 3465 | return lock_classes + class_idx - 1; | 3465 | return lock_classes + class_idx; |
| 3466 | } | 3466 | } |
| 3467 | 3467 | ||
| 3468 | /* | 3468 | /* |
| @@ -3530,7 +3530,7 @@ static void print_chain_keys_chain(struct lock_chain *chain) · 61 unmodified lines | |||
| 3530 | hlock_id = chain_hlocks[chain->base + i]; | 3530 | hlock_id = chain_hlocks[chain->base + i]; |
| 3531 | chain_key = print_chain_key_iteration(hlock_id, chain_key); | 3531 | chain_key = print_chain_key_iteration(hlock_id, chain_key); |
| 3532 | 3532 | ||
| 3533 | print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id) - 1); | 3533 | print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id)); |
| 3534 | printk("\n"); | 3534 | printk("\n"); |
| 3535 | } | 3535 | } |
| 3536 | } | 3536 | } |
| @@ -3725,12 +3725,6 @@ static noinline int do_init_module(struct module *mod) · 3724 unmodified lines | |||
| 3725 | } | 3725 | } |
| 3726 | freeinit->module_init = mod->init_layout.base; | 3726 | freeinit->module_init = mod->init_layout.base; |
| 3727 | 3727 | ||
| 3728 | /* | ||
| 3729 | * We want to find out whether @mod uses async during init. Clear | ||
| 3730 | * PF_USED_ASYNC. async_schedule*() will set it. | ||
| 3731 | */ | ||
| 3732 | current->flags &= ~PF_USED_ASYNC; | ||
| 3733 | |||
| 3734 | do_mod_ctors(mod); | 3728 | do_mod_ctors(mod); |
| 3735 | /* Start the module */ | 3729 | /* Start the module */ |
| 3736 | if (mod->init != NULL) | 3730 | if (mod->init != NULL) |
| @@ -3756,22 +3750,13 @@ static noinline int do_init_module(struct module *mod) · 19 unmodified lines | |||
| 3756 | 3750 | ||
| 3757 | /* | 3751 | /* |
| 3758 | * We need to finish all async code before the module init sequence | 3752 | * We need to finish all async code before the module init sequence |
| 3759 | * is done. This has potential to deadlock. For example, a newly | 3753 | * is done. This has potential to deadlock if synchronous module |
| 3760 | * detected block device can trigger request_module() of the | 3754 | * loading is requested from async (which is not allowed!). |
| 3761 | * default iosched from async probing task. Once userland helper | ||
| 3762 | * reaches here, async_synchronize_full() will wait on the async | ||
| 3763 | * task waiting on request_module() and deadlock. | ||
| 3764 | * | ||
| 3765 | * This deadlock is avoided by perfomring async_synchronize_full() | ||
| 3766 | * iff module init queued any async jobs. This isn't a full | ||
| 3767 | * solution as it will deadlock the same if module loading from | ||
| 3768 | * async jobs nests more than once; however, due to the various | ||
| 3769 | * constraints, this hack seems to be the best option for now. | ||
| 3770 | * Please refer to the following thread for details. | ||
| 3771 | * | 3755 | * |
| 3772 | * http://thread.gmane.org/gmane.linux.kernel/1420814 | 3756 | * See commit 0fdff3ec6d87 ("async, kmod: warn on synchronous |
| 3757 | * request_module() from async workers") for more details. | ||
| 3773 | */ | 3758 | */ |
| 3774 | if (!mod->async_probe_requested && (current->flags & PF_USED_ASYNC)) | 3759 | if (!mod->async_probe_requested) |
| 3775 | async_synchronize_full(); | 3760 | async_synchronize_full(); |
| 3776 | 3761 | ||
| 3777 | ftrace_free_mem(mod, mod->init_layout.base, mod->init_layout.base + | 3762 | ftrace_free_mem(mod, mod->init_layout.base, mod->init_layout.base + |
| @@ -250,6 +250,7 @@ void module_decompress_cleanup(struct load_info *info) · 249 unmodified lines | |||
| 250 | info->max_pages = info->used_pages = 0; | 250 | info->max_pages = info->used_pages = 0; |
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | #ifdef CONFIG_SYSFS | ||
| 253 | static ssize_t compression_show(struct kobject *kobj, | 254 | static ssize_t compression_show(struct kobject *kobj, |
| 254 | struct kobj_attribute *attr, char *buf) | 255 | struct kobj_attribute *attr, char *buf) |
| 255 | { | 256 | { |
| @@ -269,3 +270,4 @@ static int __init module_decompress_sysfs_init(void) · 13 unmodified lines | |||
| 269 | return 0; | 270 | return 0; |
| 270 | } | 271 | } |
| 271 | late_initcall(module_decompress_sysfs_init); | 272 | late_initcall(module_decompress_sysfs_init); |
| 273 | #endif | ||
| @@ -504,7 +504,10 @@ static ssize_t pm_wakeup_irq_show(struct kobject *kobj, · 503 unmodified lines | |||
| 504 | struct kobj_attribute *attr, | 504 | struct kobj_attribute *attr, |
| 505 | char *buf) | 505 | char *buf) |
| 506 | { | 506 | { |
| 507 | return pm_wakeup_irq ? sprintf(buf, "%u\n", pm_wakeup_irq) : -ENODATA; | 507 | if (!pm_wakeup_irq()) |
| 508 | return -ENODATA; | ||
| 509 | |||
| 510 | return sprintf(buf, "%u\n", pm_wakeup_irq()); | ||
| 508 | } | 511 | } |
| 509 | 512 | ||
| 510 | power_attr_ro(pm_wakeup_irq); | 513 | power_attr_ro(pm_wakeup_irq); |
| @@ -134,7 +134,7 @@ int freeze_processes(void) · 133 unmodified lines | |||
| 134 | if (!pm_freezing) | 134 | if (!pm_freezing) |
| 135 | atomic_inc(&system_freezing_cnt); | 135 | atomic_inc(&system_freezing_cnt); |
| 136 | 136 | ||
| 137 | pm_wakeup_clear(true); | 137 | pm_wakeup_clear(0); |
| 138 | pr_info("Freezing user space processes ... "); | 138 | pr_info("Freezing user space processes ... "); |
| 139 | pm_freezing = true; | 139 | pm_freezing = true; |
| 140 | error = try_to_freeze_tasks(true); | 140 | error = try_to_freeze_tasks(true); |
| @@ -978,8 +978,7 @@ static void memory_bm_recycle(struct memory_bitmap *bm) · 977 unmodified lines | |||
| 978 | * Register a range of page frames the contents of which should not be saved | 978 | * Register a range of page frames the contents of which should not be saved |
| 979 | * during hibernation (to be used in the early initialization code). | 979 | * during hibernation (to be used in the early initialization code). |
| 980 | */ | 980 | */ |
| 981 | void __init __register_nosave_region(unsigned long start_pfn, | 981 | void __init register_nosave_region(unsigned long start_pfn, unsigned long end_pfn) |
| 982 | unsigned long end_pfn, int use_kmalloc) | ||
| 983 | { | 982 | { |
| 984 | struct nosave_region *region; | 983 | struct nosave_region *region; |
| 985 | 984 | ||
| @@ -995,18 +994,12 @@ void __init __register_nosave_region(unsigned long start_pfn, · 9 unmodified lines | |||
| 995 | goto Report; | 994 | goto Report; |
| 996 | } | 995 | } |
| 997 | } | 996 | } |
| 998 | if (use_kmalloc) { | 997 | /* This allocation cannot fail */ |
| 999 | /* During init, this shouldn't fail */ | 998 | region = memblock_alloc(sizeof(struct nosave_region), |
| 1000 | region = kmalloc(sizeof(struct nosave_region), GFP_KERNEL); | 999 | SMP_CACHE_BYTES); |
| 1001 | BUG_ON(!region); | 1000 | if (!region) |
| 1002 | } else { | 1001 | panic("%s: Failed to allocate %zu bytes\n", __func__, |
| 1003 | /* This allocation cannot fail */ | 1002 | sizeof(struct nosave_region)); |
| 1004 | region = memblock_alloc(sizeof(struct nosave_region), | ||
| 1005 | SMP_CACHE_BYTES); | ||
| 1006 | if (!region) | ||
| 1007 | panic("%s: Failed to allocate %zu bytes\n", __func__, | ||
| 1008 | sizeof(struct nosave_region)); | ||
| 1009 | } | ||
| 1010 | region->start_pfn = start_pfn; | 1003 | region->start_pfn = start_pfn; |
| 1011 | region->end_pfn = end_pfn; | 1004 | region->end_pfn = end_pfn; |
| 1012 | list_add_tail(®ion->list, &nosave_regions); | 1005 | list_add_tail(®ion->list, &nosave_regions); |
| @@ -136,8 +136,6 @@ static void s2idle_loop(void) · 135 unmodified lines | |||
| 136 | break; | 136 | break; |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | pm_wakeup_clear(false); | ||
| 140 | |||
| 141 | s2idle_enter(); | 139 | s2idle_enter(); |
| 142 | } | 140 | } |
| 143 | 141 | ||
| @@ -39,23 +39,20 @@ ssize_t pm_show_wakelocks(char *buf, bool show_active) · 38 unmodified lines | |||
| 39 | { | 39 | { |
| 40 | struct rb_node *node; | 40 | struct rb_node *node; |
| 41 | struct wakelock *wl; | 41 | struct wakelock *wl; |
| 42 | char *str = buf; | 42 | int len = 0; |
| 43 | char *end = buf + PAGE_SIZE; | ||
| 44 | 43 | ||
| 45 | mutex_lock(&wakelocks_lock); | 44 | mutex_lock(&wakelocks_lock); |
| 46 | 45 | ||
| 47 | for (node = rb_first(&wakelocks_tree); node; node = rb_next(node)) { | 46 | for (node = rb_first(&wakelocks_tree); node; node = rb_next(node)) { |
| 48 | wl = rb_entry(node, struct wakelock, node); | 47 | wl = rb_entry(node, struct wakelock, node); |
| 49 | if (wl->ws->active == show_active) | 48 | if (wl->ws->active == show_active) |
| 50 | str += scnprintf(str, end - str, "%s ", wl->name); | 49 | len += sysfs_emit_at(buf, len, "%s ", wl->name); |
| 51 | } | 50 | } |
| 52 | if (str > buf) | ||
| 53 | str--; | ||
| 54 | 51 | ||
| 55 | str += scnprintf(str, end - str, "\n"); | 52 | len += sysfs_emit_at(buf, len, "\n"); |
| 56 | 53 | ||
| 57 | mutex_unlock(&wakelocks_lock); | 54 | mutex_unlock(&wakelocks_lock); |
| 58 | return (str - buf); | 55 | return len; |
| 59 | } | 56 | } |
| 60 | 57 | ||
| 61 | #if CONFIG_PM_WAKELOCKS_LIMIT > 0 | 58 | #if CONFIG_PM_WAKELOCKS_LIMIT > 0 |
| @@ -12,7 +12,7 @@ · 11 unmodified lines | |||
| 12 | static const int ten_thousand = 10000; | 12 | static const int ten_thousand = 10000; |
| 13 | 13 | ||
| 14 | static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, | 14 | static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, |
| 15 | void __user *buffer, size_t *lenp, loff_t *ppos) | 15 | void *buffer, size_t *lenp, loff_t *ppos) |
| 16 | { | 16 | { |
| 17 | if (write && !capable(CAP_SYS_ADMIN)) | 17 | if (write && !capable(CAP_SYS_ADMIN)) |
| 18 | return -EPERM; | 18 | return -EPERM; |
| @@ -123,7 +123,7 @@ static struct rcu_tasks rt_name = \ · 122 unmodified lines | |||
| 123 | .call_func = call, \ | 123 | .call_func = call, \ |
| 124 | .rtpcpu = &rt_name ## __percpu, \ | 124 | .rtpcpu = &rt_name ## __percpu, \ |
| 125 | .name = n, \ | 125 | .name = n, \ |
| 126 | .percpu_enqueue_shift = ilog2(CONFIG_NR_CPUS), \ | 126 | .percpu_enqueue_shift = ilog2(CONFIG_NR_CPUS) + 1, \ |
| 127 | .percpu_enqueue_lim = 1, \ | 127 | .percpu_enqueue_lim = 1, \ |
| 128 | .percpu_dequeue_lim = 1, \ | 128 | .percpu_dequeue_lim = 1, \ |
| 129 | .barrier_q_mutex = __MUTEX_INITIALIZER(rt_name.barrier_q_mutex), \ | 129 | .barrier_q_mutex = __MUTEX_INITIALIZER(rt_name.barrier_q_mutex), \ |
| @@ -216,6 +216,7 @@ static void cblist_init_generic(struct rcu_tasks *rtp) · 86 unmodified lines | |||
| 216 | int cpu; | 216 | int cpu; |
| 217 | unsigned long flags; | 217 | unsigned long flags; |
| 218 | int lim; | 218 | int lim; |
| 219 | int shift; | ||
| 219 | 220 | ||
| 220 | raw_spin_lock_irqsave(&rtp->cbs_gbl_lock, flags); | 221 | raw_spin_lock_irqsave(&rtp->cbs_gbl_lock, flags); |
| 221 | if (rcu_task_enqueue_lim < 0) { | 222 | if (rcu_task_enqueue_lim < 0) { |
| @@ -229,7 +230,10 @@ static void cblist_init_generic(struct rcu_tasks *rtp) · 7 unmodified lines | |||
| 229 | 230 | ||
| 230 | if (lim > nr_cpu_ids) | 231 | if (lim > nr_cpu_ids) |
| 231 | lim = nr_cpu_ids; | 232 | lim = nr_cpu_ids; |
| 232 | WRITE_ONCE(rtp->percpu_enqueue_shift, ilog2(nr_cpu_ids / lim)); | 233 | shift = ilog2(nr_cpu_ids / lim); |
| 234 | if (((nr_cpu_ids - 1) >> shift) >= lim) | ||
| 235 | shift++; | ||
| 236 | WRITE_ONCE(rtp->percpu_enqueue_shift, shift); | ||
| 233 | WRITE_ONCE(rtp->percpu_dequeue_lim, lim); | 237 | WRITE_ONCE(rtp->percpu_dequeue_lim, lim); |
| 234 | smp_store_release(&rtp->percpu_enqueue_lim, lim); | 238 | smp_store_release(&rtp->percpu_enqueue_lim, lim); |
| 235 | for_each_possible_cpu(cpu) { | 239 | for_each_possible_cpu(cpu) { |
| @@ -298,7 +302,7 @@ static void call_rcu_tasks_generic(struct rcu_head *rhp, rcu_callback_t func, · 62 unmodified lines | |||
| 298 | if (unlikely(needadjust)) { | 302 | if (unlikely(needadjust)) { |
| 299 | raw_spin_lock_irqsave(&rtp->cbs_gbl_lock, flags); | 303 | raw_spin_lock_irqsave(&rtp->cbs_gbl_lock, flags); |
| 300 | if (rtp->percpu_enqueue_lim != nr_cpu_ids) { | 304 | if (rtp->percpu_enqueue_lim != nr_cpu_ids) { |
| 301 | WRITE_ONCE(rtp->percpu_enqueue_shift, ilog2(nr_cpu_ids)); | 305 | WRITE_ONCE(rtp->percpu_enqueue_shift, ilog2(nr_cpu_ids) + 1); |
| 302 | WRITE_ONCE(rtp->percpu_dequeue_lim, nr_cpu_ids); | 306 | WRITE_ONCE(rtp->percpu_dequeue_lim, nr_cpu_ids); |
| 303 | smp_store_release(&rtp->percpu_enqueue_lim, nr_cpu_ids); | 307 | smp_store_release(&rtp->percpu_enqueue_lim, nr_cpu_ids); |
| 304 | pr_info("Switching %s to per-CPU callback queuing.\n", rtp->name); | 308 | pr_info("Switching %s to per-CPU callback queuing.\n", rtp->name); |
| @@ -413,7 +417,7 @@ static int rcu_tasks_need_gpcb(struct rcu_tasks *rtp) · 108 unmodified lines | |||
| 413 | if (rcu_task_cb_adjust && ncbs <= rcu_task_collapse_lim) { | 417 | if (rcu_task_cb_adjust && ncbs <= rcu_task_collapse_lim) { |
| 414 | raw_spin_lock_irqsave(&rtp->cbs_gbl_lock, flags); | 418 | raw_spin_lock_irqsave(&rtp->cbs_gbl_lock, flags); |
| 415 | if (rtp->percpu_enqueue_lim > 1) { | 419 | if (rtp->percpu_enqueue_lim > 1) { |
| 416 | WRITE_ONCE(rtp->percpu_enqueue_shift, ilog2(nr_cpu_ids)); | 420 | WRITE_ONCE(rtp->percpu_enqueue_shift, ilog2(nr_cpu_ids) + 1); |
| 417 | smp_store_release(&rtp->percpu_enqueue_lim, 1); | 421 | smp_store_release(&rtp->percpu_enqueue_lim, 1); |
| 418 | rtp->percpu_dequeue_gpseq = get_state_synchronize_rcu(); | 422 | rtp->percpu_dequeue_gpseq = get_state_synchronize_rcu(); |
| 419 | pr_info("Starting switch %s to CPU-0 callback queuing.\n", rtp->name); | 423 | pr_info("Starting switch %s to CPU-0 callback queuing.\n", rtp->name); |
| @@ -4426,6 +4426,7 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p) · 4425 unmodified lines | |||
| 4426 | 4426 | ||
| 4427 | init_entity_runnable_average(&p->se); | 4427 | init_entity_runnable_average(&p->se); |
| 4428 | 4428 | ||
| 4429 | |||
| 4429 | #ifdef CONFIG_SCHED_INFO | 4430 | #ifdef CONFIG_SCHED_INFO |
| 4430 | if (likely(sched_info_on())) | 4431 | if (likely(sched_info_on())) |
| 4431 | memset(&p->sched_info, 0, sizeof(p->sched_info)); | 4432 | memset(&p->sched_info, 0, sizeof(p->sched_info)); |
| @@ -4441,18 +4442,23 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p) · 9 unmodified lines | |||
| 4441 | return 0; | 4442 | return 0; |
| 4442 | } | 4443 | } |
| 4443 | 4444 | ||
| 4444 | void sched_post_fork(struct task_struct *p, struct kernel_clone_args *kargs) | 4445 | void sched_cgroup_fork(struct task_struct *p, struct kernel_clone_args *kargs) |
| 4445 | { | 4446 | { |
| 4446 | unsigned long flags; | 4447 | unsigned long flags; |
| 4447 | #ifdef CONFIG_CGROUP_SCHED | ||
| 4448 | struct task_group *tg; | ||
| 4449 | #endif | ||
| 4450 | 4448 | ||
| 4449 | /* | ||
| 4450 | * Because we're not yet on the pid-hash, p->pi_lock isn't strictly | ||
| 4451 | * required yet, but lockdep gets upset if rules are violated. | ||
| 4452 | */ | ||
| 4451 | raw_spin_lock_irqsave(&p->pi_lock, flags); | 4453 | raw_spin_lock_irqsave(&p->pi_lock, flags); |
| 4452 | #ifdef CONFIG_CGROUP_SCHED | 4454 | #ifdef CONFIG_CGROUP_SCHED |
| 4453 | tg = container_of(kargs->cset->subsys[cpu_cgrp_id], | 4455 | if (1) { |
| 4454 | struct task_group, css); | 4456 | struct task_group *tg; |
| 4455 | p->sched_task_group = autogroup_task_group(p, tg); | 4457 | tg = container_of(kargs->cset->subsys[cpu_cgrp_id], |
| 4458 | struct task_group, css); | ||
| 4459 | tg = autogroup_task_group(p, tg); | ||
| 4460 | p->sched_task_group = tg; | ||
| 4461 | } | ||
| 4456 | #endif | 4462 | #endif |
| 4457 | rseq_migrate(p); | 4463 | rseq_migrate(p); |
| 4458 | /* | 4464 | /* |
| @@ -4463,7 +4469,10 @@ void sched_post_fork(struct task_struct *p, struct kernel_clone_args *kargs) · 4 unmodified lines | |||
| 4463 | if (p->sched_class->task_fork) | 4469 | if (p->sched_class->task_fork) |
| 4464 | p->sched_class->task_fork(p); | 4470 | p->sched_class->task_fork(p); |
| 4465 | raw_spin_unlock_irqrestore(&p->pi_lock, flags); | 4471 | raw_spin_unlock_irqrestore(&p->pi_lock, flags); |
| 4472 | } | ||
| 4466 | 4473 | ||
| 4474 | void sched_post_fork(struct task_struct *p) | ||
| 4475 | { | ||
| 4467 | uclamp_post_fork(p); | 4476 | uclamp_post_fork(p); |
| 4468 | } | 4477 | } |
| 4469 | 4478 | ||
| @@ -5824,8 +5833,7 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) · 1354 unmodified lines | |||
| 5824 | } | 5833 | } |
| 5825 | 5834 | ||
| 5826 | if (schedstat_enabled() && rq->core->core_forceidle_count) { | 5835 | if (schedstat_enabled() && rq->core->core_forceidle_count) { |
| 5827 | if (cookie) | 5836 | rq->core->core_forceidle_start = rq_clock(rq->core); |
| 5828 | rq->core->core_forceidle_start = rq_clock(rq->core); | ||
| 5829 | rq->core->core_forceidle_occupation = occ; | 5837 | rq->core->core_forceidle_occupation = occ; |
| 5830 | } | 5838 | } |
| 5831 | 5839 | ||
| @@ -8139,9 +8147,7 @@ int __cond_resched_lock(spinlock_t *lock) · 2307 unmodified lines | |||
| 8139 | 8147 | ||
| 8140 | if (spin_needbreak(lock) || resched) { | 8148 | if (spin_needbreak(lock) || resched) { |
| 8141 | spin_unlock(lock); | 8149 | spin_unlock(lock); |
| 8142 | if (resched) | 8150 | if (!_cond_resched()) |
| 8143 | preempt_schedule_common(); | ||
| 8144 | else | ||
| 8145 | cpu_relax(); | 8151 | cpu_relax(); |
| 8146 | ret = 1; | 8152 | ret = 1; |
| 8147 | spin_lock(lock); | 8153 | spin_lock(lock); |
| @@ -8159,9 +8165,7 @@ int __cond_resched_rwlock_read(rwlock_t *lock) · 11 unmodified lines | |||
| 8159 | 8165 | ||
| 8160 | if (rwlock_needbreak(lock) || resched) { | 8166 | if (rwlock_needbreak(lock) || resched) { |
| 8161 | read_unlock(lock); | 8167 | read_unlock(lock); |
| 8162 | if (resched) | 8168 | if (!_cond_resched()) |
| 8163 | preempt_schedule_common(); | ||
| 8164 | else | ||
| 8165 | cpu_relax(); | 8169 | cpu_relax(); |
| 8166 | ret = 1; | 8170 | ret = 1; |
| 8167 | read_lock(lock); | 8171 | read_lock(lock); |
| @@ -8179,9 +8183,7 @@ int __cond_resched_rwlock_write(rwlock_t *lock) · 11 unmodified lines | |||
| 8179 | 8183 | ||
| 8180 | if (rwlock_needbreak(lock) || resched) { | 8184 | if (rwlock_needbreak(lock) || resched) { |
| 8181 | write_unlock(lock); | 8185 | write_unlock(lock); |
| 8182 | if (resched) | 8186 | if (!_cond_resched()) |
| 8183 | preempt_schedule_common(); | ||
| 8184 | else | ||
| 8185 | cpu_relax(); | 8187 | cpu_relax(); |
| 8186 | ret = 1; | 8188 | ret = 1; |
| 8187 | write_lock(lock); | 8189 | write_lock(lock); |
| @@ -277,7 +277,7 @@ void __sched_core_account_forceidle(struct rq *rq) · 276 unmodified lines | |||
| 277 | rq_i = cpu_rq(i); | 277 | rq_i = cpu_rq(i); |
| 278 | p = rq_i->core_pick ?: rq_i->curr; | 278 | p = rq_i->core_pick ?: rq_i->curr; |
| 279 | 279 | ||
| 280 | if (!p->core_cookie) | 280 | if (p == rq_i->idle) |
| 281 | continue; | 281 | continue; |
| 282 | 282 | ||
| 283 | __schedstat_add(p->stats.core_forceidle_sum, delta); | 283 | __schedstat_add(p->stats.core_forceidle_sum, delta); |
| @@ -3049,9 +3049,11 @@ enqueue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) · 3048 unmodified lines | |||
| 3049 | static inline void | 3049 | static inline void |
| 3050 | dequeue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) | 3050 | dequeue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) |
| 3051 | { | 3051 | { |
| 3052 | u32 divider = get_pelt_divider(&se->avg); | ||
| 3053 | sub_positive(&cfs_rq->avg.load_avg, se->avg.load_avg); | 3052 | sub_positive(&cfs_rq->avg.load_avg, se->avg.load_avg); |
| 3054 | cfs_rq->avg.load_sum = cfs_rq->avg.load_avg * divider; | 3053 | sub_positive(&cfs_rq->avg.load_sum, se_weight(se) * se->avg.load_sum); |
| 3054 | /* See update_cfs_rq_load_avg() */ | ||
| 3055 | cfs_rq->avg.load_sum = max_t(u32, cfs_rq->avg.load_sum, | ||
| 3056 | cfs_rq->avg.load_avg * PELT_MIN_DIVIDER); | ||
| 3055 | } | 3057 | } |
| 3056 | #else | 3058 | #else |
| 3057 | static inline void | 3059 | static inline void |
| @@ -3402,7 +3404,6 @@ void set_task_rq_fair(struct sched_entity *se, · 344 unmodified lines | |||
| 3402 | se->avg.last_update_time = n_last_update_time; | 3404 | se->avg.last_update_time = n_last_update_time; |
| 3403 | } | 3405 | } |
| 3404 | 3406 | ||
| 3405 | |||
| 3406 | /* | 3407 | /* |
| 3407 | * When on migration a sched_entity joins/leaves the PELT hierarchy, we need to | 3408 | * When on migration a sched_entity joins/leaves the PELT hierarchy, we need to |
| 3408 | * propagate its contribution. The key to this propagation is the invariant | 3409 | * propagate its contribution. The key to this propagation is the invariant |
| @@ -3470,15 +3471,14 @@ void set_task_rq_fair(struct sched_entity *se, · 61 unmodified lines | |||
| 3470 | * XXX: only do this for the part of runnable > running ? | 3471 | * XXX: only do this for the part of runnable > running ? |
| 3471 | * | 3472 | * |
| 3472 | */ | 3473 | */ |
| 3473 | |||
| 3474 | static inline void | 3474 | static inline void |
| 3475 | update_tg_cfs_util(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) | 3475 | update_tg_cfs_util(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) |
| 3476 | { | 3476 | { |
| 3477 | long delta = gcfs_rq->avg.util_avg - se->avg.util_avg; | 3477 | long delta_sum, delta_avg = gcfs_rq->avg.util_avg - se->avg.util_avg; |
| 3478 | u32 divider; | 3478 | u32 new_sum, divider; |
| 3479 | 3479 | ||
| 3480 | /* Nothing to update */ | 3480 | /* Nothing to update */ |
| 3481 | if (!delta) | 3481 | if (!delta_avg) |
| 3482 | return; | 3482 | return; |
| 3483 | 3483 | ||
| 3484 | /* | 3484 | /* |
| @@ -3487,23 +3487,30 @@ update_tg_cfs_util(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq · 2 unmodified lines | |||
| 3487 | */ | 3487 | */ |
| 3488 | divider = get_pelt_divider(&cfs_rq->avg); | 3488 | divider = get_pelt_divider(&cfs_rq->avg); |
| 3489 | 3489 | ||
| 3490 | |||
| 3490 | /* Set new sched_entity's utilization */ | 3491 | /* Set new sched_entity's utilization */ |
| 3491 | se->avg.util_avg = gcfs_rq->avg.util_avg; | 3492 | se->avg.util_avg = gcfs_rq->avg.util_avg; |
| 3492 | se->avg.util_sum = se->avg.util_avg * divider; | 3493 | new_sum = se->avg.util_avg * divider; |
| 3494 | delta_sum = (long)new_sum - (long)se->avg.util_sum; | ||
| 3495 | se->avg.util_sum = new_sum; | ||
| 3493 | 3496 | ||
| 3494 | /* Update parent cfs_rq utilization */ | 3497 | /* Update parent cfs_rq utilization */ |
| 3495 | add_positive(&cfs_rq->avg.util_avg, delta); | 3498 | add_positive(&cfs_rq->avg.util_avg, delta_avg); |
| 3496 | cfs_rq->avg.util_sum = cfs_rq->avg.util_avg * divider; | 3499 | add_positive(&cfs_rq->avg.util_sum, delta_sum); |
| 3500 | |||
| 3501 | /* See update_cfs_rq_load_avg() */ | ||
| 3502 | cfs_rq->avg.util_sum = max_t(u32, cfs_rq->avg.util_sum, | ||
| 3503 | cfs_rq->avg.util_avg * PELT_MIN_DIVIDER); | ||
| 3497 | } | 3504 | } |
| 3498 | 3505 | ||
| 3499 | static inline void | 3506 | static inline void |
| 3500 | update_tg_cfs_runnable(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) | 3507 | update_tg_cfs_runnable(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) |
| 3501 | { | 3508 | { |
| 3502 | long delta = gcfs_rq->avg.runnable_avg - se->avg.runnable_avg; | 3509 | long delta_sum, delta_avg = gcfs_rq->avg.runnable_avg - se->avg.runnable_avg; |
| 3503 | u32 divider; | 3510 | u32 new_sum, divider; |
| 3504 | 3511 | ||
| 3505 | /* Nothing to update */ | 3512 | /* Nothing to update */ |
| 3506 | if (!delta) | 3513 | if (!delta_avg) |
| 3507 | return; | 3514 | return; |
| 3508 | 3515 | ||
| 3509 | /* | 3516 | /* |
| @@ -3514,19 +3521,25 @@ update_tg_cfs_runnable(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cf · 4 unmodified lines | |||
| 3514 | 3521 | ||
| 3515 | /* Set new sched_entity's runnable */ | 3522 | /* Set new sched_entity's runnable */ |
| 3516 | se->avg.runnable_avg = gcfs_rq->avg.runnable_avg; | 3523 | se->avg.runnable_avg = gcfs_rq->avg.runnable_avg; |
| 3517 | se->avg.runnable_sum = se->avg.runnable_avg * divider; | 3524 | new_sum = se->avg.runnable_avg * divider; |
| 3525 | delta_sum = (long)new_sum - (long)se->avg.runnable_sum; | ||
| 3526 | se->avg.runnable_sum = new_sum; | ||
| 3518 | 3527 | ||
| 3519 | /* Update parent cfs_rq runnable */ | 3528 | /* Update parent cfs_rq runnable */ |
| 3520 | add_positive(&cfs_rq->avg.runnable_avg, delta); | 3529 | add_positive(&cfs_rq->avg.runnable_avg, delta_avg); |
| 3521 | cfs_rq->avg.runnable_sum = cfs_rq->avg.runnable_avg * divider; | 3530 | add_positive(&cfs_rq->avg.runnable_sum, delta_sum); |
| 3531 | /* See update_cfs_rq_load_avg() */ | ||
| 3532 | cfs_rq->avg.runnable_sum = max_t(u32, cfs_rq->avg.runnable_sum, | ||
| 3533 | cfs_rq->avg.runnable_avg * PELT_MIN_DIVIDER); | ||
| 3522 | } | 3534 | } |
| 3523 | 3535 | ||
| 3524 | static inline void | 3536 | static inline void |
| 3525 | update_tg_cfs_load(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) | 3537 | update_tg_cfs_load(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) |
| 3526 | { | 3538 | { |
| 3527 | long delta, running_sum, runnable_sum = gcfs_rq->prop_runnable_sum; | 3539 | long delta_avg, running_sum, runnable_sum = gcfs_rq->prop_runnable_sum; |
| 3528 | unsigned long load_avg; | 3540 | unsigned long load_avg; |
| 3529 | u64 load_sum = 0; | 3541 | u64 load_sum = 0; |
| 3542 | s64 delta_sum; | ||
| 3530 | u32 divider; | 3543 | u32 divider; |
| 3531 | 3544 | ||
| 3532 | if (!runnable_sum) | 3545 | if (!runnable_sum) |
| @@ -3553,7 +3566,7 @@ update_tg_cfs_load(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq · 20 unmodified lines | |||
| 3553 | * assuming all tasks are equally runnable. | 3566 | * assuming all tasks are equally runnable. |
| 3554 | */ | 3567 | */ |
| 3555 | if (scale_load_down(gcfs_rq->load.weight)) { | 3568 | if (scale_load_down(gcfs_rq->load.weight)) { |
| 3556 | load_sum = div_s64(gcfs_rq->avg.load_sum, | 3569 | load_sum = div_u64(gcfs_rq->avg.load_sum, |
| 3557 | scale_load_down(gcfs_rq->load.weight)); | 3570 | scale_load_down(gcfs_rq->load.weight)); |
| 3558 | } | 3571 | } |
| 3559 | 3572 | ||
| @@ -3570,19 +3583,22 @@ update_tg_cfs_load(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq · 10 unmodified lines | |||
| 3570 | running_sum = se->avg.util_sum >> SCHED_CAPACITY_SHIFT; | 3583 | running_sum = se->avg.util_sum >> SCHED_CAPACITY_SHIFT; |
| 3571 | runnable_sum = max(runnable_sum, running_sum); | 3584 | runnable_sum = max(runnable_sum, running_sum); |
| 3572 | 3585 | ||
| 3573 | load_sum = (s64)se_weight(se) * runnable_sum; | 3586 | load_sum = se_weight(se) * runnable_sum; |
| 3574 | load_avg = div_s64(load_sum, divider); | 3587 | load_avg = div_u64(load_sum, divider); |
| 3575 | |||
| 3576 | se->avg.load_sum = runnable_sum; | ||
| 3577 | 3588 | ||
| 3578 | delta = load_avg - se->avg.load_avg; | 3589 | delta_avg = load_avg - se->avg.load_avg; |
| 3579 | if (!delta) | 3590 | if (!delta_avg) |
| 3580 | return; | 3591 | return; |
| 3581 | 3592 | ||
| 3582 | se->avg.load_avg = load_avg; | 3593 | delta_sum = load_sum - (s64)se_weight(se) * se->avg.load_sum; |
| 3583 | 3594 | ||
| 3584 | add_positive(&cfs_rq->avg.load_avg, delta); | 3595 | se->avg.load_sum = runnable_sum; |
| 3585 | cfs_rq->avg.load_sum = cfs_rq->avg.load_avg * divider; | 3596 | se->avg.load_avg = load_avg; |
| 3597 | add_positive(&cfs_rq->avg.load_avg, delta_avg); | ||
| 3598 | add_positive(&cfs_rq->avg.load_sum, delta_sum); | ||
| 3599 | /* See update_cfs_rq_load_avg() */ | ||
| 3600 | cfs_rq->avg.load_sum = max_t(u32, cfs_rq->avg.load_sum, | ||
| 3601 | cfs_rq->avg.load_avg * PELT_MIN_DIVIDER); | ||
| 3586 | } | 3602 | } |
| 3587 | 3603 | ||
| 3588 | static inline void add_tg_cfs_propagate(struct cfs_rq *cfs_rq, long runnable_sum) | 3604 | static inline void add_tg_cfs_propagate(struct cfs_rq *cfs_rq, long runnable_sum) |
| @@ -3673,7 +3689,7 @@ static inline void add_tg_cfs_propagate(struct cfs_rq *cfs_rq, long runnable_sum · 84 unmodified lines | |||
| 3673 | * | 3689 | * |
| 3674 | * cfs_rq->avg is used for task_h_load() and update_cfs_share() for example. | 3690 | * cfs_rq->avg is used for task_h_load() and update_cfs_share() for example. |
| 3675 | * | 3691 | * |
| 3676 | * Returns true if the load decayed or we removed load. | 3692 | * Return: true if the load decayed or we removed load. |
| 3677 | * | 3693 | * |
| 3678 | * Since both these conditions indicate a changed cfs_rq->avg.load we should | 3694 | * Since both these conditions indicate a changed cfs_rq->avg.load we should |
| 3679 | * call update_tg_load_avg() when this function returns true. | 3695 | * call update_tg_load_avg() when this function returns true. |
| @@ -3698,15 +3714,32 @@ update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq) · 18 unmodified lines | |||
| 3698 | 3714 | ||
| 3699 | r = removed_load; | 3715 | r = removed_load; |
| 3700 | sub_positive(&sa->load_avg, r); | 3716 | sub_positive(&sa->load_avg, r); |
| 3701 | sa->load_sum = sa->load_avg * divider; | 3717 | sub_positive(&sa->load_sum, r * divider); |
| 3718 | /* See sa->util_sum below */ | ||
| 3719 | sa->load_sum = max_t(u32, sa->load_sum, sa->load_avg * PELT_MIN_DIVIDER); | ||
| 3702 | 3720 | ||
| 3703 | r = removed_util; | 3721 | r = removed_util; |
| 3704 | sub_positive(&sa->util_avg, r); | 3722 | sub_positive(&sa->util_avg, r); |
| 3705 | sa->util_sum = sa->util_avg * divider; | 3723 | sub_positive(&sa->util_sum, r * divider); |
| 3724 | /* | ||
| 3725 | * Because of rounding, se->util_sum might ends up being +1 more than | ||
| 3726 | * cfs->util_sum. Although this is not a problem by itself, detaching | ||
| 3727 | * a lot of tasks with the rounding problem between 2 updates of | ||
| 3728 | * util_avg (~1ms) can make cfs->util_sum becoming null whereas | ||
| 3729 | * cfs_util_avg is not. | ||
| 3730 | * Check that util_sum is still above its lower bound for the new | ||
| 3731 | * util_avg. Given that period_contrib might have moved since the last | ||
| 3732 | * sync, we are only sure that util_sum must be above or equal to | ||
| 3733 | * util_avg * minimum possible divider | ||
| 3734 | */ | ||
| 3735 | sa->util_sum = max_t(u32, sa->util_sum, sa->util_avg * PELT_MIN_DIVIDER); | ||
| 3706 | 3736 | ||
| 3707 | r = removed_runnable; | 3737 | r = removed_runnable; |
| 3708 | sub_positive(&sa->runnable_avg, r); | 3738 | sub_positive(&sa->runnable_avg, r); |
| 3709 | sa->runnable_sum = sa->runnable_avg * divider; | 3739 | sub_positive(&sa->runnable_sum, r * divider); |
| 3740 | /* See sa->util_sum above */ | ||
| 3741 | sa->runnable_sum = max_t(u32, sa->runnable_sum, | ||
| 3742 | sa->runnable_avg * PELT_MIN_DIVIDER); | ||
| 3710 | 3743 | ||
| 3711 | /* | 3744 | /* |
| 3712 | * removed_runnable is the unweighted version of removed_load so we | 3745 | * removed_runnable is the unweighted version of removed_load so we |
| @@ -3793,17 +3826,18 @@ static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s · 80 unmodified lines | |||
| 3793 | */ | 3826 | */ |
| 3794 | static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) | 3827 | static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) |
| 3795 | { | 3828 | { |
| 3796 | /* | ||
| 3797 | * cfs_rq->avg.period_contrib can be used for both cfs_rq and se. | ||
| 3798 | * See ___update_load_avg() for details. | ||
| 3799 | */ | ||
| 3800 | u32 divider = get_pelt_divider(&cfs_rq->avg); | ||
| 3801 | |||
| 3802 | dequeue_load_avg(cfs_rq, se); | 3829 | dequeue_load_avg(cfs_rq, se); |
| 3803 | sub_positive(&cfs_rq->avg.util_avg, se->avg.util_avg); | 3830 | sub_positive(&cfs_rq->avg.util_avg, se->avg.util_avg); |
| 3804 | cfs_rq->avg.util_sum = cfs_rq->avg.util_avg * divider; | 3831 | sub_positive(&cfs_rq->avg.util_sum, se->avg.util_sum); |
| 3832 | /* See update_cfs_rq_load_avg() */ | ||
| 3833 | cfs_rq->avg.util_sum = max_t(u32, cfs_rq->avg.util_sum, | ||
| 3834 | cfs_rq->avg.util_avg * PELT_MIN_DIVIDER); | ||
| 3835 | |||
| 3805 | sub_positive(&cfs_rq->avg.runnable_avg, se->avg.runnable_avg); | 3836 | sub_positive(&cfs_rq->avg.runnable_avg, se->avg.runnable_avg); |
| 3806 | cfs_rq->avg.runnable_sum = cfs_rq->avg.runnable_avg * divider; | 3837 | sub_positive(&cfs_rq->avg.runnable_sum, se->avg.runnable_sum); |
| 3838 | /* See update_cfs_rq_load_avg() */ | ||
| 3839 | cfs_rq->avg.runnable_sum = max_t(u32, cfs_rq->avg.runnable_sum, | ||
| 3840 | cfs_rq->avg.runnable_avg * PELT_MIN_DIVIDER); | ||
| 3807 | 3841 | ||
| 3808 | add_tg_cfs_propagate(cfs_rq, -se->avg.load_sum); | 3842 | add_tg_cfs_propagate(cfs_rq, -se->avg.load_sum); |
| 3809 | 3843 | ||
| @@ -8560,6 +8594,8 @@ group_type group_classify(unsigned int imbalance_pct, · 4750 unmodified lines | |||
| 8560 | * | 8594 | * |
| 8561 | * If @sg does not have SMT siblings, only pull tasks if all of the SMT siblings | 8595 | * If @sg does not have SMT siblings, only pull tasks if all of the SMT siblings |
| 8562 | * of @dst_cpu are idle and @sg has lower priority. | 8596 | * of @dst_cpu are idle and @sg has lower priority. |
| 8597 | * | ||
| 8598 | * Return: true if @dst_cpu can pull tasks, false otherwise. | ||
| 8563 | */ | 8599 | */ |
| 8564 | static bool asym_smt_can_pull_tasks(int dst_cpu, struct sd_lb_stats *sds, | 8600 | static bool asym_smt_can_pull_tasks(int dst_cpu, struct sd_lb_stats *sds, |
| 8565 | struct sg_lb_stats *sgs, | 8601 | struct sg_lb_stats *sgs, |
| @@ -8635,6 +8671,7 @@ sched_asym(struct lb_env *env, struct sd_lb_stats *sds, struct sg_lb_stats *sgs · 69 unmodified lines | |||
| 8635 | /** | 8671 | /** |
| 8636 | * update_sg_lb_stats - Update sched_group's statistics for load balancing. | 8672 | * update_sg_lb_stats - Update sched_group's statistics for load balancing. |
| 8637 | * @env: The load balancing environment. | 8673 | * @env: The load balancing environment. |
| 8674 | * @sds: Load-balancing data with statistics of the local group. | ||
| 8638 | * @group: sched_group whose statistics are to be updated. | 8675 | * @group: sched_group whose statistics are to be updated. |
| 8639 | * @sgs: variable to hold the statistics for this group. | 8676 | * @sgs: variable to hold the statistics for this group. |
| 8640 | * @sg_status: Holds flag indicating the status of the sched_group | 8677 | * @sg_status: Holds flag indicating the status of the sched_group |
| @@ -9443,12 +9480,11 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s · 802 unmodified lines | |||
| 9443 | /** | 9480 | /** |
| 9444 | * find_busiest_group - Returns the busiest group within the sched_domain | 9481 | * find_busiest_group - Returns the busiest group within the sched_domain |
| 9445 | * if there is an imbalance. | 9482 | * if there is an imbalance. |
| 9483 | * @env: The load balancing environment. | ||
| 9446 | * | 9484 | * |
| 9447 | * Also calculates the amount of runnable load which should be moved | 9485 | * Also calculates the amount of runnable load which should be moved |
| 9448 | * to restore balance. | 9486 | * to restore balance. |
| 9449 | * | 9487 | * |
| 9450 | * @env: The load balancing environment. | ||
| 9451 | * | ||
| 9452 | * Return: - The busiest group if imbalance exists. | 9488 | * Return: - The busiest group if imbalance exists. |
| 9453 | */ | 9489 | */ |
| 9454 | static struct sched_group *find_busiest_group(struct lb_env *env) | 9490 | static struct sched_group *find_busiest_group(struct lb_env *env) |
| @@ -147,11 +147,11 @@ · 146 unmodified lines | |||
| 147 | #endif | 147 | #endif |
| 148 | 148 | ||
| 149 | #ifdef CONFIG_RSEQ | 149 | #ifdef CONFIG_RSEQ |
| 150 | #define MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ_BITMASK \ | 150 | #define MEMBARRIER_PRIVATE_EXPEDITED_RSEQ_BITMASK \ |
| 151 | (MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ \ | 151 | (MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ \ |
| 152 | | MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ_BITMASK) | 152 | | MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ) |
| 153 | #else | 153 | #else |
| 154 | #define MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ_BITMASK 0 | 154 | #define MEMBARRIER_PRIVATE_EXPEDITED_RSEQ_BITMASK 0 |
| 155 | #endif | 155 | #endif |
| 156 | 156 | ||
| 157 | #define MEMBARRIER_CMD_BITMASK \ | 157 | #define MEMBARRIER_CMD_BITMASK \ |
| @@ -159,7 +159,8 @@ · 1 unmodified line | |||
| 159 | | MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED \ | 159 | | MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED \ |
| 160 | | MEMBARRIER_CMD_PRIVATE_EXPEDITED \ | 160 | | MEMBARRIER_CMD_PRIVATE_EXPEDITED \ |
| 161 | | MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED \ | 161 | | MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED \ |
| 162 | | MEMBARRIER_PRIVATE_EXPEDITED_SYNC_CORE_BITMASK) | 162 | | MEMBARRIER_PRIVATE_EXPEDITED_SYNC_CORE_BITMASK \ |
| 163 | | MEMBARRIER_PRIVATE_EXPEDITED_RSEQ_BITMASK) | ||
| 163 | 164 | ||
| 164 | static void ipi_mb(void *info) | 165 | static void ipi_mb(void *info) |
| 165 | { | 166 | { |
| @@ -37,9 +37,11 @@ update_irq_load_avg(struct rq *rq, u64 running) · 36 unmodified lines | |||
| 37 | } | 37 | } |
| 38 | #endif | 38 | #endif |
| 39 | 39 | ||
| 40 | #define PELT_MIN_DIVIDER (LOAD_AVG_MAX - 1024) | ||
| 41 | |||
| 40 | static inline u32 get_pelt_divider(struct sched_avg *avg) | 42 | static inline u32 get_pelt_divider(struct sched_avg *avg) |
| 41 | { | 43 | { |
| 42 | return LOAD_AVG_MAX - 1024 + avg->period_contrib; | 44 | return PELT_MIN_DIVIDER + avg->period_contrib; |
| 43 | } | 45 | } |
| 44 | 46 | ||
| 45 | static inline void cfs_se_util_change(struct sched_avg *avg) | 47 | static inline void cfs_se_util_change(struct sched_avg *avg) |
| @@ -1137,7 +1137,6 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group, · 1136 unmodified lines | |||
| 1137 | t->event = 0; | 1137 | t->event = 0; |
| 1138 | t->last_event_time = 0; | 1138 | t->last_event_time = 0; |
| 1139 | init_waitqueue_head(&t->event_wait); | 1139 | init_waitqueue_head(&t->event_wait); |
| 1140 | kref_init(&t->refcount); | ||
| 1141 | t->pending_event = false; | 1140 | t->pending_event = false; |
| 1142 | 1141 | ||
| 1143 | mutex_lock(&group->trigger_lock); | 1142 | mutex_lock(&group->trigger_lock); |
| @@ -1167,15 +1166,19 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group, · 23 unmodified lines | |||
| 1167 | return t; | 1166 | return t; |
| 1168 | } | 1167 | } |
| 1169 | 1168 | ||
| 1170 | static void psi_trigger_destroy(struct kref *ref) | 1169 | void psi_trigger_destroy(struct psi_trigger *t) |
| 1171 | { | 1170 | { |
| 1172 | struct psi_trigger *t = container_of(ref, struct psi_trigger, refcount); | 1171 | struct psi_group *group; |
| 1173 | struct psi_group *group = t->group; | ||
| 1174 | struct task_struct *task_to_destroy = NULL; | 1172 | struct task_struct *task_to_destroy = NULL; |
| 1175 | 1173 | ||
| 1176 | if (static_branch_likely(&psi_disabled)) | 1174 | /* |
| 1175 | * We do not check psi_disabled since it might have been disabled after | ||
| 1176 | * the trigger got created. | ||
| 1177 | */ | ||
| 1178 | if (!t) | ||
| 1177 | return; | 1179 | return; |
| 1178 | 1180 | ||
| 1181 | group = t->group; | ||
| 1179 | /* | 1182 | /* |
| 1180 | * Wakeup waiters to stop polling. Can happen if cgroup is deleted | 1183 | * Wakeup waiters to stop polling. Can happen if cgroup is deleted |
| 1181 | * from under a polling process. | 1184 | * from under a polling process. |
| @@ -1211,9 +1214,9 @@ static void psi_trigger_destroy(struct kref *ref) · 29 unmodified lines | |||
| 1211 | mutex_unlock(&group->trigger_lock); | 1214 | mutex_unlock(&group->trigger_lock); |
| 1212 | 1215 | ||
| 1213 | /* | 1216 | /* |
| 1214 | * Wait for both *trigger_ptr from psi_trigger_replace and | 1217 | * Wait for psi_schedule_poll_work RCU to complete its read-side |
| 1215 | * poll_task RCUs to complete their read-side critical sections | 1218 | * critical section before destroying the trigger and optionally the |
| 1216 | * before destroying the trigger and optionally the poll_task | 1219 | * poll_task. |
| 1217 | */ | 1220 | */ |
| 1218 | synchronize_rcu(); | 1221 | synchronize_rcu(); |
| 1219 | /* | 1222 | /* |
| @@ -1230,18 +1233,6 @@ static void psi_trigger_destroy(struct kref *ref) · 10 unmodified lines | |||
| 1230 | kfree(t); | 1233 | kfree(t); |
| 1231 | } | 1234 | } |
| 1232 | 1235 | ||
| 1233 | void psi_trigger_replace(void **trigger_ptr, struct psi_trigger *new) | ||
| 1234 | { | ||
| 1235 | struct psi_trigger *old = *trigger_ptr; | ||
| 1236 | |||
| 1237 | if (static_branch_likely(&psi_disabled)) | ||
| 1238 | return; | ||
| 1239 | |||
| 1240 | rcu_assign_pointer(*trigger_ptr, new); | ||
| 1241 | if (old) | ||
| 1242 | kref_put(&old->refcount, psi_trigger_destroy); | ||
| 1243 | } | ||
| 1244 | |||
| 1245 | __poll_t psi_trigger_poll(void **trigger_ptr, | 1236 | __poll_t psi_trigger_poll(void **trigger_ptr, |
| 1246 | struct file *file, poll_table *wait) | 1237 | struct file *file, poll_table *wait) |
| 1247 | { | 1238 | { |
| @@ -1251,24 +1242,15 @@ __poll_t psi_trigger_poll(void **trigger_ptr, · 3 unmodified lines | |||
| 1251 | if (static_branch_likely(&psi_disabled)) | 1242 | if (static_branch_likely(&psi_disabled)) |
| 1252 | return DEFAULT_POLLMASK | EPOLLERR | EPOLLPRI; | 1243 | return DEFAULT_POLLMASK | EPOLLERR | EPOLLPRI; |
| 1253 | 1244 | ||
| 1254 | rcu_read_lock(); | 1245 | t = smp_load_acquire(trigger_ptr); |
| 1255 | 1246 | if (!t) | |
| 1256 | t = rcu_dereference(*(void __rcu __force **)trigger_ptr); | ||
| 1257 | if (!t) { | ||
| 1258 | rcu_read_unlock(); | ||
| 1259 | return DEFAULT_POLLMASK | EPOLLERR | EPOLLPRI; | 1247 | return DEFAULT_POLLMASK | EPOLLERR | EPOLLPRI; |
| 1260 | } | ||
| 1261 | kref_get(&t->refcount); | ||
| 1262 | |||
| 1263 | rcu_read_unlock(); | ||
| 1264 | 1248 | ||
| 1265 | poll_wait(file, &t->event_wait, wait); | 1249 | poll_wait(file, &t->event_wait, wait); |
| 1266 | 1250 | ||
| 1267 | if (cmpxchg(&t->event, 1, 0) == 1) | 1251 | if (cmpxchg(&t->event, 1, 0) == 1) |
| 1268 | ret |= EPOLLPRI; | 1252 | ret |= EPOLLPRI; |
| 1269 | 1253 | ||
| 1270 | kref_put(&t->refcount, psi_trigger_destroy); | ||
| 1271 | |||
| 1272 | return ret; | 1254 | return ret; |
| 1273 | } | 1255 | } |
| 1274 | 1256 | ||
| @@ -1331,14 +1313,24 @@ static ssize_t psi_write(struct file *file, const char __user *user_buf, · 56 unmodified lines | |||
| 1331 | 1313 | ||
| 1332 | buf[buf_size - 1] = '\0'; | 1314 | buf[buf_size - 1] = '\0'; |
| 1333 | 1315 | ||
| 1334 | new = psi_trigger_create(&psi_system, buf, nbytes, res); | ||
| 1335 | if (IS_ERR(new)) | ||
| 1336 | return PTR_ERR(new); | ||
| 1337 | |||
| 1338 | seq = file->private_data; | 1316 | seq = file->private_data; |
| 1317 | |||
| 1339 | /* Take seq->lock to protect seq->private from concurrent writes */ | 1318 | /* Take seq->lock to protect seq->private from concurrent writes */ |
| 1340 | mutex_lock(&seq->lock); | 1319 | mutex_lock(&seq->lock); |
| 1341 | psi_trigger_replace(&seq->private, new); | 1320 | |
| 1321 | /* Allow only one trigger per file descriptor */ | ||
| 1322 | if (seq->private) { | ||
| 1323 | mutex_unlock(&seq->lock); | ||
| 1324 | return -EBUSY; | ||
| 1325 | } | ||
| 1326 | |||
| 1327 | new = psi_trigger_create(&psi_system, buf, nbytes, res); | ||
| 1328 | if (IS_ERR(new)) { | ||
| 1329 | mutex_unlock(&seq->lock); | ||
| 1330 | return PTR_ERR(new); | ||
| 1331 | } | ||
| 1332 | |||
| 1333 | smp_store_release(&seq->private, new); | ||
| 1342 | mutex_unlock(&seq->lock); | 1334 | mutex_unlock(&seq->lock); |
| 1343 | 1335 | ||
| 1344 | return nbytes; | 1336 | return nbytes; |
| @@ -1373,7 +1365,7 @@ static int psi_fop_release(struct inode *inode, struct file *file) · 28 unmodified lines | |||
| 1373 | { | 1365 | { |
| 1374 | struct seq_file *seq = file->private_data; | 1366 | struct seq_file *seq = file->private_data; |
| 1375 | 1367 | ||
| 1376 | psi_trigger_replace(&seq->private, NULL); | 1368 | psi_trigger_destroy(seq->private); |
| 1377 | return single_release(inode, file); | 1369 | return single_release(inode, file); |
| 1378 | } | 1370 | } |
| 1379 | 1371 | ||
| @@ -29,6 +29,9 @@ · 28 unmodified lines | |||
| 29 | #include <linux/syscalls.h> | 29 | #include <linux/syscalls.h> |
| 30 | #include <linux/sysctl.h> | 30 | #include <linux/sysctl.h> |
| 31 | 31 | ||
| 32 | /* Not exposed in headers: strictly internal use only. */ | ||
| 33 | #define SECCOMP_MODE_DEAD (SECCOMP_MODE_FILTER + 1) | ||
| 34 | |||
| 32 | #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER | 35 | #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER |
| 33 | #include <asm/syscall.h> | 36 | #include <asm/syscall.h> |
| 34 | #endif | 37 | #endif |
| @@ -1010,6 +1013,7 @@ static void __secure_computing_strict(int this_syscall) · 975 unmodified lines | |||
| 1010 | #ifdef SECCOMP_DEBUG | 1013 | #ifdef SECCOMP_DEBUG |
| 1011 | dump_stack(); | 1014 | dump_stack(); |
| 1012 | #endif | 1015 | #endif |
| 1016 | current->seccomp.mode = SECCOMP_MODE_DEAD; | ||
| 1013 | seccomp_log(this_syscall, SIGKILL, SECCOMP_RET_KILL_THREAD, true); | 1017 | seccomp_log(this_syscall, SIGKILL, SECCOMP_RET_KILL_THREAD, true); |
| 1014 | do_exit(SIGKILL); | 1018 | do_exit(SIGKILL); |
| 1015 | } | 1019 | } |
| @@ -1261,6 +1265,7 @@ static int __seccomp_filter(int this_syscall, const struct seccomp_data *sd, · 245 unmodified lines | |||
| 1261 | case SECCOMP_RET_KILL_THREAD: | 1265 | case SECCOMP_RET_KILL_THREAD: |
| 1262 | case SECCOMP_RET_KILL_PROCESS: | 1266 | case SECCOMP_RET_KILL_PROCESS: |
| 1263 | default: | 1267 | default: |
| 1268 | current->seccomp.mode = SECCOMP_MODE_DEAD; | ||
| 1264 | seccomp_log(this_syscall, SIGSYS, action, true); | 1269 | seccomp_log(this_syscall, SIGSYS, action, true); |
| 1265 | /* Dump core only if this is the last remaining thread. */ | 1270 | /* Dump core only if this is the last remaining thread. */ |
| 1266 | if (action != SECCOMP_RET_KILL_THREAD || | 1271 | if (action != SECCOMP_RET_KILL_THREAD || |
| @@ -1309,6 +1314,11 @@ int __secure_computing(const struct seccomp_data *sd) · 42 unmodified lines | |||
| 1309 | return 0; | 1314 | return 0; |
| 1310 | case SECCOMP_MODE_FILTER: | 1315 | case SECCOMP_MODE_FILTER: |
| 1311 | return __seccomp_filter(this_syscall, sd, false); | 1316 | return __seccomp_filter(this_syscall, sd, false); |
| 1317 | /* Surviving SECCOMP_RET_KILL_* must be proactively impossible. */ | ||
| 1318 | case SECCOMP_MODE_DEAD: | ||
| 1319 | WARN_ON_ONCE(1); | ||
| 1320 | do_exit(SIGKILL); | ||
| 1321 | return -1; | ||
| 1312 | default: | 1322 | default: |
| 1313 | BUG(); | 1323 | BUG(); |
| 1314 | } | 1324 | } |
| @@ -1342,9 +1342,10 @@ force_sig_info_to_task(struct kernel_siginfo *info, struct task_struct *t, · 1341 unmodified lines | |||
| 1342 | } | 1342 | } |
| 1343 | /* | 1343 | /* |
| 1344 | * Don't clear SIGNAL_UNKILLABLE for traced tasks, users won't expect | 1344 | * Don't clear SIGNAL_UNKILLABLE for traced tasks, users won't expect |
| 1345 | * debugging to leave init killable. | 1345 | * debugging to leave init killable. But HANDLER_EXIT is always fatal. |
| 1346 | */ | 1346 | */ |
| 1347 | if (action->sa.sa_handler == SIG_DFL && !t->ptrace) | 1347 | if (action->sa.sa_handler == SIG_DFL && |
| 1348 | (!t->ptrace || (handler == HANDLER_EXIT))) | ||
| 1348 | t->signal->flags &= ~SIGNAL_UNKILLABLE; | 1349 | t->signal->flags &= ~SIGNAL_UNKILLABLE; |
| 1349 | ret = send_signal(sig, info, t, PIDTYPE_PID); | 1350 | ret = send_signal(sig, info, t, PIDTYPE_PID); |
| 1350 | spin_unlock_irqrestore(&t->sighand->siglock, flags); | 1351 | spin_unlock_irqrestore(&t->sighand->siglock, flags); |
| @@ -70,7 +70,7 @@ late_initcall(stackleak_sysctls_init); · 69 unmodified lines | |||
| 70 | #define skip_erasing() false | 70 | #define skip_erasing() false |
| 71 | #endif /* CONFIG_STACKLEAK_RUNTIME_DISABLE */ | 71 | #endif /* CONFIG_STACKLEAK_RUNTIME_DISABLE */ |
| 72 | 72 | ||
| 73 | asmlinkage void notrace stackleak_erase(void) | 73 | asmlinkage void noinstr stackleak_erase(void) |
| 74 | { | 74 | { |
| 75 | /* It would be nice not to have 'kstack_ptr' and 'boundary' on stack */ | 75 | /* It would be nice not to have 'kstack_ptr' and 'boundary' on stack */ |
| 76 | unsigned long kstack_ptr = current->lowest_stack; | 76 | unsigned long kstack_ptr = current->lowest_stack; |
| @@ -124,9 +124,8 @@ asmlinkage void notrace stackleak_erase(void) · 47 unmodified lines | |||
| 124 | /* Reset the 'lowest_stack' value for the next syscall */ | 124 | /* Reset the 'lowest_stack' value for the next syscall */ |
| 125 | current->lowest_stack = current_top_of_stack() - THREAD_SIZE/64; | 125 | current->lowest_stack = current_top_of_stack() - THREAD_SIZE/64; |
| 126 | } | 126 | } |
| 127 | NOKPROBE_SYMBOL(stackleak_erase); | ||
| 128 | 127 | ||
| 129 | void __used __no_caller_saved_registers notrace stackleak_track_stack(void) | 128 | void __used __no_caller_saved_registers noinstr stackleak_track_stack(void) |
| 130 | { | 129 | { |
| 131 | unsigned long sp = current_stack_pointer; | 130 | unsigned long sp = current_stack_pointer; |
| 132 | 131 | ||
| @@ -472,6 +472,16 @@ static int set_user(struct cred *new) · 471 unmodified lines | |||
| 472 | if (!new_user) | 472 | if (!new_user) |
| 473 | return -EAGAIN; | 473 | return -EAGAIN; |
| 474 | 474 | ||
| 475 | free_uid(new->user); | ||
| 476 | new->user = new_user; | ||
| 477 | return 0; | ||
| 478 | } | ||
| 479 | |||
| 480 | static void flag_nproc_exceeded(struct cred *new) | ||
| 481 | { | ||
| 482 | if (new->ucounts == current_ucounts()) | ||
| 483 | return; | ||
| 484 | |||
| 475 | /* | 485 | /* |
| 476 | * We don't fail in case of NPROC limit excess here because too many | 486 | * We don't fail in case of NPROC limit excess here because too many |
| 477 | * poorly written programs don't check set*uid() return code, assuming | 487 | * poorly written programs don't check set*uid() return code, assuming |
| @@ -480,15 +490,10 @@ static int set_user(struct cred *new) · 2 unmodified lines | |||
| 480 | * failure to the execve() stage. | 490 | * failure to the execve() stage. |
| 481 | */ | 491 | */ |
| 482 | if (is_ucounts_overlimit(new->ucounts, UCOUNT_RLIMIT_NPROC, rlimit(RLIMIT_NPROC)) && | 492 | if (is_ucounts_overlimit(new->ucounts, UCOUNT_RLIMIT_NPROC, rlimit(RLIMIT_NPROC)) && |
| 483 | new_user != INIT_USER && | 493 | new->user != INIT_USER) |
| 484 | !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN)) | ||
| 485 | current->flags |= PF_NPROC_EXCEEDED; | 494 | current->flags |= PF_NPROC_EXCEEDED; |
| 486 | else | 495 | else |
| 487 | current->flags &= ~PF_NPROC_EXCEEDED; | 496 | current->flags &= ~PF_NPROC_EXCEEDED; |
| 488 | |||
| 489 | free_uid(new->user); | ||
| 490 | new->user = new_user; | ||
| 491 | return 0; | ||
| 492 | } | 497 | } |
| 493 | 498 | ||
| 494 | /* | 499 | /* |
| @@ -563,6 +568,7 @@ long __sys_setreuid(uid_t ruid, uid_t euid) · 68 unmodified lines | |||
| 563 | if (retval < 0) | 568 | if (retval < 0) |
| 564 | goto error; | 569 | goto error; |
| 565 | 570 | ||
| 571 | flag_nproc_exceeded(new); | ||
| 566 | return commit_creds(new); | 572 | return commit_creds(new); |
| 567 | 573 | ||
| 568 | error: | 574 | error: |
| @@ -625,6 +631,7 @@ long __sys_setuid(uid_t uid) · 56 unmodified lines | |||
| 625 | if (retval < 0) | 631 | if (retval < 0) |
| 626 | goto error; | 632 | goto error; |
| 627 | 633 | ||
| 634 | flag_nproc_exceeded(new); | ||
| 628 | return commit_creds(new); | 635 | return commit_creds(new); |
| 629 | 636 | ||
| 630 | error: | 637 | error: |
| @@ -704,6 +711,7 @@ long __sys_setresuid(uid_t ruid, uid_t euid, uid_t suid) · 73 unmodified lines | |||
| 704 | if (retval < 0) | 711 | if (retval < 0) |
| 705 | goto error; | 712 | goto error; |
| 706 | 713 | ||
| 714 | flag_nproc_exceeded(new); | ||
| 707 | return commit_creds(new); | 715 | return commit_creds(new); |
| 708 | 716 | ||
| 709 | error: | 717 | error: |
| @@ -70,10 +70,16 @@ config HAVE_C_RECORDMCOUNT · 69 unmodified lines | |||
| 70 | help | 70 | help |
| 71 | C version of recordmcount available? | 71 | C version of recordmcount available? |
| 72 | 72 | ||
| 73 | config HAVE_BUILDTIME_MCOUNT_SORT | ||
| 74 | bool | ||
| 75 | help | ||
| 76 | An architecture selects this if it sorts the mcount_loc section | ||
| 77 | at build time. | ||
| 78 | |||
| 73 | config BUILDTIME_MCOUNT_SORT | 79 | config BUILDTIME_MCOUNT_SORT |
| 74 | bool | 80 | bool |
| 75 | default y | 81 | default y |
| 76 | depends on BUILDTIME_TABLE_SORT && !S390 | 82 | depends on HAVE_BUILDTIME_MCOUNT_SORT && DYNAMIC_FTRACE |
| 77 | help | 83 | help |
| 78 | Sort the mcount_loc section at build time. | 84 | Sort the mcount_loc section at build time. |
| 79 | 85 | ||
| @@ -252,6 +252,10 @@ __setup("trace_clock=", set_trace_boot_clock); · 251 unmodified lines | |||
| 252 | 252 | ||
| 253 | static int __init set_tracepoint_printk(char *str) | 253 | static int __init set_tracepoint_printk(char *str) |
| 254 | { | 254 | { |
| 255 | /* Ignore the "tp_printk_stop_on_boot" param */ | ||
| 256 | if (*str == '_') | ||
| 257 | return 0; | ||
| 258 | |||
| 255 | if ((strcmp(str, "=0") != 0 && strcmp(str, "=off") != 0)) | 259 | if ((strcmp(str, "=0") != 0 && strcmp(str, "=off") != 0)) |
| 256 | tracepoint_printk = 1; | 260 | tracepoint_printk = 1; |
| 257 | return 1; | 261 | return 1; |
| @@ -7740,7 +7744,8 @@ static struct tracing_log_err *get_tracing_log_err(struct trace_array *tr) · 7482 unmodified lines | |||
| 7740 | err = kzalloc(sizeof(*err), GFP_KERNEL); | 7744 | err = kzalloc(sizeof(*err), GFP_KERNEL); |
| 7741 | if (!err) | 7745 | if (!err) |
| 7742 | err = ERR_PTR(-ENOMEM); | 7746 | err = ERR_PTR(-ENOMEM); |
| 7743 | tr->n_err_log_entries++; | 7747 | else |
| 7748 | tr->n_err_log_entries++; | ||
| 7744 | 7749 | ||
| 7745 | return err; | 7750 | return err; |
| 7746 | } | 7751 | } |
| @@ -2503,6 +2503,8 @@ static struct hist_field *parse_unary(struct hist_trigger_data *hist_data, · 2502 unmodified lines | |||
| 2503 | (HIST_FIELD_FL_TIMESTAMP | HIST_FIELD_FL_TIMESTAMP_USECS); | 2503 | (HIST_FIELD_FL_TIMESTAMP | HIST_FIELD_FL_TIMESTAMP_USECS); |
| 2504 | expr->fn = hist_field_unary_minus; | 2504 | expr->fn = hist_field_unary_minus; |
| 2505 | expr->operands[0] = operand1; | 2505 | expr->operands[0] = operand1; |
| 2506 | expr->size = operand1->size; | ||
| 2507 | expr->is_signed = operand1->is_signed; | ||
| 2506 | expr->operator = FIELD_OP_UNARY_MINUS; | 2508 | expr->operator = FIELD_OP_UNARY_MINUS; |
| 2507 | expr->name = expr_str(expr, 0); | 2509 | expr->name = expr_str(expr, 0); |
| 2508 | expr->type = kstrdup_const(operand1->type, GFP_KERNEL); | 2510 | expr->type = kstrdup_const(operand1->type, GFP_KERNEL); |
| @@ -2719,6 +2721,7 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data, · 210 unmodified lines | |||
| 2719 | 2721 | ||
| 2720 | /* The operand sizes should be the same, so just pick one */ | 2722 | /* The operand sizes should be the same, so just pick one */ |
| 2721 | expr->size = operand1->size; | 2723 | expr->size = operand1->size; |
| 2724 | expr->is_signed = operand1->is_signed; | ||
| 2722 | 2725 | ||
| 2723 | expr->operator = field_op; | 2726 | expr->operator = field_op; |
| 2724 | expr->type = kstrdup_const(operand1->type, GFP_KERNEL); | 2727 | expr->type = kstrdup_const(operand1->type, GFP_KERNEL); |
| @@ -3935,6 +3938,7 @@ static int trace_action_create(struct hist_trigger_data *hist_data, · 1210 unmodified lines | |||
| 3935 | 3938 | ||
| 3936 | var_ref_idx = find_var_ref_idx(hist_data, var_ref); | 3939 | var_ref_idx = find_var_ref_idx(hist_data, var_ref); |
| 3937 | if (WARN_ON(var_ref_idx < 0)) { | 3940 | if (WARN_ON(var_ref_idx < 0)) { |
| 3941 | kfree(p); | ||
| 3938 | ret = var_ref_idx; | 3942 | ret = var_ref_idx; |
| 3939 | goto err; | 3943 | goto err; |
| 3940 | } | 3944 | } |
| @@ -6163,7 +6167,9 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops, · 2222 unmodified lines | |||
| 6163 | 6167 | ||
| 6164 | lockdep_assert_held(&event_mutex); | 6168 | lockdep_assert_held(&event_mutex); |
| 6165 | 6169 | ||
| 6166 | if (glob && strlen(glob)) { | 6170 | WARN_ON(!glob); |
| 6171 | |||
| 6172 | if (strlen(glob)) { | ||
| 6167 | hist_err_clear(); | 6173 | hist_err_clear(); |
| 6168 | last_cmd_set(file, param); | 6174 | last_cmd_set(file, param); |
| 6169 | } | 6175 | } |
| @@ -6196,7 +6202,7 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops, · 26 unmodified lines | |||
| 6196 | continue; | 6202 | continue; |
| 6197 | } | 6203 | } |
| 6198 | break; | 6204 | break; |
| 6199 | } while (p); | 6205 | } while (1); |
| 6200 | 6206 | ||
| 6201 | if (!p) | 6207 | if (!p) |
| 6202 | param = NULL; | 6208 | param = NULL; |
| @@ -190,6 +190,7 @@ struct ucounts *alloc_ucounts(struct user_namespace *ns, kuid_t uid) · 189 unmodified lines | |||
| 190 | kfree(new); | 190 | kfree(new); |
| 191 | } else { | 191 | } else { |
| 192 | hlist_add_head(&new->node, hashent); | 192 | hlist_add_head(&new->node, hashent); |
| 193 | get_user_ns(new->ns); | ||
| 193 | spin_unlock_irq(&ucounts_lock); | 194 | spin_unlock_irq(&ucounts_lock); |
| 194 | return new; | 195 | return new; |
| 195 | } | 196 | } |
| @@ -210,6 +211,7 @@ void put_ucounts(struct ucounts *ucounts) · 14 unmodified lines | |||
| 210 | if (atomic_dec_and_lock_irqsave(&ucounts->count, &ucounts_lock, flags)) { | 211 | if (atomic_dec_and_lock_irqsave(&ucounts->count, &ucounts_lock, flags)) { |
| 211 | hlist_del_init(&ucounts->node); | 212 | hlist_del_init(&ucounts->node); |
| 212 | spin_unlock_irqrestore(&ucounts_lock, flags); | 213 | spin_unlock_irqrestore(&ucounts_lock, flags); |
| 214 | put_user_ns(ucounts->ns); | ||
| 213 | kfree(ucounts); | 215 | kfree(ucounts); |
| 214 | } | 216 | } |
| 215 | } | 217 | } |
| @@ -348,7 +350,8 @@ bool is_ucounts_overlimit(struct ucounts *ucounts, enum ucount_type type, unsign · 132 unmodified lines | |||
| 348 | if (rlimit > LONG_MAX) | 350 | if (rlimit > LONG_MAX) |
| 349 | max = LONG_MAX; | 351 | max = LONG_MAX; |
| 350 | for (iter = ucounts; iter; iter = iter->ns->ucounts) { | 352 | for (iter = ucounts; iter; iter = iter->ns->ucounts) { |
| 351 | if (get_ucounts_value(iter, type) > max) | 353 | long val = get_ucounts_value(iter, type); |
| 354 | if (val < 0 || val > max) | ||
| 352 | return true; | 355 | return true; |
| 353 | max = READ_ONCE(iter->ns->ucount_max[type]); | 356 | max = READ_ONCE(iter->ns->ucount_max[type]); |
| 354 | } | 357 | } |