1. Apr 12, 2022
    • Paul E. McKenney's avatar
      srcu: Add boot-time control over srcu_node array allocation · c69a00a1
      Paul E. McKenney authored
      
      
      This commit adds an srcu_tree.convert_to_big kernel parameter that either
      refuses to convert at all (0), converts immediately at init_srcu_struct()
      time (1), or lets rcutorture convert it (2).  An addition contention-based
      dynamic conversion choice will be added, along with documentation.
      
      [ paulmck: Apply callback-scanning feedback from Neeraj Upadhyay. ]
      
      Co-developed-by: default avatarNeeraj Upadhyay <quic_neeraju@quicinc.com>
      Signed-off-by: default avatarNeeraj Upadhyay <quic_neeraju@quicinc.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      c69a00a1
    • Neeraj Upadhyay's avatar
      srcu: Ensure snp nodes tree is fully initialized before traversal · 0b56f953
      Neeraj Upadhyay authored
      
      
      For configurations where snp node tree is not initialized at
      init time (added in subsequent commits), srcu_funnel_gp_start()
      and srcu_funnel_exp_start() can potential traverse and observe
      the snp nodes' transient (uninitialized) states. This can potentially
      happen, when init_srcu_struct_nodes() initialization of sdp->mynode
      races with srcu_funnel_gp_start() and srcu_funnel_exp_start()
      
      Consider the case below where srcu_funnel_gp_start() observes
      sdp->mynode to be not NULL and uses an uninitialized sdp->grpmask
      
                P1                                  P2
      
      init_srcu_struct_nodes()           void srcu_funnel_gp_start(...)
      {
      for_each_possible_cpu(cpu) {
        ...
        sdp->mynode = &snp_first[...];
        for (snp = sdp->mynode;...)       struct srcu_node *snp_leaf =
                                             smp_load_acquire(&sdp->mynode)
          ...                             if (snp_leaf) {
                                            for (snp = snp_leaf; ...)
                                              ...
      					if (snp == snp_leaf)
                                               snp->srcu_data_have_cbs[idx] |=
                                                 sdp->grpmask;
          sdp->grpmask =
            1 << (cpu - sdp->mynode->grplo);
        }
      }
      
      Similarly, init_srcu_struct_nodes() and srcu_funnel_exp_start() can
      race, where srcu_funnel_exp_start() could observe state of snp lock
      before spin_lock_init().
      
                P1                                      P2
      
      init_srcu_struct_nodes()               void srcu_funnel_exp_start(...)
      {
        srcu_for_each_node_breadth_first(ssp, snp) {      for (; ...) {
                                                            spin_lock_...(snp, )
      	spin_lock_init(&ACCESS_PRIVATE(snp, lock));
          ...
        }
        for_each_possible_cpu(cpu) {
          ...
          sdp->mynode = &snp_first[...];
      
      To avoid these issues, ensure that snp node tree initialization is
      complete i.e. after SRCU_SIZE_WAIT_BARRIER srcu_size_state is reached,
      before traversing the tree. Given that srcu_funnel_gp_start() and
      srcu_funnel_exp_start() are called within SRCU read side critical
      sections, this check is safe, in the sense that all callbacks are
      enqueued on CPU0 srcu_cblist until SRCU_SIZE_WAIT_CALL is entered,
      and these read side critical sections (containing srcu_funnel_gp_start()
      and srcu_funnel_exp_start()) need to complete, before SRCU_SIZE_WAIT_CALL
      is reached.
      
      Signed-off-by: default avatarNeeraj Upadhyay <quic_neeraju@quicinc.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      0b56f953
    • Paul E. McKenney's avatar
      srcu: Use invalid initial value for srcu_node GP sequence numbers · cbdc98e9
      Paul E. McKenney authored
      
      
      Currently, tree SRCU relies on the srcu_node structures being initialized
      at the same time that the srcu_struct itself is initialized, and thus
      use the initial grace-period sequence number as the initial value for
      the srcu_node structure's ->srcu_have_cbs[] and ->srcu_gp_seq_needed_exp
      fields.  Although this has a high probability of also working when the
      srcu_node array is allocated and initialized at some random later time,
      it would be better to avoid leaving such things to chance.
      
      This commit therefore initializes these fields with 0x2, which is a
      recognizable invalid value.  It then adds the required checks for this
      invalid value in order to avoid confusion on long-running kernels
      (especially those on 32-bit systems) that allocate and initialize
      srcu_node arrays late in life.
      
      Co-developed-by: default avatarNeeraj Upadhyay <quic_neeraju@quicinc.com>
      Signed-off-by: default avatarNeeraj Upadhyay <quic_neeraju@quicinc.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      cbdc98e9
    • Paul E. McKenney's avatar
      srcu: Compute snp_seq earlier in srcu_funnel_gp_start() · aeb9b39b
      Paul E. McKenney authored
      
      
      Currently, srcu_funnel_gp_start() tests snp->srcu_have_cbs[idx] and then
      separately assigns it to the snp_seq local variable.  This commit does
      the assignment earlier to simplify the code a bit.  While in the area,
      this commit also takes advantage of the 100-character line limit to put
      the call to srcu_schedule_cbs_sdp() on a single line.
      
      Co-developed-by: default avatarNeeraj Upadhyay <quic_neeraju@quicinc.com>
      Signed-off-by: default avatarNeeraj Upadhyay <quic_neeraju@quicinc.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      aeb9b39b
    • Paul E. McKenney's avatar
      srcu: Make rcutorture dump the SRCU size state · 3bedebcf
      Paul E. McKenney authored
      
      
      This commit adds the numeric and string version of ->srcu_size_state to
      the Tree-SRCU-specific portion of the rcutorture output.
      
      [ paulmck: Apply feedback from kernel test robot and Dan Carpenter. ]
      [ quic_neeraju: Apply feedback from Jiapeng Chong. ]
      
      Co-developed-by: default avatarNeeraj Upadhyay <quic_neeraju@quicinc.com>
      Signed-off-by: default avatarNeeraj Upadhyay <quic_neeraju@quicinc.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      3bedebcf
    • Paul E. McKenney's avatar
      srcu: Add size-state transitioning code · e2f63836
      Paul E. McKenney authored
      
      
      This is just dead code at the moment, and will be used once
      the state-transition code is activated.
      
      Because srcu_barrier() must be aware of transition before call_srcu(), the
      state machine waits for an SRCU grace period before callbacks are queued
      to the non-CPU-0 queues.  This requres that portions of srcu_barrier()
      be enclosed in an SRCU read-side critical section.
      
      Co-developed-by: default avatarNeeraj Upadhyay <quic_neeraju@quicinc.com>
      Signed-off-by: default avatarNeeraj Upadhyay <quic_neeraju@quicinc.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      e2f63836
    • Paul E. McKenney's avatar
      srcu: Dynamically allocate srcu_node array · 2ec30311
      Paul E. McKenney authored
      
      
      This commit shrinks the srcu_struct structure by converting its ->node
      field from a fixed-size compile-time array to a pointer to a dynamically
      allocated array.  In kernels built with large values of NR_CPUS that boot
      on systems with smaller numbers of CPUs, this can save significant memory.
      
      [ paulmck: Apply kernel test robot feedback. ]
      
      Reported-by: A cast of thousands
      Co-developed-by: default avatarNeeraj Upadhyay <quic_neeraju@quicinc.com>
      Signed-off-by: default avatarNeeraj Upadhyay <quic_neeraju@quicinc.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      2ec30311
    • Paul E. McKenney's avatar
      srcu: Make Tree SRCU able to operate without snp_node array · 994f7068
      Paul E. McKenney authored
      
      
      This commit makes Tree SRCU able to operate without an snp_node
      array, that is, when the srcu_data structures' ->mynode pointers
      are NULL.  This can result in high contention on the srcu_struct
      structure's ->lock, but only when there are lots of call_srcu(),
      synchronize_srcu(), and synchronize_srcu_expedited() calls.
      
      Note that when there is no snp_node array, all SRCU callbacks use
      CPU 0's callback queue.  This is optimal in the common case of low
      update-side load because it removes the need to search each CPU
      for the single callback that made the grace period happen.
      
      Co-developed-by: default avatarNeeraj Upadhyay <quic_neeraju@quicinc.com>
      Signed-off-by: default avatarNeeraj Upadhyay <quic_neeraju@quicinc.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      994f7068
    • Paul E. McKenney's avatar
      srcu: Make srcu_funnel_gp_start() cache ->mynode in snp_leaf · 7b9e9b58
      Paul E. McKenney authored
      
      
      Currently, the srcu_funnel_gp_start() walks its local variable snp up the
      tree and reloads sdp->mynode whenever it is necessary to check whether
      it is still at the leaf srcu_node level.  This works, but is a bit more
      obtuse than absolutely necessary.  In addition, upcoming commits will
      dynamically size srcu_struct structures, in which case sdp->mynode will
      no longer necessarily be a constant, and this commit helps prepare for
      that dynamic sizing.
      
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      7b9e9b58
    • Paul E. McKenney's avatar
      srcu: Fix s/is/if/ typo in srcu_node comment · 95ebe80d
      Paul E. McKenney authored
      
      
      This commit fixed a typo in the srcu_node structure's ->srcu_have_cbs
      comment.  While in the area, redo a couple of comments to take advantage
      of 100-character line lengths.
      
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      95ebe80d
    • Paul E. McKenney's avatar
      srcu: Tighten cleanup_srcu_struct() GP checks · 8ed00760
      Paul E. McKenney authored
      
      
      Currently, cleanup_srcu_struct() checks for a grace period in progress,
      but it does not check for a grace period that has not yet started but
      which might start at any time.  Such a situation could result in a
      use-after-free bug, so this commit adds a check for a grace period that
      is needed but not yet started to cleanup_srcu_struct().
      
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      8ed00760
  2. Apr 04, 2022
    • Linus Torvalds's avatar
      Linux 5.18-rc1 · 31231092
      Linus Torvalds authored
      31231092
    • Linus Torvalds's avatar
      Merge tag 'trace-v5.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace · 09bb8856
      Linus Torvalds authored
      Pull more tracing updates from Steven Rostedt:
      
       - Rename the staging files to give them some meaning. Just
         stage1,stag2,etc, does not show what they are for
      
       - Check for NULL from allocation in bootconfig
      
       - Hold event mutex for dyn_event call in user events
      
       - Mark user events to broken (to work on the API)
      
       - Remove eBPF updates from user events
      
       - Remove user events from uapi header to keep it from being installed.
      
       - Move ftrace_graph_is_dead() into inline as it is called from hot
         paths and also convert it into a static branch.
      
      * tag 'trace-v5.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
        tracing: Move user_events.h temporarily out of include/uapi
        ftrace: Make ftrace_graph_is_dead() a static branch
        tracing: Set user_events to BROKEN
        tracing/user_events: Remove eBPF interfaces
        tracing/user_events: Hold event_mutex during dyn_event_add
        proc: bootconfig: Add null pointer check
        tracing: Rename the staging files for trace_events
      09bb8856
    • Linus Torvalds's avatar
      Merge tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux · 34a53ff9
      Linus Torvalds authored
      Pull clk fix from Stephen Boyd:
       "A single revert to fix a boot regression seen when clk_put() started
        dropping rate range requests. It's best to keep various systems
        booting so we'll kick this out and try again next time"
      
      * tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux:
        Revert "clk: Drop the rate range on clk_put()"
      34a53ff9
    • Linus Torvalds's avatar
      Merge tag 'x86-urgent-2022-04-03' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 8b5656bc
      Linus Torvalds authored
      Pull x86 fixes from Thomas Gleixner:
       "A set of x86 fixes and updates:
      
         - Make the prctl() for enabling dynamic XSTATE components correct so
           it adds the newly requested feature to the permission bitmap
           instead of overwriting it. Add a selftest which validates that.
      
         - Unroll string MMIO for encrypted SEV guests as the hypervisor
           cannot emulate it.
      
         - Handle supervisor states correctly in the FPU/XSTATE code so it
           takes the feature set of the fpstate buffer into account. The
           feature sets can differ between host and guest buffers. Guest
           buffers do not contain supervisor states. So far this was not an
           issue, but with enabling PASID it needs to be handled in the buffer
           offset calculation and in the permission bitmaps.
      
         - Avoid a gazillion of repeated CPUID invocations in by caching the
           values early in the FPU/XSTATE code.
      
         - Enable CONFIG_WERROR in x86 defconfig.
      
         - Make the X86 defconfigs more useful by adapting them to Y2022
           reality"
      
      * tag 'x86-urgent-2022-04-03' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/fpu/xstate: Consolidate size calculations
        x86/fpu/xstate: Handle supervisor states in XSTATE permissions
        x86/fpu/xsave: Handle compacted offsets correctly with supervisor states
        x86/fpu: Cache xfeature flags from CPUID
        x86/fpu/xsave: Initialize offset/size cache early
        x86/fpu: Remove unused supervisor only offsets
        x86/fpu: Remove redundant XCOMP_BV initialization
        x86/sev: Unroll string mmio with CC_ATTR_GUEST_UNROLL_STRING_IO
        x86/config: Make the x86 defconfigs a bit more usable
        x86/defconfig: Enable WERROR
        selftests/x86/amx: Update the ARCH_REQ_XCOMP_PERM test
        x86/fpu/xstate: Fix the ARCH_REQ_XCOMP_PERM implementation
      8b5656bc
    • Linus Torvalds's avatar
      Merge tag 'core-urgent-2022-04-03' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · e235f419
      Linus Torvalds authored
      Pull RT signal fix from Thomas Gleixner:
       "Revert the RT related signal changes. They need to be reworked and
        generalized"
      
      * tag 'core-urgent-2022-04-03' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        Revert "signal, x86: Delay calling signals in atomic on RT enabled kernels"
      e235f419
    • Linus Torvalds's avatar
      Merge tag 'dma-mapping-5.18-1' of git://git.infradead.org/users/hch/dma-mapping · 63d12cc3
      Linus Torvalds authored
      Pull more dma-mapping updates from Christoph Hellwig:
      
       - fix a regression in dma remap handling vs AMD memory encryption (me)
      
       - finally kill off the legacy PCI DMA API (Christophe JAILLET)
      
      * tag 'dma-mapping-5.18-1' of git://git.infradead.org/users/hch/dma-mapping:
        dma-mapping: move pgprot_decrypted out of dma_pgprot
        PCI/doc: cleanup references to the legacy PCI DMA API
        PCI: Remove the deprecated "pci-dma-compat.h" API
      63d12cc3
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm · 5dee8721
      Linus Torvalds authored
      Pull ARM fixes from Russell King:
      
       - avoid unnecessary rebuilds for library objects
      
       - fix return value of __setup handlers
      
       - fix invalid input check for "crashkernel=" kernel option
      
       - silence KASAN warnings in unwind_frame
      
      * tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm:
        ARM: 9191/1: arm/stacktrace, kasan: Silence KASAN warnings in unwind_frame()
        ARM: 9190/1: kdump: add invalid input check for 'crashkernel=0'
        ARM: 9187/1: JIVE: fix return value of __setup handler
        ARM: 9189/1: decompressor: fix unneeded rebuilds of library objects
      5dee8721
  3. Apr 03, 2022
  4. Apr 02, 2022