Re: [PATCH v2] rcu/kfree: Do not request RCU when not needed

From: Uladzislau Rezki
Date: Wed Nov 16 2022 - 14:19:53 EST


Hello, Paul, Joel.

> >
> > Yes sure, I am doing a run now with my patch. However, I have a
> > question -- why do you feel blocking in the kworker is not an issue?
> > You are taking a snapshot before queuing the normal kwork and then
> > reading the snapshot when the normal kwork runs. Considering it is a
> > high priority queue, the delay between when you are taking the
> > snapshot, and reading it is likely small so there is a bigger chance
> > of blocking in cond_synchronize_rcu(). Did I miss something?
> >
> We can wait indeed in the reclaim worker. But the worker does not do any
> nasty or extra work here. If there is a need we block and wait. After a
> grace period, we are awoken and proceed.
>
> Therefore i do not see the reason in handling two cases:
>
> if (gp_done)
> queue_work();
> else
> queue_rcu_work();
>
> it is the same if we just queue the work and check on entry. The current
> scenario is: queue the work after a grace period. This is the difference.
>
> Right if the reclaimer was a high prio kthread a time would be shorter.
>
> In your scenario the time seems even shorter(i have not checked) because
> you update a snapshot of krcp each time a kvfree_rcu() is invoked. So
> basically even though you have objects whose grace period is passed you
> do not separate it anyhow. Because you update the:
>
> krcp->gp_snap = get_state_synchronize_rcu();
>
> too often.
>
Once upon a time we discussed that it is worth to keep track of GP
per-a-page in order to reduce a memory footprint. Below patch addresses
it:

<snip>