<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/kernel/rcu/srcutree.c, branch v6.5.3</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v6.5.3</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v6.5.3'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2023-04-05T13:50:37Z</updated>
<entry>
<title>Merge branches 'rcu/staging-core', 'rcu/staging-docs' and 'rcu/staging-kfree', remote-tracking branches 'paul/srcu-cf.2023.04.04a', 'fbq/rcu/lockdep.2023.03.27a' and 'fbq/rcu/rcutorture.2023.03.20a' into rcu/staging</title>
<updated>2023-04-05T13:50:37Z</updated>
<author>
<name>Joel Fernandes (Google)</name>
<email>joel@joelfernandes.org</email>
</author>
<published>2023-04-05T13:50:37Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=8ae99857748bece993962dd8d04e096f9e76731f'/>
<id>urn:sha1:8ae99857748bece993962dd8d04e096f9e76731f</id>
<content type='text'>
</content>
</entry>
<entry>
<title>srcu: Clarify comments on memory barrier "E"</title>
<updated>2023-04-05T13:47:18Z</updated>
<author>
<name>Joel Fernandes (Google)</name>
<email>joel@joelfernandes.org</email>
</author>
<published>2023-01-28T03:59:01Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=754aa6427efeb8a059233e18e810263a108fdd71'/>
<id>urn:sha1:754aa6427efeb8a059233e18e810263a108fdd71</id>
<content type='text'>
There is an smp_mb() named "E" in srcu_flip() immediately before the
increment (flip) of the srcu_struct structure's -&gt;srcu_idx.

The purpose of E is to order the preceding scan's read of lock counters
against the flipping of the -&gt;srcu_idx, in order to prevent new readers
from continuing to use the old -&gt;srcu_idx value, which might needlessly
extend the grace period.

However, this ordering is already enforced because of the control
dependency between the preceding scan and the -&gt;srcu_idx flip.
This control dependency exists because atomic_long_read() is used
to scan the counts, because WRITE_ONCE() is used to flip -&gt;srcu_idx,
and because -&gt;srcu_idx is not flipped until the -&gt;srcu_lock_count[] and
-&gt;srcu_unlock_count[] counts match.  And such a match cannot happen when
there is an in-flight reader that started before the flip (observation
courtesy Mathieu Desnoyers).

The litmus test below (courtesy of Frederic Weisbecker, with changes
for ctrldep by Boqun and Joel) shows this:

C srcu
(*
 * bad condition: P0's first scan (SCAN1) saw P1's idx=0 LOCK count inc, though P1 saw flip.
 *
 * So basically, the -&gt;po ordering on both P0 and P1 is enforced via -&gt;ppo
 * (control deps) on both sides, and both P0 and P1 are interconnected by -&gt;rf
 * relations. Combining the -&gt;ppo with -&gt;rf, a cycle is impossible.
 *)

{}

// updater
P0(int *IDX, int *LOCK0, int *UNLOCK0, int *LOCK1, int *UNLOCK1)
{
        int lock1;
        int unlock1;
        int lock0;
        int unlock0;

        // SCAN1
        unlock1 = READ_ONCE(*UNLOCK1);
        smp_mb(); // A
        lock1 = READ_ONCE(*LOCK1);

        // FLIP
        if (lock1 == unlock1) {   // Control dep
                smp_mb(); // E    // Remove E and still passes.
                WRITE_ONCE(*IDX, 1);
                smp_mb(); // D

                // SCAN2
                unlock0 = READ_ONCE(*UNLOCK0);
                smp_mb(); // A
                lock0 = READ_ONCE(*LOCK0);
        }
}

// reader
P1(int *IDX, int *LOCK0, int *UNLOCK0, int *LOCK1, int *UNLOCK1)
{
        int tmp;
        int idx1;
        int idx2;

        // 1st reader
        idx1 = READ_ONCE(*IDX);
        if (idx1 == 0) {         // Control dep
                tmp = READ_ONCE(*LOCK0);
                WRITE_ONCE(*LOCK0, tmp + 1);
                smp_mb(); /* B and C */
                tmp = READ_ONCE(*UNLOCK0);
                WRITE_ONCE(*UNLOCK0, tmp + 1);
        } else {
                tmp = READ_ONCE(*LOCK1);
                WRITE_ONCE(*LOCK1, tmp + 1);
                smp_mb(); /* B and C */
                tmp = READ_ONCE(*UNLOCK1);
                WRITE_ONCE(*UNLOCK1, tmp + 1);
        }
}

exists (0:lock1=1 /\ 1:idx1=1)

More complicated litmus tests with multiple SRCU readers also show that
memory barrier E is not needed.

This commit therefore clarifies the comment on memory barrier E.

Why not also remove that redundant smp_mb()?

Because control dependencies are quite fragile due to their not being
recognized by most compilers and tools.  Control dependencies therefore
exact an ongoing maintenance burden, and such a burden cannot be justified
in this slowpath.  Therefore, that smp_mb() stays until such time as
its overhead becomes a measurable problem in a real workload running on
a real production system, or until such time as compilers start paying
attention to this sort of control dependency.

Co-developed-by: Frederic Weisbecker &lt;frederic@kernel.org&gt;
Signed-off-by: Frederic Weisbecker &lt;frederic@kernel.org&gt;
Co-developed-by: Mathieu Desnoyers &lt;mathieu.desnoyers@efficios.com&gt;
Signed-off-by: Mathieu Desnoyers &lt;mathieu.desnoyers@efficios.com&gt;
Co-developed-by: Boqun Feng &lt;boqun.feng@gmail.com&gt;
Signed-off-by: Boqun Feng &lt;boqun.feng@gmail.com&gt;
Reviewed-by: Paul E. McKenney &lt;paulmck@kernel.org&gt;
Signed-off-by: Joel Fernandes (Google) &lt;joel@joelfernandes.org&gt;
</content>
</entry>
<entry>
<title>srcu: Fix long lines in srcu_funnel_gp_start()</title>
<updated>2023-04-04T15:37:08Z</updated>
<author>
<name>Paul E. McKenney</name>
<email>paulmck@kernel.org</email>
</author>
<published>2023-03-18T19:31:53Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=cefc0a599b19d8dd0e26d0b2e43311bae7530ca1'/>
<id>urn:sha1:cefc0a599b19d8dd0e26d0b2e43311bae7530ca1</id>
<content type='text'>
This commit creates an srcu_usage pointer named "sup" as a shorter
synonym for the "ssp-&gt;srcu_sup" that was bloating several lines of code.

Cc: Christoph Hellwig &lt;hch@lst.de&gt;
Tested-by: Sachin Sant &lt;sachinp@linux.ibm.com&gt;
Tested-by: "Zhang, Qiang1" &lt;qiang1.zhang@intel.com&gt;
Tested-by: Joel Fernandes (Google) &lt;joel@joelfernandes.org&gt;
Signed-off-by: Paul E. McKenney &lt;paulmck@kernel.org&gt;
</content>
</entry>
<entry>
<title>srcu: Fix long lines in srcu_gp_end()</title>
<updated>2023-04-04T15:37:02Z</updated>
<author>
<name>Paul E. McKenney</name>
<email>paulmck@kernel.org</email>
</author>
<published>2023-03-18T17:52:48Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=6c366522e10f2b5e916b3f08ac042df1a1cd512a'/>
<id>urn:sha1:6c366522e10f2b5e916b3f08ac042df1a1cd512a</id>
<content type='text'>
This commit creates an srcu_usage pointer named "sup" as a shorter
synonym for the "ssp-&gt;srcu_sup" that was bloating several lines of code.

Cc: Christoph Hellwig &lt;hch@lst.de&gt;
Tested-by: Sachin Sant &lt;sachinp@linux.ibm.com&gt;
Tested-by: "Zhang, Qiang1" &lt;qiang1.zhang@intel.com&gt;
Tested-by: Joel Fernandes (Google) &lt;joel@joelfernandes.org&gt;
Signed-off-by: Paul E. McKenney &lt;paulmck@kernel.org&gt;
</content>
</entry>
<entry>
<title>srcu: Fix long lines in cleanup_srcu_struct()</title>
<updated>2023-04-04T15:36:57Z</updated>
<author>
<name>Paul E. McKenney</name>
<email>paulmck@kernel.org</email>
</author>
<published>2023-03-18T17:51:50Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=5ff8319f07db11c3b9347ce1dc0a6d951ae96d29'/>
<id>urn:sha1:5ff8319f07db11c3b9347ce1dc0a6d951ae96d29</id>
<content type='text'>
This commit creates an srcu_usage pointer named "sup" as a shorter
synonym for the "ssp-&gt;srcu_sup" that was bloating several lines of code.

Cc: Christoph Hellwig &lt;hch@lst.de&gt;
Tested-by: Sachin Sant &lt;sachinp@linux.ibm.com&gt;
Tested-by: "Zhang, Qiang1" &lt;qiang1.zhang@intel.com&gt;
Tested-by: Joel Fernandes (Google) &lt;joel@joelfernandes.org&gt;
Signed-off-by: Paul E. McKenney &lt;paulmck@kernel.org&gt;
</content>
</entry>
<entry>
<title>srcu: Fix long lines in srcu_get_delay()</title>
<updated>2023-04-04T15:36:48Z</updated>
<author>
<name>Paul E. McKenney</name>
<email>paulmck@kernel.org</email>
</author>
<published>2023-03-18T16:34:52Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=eabe7625f053050e4cecbbe98bd944f7e8eb14f5'/>
<id>urn:sha1:eabe7625f053050e4cecbbe98bd944f7e8eb14f5</id>
<content type='text'>
This commit creates an srcu_usage pointer named "sup" as a shorter
synonym for the "ssp-&gt;srcu_sup" that was bloating several lines of code.

Tested-by: Sachin Sant &lt;sachinp@linux.ibm.com&gt;
Tested-by: "Zhang, Qiang1" &lt;qiang1.zhang@intel.com&gt;
Cc: Christoph Hellwig &lt;hch@lst.de&gt;
Tested-by: Joel Fernandes (Google) &lt;joel@joelfernandes.org&gt;
Signed-off-by: Paul E. McKenney &lt;paulmck@kernel.org&gt;
</content>
</entry>
<entry>
<title>srcu: Check for readers at module-exit time</title>
<updated>2023-04-04T15:36:43Z</updated>
<author>
<name>Paul E. McKenney</name>
<email>paulmck@kernel.org</email>
</author>
<published>2023-03-24T16:05:50Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=a7bf4d7c16c1cf9753873879630a5d5169eb3206'/>
<id>urn:sha1:a7bf4d7c16c1cf9753873879630a5d5169eb3206</id>
<content type='text'>
If a given statically allocated in-module srcu_struct structure was ever
used for updates, srcu_module_going() will invoke cleanup_srcu_struct()
at module-exit time.  This will check for the error case of SRCU readers
persisting past module-exit time.  On the other hand, if this srcu_struct
structure never went through a grace period, srcu_module_going() only
invokes free_percpu(), which would result in strange failures if SRCU
readers persisted past module-exit time.

This commit therefore adds a srcu_readers_active() check to
srcu_module_going(), splatting if readers have persisted and refraining
from invoking free_percpu() in that case.  Better to leak memory than
to suffer silent memory corruption!

[ paulmck: Apply Zhang, Qiang1 feedback on memory leak. ]

Tested-by: Joel Fernandes (Google) &lt;joel@joelfernandes.org&gt;
Signed-off-by: Paul E. McKenney &lt;paulmck@kernel.org&gt;
</content>
</entry>
<entry>
<title>srcu: Move work-scheduling fields from srcu_struct to srcu_usage</title>
<updated>2023-04-04T15:36:37Z</updated>
<author>
<name>Paul E. McKenney</name>
<email>paulmck@kernel.org</email>
</author>
<published>2023-03-18T04:30:32Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=fd1b3f8e097b7fbbab8ac4a802b24fc23c703dcf'/>
<id>urn:sha1:fd1b3f8e097b7fbbab8ac4a802b24fc23c703dcf</id>
<content type='text'>
This commit moves the -&gt;reschedule_jiffies, -&gt;reschedule_count, and
-&gt;work fields from the srcu_struct structure to the srcu_usage structure
to reduce the size of the former in order to improve cache locality.

However, this means that the container_of() calls cannot get a pointer
to the srcu_struct because they are no longer in the srcu_struct.
This issue is addressed by adding a -&gt;srcu_ssp field in the srcu_usage
structure that references the corresponding srcu_struct structure.
And given the presence of the sup pointer to the srcu_usage structure,
replace some ssp-&gt;srcu_usage-&gt; instances with sup-&gt;.

[ paulmck Apply feedback from kernel test robot. ]

Link: https://lore.kernel.org/oe-kbuild-all/202303191400.iO5BOqka-lkp@intel.com/
Suggested-by: Christoph Hellwig &lt;hch@lst.de&gt;
Tested-by: Sachin Sant &lt;sachinp@linux.ibm.com&gt;
Tested-by: "Zhang, Qiang1" &lt;qiang1.zhang@intel.com&gt;
Tested-by: Joel Fernandes (Google) &lt;joel@joelfernandes.org&gt;
Signed-off-by: Paul E. McKenney &lt;paulmck@kernel.org&gt;
</content>
</entry>
<entry>
<title>srcu: Move srcu_barrier() fields from srcu_struct to srcu_usage</title>
<updated>2023-04-04T15:36:33Z</updated>
<author>
<name>Paul E. McKenney</name>
<email>paulmck@kernel.org</email>
</author>
<published>2023-03-18T04:08:18Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=d20162e0bfc222183a7c94cd00e74b6bbf1a605b'/>
<id>urn:sha1:d20162e0bfc222183a7c94cd00e74b6bbf1a605b</id>
<content type='text'>
This commit moves the -&gt;srcu_barrier_seq, -&gt;srcu_barrier_mutex,
-&gt;srcu_barrier_completion, and -&gt;srcu_barrier_cpu_cnt fields from the
srcu_struct structure to the srcu_usage structure to reduce the size of
the former in order to improve cache locality.

Suggested-by: Christoph Hellwig &lt;hch@lst.de&gt;
Tested-by: Sachin Sant &lt;sachinp@linux.ibm.com&gt;
Tested-by: "Zhang, Qiang1" &lt;qiang1.zhang@intel.com&gt;
Tested-by: Joel Fernandes (Google) &lt;joel@joelfernandes.org&gt;
Signed-off-by: Paul E. McKenney &lt;paulmck@kernel.org&gt;
</content>
</entry>
<entry>
<title>srcu: Move -&gt;sda_is_static from srcu_struct to srcu_usage</title>
<updated>2023-04-04T15:36:28Z</updated>
<author>
<name>Paul E. McKenney</name>
<email>paulmck@kernel.org</email>
</author>
<published>2023-03-18T03:22:58Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=660349ac79cb22bb64c44b026d879069783e97d5'/>
<id>urn:sha1:660349ac79cb22bb64c44b026d879069783e97d5</id>
<content type='text'>
This commit moves the -&gt;sda_is_static field from the srcu_struct structure
to the srcu_usage structure to reduce the size of the former in order
to improve cache locality.

Suggested-by: Christoph Hellwig &lt;hch@lst.de&gt;
Tested-by: Sachin Sant &lt;sachinp@linux.ibm.com&gt;
Tested-by: "Zhang, Qiang1" &lt;qiang1.zhang@intel.com&gt;
Tested-by: Joel Fernandes (Google) &lt;joel@joelfernandes.org&gt;
Signed-off-by: Paul E. McKenney &lt;paulmck@kernel.org&gt;
</content>
</entry>
</feed>
