1. 27 Apr, 2020 34 commits
    • Paul E. McKenney's avatar
      rcu-tasks: Avoid IPIing userspace/idle tasks if kernel is so built · 7d0c9c50
      Paul E. McKenney authored
      Systems running CPU-bound real-time task do not want IPIs sent to CPUs
      executing nohz_full userspace tasks.  Battery-powered systems don't
      want IPIs sent to idle CPUs in low-power mode.  Unfortunately, RCU tasks
      trace can and will send such IPIs in some cases.
      
      Both of these situations occur only when the target CPU is in RCU
      dyntick-idle mode, in other words, when RCU is not watching the
      target CPU.  This suggests that CPUs in dyntick-idle mode should use
      memory barriers in outermost invocations of rcu_read_lock_trace()
      and rcu_read_unlock_trace(), which would allow the RCU tasks trace
      grace period to directly read out the target CPU's read-side state.
      One challenge is that RCU tasks trace is not targeting a specific
      CPU, but rather a task.  And that task could switch from one CPU to
      another at any time.
      
      This commit therefore uses try_invoke_on_locked_down_task()
      and checks for task_curr() in trc_inspect_reader_notrunning().
      When this condition holds, the target task is running and cannot move.
      If CONFIG_TASKS_TRACE_RCU_READ_MB=y, the new rcu_dynticks_zero_in_eqs()
      function can be used to check if the specified integer (in this case,
      t->trc_reader_nesting) is zero while the target CPU remains in that same
      dyntick-idle sojourn.  If so, the target task is in a quiescent state.
      If not, trc_read_check_handler() must indicate failure so that the
      grace-period kthread can take appropriate action or retry after an
      appropriate delay, as the case may be.
      
      With this change, given CONFIG_TASKS_TRACE_RCU_READ_MB=y, if a given
      CPU remains idle or a given task continues executing in nohz_full mode,
      the RCU tasks trace grace-period kthread will detect this without the
      need to send an IPI.
      Suggested-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      7d0c9c50
    • Paul E. McKenney's avatar
      rcu-tasks: Add Kconfig option to mediate smp_mb() vs. IPI · 9ae58d7b
      Paul E. McKenney authored
      This commit provides a new TASKS_TRACE_RCU_READ_MB Kconfig option that
      enables use of read-side memory barriers by both rcu_read_lock_trace()
      and rcu_read_unlock_trace() when the are executed with the
      current->trc_reader_special.b.need_mb flag set.  This flag is currently
      never set.  Doing that is the subject of a later commit.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      9ae58d7b
    • Paul E. McKenney's avatar
      rcu-tasks: Add grace-period and IPI counts to statistics · 238dbce3
      Paul E. McKenney authored
      This commit adds a grace-period count and a count of IPIs sent since
      boot, which is printed in response to rcutorture writer stalls and at
      the end of rcutorture testing.  These counts will be used to evaluate
      various schemes to reduce the number of IPIs sent.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      238dbce3
    • Paul E. McKenney's avatar
      rcu-tasks: Split ->trc_reader_need_end · 276c4104
      Paul E. McKenney authored
      This commit splits ->trc_reader_need_end by using the rcu_special union.
      This change permits readers to check to see if a memory barrier is
      required without any added overhead in the common case where no such
      barrier is required.  This commit also adds the read-side checking.
      Later commits will add the machinery to properly set the new
      ->trc_reader_special.b.need_mb field.
      
      This commit also makes rcu_read_unlock_trace_special() tolerate nested
      read-side critical sections within interrupt and NMI handlers.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      276c4104
    • Paul E. McKenney's avatar
      rcu-tasks: Provide boot parameter to delay IPIs until late in grace period · b0afa0f0
      Paul E. McKenney authored
      This commit provides a rcupdate.rcu_task_ipi_delay kernel boot parameter
      that specifies how old the RCU tasks trace grace period must be before
      the grace-period kthread starts sending IPIs.  This delay allows more
      tasks to pass through rcu_tasks_qs() quiescent states, thus reducing
      (or even eliminating) the number of IPIs that must be sent.
      
      On a short rcutorture test setting this kernel boot parameter to HZ/2
      resulted in zero IPIs for all 877 RCU-tasks trace grace periods that
      elapsed during that test.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      b0afa0f0
    • Paul E. McKenney's avatar
      rcu-tasks: Add a grace-period start time for throttling and debug · 88092d0c
      Paul E. McKenney authored
      This commit adds a place to record the grace-period start in jiffies.
      This will be used by later commits for debugging purposes and to throttle
      IPIs early in the grace period.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      88092d0c
    • Paul E. McKenney's avatar
      rcu-tasks: Make RCU Tasks Trace make use of RCU scheduler hooks · 43766c3e
      Paul E. McKenney authored
      This commit makes the calls to rcu_tasks_qs() detect and report
      quiescent states for RCU tasks trace.  If the task is in a quiescent
      state and if ->trc_reader_checked is not yet set, the task sets its own
      ->trc_reader_checked.  This will cause the grace-period kthread to
      remove it from the holdout list if it still remains there.
      
      [ paulmck: Fix conditional compilation per kbuild test robot feedback. ]
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      43766c3e
    • Paul E. McKenney's avatar
      rcu-tasks: Make rcutorture writer stall output include GP state · af051ca4
      Paul E. McKenney authored
      This commit adds grace-period state and time to the rcutorture writer
      stall output.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      af051ca4
    • Paul E. McKenney's avatar
      rcu-tasks: Add RCU tasks to rcutorture writer stall output · e21408ce
      Paul E. McKenney authored
      This commit adds state for each RCU-tasks flavor to the rcutorture
      writer stall output.  The initial state is minimal, but you have to
      start somewhere.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      [ paulmck: Fixes based on feedback from kbuild test robot. ]
      e21408ce
    • Paul E. McKenney's avatar
      rcu-tasks: Move #ifdef into tasks.h · 8fd8ca38
      Paul E. McKenney authored
      This commit pushes the #ifdef CONFIG_TASKS_RCU_GENERIC from
      kernel/rcu/update.c to kernel/rcu/tasks.h in order to improve
      readability as more APIs are added.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      8fd8ca38
    • Paul E. McKenney's avatar
      rcu-tasks: Add stall warnings for RCU Tasks Trace · 4593e772
      Paul E. McKenney authored
      This commit adds RCU CPU stall warnings for RCU Tasks Trace.  These
      dump out any tasks blocking the current grace period, as well as any
      CPUs that have not responded to an IPI request.  This happens in two
      phases, when initially extracting state from the tasks and later when
      waiting for any holdout tasks to check in.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      4593e772
    • Paul E. McKenney's avatar
      rcutorture: Add torture tests for RCU Tasks Trace · c1a76c0b
      Paul E. McKenney authored
      This commit adds the definitions required to torture the tracing flavor
      of RCU tasks.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      c1a76c0b
    • Paul E. McKenney's avatar
      rcu-tasks: Add an RCU Tasks Trace to simplify protection of tracing hooks · d5f177d3
      Paul E. McKenney authored
      Because RCU does not watch exception early-entry/late-exit, idle-loop,
      or CPU-hotplug execution, protection of tracing and BPF operations is
      needlessly complicated.  This commit therefore adds a variant of
      Tasks RCU that:
      
      o	Has explicit read-side markers to allow finite grace periods in
      	the face of in-kernel loops for PREEMPT=n builds.  These markers
      	are rcu_read_lock_trace() and rcu_read_unlock_trace().
      
      o	Protects code in the idle loop, exception entry/exit, and
      	CPU-hotplug code paths.  In this respect, RCU-tasks trace is
      	similar to SRCU, but with lighter-weight readers.
      
      o	Avoids expensive read-side instruction, having overhead similar
      	to that of Preemptible RCU.
      
      There are of course downsides:
      
      o	The grace-period code can send IPIs to CPUs, even when those
      	CPUs are in the idle loop or in nohz_full userspace.  This is
      	mitigated by later commits.
      
      o	It is necessary to scan the full tasklist, much as for Tasks RCU.
      
      o	There is a single callback queue guarded by a single lock,
      	again, much as for Tasks RCU.  However, those early use cases
      	that request multiple grace periods in quick succession are
      	expected to do so from a single task, which makes the single
      	lock almost irrelevant.  If needed, multiple callback queues
      	can be provided using any number of schemes.
      
      Perhaps most important, this variant of RCU does not affect the vanilla
      flavors, rcu_preempt and rcu_sched.  The fact that RCU Tasks Trace
      readers can operate from idle, offline, and exception entry/exit in no
      way enables rcu_preempt and rcu_sched readers to do so.
      
      The memory ordering was outlined here:
      https://lore.kernel.org/lkml/20200319034030.GX3199@paulmck-ThinkPad-P72/
      
      This effort benefited greatly from off-list discussions of BPF
      requirements with Alexei Starovoitov and Andrii Nakryiko.  At least
      some of the on-list discussions are captured in the Link: tags below.
      In addition, KCSAN was quite helpful in finding some early bugs.
      
      Link: https://lore.kernel.org/lkml/20200219150744.428764577@infradead.org/
      Link: https://lore.kernel.org/lkml/87mu8p797b.fsf@nanos.tec.linutronix.de/
      Link: https://lore.kernel.org/lkml/20200225221305.605144982@linutronix.de/
      Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      [ paulmck: Apply feedback from Steve Rostedt and Joel Fernandes. ]
      [ paulmck: Decrement trc_n_readers_need_end upon IPI failure. ]
      [ paulmck: Fix locking issue reported by rcutorture. ]
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      d5f177d3
    • Paul E. McKenney's avatar
      rcu-tasks: Code movement to allow more Tasks RCU variants · d01aa263
      Paul E. McKenney authored
      This commit does nothing but move rcu_tasks_wait_gp() up to a new section
      for common code.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      d01aa263
    • Paul E. McKenney's avatar
      rcu-tasks: Further refactor RCU-tasks to allow adding more variants · e4fe5dd6
      Paul E. McKenney authored
      This commit refactors RCU tasks to allow variants to be added.  These
      variants will share the current Tasks-RCU tasklist scan and the holdout
      list processing.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      e4fe5dd6
    • Paul E. McKenney's avatar
      rcu-tasks: Use unique names for RCU-Tasks kthreads and messages · c97d12a6
      Paul E. McKenney authored
      This commit causes the flavors of RCU Tasks to use different names
      for their kthreads and in their console messages.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      c97d12a6
    • Paul E. McKenney's avatar
      rcutorture: Add torture tests for RCU Tasks Rude · 3d6e43c7
      Paul E. McKenney authored
      This commit adds the definitions required to torture the rude flavor of
      RCU tasks.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      3d6e43c7
    • Paul E. McKenney's avatar
      rcu-tasks: Add an RCU-tasks rude variant · c84aad76
      Paul E. McKenney authored
      This commit adds a "rude" variant of RCU-tasks that has as quiescent
      states schedule(), cond_resched_tasks_rcu_qs(), userspace execution,
      and (in theory, anyway) cond_resched().  In other words, RCU-tasks rude
      readers are regions of code with preemption disabled, but excluding code
      early in the CPU-online sequence and late in the CPU-offline sequence.
      Updates make use of IPIs and force an IPI and a context switch on each
      online CPU.  This variant is useful in some situations in tracing.
      Suggested-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      [ paulmck: Apply EXPORT_SYMBOL_GPL() feedback from Qiujun Huang. ]
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      [ paulmck: Apply review feedback from Steve Rostedt. ]
      c84aad76
    • Paul E. McKenney's avatar
      rcu-tasks: Refactor RCU-tasks to allow variants to be added · 5873b8a9
      Paul E. McKenney authored
      This commit splits out generic processing from RCU-tasks-specific
      processing in order to allow additional flavors to be added.  It also
      adds a def_bool TASKS_RCU_GENERIC to enable the common RCU-tasks
      infrastructure code.
      
      This is primarily, but not entirely, a code-movement commit.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      5873b8a9
    • Paul E. McKenney's avatar
      rcutorture: Add a test for synchronize_rcu_mult() · 9cf8fc6f
      Paul E. McKenney authored
      This commit adds a crude test for synchronize_rcu_mult().  This is
      currently a smoke test rather than a high-quality stress test.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      9cf8fc6f
    • Paul E. McKenney's avatar
      rcu: Reinstate synchronize_rcu_mult() · b3d73156
      Paul E. McKenney authored
      With the advent and likely usage of synchronize_rcu_rude(), there is
      again a need to wait on multiple types of RCU grace periods, for
      example, call_rcu_tasks() and call_rcu_tasks_rude().  This commit
      therefore reinstates synchronize_rcu_mult() in order to allow these
      grace periods to be straightforwardly waited on concurrently.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      b3d73156
    • Paul E. McKenney's avatar
      rcu-tasks: Create struct to hold state information · 07e10515
      Paul E. McKenney authored
      This commit creates an rcu_tasks struct to hold state information for
      RCU Tasks.  This is a preparation commit for adding additional flavors
      of Tasks RCU, each of which would have its own rcu_tasks struct.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      07e10515
    • Paul E. McKenney's avatar
      rcu-tasks: Move Tasks RCU to its own file · eacd6f04
      Paul E. McKenney authored
      This code-movement-only commit is in preparation for adding an additional
      flavor of Tasks RCU, which relies on workqueues to detect grace periods.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      eacd6f04
    • Paul E. McKenney's avatar
      rcu: Add per-task state to RCU CPU stall warnings · 5bef8da6
      Paul E. McKenney authored
      Currently, an RCU-preempt CPU stall warning simply lists the PIDs of
      those tasks holding up the current grace period.  This can be helpful,
      but more can be even more helpful.
      
      To this end, this commit adds the nesting level, whether the task
      thinks it was preempted in its current RCU read-side critical section,
      whether RCU core has asked this task for a quiescent state, whether the
      expedited-grace-period hint is set, and whether the task believes that
      it is on the blocked-tasks list (it must be, or it would not be printed,
      but if things are broken, best not to take too much for granted).
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      5bef8da6
    • Paul E. McKenney's avatar
      sched/core: Add function to sample state of locked-down task · 2beaf328
      Paul E. McKenney authored
      A running task's state can be sampled in a consistent manner (for example,
      for diagnostic purposes) simply by invoking smp_call_function_single()
      on its CPU, which may be obtained using task_cpu(), then having the
      IPI handler verify that the desired task is in fact still running.
      However, if the task is not running, this sampling can in theory be done
      immediately and directly.  In practice, the task might start running at
      any time, including during the sampling period.  Gaining a consistent
      sample of a not-running task therefore requires that something be done
      to lock down the target task's state.
      
      This commit therefore adds a try_invoke_on_locked_down_task() function
      that invokes a specified function if the specified task can be locked
      down, returning true if successful and if the specified function returns
      true.  Otherwise this function simply returns false.  Given that the
      function passed to try_invoke_on_nonrunning_task() might be invoked with
      a runqueue lock held, that function had better be quite lightweight.
      
      The function is passed the target task's task_struct pointer and the
      argument passed to try_invoke_on_locked_down_task(), allowing easy access
      to task state and to a location for further variables to be passed in
      and out.
      
      Note that the specified function will be called even if the specified
      task is currently running.  The function can use ->on_rq and task_curr()
      to quickly and easily determine the task's state, and can return false
      if this state is not to the function's liking.  The caller of the
      try_invoke_on_locked_down_task() would then see the false return value,
      and could take appropriate action, for example, trying again later or
      sending an IPI if matters are more urgent.
      
      It is expected that use cases such as the RCU CPU stall warning code will
      simply return false if the task is currently running.  However, there are
      use cases involving nohz_full CPUs where the specified function might
      instead fall back to an alternative sampling scheme that relies on heavier
      synchronization (such as memory barriers) in the target task.
      
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Vincent Guittot <vincent.guittot@linaro.org>
      Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
      Cc: Ben Segall <bsegall@google.com>
      Cc: Mel Gorman <mgorman@suse.de>
      [ paulmck: Apply feedback from Peter Zijlstra and Steven Rostedt. ]
      [ paulmck: Invoke if running to handle feedback from Mathieu Desnoyers. ]
      Reviewed-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Reviewed-by: default avatarJoel Fernandes (Google) <joel@joelfernandes.org>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      2beaf328
    • Paul E. McKenney's avatar
      rcu-tasks: Use context-switch hook for PREEMPT=y kernels · 66777e58
      Paul E. McKenney authored
      Currently, the PREEMPT=y version of rcu_note_context_switch() does not
      invoke rcu_tasks_qs(), and we need it to in order to keep RCU Tasks
      Trace's IPIs down to a dull roar.  This commit therefore enables this
      hook.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      66777e58
    • Paul E. McKenney's avatar
      rcu: Add comments marking transitions between RCU watching and not · ac3caf82
      Paul E. McKenney authored
      It is not as clear as it might be just where in RCU's idle entry/exit
      code RCU stops and starts watching the current CPU.  This commit therefore
      adds comments calling out the transitions.
      Reported-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      ac3caf82
    • Paul E. McKenney's avatar
      rcutorture: Add test of holding scheduler locks across rcu_read_unlock() · 52b1fc3f
      Paul E. McKenney authored
      Now that it should be safe to hold scheduler locks across
      rcu_read_unlock(), even in cases where the corresponding RCU read-side
      critical section might have been preempted and boosted, the commit adds
      a test of this capability to rcutorture.  This has been tested on current
      mainline (which can deadlock in this situation), and lockdep duly reported
      the expected deadlock.  On -rcu, lockdep is silent, thus far, anyway.
      
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Vincent Guittot <vincent.guittot@linaro.org>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      52b1fc3f
    • Lai Jiangshan's avatar
      rcu: Don't use negative nesting depth in __rcu_read_unlock() · 5f5fa7ea
      Lai Jiangshan authored
      Now that RCU flavors have been consolidated, an RCU-preempt
      rcu_read_unlock() in an interrupt or softirq handler cannot possibly
      end the RCU read-side critical section.  Consider the old vulnerability
      involving rcu_read_unlock() being invoked within such a handler that
      interrupted an __rcu_read_unlock_special(), in which a wakeup might be
      invoked with a scheduler lock held.  Because rcu_read_unlock_special()
      no longer does wakeups in such situations, it is no longer necessary
      for __rcu_read_unlock() to set the nesting level negative.
      
      This commit therefore removes this recursion-protection code from
      __rcu_read_unlock().
      
      [ paulmck: Let rcu_exp_handler() continue to call rcu_report_exp_rdp(). ]
      [ paulmck: Adjust other checks given no more negative nesting. ]
      Signed-off-by: default avatarLai Jiangshan <laijs@linux.alibaba.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      5f5fa7ea
    • Lai Jiangshan's avatar
      rcu: Remove unused ->rcu_read_unlock_special.b.deferred_qs field · f0bdf6d4
      Lai Jiangshan authored
      The ->rcu_read_unlock_special.b.deferred_qs field is set to true in
      rcu_read_unlock_special() but never set to false.  This is not
      particularly useful, so this commit removes this field.
      
      The only possible justification for this field is to ease debugging
      of RCU deferred quiscent states, but the combination of the other
      ->rcu_read_unlock_special fields plus ->rcu_blocked_node and of course
      ->rcu_read_lock_nesting should cover debugging needs.  And if this last
      proves incorrect, this patch can always be reverted, along with the
      required setting of ->rcu_read_unlock_special.b.deferred_qs to false
      in rcu_preempt_deferred_qs_irqrestore().
      Signed-off-by: default avatarLai Jiangshan <laijs@linux.alibaba.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      f0bdf6d4
    • Lai Jiangshan's avatar
      rcu: Don't set nesting depth negative in rcu_preempt_deferred_qs() · 07b4a930
      Lai Jiangshan authored
      Now that RCU flavors have been consolidated, an RCU-preempt
      rcu_read_unlock() in an interrupt or softirq handler cannot possibly
      end the RCU read-side critical section.  Consider the old vulnerability
      involving rcu_preempt_deferred_qs() being invoked within such a handler
      that interrupted an extended RCU read-side critical section, in which
      a wakeup might be invoked with a scheduler lock held.  Because
      rcu_read_unlock_special() no longer does wakeups in such situations,
      it is no longer necessary for rcu_preempt_deferred_qs() to set the
      nesting level negative.
      
      This commit therefore removes this recursion-protection code from
      rcu_preempt_deferred_qs().
      
      [ paulmck: Fix typo in commit log per Steve Rostedt. ]
      Signed-off-by: default avatarLai Jiangshan <laijs@linux.alibaba.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      07b4a930
    • Paul E. McKenney's avatar
      rcu: Make rcu_read_unlock_special() safe for rq/pi locks · e4453d8a
      Paul E. McKenney authored
      The scheduler is currently required to hold rq/pi locks across the entire
      RCU read-side critical section or not at all.  This is inconvenient and
      leaves traps for the unwary, including the author of this commit.
      
      But now that excessively long grace periods enable scheduling-clock
      interrupts for holdout nohz_full CPUs, the nohz_full rescue logic in
      rcu_read_unlock_special() can be dispensed with.  In other words, the
      rcu_read_unlock_special() function can refrain from doing wakeups unless
      such wakeups are guaranteed safe.
      
      This commit therefore avoids unsafe wakeups, freeing the scheduler to
      hold rq/pi locks across rcu_read_unlock() even if the corresponding RCU
      read-side critical section might have been preempted.  This commit also
      updates RCU's requirements documentation.
      
      This commit is inspired by a patch from Lai Jiangshan:
      https://lore.kernel.org/lkml/20191102124559.1135-2-laijs@linux.alibaba.com
      This commit is further intended to be a step towards his goal of permitting
      the inlining of RCU-preempt's rcu_read_lock() and rcu_read_unlock().
      
      Cc: Lai Jiangshan <laijs@linux.alibaba.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      e4453d8a
    • Paul E. McKenney's avatar
      rcu: Add KCSAN stubs to update.c · c76e7e0b
      Paul E. McKenney authored
      This commit adds stubs for KCSAN's data_race(), ASSERT_EXCLUSIVE_WRITER(),
      and ASSERT_EXCLUSIVE_ACCESS() macros to allow code using these macros
      to move ahead.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      c76e7e0b
    • Paul E. McKenney's avatar
      rcu: Add KCSAN stubs · 35315936
      Paul E. McKenney authored
      This commit adds stubs for KCSAN's data_race(), ASSERT_EXCLUSIVE_WRITER(),
      and ASSERT_EXCLUSIVE_ACCESS() macros to allow code using these macros to
      move ahead.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      35315936
  2. 19 Apr, 2020 6 commits
    • Linus Torvalds's avatar
      Linux 5.7-rc2 · ae83d0b4
      Linus Torvalds authored
      ae83d0b4
    • Brian Geffon's avatar
      mm: Fix MREMAP_DONTUNMAP accounting on VMA merge · dadbd85f
      Brian Geffon authored
      When remapping a mapping where a portion of a VMA is remapped
      into another portion of the VMA it can cause the VMA to become
      split. During the copy_vma operation the VMA can actually
      be remerged if it's an anonymous VMA whose pages have not yet
      been faulted. This isn't normally a problem because at the end
      of the remap the original portion is unmapped causing it to
      become split again.
      
      However, MREMAP_DONTUNMAP leaves that original portion in place which
      means that the VMA which was split and then remerged is not actually
      split at the end of the mremap. This patch fixes a bug where
      we don't detect that the VMAs got remerged and we end up
      putting back VM_ACCOUNT on the next mapping which is completely
      unreleated. When that next mapping is unmapped it results in
      incorrectly unaccounting for the memory which was never accounted,
      and eventually we will underflow on the memory comittment.
      
      There is also another issue which is similar, we're currently
      accouting for the number of pages in the new_vma but that's wrong.
      We need to account for the length of the remap operation as that's
      all that is being added. If there was a mapping already at that
      location its comittment would have been adjusted as part of
      the munmap at the start of the mremap.
      
      A really simple repro can be seen in:
      https://gist.github.com/bgaff/e101ce99da7d9a8c60acc641d07f312c
      
      Fixes: e346b381 ("mm/mremap: add MREMAP_DONTUNMAP to mremap()")
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarBrian Geffon <bgeffon@google.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      dadbd85f
    • Linus Torvalds's avatar
      Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux · 86cc3398
      Linus Torvalds authored
      Pull clk fixes from Stephen Boyd:
       "Two build fixes for a couple clk drivers and a fix for the Unisoc
        serial clk where we want to keep it on for earlycon"
      
      * tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux:
        clk: sprd: don't gate uart console clock
        clk: mmp2: fix link error without mmp2
        clk: asm9260: fix __clk_hw_register_fixed_rate_with_accuracy typo
      86cc3398
    • Linus Torvalds's avatar
      Merge tag 'x86-urgent-2020-04-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 0fe5f9ca
      Linus Torvalds authored
      Pull x86 and objtool fixes from Thomas Gleixner:
       "A set of fixes for x86 and objtool:
      
        objtool:
      
         - Ignore the double UD2 which is emitted in BUG() when
           CONFIG_UBSAN_TRAP is enabled.
      
         - Support clang non-section symbols in objtool ORC dump
      
         - Fix switch table detection in .text.unlikely
      
         - Make the BP scratch register warning more robust.
      
        x86:
      
         - Increase microcode maximum patch size for AMD to cope with new CPUs
           which have a larger patch size.
      
         - Fix a crash in the resource control filesystem when the removal of
           the default resource group is attempted.
      
         - Preserve Code and Data Prioritization enabled state accross CPU
           hotplug.
      
         - Update split lock cpu matching to use the new X86_MATCH macros.
      
         - Change the split lock enumeration as Intel finaly decided that the
           IA32_CORE_CAPABILITIES bits are not architectural contrary to what
           the SDM claims. !@#%$^!
      
         - Add Tremont CPU models to the split lock detection cpu match.
      
         - Add a missing static attribute to make sparse happy"
      
      * tag 'x86-urgent-2020-04-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/split_lock: Add Tremont family CPU models
        x86/split_lock: Bits in IA32_CORE_CAPABILITIES are not architectural
        x86/resctrl: Preserve CDP enable over CPU hotplug
        x86/resctrl: Fix invalid attempt at removing the default resource group
        x86/split_lock: Update to use X86_MATCH_INTEL_FAM6_MODEL()
        x86/umip: Make umip_insns static
        x86/microcode/AMD: Increase microcode PATCH_MAX_SIZE
        objtool: Make BP scratch register warning more robust
        objtool: Fix switch table detection in .text.unlikely
        objtool: Support Clang non-section symbols in ORC generation
        objtool: Support Clang non-section symbols in ORC dump
        objtool: Fix CONFIG_UBSAN_TRAP unreachable warnings
      0fe5f9ca
    • Linus Torvalds's avatar
      Merge tag 'timers-urgent-2020-04-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 3e0dea57
      Linus Torvalds authored
      Pull time namespace fix from Thomas Gleixner:
       "An update for the proc interface of time namespaces: Use symbolic
        names instead of clockid numbers. The usability nuisance of numbers
        was noticed by Michael when polishing the man page"
      
      * tag 'timers-urgent-2020-04-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        proc, time/namespace: Show clock symbolic names in /proc/pid/timens_offsets
      3e0dea57
    • Linus Torvalds's avatar
      Merge tag 'perf-urgent-2020-04-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · b7374586
      Linus Torvalds authored
      Pull perf tooling fixes and updates from Thomas Gleixner:
      
       - Fix the header line of perf stat output for '--metric-only --per-socket'
      
       - Fix the python build with clang
      
       - The usual tools UAPI header synchronization
      
      * tag 'perf-urgent-2020-04-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        tools headers: Synchronize linux/bits.h with the kernel sources
        tools headers: Adopt verbatim copy of compiletime_assert() from kernel sources
        tools headers: Update x86's syscall_64.tbl with the kernel sources
        tools headers UAPI: Sync drm/i915_drm.h with the kernel sources
        tools headers UAPI: Update tools's copy of drm.h headers
        tools headers kvm: Sync linux/kvm.h with the kernel sources
        tools headers UAPI: Sync linux/fscrypt.h with the kernel sources
        tools include UAPI: Sync linux/vhost.h with the kernel sources
        tools arch x86: Sync asm/cpufeatures.h with the kernel sources
        tools headers UAPI: Sync linux/mman.h with the kernel
        tools headers UAPI: Sync sched.h with the kernel
        tools headers: Update linux/vdso.h and grab a copy of vdso/const.h
        perf stat: Fix no metric header if --per-socket and --metric-only set
        perf python: Check if clang supports -fno-semantic-interposition
        tools arch x86: Sync the msr-index.h copy with the kernel sources
      b7374586