On Tue, May 02, 2023 at 11:51:33PM +0800, Alan Huang wrote: > > > > 2023年5月2日 03:02,Paul E. McKenney <paulmck@xxxxxxxxxx> 写道: > > > > On Mon, May 01, 2023 at 07:09:49PM +0800, Alan Huang wrote: > >> > >>> 2023年5月1日 下午7:05,Alan Huang <mmpgouride@xxxxxxxxx> 写道: > >>> > >>> Hi, > >>> > >>> I’m reading section 9.5.4.9, in the second to the last paragraph, there is: > >>> > >>> Before the first horizontal line, all readers see the leftmost myconfig structure, > >>> and after the second horizontal line, all readers will see the rightmost structure. > >>> Between the two lines, that is, during the grace period, different readers might see different objects > >>> > >>> I’m a little confused, in Figure 9.29, the xchg is before the first horizontal line, in my understanding, if the > >>> reader’s reading is before the xchg, it will read the leftmost myconfg structure. > >> > >> And if reader’s reading is after the xchg, it will see the rightmost structure, and because xchg is before the first horizontal line, > >> Readers before the first horizontal line may also see the rightmost structure. > >> > >>> > >>> So, are there some conflicts between the paragraph and the figure? > >>> > >>> Please correct me if I’m wrong. > > > > Consider the point in time just before the left-hand reader's > > rcu_read_unlock() and just after the right-hand reader's rcu_read_lock(). > > These two readers are both running at that time, and one of those readers > > sees the old state and the other sees the new state. > > The sentence that may lead to conflict is this one from the original text: > > Before the first horizontal line, all readers see the leftmost myconfig structure. > > There may be a situation where: > > mcp = xchg(&curconfig, mcp); > rcu_read_lock(); > mcp = … > *cur_a = mcp->a; > -------------------------------------------------first horizontal line------------------------------------------------- > > So, the reader will see the rightmost myconfig structure although it is before the first horizontal line. Ah, I understand now, good catch and thank you! I updated that paragraph to the following, with your Reported-by: The two horizontal grey dashed lines represent the period of time during which different readers get different results, however, each reader will see one and only one of the two objects. All readers that end before the first horizontal line will see the leftmost myconfig structure, and all readers that start after the second horizontal line will see the rightmost structure. Between the two lines, that is, during the grace period, different readers might see different objects, but as long as each reader loads the curconfig pointer only once, each reader will see a consistent view of its myconfig structure. Does that help? > BTW, the original text says that black dotted arrows pointing from an older event to a newer event, > but there exists two black dotted arrows in the wrong direction: > > 1.The arrow pointing from synchronize_rcu() to left-hand rcu_read_lock() > 2.The arrow pointing right-hand rcu_read_lock() to synchronize_rcu() > > The directions of the two arrows above may need to be adjusted. I tried to modify this, but after a few hours, I still can’t figure out the svg... The trick is to use an SVG editor. For better or for worse, I use inkscape. But easy for me to change, so I did, again, with your Reported-by. The trick is to flip each arrow horizontally and then vertically, which reverses the direction without having to test one's manual dexterity, which I lack in abundance. ;-) Thanx, Paul > Thanks, > Alan > > > > > Does that help, or am I missing the point of your question? > > > > Thanx, Paul >