]> Git Repo - linux.git/commitdiff
Merge tag 'perf-kprobes-2020-12-14' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <[email protected]>
Tue, 15 Dec 2020 01:41:38 +0000 (17:41 -0800)
committerLinus Torvalds <[email protected]>
Tue, 15 Dec 2020 01:41:38 +0000 (17:41 -0800)
Pull perf/kprobes updates from Thomas Gleixner:
 "Make kretprobes lockless to avoid the rp->lock performance and
  potential lock ordering issues"

* tag 'perf-kprobes-2020-12-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  locking/atomics: Regenerate the atomics-check SHA1's
  kprobes: Replace rp->free_instance with freelist
  freelist: Implement lockless freelist
  asm-generic/atomic: Add try_cmpxchg() fallbacks
  kprobes: Remove kretprobe hash
  llist: Add nonatomic __llist_add() and __llist_dell_all()

1  2 
include/linux/sched.h
kernel/fork.c

diff --combined include/linux/sched.h
index 1cac7efabc83ae74884a21f88bd325e868ceed22,393db06901016d13bbaaf24db419af2e4e9a6fd4..bd4225b73a1f5d37f00c47e7a8fa7cd1d50e2be5
@@@ -28,7 -28,6 +28,7 @@@
  #include <linux/sched/prio.h>
  #include <linux/sched/types.h>
  #include <linux/signal_types.h>
 +#include <linux/syscall_user_dispatch.h>
  #include <linux/mm_types_task.h>
  #include <linux/task_io_accounting.h>
  #include <linux/posix-timers.h>
@@@ -553,6 -552,7 +553,6 @@@ struct sched_dl_entity 
         * overruns.
         */
        unsigned int                    dl_throttled      : 1;
 -      unsigned int                    dl_boosted        : 1;
        unsigned int                    dl_yielded        : 1;
        unsigned int                    dl_non_contending : 1;
        unsigned int                    dl_overrun        : 1;
         * time.
         */
        struct hrtimer inactive_timer;
 +
 +#ifdef CONFIG_RT_MUTEXES
 +      /*
 +       * Priority Inheritance. When a DEADLINE scheduling entity is boosted
 +       * pi_se points to the donor, otherwise points to the dl_se it belongs
 +       * to (the original one/itself).
 +       */
 +      struct sched_dl_entity *pi_se;
 +#endif
  };
  
  #ifdef CONFIG_UCLAMP_TASK
@@@ -779,6 -770,7 +779,6 @@@ struct task_struct 
        unsigned                        sched_reset_on_fork:1;
        unsigned                        sched_contributes_to_load:1;
        unsigned                        sched_migrated:1;
 -      unsigned                        sched_remote_wakeup:1;
  #ifdef CONFIG_PSI
        unsigned                        sched_psi_wake_requeue:1;
  #endif
  
        /* Unserialized, strictly 'current' */
  
 +      /*
 +       * This field must not be in the scheduler word above due to wakelist
 +       * queueing no longer being serialized by p->on_cpu. However:
 +       *
 +       * p->XXX = X;                  ttwu()
 +       * schedule()                     if (p->on_rq && ..) // false
 +       *   smp_mb__after_spinlock();    if (smp_load_acquire(&p->on_cpu) && //true
 +       *   deactivate_task()                ttwu_queue_wakelist())
 +       *     p->on_rq = 0;                    p->sched_remote_wakeup = Y;
 +       *
 +       * guarantees all stores of 'current' are visible before
 +       * ->sched_remote_wakeup gets used, so it can be in this word.
 +       */
 +      unsigned                        sched_remote_wakeup:1;
 +
        /* Bit to tell LSMs we're in execve(): */
        unsigned                        in_execve:1;
        unsigned                        in_iowait:1;
        unsigned int                    sessionid;
  #endif
        struct seccomp                  seccomp;
 +      struct syscall_user_dispatch    syscall_dispatch;
  
        /* Thread group tracking: */
        u64                             parent_exec_id;
        struct callback_head            mce_kill_me;
  #endif
  
+ #ifdef CONFIG_KRETPROBES
+       struct llist_head               kretprobe_instances;
+ #endif
        /*
         * New fields for task_struct should be added above here, so that
         * they are included in the randomized portion of task_struct.
diff --combined kernel/fork.c
index 09be1be28cdef4f5706f2948014cdac8e9b14821,b9c289d0f4ef422932ea6975623c18f1d4bcec43..1513832de220b98c682dadb202c100aa920ef640
@@@ -906,7 -906,6 +906,7 @@@ static struct task_struct *dup_task_str
        clear_user_return_notifier(tsk);
        clear_tsk_need_resched(tsk);
        set_task_stack_end_magic(tsk);
 +      clear_syscall_work_syscall_user_dispatch(tsk);
  
  #ifdef CONFIG_STACKPROTECTOR
        tsk->stack_canary = get_random_canary();
@@@ -1626,7 -1625,7 +1626,7 @@@ static void copy_seccomp(struct task_st
         * to manually enable the seccomp thread flag here.
         */
        if (p->seccomp.mode != SECCOMP_MODE_DISABLED)
 -              set_tsk_thread_flag(p, TIF_SECCOMP);
 +              set_task_syscall_work(p, SECCOMP);
  #endif
  }
  
@@@ -2159,18 -2158,23 +2159,18 @@@ static __latent_entropy struct task_str
         * child regardless of CLONE_PTRACE.
         */
        user_disable_single_step(p);
 -      clear_tsk_thread_flag(p, TIF_SYSCALL_TRACE);
 -#ifdef TIF_SYSCALL_EMU
 -      clear_tsk_thread_flag(p, TIF_SYSCALL_EMU);
 +      clear_task_syscall_work(p, SYSCALL_TRACE);
 +#if defined(CONFIG_GENERIC_ENTRY) || defined(TIF_SYSCALL_EMU)
 +      clear_task_syscall_work(p, SYSCALL_EMU);
  #endif
        clear_tsk_latency_tracing(p);
  
        /* ok, now we should be set up.. */
        p->pid = pid_nr(pid);
        if (clone_flags & CLONE_THREAD) {
 -              p->exit_signal = -1;
                p->group_leader = current->group_leader;
                p->tgid = current->tgid;
        } else {
 -              if (clone_flags & CLONE_PARENT)
 -                      p->exit_signal = current->group_leader->exit_signal;
 -              else
 -                      p->exit_signal = args->exit_signal;
                p->group_leader = p;
                p->tgid = p->pid;
        }
        INIT_LIST_HEAD(&p->thread_group);
        p->task_works = NULL;
  
+ #ifdef CONFIG_KRETPROBES
+       p->kretprobe_instances.first = NULL;
+ #endif
        /*
         * Ensure that the cgroup subsystem policies allow the new process to be
         * forked. It should be noted that the new process's css_set can be changed
        if (clone_flags & (CLONE_PARENT|CLONE_THREAD)) {
                p->real_parent = current->real_parent;
                p->parent_exec_id = current->parent_exec_id;
 +              if (clone_flags & CLONE_THREAD)
 +                      p->exit_signal = -1;
 +              else
 +                      p->exit_signal = current->group_leader->exit_signal;
        } else {
                p->real_parent = current;
                p->parent_exec_id = current->self_exec_id;
 +              p->exit_signal = args->exit_signal;
        }
  
        klp_copy_process(p);
This page took 0.083074 seconds and 4 git commands to generate.