]> Git Repo - J-linux.git/commitdiff
Merge tag 'rcu.next.v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/boqun...
authorLinus Torvalds <[email protected]>
Mon, 11 Mar 2024 19:02:50 +0000 (12:02 -0700)
committerLinus Torvalds <[email protected]>
Mon, 11 Mar 2024 19:02:50 +0000 (12:02 -0700)
Pull RCU updates from Boqun Feng:

 - Eliminate deadlocks involving do_exit() and RCU tasks, by Paul:
   Instead of SRCU read side critical sections, now a percpu list is
   used in do_exit() for scaning yet-to-exit tasks

 - Fix a deadlock due to the dependency between workqueue and RCU
   expedited grace period, reported by Anna-Maria Behnsen and Thomas
   Gleixner and fixed by Frederic: Now RCU expedited always uses its own
   kthread worker instead of a workqueue

 - RCU NOCB updates, code cleanups, unnecessary barrier removals and
   minor bug fixes

 - Maintain real-time response in rcu_tasks_postscan() and a minor fix
   for tasks trace quiescence check

 - Misc updates, comments and readibility improvement, boot time
   parameter for lazy RCU and rcutorture improvement

 - Documentation updates

* tag 'rcu.next.v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/boqun/linux: (34 commits)
  rcu-tasks: Maintain real-time response in rcu_tasks_postscan()
  rcu-tasks: Eliminate deadlocks involving do_exit() and RCU tasks
  rcu-tasks: Maintain lists to eliminate RCU-tasks/do_exit() deadlocks
  rcu-tasks: Initialize data to eliminate RCU-tasks/do_exit() deadlocks
  rcu-tasks: Initialize callback lists at rcu_init() time
  rcu-tasks: Add data to eliminate RCU-tasks/do_exit() deadlocks
  rcu-tasks: Repair RCU Tasks Trace quiescence check
  rcu/sync: remove un-used rcu_sync_enter_start function
  rcutorture: Suppress rtort_pipe_count warnings until after stalls
  srcu: Improve comments about acceleration leak
  rcu: Provide a boot time parameter to control lazy RCU
  rcu: Rename jiffies_till_flush to jiffies_lazy_flush
  doc: Update checklist.rst discussion of callback execution
  doc: Clarify use of slab constructors and SLAB_TYPESAFE_BY_RCU
  context_tracking: Fix kerneldoc headers for __ct_user_{enter,exit}()
  doc: Add EARLY flag to early-parsed kernel boot parameters
  doc: Add CONFIG_RCU_STRICT_GRACE_PERIOD to checklist.rst
  doc: Make checklist.rst note that spinlocks are implied RCU readers
  doc: Make whatisRCU.rst note that spinlocks are RCU readers
  doc: Spinlocks are implied RCU readers
  ...

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

diff --combined include/linux/sched.h
index 15b7cb478d166a2298c1139ba09827e304358df5,5eeebed2dd9ba248cb5bc282dfcf367ebdf58343..17cb0761ff658e6838aa4e04eb429d4155e55e81
@@@ -858,6 -858,8 +858,8 @@@ struct task_struct 
        u8                              rcu_tasks_idx;
        int                             rcu_tasks_idle_cpu;
        struct list_head                rcu_tasks_holdout_list;
+       int                             rcu_tasks_exit_cpu;
+       struct list_head                rcu_tasks_exit_list;
  #endif /* #ifdef CONFIG_TASKS_RCU */
  
  #ifdef CONFIG_TASKS_TRACE_RCU
@@@ -1642,7 -1644,7 +1644,7 @@@ extern struct pid *cad_pid
  #define PF_NO_SETAFFINITY     0x04000000      /* Userland is not allowed to meddle with cpus_mask */
  #define PF_MCE_EARLY          0x08000000      /* Early kill for mce process policy */
  #define PF_MEMALLOC_PIN               0x10000000      /* Allocation context constrained to zones which allow long term pinning. */
 -#define PF__HOLE__20000000    0x20000000
 +#define PF_BLOCK_TS           0x20000000      /* plug has ts that needs updating */
  #define PF__HOLE__40000000    0x40000000
  #define PF_SUSPEND_TASK               0x80000000      /* This thread called freeze_processes() and should not be frozen */
  
diff --combined kernel/fork.c
index 1af8dfd149ee03fa60aad39981a1a6d97e8c2d78,af7203be1d2d199cd3184deb265ba36a72e6567c..39a5046c2f0bf49e1bcade15c4c3c5574742b09d
  #include <linux/user_events.h>
  #include <linux/iommu.h>
  #include <linux/rseq.h>
 +#include <uapi/linux/pidfd.h>
 +#include <linux/pidfs.h>
  
  #include <asm/pgalloc.h>
  #include <linux/uaccess.h>
@@@ -1978,6 -1976,7 +1978,7 @@@ static inline void rcu_copy_process(str
        p->rcu_tasks_holdout = false;
        INIT_LIST_HEAD(&p->rcu_tasks_holdout_list);
        p->rcu_tasks_idle_cpu = -1;
+       INIT_LIST_HEAD(&p->rcu_tasks_exit_list);
  #endif /* #ifdef CONFIG_TASKS_RCU */
  #ifdef CONFIG_TASKS_TRACE_RCU
        p->trc_reader_nesting = 0;
  #endif /* #ifdef CONFIG_TASKS_TRACE_RCU */
  }
  
 -struct pid *pidfd_pid(const struct file *file)
 -{
 -      if (file->f_op == &pidfd_fops)
 -              return file->private_data;
 -
 -      return ERR_PTR(-EBADF);
 -}
 -
 -static int pidfd_release(struct inode *inode, struct file *file)
 -{
 -      struct pid *pid = file->private_data;
 -
 -      file->private_data = NULL;
 -      put_pid(pid);
 -      return 0;
 -}
 -
 -#ifdef CONFIG_PROC_FS
 -/**
 - * pidfd_show_fdinfo - print information about a pidfd
 - * @m: proc fdinfo file
 - * @f: file referencing a pidfd
 - *
 - * Pid:
 - * This function will print the pid that a given pidfd refers to in the
 - * pid namespace of the procfs instance.
 - * If the pid namespace of the process is not a descendant of the pid
 - * namespace of the procfs instance 0 will be shown as its pid. This is
 - * similar to calling getppid() on a process whose parent is outside of
 - * its pid namespace.
 - *
 - * NSpid:
 - * If pid namespaces are supported then this function will also print
 - * the pid of a given pidfd refers to for all descendant pid namespaces
 - * starting from the current pid namespace of the instance, i.e. the
 - * Pid field and the first entry in the NSpid field will be identical.
 - * If the pid namespace of the process is not a descendant of the pid
 - * namespace of the procfs instance 0 will be shown as its first NSpid
 - * entry and no others will be shown.
 - * Note that this differs from the Pid and NSpid fields in
 - * /proc/<pid>/status where Pid and NSpid are always shown relative to
 - * the  pid namespace of the procfs instance. The difference becomes
 - * obvious when sending around a pidfd between pid namespaces from a
 - * different branch of the tree, i.e. where no ancestral relation is
 - * present between the pid namespaces:
 - * - create two new pid namespaces ns1 and ns2 in the initial pid
 - *   namespace (also take care to create new mount namespaces in the
 - *   new pid namespace and mount procfs)
 - * - create a process with a pidfd in ns1
 - * - send pidfd from ns1 to ns2
 - * - read /proc/self/fdinfo/<pidfd> and observe that both Pid and NSpid
 - *   have exactly one entry, which is 0
 - */
 -static void pidfd_show_fdinfo(struct seq_file *m, struct file *f)
 -{
 -      struct pid *pid = f->private_data;
 -      struct pid_namespace *ns;
 -      pid_t nr = -1;
 -
 -      if (likely(pid_has_task(pid, PIDTYPE_PID))) {
 -              ns = proc_pid_ns(file_inode(m->file)->i_sb);
 -              nr = pid_nr_ns(pid, ns);
 -      }
 -
 -      seq_put_decimal_ll(m, "Pid:\t", nr);
 -
 -#ifdef CONFIG_PID_NS
 -      seq_put_decimal_ll(m, "\nNSpid:\t", nr);
 -      if (nr > 0) {
 -              int i;
 -
 -              /* If nr is non-zero it means that 'pid' is valid and that
 -               * ns, i.e. the pid namespace associated with the procfs
 -               * instance, is in the pid namespace hierarchy of pid.
 -               * Start at one below the already printed level.
 -               */
 -              for (i = ns->level + 1; i <= pid->level; i++)
 -                      seq_put_decimal_ll(m, "\t", pid->numbers[i].nr);
 -      }
 -#endif
 -      seq_putc(m, '\n');
 -}
 -#endif
 -
 -/*
 - * Poll support for process exit notification.
 - */
 -static __poll_t pidfd_poll(struct file *file, struct poll_table_struct *pts)
 -{
 -      struct pid *pid = file->private_data;
 -      __poll_t poll_flags = 0;
 -
 -      poll_wait(file, &pid->wait_pidfd, pts);
 -
 -      /*
 -       * Inform pollers only when the whole thread group exits.
 -       * If the thread group leader exits before all other threads in the
 -       * group, then poll(2) should block, similar to the wait(2) family.
 -       */
 -      if (thread_group_exited(pid))
 -              poll_flags = EPOLLIN | EPOLLRDNORM;
 -
 -      return poll_flags;
 -}
 -
 -const struct file_operations pidfd_fops = {
 -      .release = pidfd_release,
 -      .poll = pidfd_poll,
 -#ifdef CONFIG_PROC_FS
 -      .show_fdinfo = pidfd_show_fdinfo,
 -#endif
 -};
 -
  /**
   * __pidfd_prepare - allocate a new pidfd_file and reserve a pidfd
   * @pid:   the struct pid for which to create a pidfd
@@@ -2020,20 -2132,20 +2021,20 @@@ static int __pidfd_prepare(struct pid *
        int pidfd;
        struct file *pidfd_file;
  
 -      if (flags & ~(O_NONBLOCK | O_RDWR | O_CLOEXEC))
 -              return -EINVAL;
 -
 -      pidfd = get_unused_fd_flags(O_RDWR | O_CLOEXEC);
 +      pidfd = get_unused_fd_flags(O_CLOEXEC);
        if (pidfd < 0)
                return pidfd;
  
 -      pidfd_file = anon_inode_getfile("[pidfd]", &pidfd_fops, pid,
 -                                      flags | O_RDWR | O_CLOEXEC);
 +      pidfd_file = pidfs_alloc_file(pid, flags | O_RDWR);
        if (IS_ERR(pidfd_file)) {
                put_unused_fd(pidfd);
                return PTR_ERR(pidfd_file);
        }
 -      get_pid(pid); /* held by pidfd_file now */
 +      /*
 +       * anon_inode_getfile() ignores everything outside of the
 +       * O_ACCMODE | O_NONBLOCK mask, set PIDFD_THREAD manually.
 +       */
 +      pidfd_file->f_flags |= (flags & PIDFD_THREAD);
        *ret = pidfd_file;
        return pidfd;
  }
   * Allocate a new file that stashes @pid and reserve a new pidfd number in the
   * caller's file descriptor table. The pidfd is reserved but not installed yet.
   *
 - * The helper verifies that @pid is used as a thread group leader.
 + * The helper verifies that @pid is still in use, without PIDFD_THREAD the
 + * task identified by @pid must be a thread-group leader.
   *
   * If this function returns successfully the caller is responsible to either
   * call fd_install() passing the returned pidfd and pidfd file as arguments in
   */
  int pidfd_prepare(struct pid *pid, unsigned int flags, struct file **ret)
  {
 -      if (!pid || !pid_has_task(pid, PIDTYPE_TGID))
 +      bool thread = flags & PIDFD_THREAD;
 +
 +      if (!pid || !pid_has_task(pid, thread ? PIDTYPE_PID : PIDTYPE_TGID))
                return -EINVAL;
  
        return __pidfd_prepare(pid, flags, ret);
@@@ -2191,8 -2300,9 +2192,8 @@@ __latent_entropy struct task_struct *co
                /*
                 * - CLONE_DETACHED is blocked so that we can potentially
                 *   reuse it later for CLONE_PIDFD.
 -               * - CLONE_THREAD is blocked until someone really needs it.
                 */
 -              if (clone_flags & (CLONE_DETACHED | CLONE_THREAD))
 +              if (clone_flags & CLONE_DETACHED)
                        return ERR_PTR(-EINVAL);
        }
  
         * if the fd table isn't shared).
         */
        if (clone_flags & CLONE_PIDFD) {
 +              int flags = (clone_flags & CLONE_THREAD) ? PIDFD_THREAD : 0;
 +
                /* Note that no task has been attached to @pid yet. */
 -              retval = __pidfd_prepare(pid, O_RDWR | O_CLOEXEC, &pidfile);
 +              retval = __pidfd_prepare(pid, flags, &pidfile);
                if (retval < 0)
                        goto bad_fork_free_pid;
                pidfd = retval;
@@@ -2769,8 -2877,8 +2770,8 @@@ pid_t kernel_clone(struct kernel_clone_
         * here has the advantage that we don't need to have a separate helper
         * to check for legacy clone().
         */
 -      if ((args->flags & CLONE_PIDFD) &&
 -          (args->flags & CLONE_PARENT_SETTID) &&
 +      if ((clone_flags & CLONE_PIDFD) &&
 +          (clone_flags & CLONE_PARENT_SETTID) &&
            (args->pidfd == args->parent_tid))
                return -EINVAL;
  
This page took 0.095818 seconds and 4 git commands to generate.