1. 20 Apr, 2022 1 commit
  2. 22 Oct, 2021 1 commit
  3. 07 Oct, 2021 1 commit
  4. 11 Aug, 2021 1 commit
    • Randy Dunlap's avatar
      smp: Fix all kernel-doc warnings · 49b3bd21
      Randy Dunlap authored
      
      Fix the following warnings:
      
      kernel/smp.c:1189: warning: cannot understand function prototype: 'struct smp_call_on_cpu_struct '
      kernel/smp.c:788: warning: No description found for return value of 'smp_call_function_single_async'
      kernel/smp.c:990: warning: Function parameter or member 'wait' not described in 'smp_call_function_many'
      kernel/smp.c:990: warning: Excess function parameter 'flags' description in 'smp_call_function_many'
      kernel/smp.c:1198: warning: Function parameter or member 'work' not described in 'smp_call_on_cpu_struct'
      kernel/smp.c:1198: warning: Function parameter or member 'done' not described in 'smp_call_on_cpu_struct'
      kernel/smp.c:1198: warning: Function parameter or member 'func' not described in 'smp_call_on_cpu_struct'
      kernel/smp.c:1198: warning: Function parameter or member 'data' not described in 'smp_call_on_cpu_struct'
      kernel/smp.c:1198: warning: Function parameter or member 'ret' not described in 'smp_call_on_cpu_struct'
      kernel/smp.c:1198: warning: Function parameter or member 'cpu' not described in 'smp_call_on_cpu_struct'
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Link: https://lore.kernel.org/r/20210810225051.3938-1-rdunlap@infradead.org
      49b3bd21
  5. 06 May, 2021 1 commit
    • Arnd Bergmann's avatar
      smp: Fix smp_call_function_single_async prototype · 1139aeb1
      Arnd Bergmann authored
      As of commit 966a9671 ("smp: Avoid using two cache lines for struct
      call_single_data"), the smp code prefers 32-byte aligned call_single_data
      objects for performance reasons, but the block layer includes an instance
      of this structure in the main 'struct request' that is more senstive
      to size than to performance here, see 4ccafe03
      
       ("block: unalign
      call_single_data in struct request").
      
      The result is a violation of the calling conventions that clang correctly
      points out:
      
      block/blk-mq.c:630:39: warning: passing 8-byte aligned argument to 32-byte aligned parameter 2 of 'smp_call_function_single_async' may result in an unaligned pointer access [-Walign-mismatch]
                      smp_call_function_single_async(cpu, &rq->csd);
      
      It does seem that the usage of the call_single_data without cache line
      alignment should still be allowed by the smp code, so just change the
      function prototype so it accepts both, but leave the default alignment
      unchanged for the other users. This seems better to me than adding
      a local hack to shut up an otherwise correct warning in the caller.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarJens Axboe <axboe@kernel.dk>
      Link: https://lkml.kernel.org/r/20210505211300.3174456-1-arnd@kernel.org
      1139aeb1
  6. 06 Mar, 2021 6 commits
    • Peter Zijlstra's avatar
      smp: Micro-optimize smp_call_function_many_cond() · d43f17a1
      Peter Zijlstra authored
      
      Call the generic send_call_function_single_ipi() function, which
      will avoid the IPI when @last_cpu is idle.
      Signed-off-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      d43f17a1
    • Nadav Amit's avatar
      smp: Inline on_each_cpu_cond() and on_each_cpu() · a5aa5ce3
      Nadav Amit authored
      
      Simplify the code and avoid having an additional function on the stack
      by inlining on_each_cpu_cond() and on_each_cpu().
      Suggested-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarNadav Amit <namit@vmware.com>
      [ Minor edits. ]
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20210220231712.2475218-10-namit@vmware.com
      a5aa5ce3
    • Nadav Amit's avatar
      smp: Run functions concurrently in smp_call_function_many_cond() · a32a4d8a
      Nadav Amit authored
      
      Currently, on_each_cpu() and similar functions do not exploit the
      potential of concurrency: the function is first executed remotely and
      only then it is executed locally. Functions such as TLB flush can take
      considerable time, so this provides an opportunity for performance
      optimization.
      
      To do so, modify smp_call_function_many_cond(), to allows the callers to
      provide a function that should be executed (remotely/locally), and run
      them concurrently. Keep other smp_call_function_many() semantic as it is
      today for backward compatibility: the called function is not executed in
      this case locally.
      
      smp_call_function_many_cond() does not use the optimized version for a
      single remote target that smp_call_function_single() implements. For
      synchronous function call, smp_call_function_single() keeps a
      call_single_data (which is used for synchronization) on the stack.
      Interestingly, it seems that not using this optimization provides
      greater performance improvements (greater speedup with a single remote
      target than with multiple ones). Presumably, holding data structures
      that are intended for synchronization on the stack can introduce
      overheads due to TLB misses and false-sharing when the stack is used for
      other purposes.
      Signed-off-by: default avatarNadav Amit <namit@vmware.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Reviewed-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
      Link: https://lore.kernel.org/r/20210220231712.2475218-2-namit@vmware.com
      a32a4d8a
    • Juergen Gross's avatar
      locking/csd_lock: Add more data to CSD lock debugging · a5aabace
      Juergen Gross authored
      In order to help identifying problems with IPI handling and remote
      function execution add some more data to IPI debugging code.
      
      There have been multiple reports of CPUs looping long times (many
      seconds) in smp_call_function_many() waiting for another CPU executing
      a function like tlb flushing. Most of these reports have been for
      cases where the kernel was running as a guest on top of KVM or Xen
      (there are rumours of that happening under VMWare, too, and even on
      bare metal).
      
      Finding the root cause hasn't been successful yet, even after more than
      2 years of chasing this bug by different developers.
      
      Commit:
      
        35feb604
      
       ("kernel/smp: Provide CSD lock timeout diagnostics")
      
      tried to address this by adding some debug code and by issuing another
      IPI when a hang was detected. This helped mitigating the problem
      (the repeated IPI unlocks the hang), but the root cause is still unknown.
      
      Current available data suggests that either an IPI wasn't sent when it
      should have been, or that the IPI didn't result in the target CPU
      executing the queued function (due to the IPI not reaching the CPU,
      the IPI handler not being called, or the handler not seeing the queued
      request).
      
      Try to add more diagnostic data by introducing a global atomic counter
      which is being incremented when doing critical operations (before and
      after queueing a new request, when sending an IPI, and when dequeueing
      a request). The counter value is stored in percpu variables which can
      be printed out when a hang is detected.
      
      The data of the last event (consisting of sequence counter, source
      CPU, target CPU, and event type) is stored in a global variable. When
      a new event is to be traced, the data of the last event is stored in
      the event related percpu location and the global data is updated with
      the new event's data. This allows to track two events in one data
      location: one by the value of the event data (the event before the
      current one), and one by the location itself (the current event).
      
      A typical printout with a detected hang will look like this:
      
      csd: Detected non-responsive CSD lock (#1) on CPU#1, waiting 5000000003 ns for CPU#06 scf_handler_1+0x0/0x50(0xffffa2a881bb1410).
      	csd: CSD lock (#1) handling prior scf_handler_1+0x0/0x50(0xffffa2a8813823c0) request.
              csd: cnt(00008cc): ffff->0000 dequeue (src cpu 0 == empty)
              csd: cnt(00008cd): ffff->0006 idle
              csd: cnt(0003668): 0001->0006 queue
              csd: cnt(0003669): 0001->0006 ipi
              csd: cnt(0003e0f): 0007->000a queue
              csd: cnt(0003e10): 0001->ffff ping
              csd: cnt(0003e71): 0003->0000 ping
              csd: cnt(0003e72): ffff->0006 gotipi
              csd: cnt(0003e73): ffff->0006 handle
              csd: cnt(0003e74): ffff->0006 dequeue (src cpu 0 == empty)
              csd: cnt(0003e7f): 0004->0006 ping
              csd: cnt(0003e80): 0001->ffff pinged
              csd: cnt(0003eb2): 0005->0001 noipi
              csd: cnt(0003eb3): 0001->0006 queue
              csd: cnt(0003eb4): 0001->0006 noipi
              csd: cnt now: 0003f00
      
      The idea is to print only relevant entries. Those are all events which
      are associated with the hang (so sender side events for the source CPU
      of the hanging request, and receiver side events for the target CPU),
      and the related events just before those (for adding data needed to
      identify a possible race). Printing all available data would be
      possible, but this would add large amounts of data printed on larger
      configurations.
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      [ Minor readability edits. Breaks col80 but is far more readable. ]
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Tested-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      Link: https://lore.kernel.org/r/20210301101336.7797-4-jgross@suse.com
      a5aabace
    • Juergen Gross's avatar
      locking/csd_lock: Prepare more CSD lock debugging · de7b09ef
      Juergen Gross authored
      
      In order to be able to easily add more CSD lock debugging data to
      struct call_function_data->csd move the call_single_data_t element
      into a sub-structure.
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20210301101336.7797-3-jgross@suse.com
      de7b09ef
    • Juergen Gross's avatar
      locking/csd_lock: Add boot parameter for controlling CSD lock debugging · 8d0968cc
      Juergen Gross authored
      
      Currently CSD lock debugging can be switched on and off via a kernel
      config option only. Unfortunately there is at least one problem with
      CSD lock handling pending for about 2 years now, which has been seen
      in different environments (mostly when running virtualized under KVM
      or Xen, at least once on bare metal). Multiple attempts to catch this
      issue have finally led to introduction of CSD lock debug code, but
      this code is not in use in most distros as it has some impact on
      performance.
      
      In order to be able to ship kernels with CONFIG_CSD_LOCK_WAIT_DEBUG
      enabled even for production use, add a boot parameter for switching
      the debug functionality on. This will reduce any performance impact
      of the debug coding to a bare minimum when not being used.
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      [ Minor edits. ]
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20210301101336.7797-2-jgross@suse.com
      8d0968cc
  7. 17 Feb, 2021 1 commit
  8. 10 Feb, 2021 1 commit
  9. 24 Nov, 2020 1 commit
  10. 16 Oct, 2020 1 commit
  11. 04 Sep, 2020 3 commits
  12. 22 Jul, 2020 1 commit
  13. 28 Jun, 2020 1 commit
  14. 02 Jun, 2020 1 commit
  15. 28 May, 2020 6 commits
  16. 19 Apr, 2020 1 commit
  17. 25 Mar, 2020 1 commit
  18. 06 Mar, 2020 1 commit
    • Peter Xu's avatar
      smp: Allow smp_call_function_single_async() to insert locked csd · 5a18ceca
      Peter Xu authored
      
      Previously we will raise an warning if we want to insert a csd object
      which is with the LOCK flag set, and if it happens we'll also wait for
      the lock to be released.  However, this operation does not match
      perfectly with how the function is named - the name with "_async"
      suffix hints that this function should not block, while we will.
      
      This patch changed this behavior by simply return -EBUSY instead of
      waiting, at the meantime we allow this operation to happen without
      warning the user to change this into a feature when the caller wants
      to "insert a csd object, if it's there, just wait for that one".
      
      This is pretty safe because in flush_smp_call_function_queue() for
      async csd objects (where csd->flags&SYNC is zero) we'll first do the
      unlock then we call the csd->func().  So if we see the csd->flags&LOCK
      is true in smp_call_function_single_async(), then it's guaranteed that
      csd->func() will be called after this smp_call_function_single_async()
      returns -EBUSY.
      
      Update the comment of the function too to refect this.
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lkml.kernel.org/r/20191216213125.9536-2-peterx@redhat.com
      5a18ceca
  19. 28 Jan, 2020 1 commit
  20. 24 Jan, 2020 3 commits
  21. 20 Jul, 2019 1 commit
  22. 23 Jun, 2019 2 commits
  23. 21 May, 2019 1 commit
  24. 30 Jan, 2019 1 commit
    • Josh Poimboeuf's avatar
      cpu/hotplug: Fix "SMT disabled by BIOS" detection for KVM · b284909a
      Josh Poimboeuf authored
      With the following commit:
      
        73d5e2b4 ("cpu/hotplug: detect SMT disabled by BIOS")
      
      ... the hotplug code attempted to detect when SMT was disabled by BIOS,
      in which case it reported SMT as permanently disabled.  However, that
      code broke a virt hotplug scenario, where the guest is booted with only
      primary CPU threads, and a sibling is brought online later.
      
      The problem is that there doesn't seem to be a way to reliably
      distinguish between the HW "SMT disabled by BIOS" case and the virt
      "sibling not yet brought online" case.  So the above-mentioned commit
      was a bit misguided, as it permanently disabled SMT for both cases,
      preventing future virt sibling hotplugs.
      
      Going back and reviewing the original problems which were attempted to
      be solved by that commit, when SMT was disabled in BIOS:
      
        1) /sys/devices/system/cpu/smt/control showed "on" instead of
           "notsupported"; and
      
        2) vmx_vm_init() was incorrectly showing the L1TF_MSG_SMT warning.
      
      I'd propose that we instead consider #1 above to not actually be a
      problem.  Because, at least in the virt case, it's possible that SMT
      wasn't disabled by BIOS and a sibling thread could be brought online
      later.  So it makes sense to just always default the smt control to "on"
      to allow for that possibility (assuming cpuid indicates that the CPU
      supports SMT).
      
      The real problem is #2, which has a simple fix: change vmx_vm_init() to
      query the actual current SMT state -- i.e., whether any siblings are
      currently online -- instead of looking at the SMT "control" sysfs value.
      
      So fix it by:
      
        a) reverting the original "fix" and its followup fix:
      
           73d5e2b4 ("cpu/hotplug: detect SMT disabled by BIOS")
           bc2d8d26 ("cpu/hotplug: Fix SMT supported evaluation")
      
           and
      
        b) changing vmx_vm_init() to query the actual current SMT state --
           instead of the sysfs control value -- to determine whether the L1TF
           warning is needed.  This also requires the 'sched_smt_present'
           variable to exported, instead of 'cpu_smt_control'.
      
      Fixes: 73d5e2b4
      
       ("cpu/hotplug: detect SMT disabled by BIOS")
      Reported-by: default avatarIgor Mammedov <imammedo@redhat.com>
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Joe Mario <jmario@redhat.com>
      Cc: Jiri Kosina <jikos@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: kvm@vger.kernel.org
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/e3a85d585da28cc333ecbc1e78ee9216e6da9396.1548794349.git.jpoimboe@redhat.com
      b284909a
  25. 09 Oct, 2018 1 commit