[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <453bcbbd-94f4-46da-98f6-c9fa5f931231@paulmck-laptop>
Date: Fri, 14 Jul 2023 11:44:06 -0700
From: "Paul E. McKenney" <paulmck@...nel.org>
To: Alan Huang <mmpgouride@...il.com>
Cc: Joel Fernandes <joel@...lfernandes.org>,
Gao Xiang <hsiangkao@...ux.alibaba.com>,
Sandeep Dhavale <dhavale@...gle.com>,
Frederic Weisbecker <frederic@...nel.org>,
Neeraj Upadhyay <quic_neeraju@...cinc.com>,
Josh Triplett <josh@...htriplett.org>,
Boqun Feng <boqun.feng@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Lai Jiangshan <jiangshanlai@...il.com>,
Zqiang <qiang.zhang1211@...il.com>,
Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>,
linux-erofs@...ts.ozlabs.org, xiang@...nel.org,
Will Shiu <Will.Shiu@...iatek.com>, kernel-team@...roid.com,
rcu@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org
Subject: Re: [PATCH v1] rcu: Fix and improve RCU read lock checks when
!CONFIG_DEBUG_LOCK_ALLOC
On Sat, Jul 15, 2023 at 02:40:08AM +0800, Alan Huang wrote:
> > 2023年7月15日 01:02,Paul E. McKenney <paulmck@...nel.org> 写道:
> > On Fri, Jul 14, 2023 at 11:54:47PM +0800, Alan Huang wrote:
> >>> 2023年7月14日 23:35,Alan Huang <mmpgouride@...il.com> 写道:
> >>>> 2023年7月14日 10:16,Paul E. McKenney <paulmck@...nel.org> 写道:
[ . . . ]
> >>>>> How can this be solved?
> >>>>>
> >>>>> 1. Always use a workqueue. Simple, but is said to have performance
> >>>>> issues.
> >>>>>
> >>>>> 2. Pass a flag in that indicates whether or not the caller is in an
> >>>>> RCU read-side critical section. Conceptually simple, but might
> >>>>> or might not be reasonable to actually implement in the code as
> >>>>> it exists now. (You tell me!)
> >>>>>
> >>>>> 3. Create a function in z_erofs that gives you a decent
> >>>>> approximation, maybe something like the following.
> >>>>>
> >>>>> 4. Other ideas here.
> >>>>
> >>>> 5. #3 plus make the corresponding Kconfig option select
> >>>> PREEMPT_COUNT, assuming that any users needing compression in
> >>>> non-preemptible kernels are OK with PREEMPT_COUNT being set.
> >>>> (Some users of non-preemptible kernels object strenuously
> >>>> to the added overhead from CONFIG_PREEMPT_COUNT=y.)
> >>>
> >>> 6. Set one bit in bio->bi_private, check the bit and flip it in rcu_read_lock() path,
> >>> then in z_erofs_decompressqueue_endio, check if the bit has changed.
> >>
> >> Seems bad, read and modify bi_private is a bad idea.
> >
> > Is there some other field that would work?
>
> Maybe bio->bi_opf, btrfs uses some bits of it.
Sandeep, thoughts?
Thanx, Paul
> >>> Not sure if this is feasible or acceptable. :)
> >>>
> >>>>
> >>>> Thanx, Paul
> >>>>
> >>>>> The following is untested, and is probably quite buggy, but it should
> >>>>> provide you with a starting point.
> >>>>>
> >>>>> static bool z_erofs_wq_needed(void)
> >>>>> {
> >>>>> if (IS_ENABLED(CONFIG_PREEMPTION) && rcu_preempt_depth())
> >>>>> return true; // RCU reader
> >>>>> if (IS_ENABLED(CONFIG_PREEMPT_COUNT) && !preemptible())
> >>>>> return true; // non-preemptible
> >>>>> if (!IS_ENABLED(CONFIG_PREEMPT_COUNT))
> >>>>> return true; // non-preeemptible kernel, so play it safe
> >>>>> return false;
> >>>>> }
> >>>>>
> >>>>> You break it, you buy it! ;-)
> >>>>>
> >>>>> Thanx, Paul
>
>
Powered by blists - more mailing lists