hi, Paul,

On Wed, Sep 25, 2024 at 01:57:45AM -0700, Paul E. McKenney wrote:
> > 
> > If you fix the issue in a separate patch/commit (i.e. not just a new 
> > version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <[email protected]>
> > | Closes: https://lore.kernel.org/oe-lkp/[email protected]
> > 
> > 
> > [  169.560380][   T76] BUG: using __this_cpu_read() in preemptible 
> > [00000000] code: kworker/1:2/76
> > [ 169.561229][ T76] caller is try_check_zero (kernel/rcu/srcutree.c:485 
> > kernel/rcu/srcutree.c:1149) 
> 
> Does this diff fix things for you?  Here the per-CPU access is a
> heuristic that reduces overhead once the bulk of the CPUs have done
> srcu_read_lock_lite().  So it is OK to get migrated just after the check.

yes, this patch fixed the random failures in our tests.
Tested-by: kernel test robot <[email protected]>

we applied patch upon 26cb612c43 and run the same tests up to 200 times,
didn't observe the issue. thanks!

=========================================================================================
compiler/kconfig/rootfs/runtime/tbox_group/test/testcase/torture_type:
  
gcc-12/x86_64-randconfig-006-20240921/debian-12-x86_64-20240206.cgz/300s/vm-snb/cpuhotplug/rcutorture/srcud

commit:
  daf812f27d6bb ("srcu: Standardize srcu_data pointers to "sdp" and similar")
  26cb612c431de ("srcu: Add srcu_read_lock_lite() and srcu_read_unlock_lite()")
  f2f1565029268  <--- your patch

daf812f27d6bbe4c 26cb612c431de5093ae6a3a67ec f2f1565029268e27760307bc82b
---------------- --------------------------- ---------------------------
       fail:runs  %reproduction    fail:runs  %reproduction    fail:runs
           |             |             |             |             |
           :50          66%          33:50           0%            :200   
dmesg.BUG:using__this_cpu_read()in_preemptible


> 
>                                                       Thanx, Paul
> 
> ------------------------------------------------------------------------
> 
> diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
> index f3db4d42e70ab..07147efcb64d3 100644
> --- a/kernel/rcu/srcutree.c
> +++ b/kernel/rcu/srcutree.c
> @@ -482,7 +482,7 @@ static unsigned long srcu_readers_unlock_idx(struct 
> srcu_struct *ssp, int idx)
>   */
>  static bool srcu_readers_active_idx_check(struct srcu_struct *ssp, int idx)
>  {
> -     bool did_gp = !!(__this_cpu_read(ssp->sda->srcu_reader_flavor) & 
> SRCU_READ_FLAVOR_LITE);
> +     bool did_gp = !!(raw_cpu_read(ssp->sda->srcu_reader_flavor) & 
> SRCU_READ_FLAVOR_LITE);
>       unsigned long unlocks;
>  
>       unlocks = srcu_readers_unlock_idx(ssp, idx);
> 
> ------------------------------------------------------------------------

Reply via email to