Re: [PATCH] arm: smp: Avoid false positive CPU hotplug Lockdep-RCU splat

2024-03-08 Thread Stefan Wiehler
> I agree with the problem but disagree with the patch because it feels like a > terrible workaround. > > Can we just use arch_spin_lock() for the cpu_asid_lock? This might require > acquiring the raw_lock within the raw_spinlock_t, but there is precedent: > > arch/powerpc/kvm/book3s_hv_rm_mmu.c:

[PATCH 5/5] KVM: VMX: Always honor guest PAT on CPUs that support self-snoop

2024-03-08 Thread Sean Christopherson
Unconditionally honor guest PAT on CPUs that support self-snoop, as Intel has confirmed that CPUs that support self-snoop always snoop caches and store buffers. I.e. CPUs with self-snoop maintain cache coherency even in the presence of aliased memtypes, thus there is no need to trust the guest beh

[PATCH 4/5] KVM: x86: Ensure a full memory barrier is emitted in the VM-Exit path

2024-03-08 Thread Sean Christopherson
From: Yan Zhao Ensure a full memory barrier is emitted in the VM-Exit path, as a full barrier is required on Intel CPUs to evict WC buffers. This will allow unconditionally honoring guest PAT on Intel CPUs that support self-snoop. As srcu_read_lock() is always called in the VM-Exit path and it

[PATCH 3/5] srcu: Add an API for a memory barrier after SRCU read lock

2024-03-08 Thread Sean Christopherson
From: Yan Zhao To avoid redundant memory barriers, add smp_mb__after_srcu_read_lock() to pair with smp_mb__after_srcu_read_unlock() for use in paths that need to emit a memory barrier, but already do srcu_read_lock(), which includes a full memory barrier. Provide an API, e.g. as opposed to havin

[PATCH 2/5] KVM: VMX: Drop support for forcing UC memory when guest CR0.CD=1

2024-03-08 Thread Sean Christopherson
Drop KVM's emulation of CR0.CD=1 on Intel CPUs now that KVM no longer honors guest MTRR memtypes, as forcing UC memory for VMs with non-coherent DMA only makes sense if the guest is using something other than PAT to configure the memtype for the DMA region. Furthermore, KVM has forced WB memory fo

[PATCH 1/5] KVM: x86: Remove VMX support for virtualizing guest MTRR memtypes

2024-03-08 Thread Sean Christopherson
Remove KVM's support for virtualizing guest MTRR memtypes, as full MTRR adds no value, negatively impacts guest performance, and is a maintenance burden due to it's complexity and oddities. KVM's approach to virtualizating MTRRs make no sense, at all. KVM *only* honors guest MTRR memtypes if EPT

[PATCH 0/5] KVM: VMX: Drop MTRR virtualization, honor guest PAT

2024-03-08 Thread Sean Christopherson
First, rip out KVM's support for virtualizing guest MTRRs on VMX. The code is costly to main, a drag on guest boot performance, imperfect, and not required for functional correctness with modern guest kernels. Many details in patch 1's changelog. With MTRR virtualization gone, always honor guest

Re: [PATCH] [RFC] rcu/tree: Reduce wake up for synchronize_rcu() common case

2024-03-08 Thread Joel Fernandes
On 3/8/2024 4:52 PM, Paul E. McKenney wrote: > On Fri, Mar 08, 2024 at 06:38:37PM +0100, Uladzislau Rezki wrote: >> On Fri, Mar 08, 2024 at 04:05:15PM +0100, Uladzislau Rezki wrote: >>> On Thu, Mar 07, 2024 at 04:06:06PM -0800, Paul E. McKenney wrote: On Thu, Mar 07, 2024 at 06:52:14PM -050

[PATCH v2 rcu/dev 2/2] rcu/tree: Add comments explaining now-offline-CPU QS reports

2024-03-08 Thread Joel Fernandes (Google)
This a confusing piece of code (rightfully so as the issue it deals with is complex). Recent discussions brought up a question -- what prevents the rcu_implicit_dyntick_qs() from warning about QS reports for offline CPUs. QS reporting for now-offline CPUs should only happen from: - gp_init() - rcu

[PATCH v2 rcu/dev 1/2] rcu/tree: Reduce wake up for synchronize_rcu() common case

2024-03-08 Thread Joel Fernandes (Google)
In the synchronize_rcu() common case, we will have less than SR_MAX_USERS_WAKE_FROM_GP number of users per GP. Waking up the kworker is pointless just to free the last injected wait head since at that point, all the users have already been awakened. Introduce a new counter to track this and preven

Re: [PATCH RFC rcu] Inform KCSAN of one-byte cmpxchg() in rcu_trc_cmpxchg_need_qs()

2024-03-08 Thread Paul E. McKenney
On Fri, Mar 08, 2024 at 11:02:28PM +0100, Marco Elver wrote: > On Fri, 8 Mar 2024 at 22:41, Paul E. McKenney wrote: > > > > Tasks Trace RCU needs a single-byte cmpxchg(), but no such thing exists. > > Because not all architectures support 1-byte cmpxchg? > What prevents us from implementing it?

Re: [PATCH] [RFC] rcu/tree: Reduce wake up for synchronize_rcu() common case

2024-03-08 Thread Frederic Weisbecker
Le Thu, Mar 07, 2024 at 06:48:51PM -0500, Joel Fernandes (Google) a écrit : > In the synchronize_rcu() common case, we will have less than > SR_MAX_USERS_WAKE_FROM_GP number of users per GP. Waking up the kworker > is pointless just to free the last injected wait head since at that point, > all the

Re: [PATCH RFC rcu] Inform KCSAN of one-byte cmpxchg() in rcu_trc_cmpxchg_need_qs()

2024-03-08 Thread Marco Elver
On Fri, 8 Mar 2024 at 22:41, Paul E. McKenney wrote: > > Tasks Trace RCU needs a single-byte cmpxchg(), but no such thing exists. Because not all architectures support 1-byte cmpxchg? What prevents us from implementing it? > Therefore, rcu_trc_cmpxchg_need_qs() emulates one using field substitut

Re: [PATCH] [RFC] rcu/tree: Reduce wake up for synchronize_rcu() common case

2024-03-08 Thread Paul E. McKenney
On Fri, Mar 08, 2024 at 06:38:37PM +0100, Uladzislau Rezki wrote: > On Fri, Mar 08, 2024 at 04:05:15PM +0100, Uladzislau Rezki wrote: > > On Thu, Mar 07, 2024 at 04:06:06PM -0800, Paul E. McKenney wrote: > > > On Thu, Mar 07, 2024 at 06:52:14PM -0500, Joel Fernandes wrote: > > > > On Thu, Mar 7, 20

Re: [PATCH v6 0/6] Reduce synchronize_rcu() latency(v6)

2024-03-08 Thread Paul E. McKenney
On Fri, Mar 08, 2024 at 06:34:03PM +0100, Uladzislau Rezki (Sony) wrote: > This is v6. It is based on the Paul's "dev" branch: > > HEAD: f1bfe538c7970283040a7188a291aca9f18f0c42 > > please note, that patches should be applied from scratch, > i.e. the v5 has to be dropped from the "dev". > > v5 -

[PATCH RFC rcu] Inform KCSAN of one-byte cmpxchg() in rcu_trc_cmpxchg_need_qs()

2024-03-08 Thread Paul E. McKenney
Tasks Trace RCU needs a single-byte cmpxchg(), but no such thing exists. Therefore, rcu_trc_cmpxchg_need_qs() emulates one using field substitution and a four-byte cmpxchg(), such that the other three bytes are always atomically updated to their old values. This works, but results in false-positiv

Re: [PATCH] [RFC] rcu/tree: Reduce wake up for synchronize_rcu() common case

2024-03-08 Thread Uladzislau Rezki
On Fri, Mar 08, 2024 at 04:05:15PM +0100, Uladzislau Rezki wrote: > On Thu, Mar 07, 2024 at 04:06:06PM -0800, Paul E. McKenney wrote: > > On Thu, Mar 07, 2024 at 06:52:14PM -0500, Joel Fernandes wrote: > > > On Thu, Mar 7, 2024 at 6:48 PM Joel Fernandes (Google) > > > wrote: > > > > > > > > In the

[PATCH v6 6/6] rcu: Allocate WQ with WQ_MEM_RECLAIM bit set

2024-03-08 Thread Uladzislau Rezki (Sony)
synchronize_rcu() users have to be processed regardless of memory pressure so our private WQ needs to have at least one execution context what WQ_MEM_RECLAIM flag guarantees. Reviewed-by: Joel Fernandes (Google) --- kernel/rcu/tree.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) di

[PATCH v6 5/6] rcu: Do not release a wait-head from a GP kthread

2024-03-08 Thread Uladzislau Rezki (Sony)
Fix a below race by not releasing a wait-head from the GP-kthread as it can lead for reusing it whereas a worker can still access it thus execute newly added callbacks too early. CPU 0 CPU 1 - - // wait_tail == HEAD1 rcu_sr_normal_

[PATCH v6 4/6] rcu: Support direct wake-up of synchronize_rcu() users

2024-03-08 Thread Uladzislau Rezki (Sony)
This patch introduces a small enhancement which allows to do a direct wake-up of synchronize_rcu() callers. It occurs after a completion of grace period, thus by the gp-kthread. Number of clients is limited by the hard-coded maximum allowed threshold. The remaining part, if still exists is deferre

[PATCH v6 2/6] rcu: Reduce synchronize_rcu() latency

2024-03-08 Thread Uladzislau Rezki (Sony)
A call to a synchronize_rcu() can be optimized from a latency point of view. Workloads which depend on this can benefit of it. The delay of wakeme_after_rcu() callback, which unblocks a waiter, depends on several factors: - how fast a process of offloading is started. Combination of: - !CONFI

[PATCH v6 3/6] rcu: Add a trace event for synchronize_rcu_normal()

2024-03-08 Thread Uladzislau Rezki (Sony)
Add an rcu_sr_normal() trace event. It takes three arguments first one is the name of RCU flavour, second one is a user id which triggeres synchronize_rcu_normal() and last one is an event. There are two traces in the synchronize_rcu_normal(). On entry, when a new request is registered and on exit

[PATCH v6 1/6] rcu: Add data structures for synchronize_rcu()

2024-03-08 Thread Uladzislau Rezki (Sony)
The synchronize_rcu() call is going to be reworked, thus this patch adds dedicated fields into the rcu_state structure. Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/tree.h | 14 ++ 1 file changed, 14 insertions(+) diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h index df4

[PATCH v6 0/6] Reduce synchronize_rcu() latency(v6)

2024-03-08 Thread Uladzislau Rezki (Sony)
This is v6. It is based on the Paul's "dev" branch: HEAD: f1bfe538c7970283040a7188a291aca9f18f0c42 please note, that patches should be applied from scratch, i.e. the v5 has to be dropped from the "dev". v5 -> v6: - Fix a race due to realising a wait-head from the gp-kthread; - Use our own priv

[GIT PULL] RCU changes for v6.9

2024-03-08 Thread Boqun Feng
Hi Linus, Please pull this for the RCU changes of v6.9: The following changes since commit 41bccc98fb7931d63d03f326a746ac4d429c1dd3: Linux 6.8-rc2 (2024-01-28 17:01:12 -0800) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/boqun/linux.git tags/rcu.nex

Re: [PATCH] [RFC] rcu/tree: Reduce wake up for synchronize_rcu() common case

2024-03-08 Thread Uladzislau Rezki
On Thu, Mar 07, 2024 at 04:06:06PM -0800, Paul E. McKenney wrote: > On Thu, Mar 07, 2024 at 06:52:14PM -0500, Joel Fernandes wrote: > > On Thu, Mar 7, 2024 at 6:48 PM Joel Fernandes (Google) > > wrote: > > > > > > In the synchronize_rcu() common case, we will have less than > > > SR_MAX_USERS_WAKE

Re: [PATCH] arm: smp: Avoid false positive CPU hotplug Lockdep-RCU splat

2024-03-08 Thread Joel Fernandes
On 3/7/2024 11:09 AM, Stefan Wiehler wrote: > With CONFIG_PROVE_RCU_LIST=y and by executing > > $ echo 0 > /sys/devices/system/cpu/cpu1/online > > one can trigger the following Lockdep-RCU splat on ARM: > > = > WARNING: suspicious RCU usage > 6.8.0-rc7-

Re: [PATCH] arm: smp: Avoid false positive CPU hotplug Lockdep-RCU splat

2024-03-08 Thread Stefan Wiehler
> I'm not sure this is a false-positive: if you traverse an RCU-list > without RCU watching the CPU, then a grace period may pass, the next > list can be garbage and you can go anywhere from the list. Or am I > missing something that a CPU hotplug can block a grace period? Thanks for the feedback!