dn_route.c momentarily exiting RCU read-side critical section
Subsystems (2)
Hello!
net/decnet/dn_route.c in dn_rt_cache_get_next() is as follows:
static struct dn_route *dn_rt_cache_get_next(struct seq_file *seq, struct dn_route *rt)
{
struct dn_rt_cache_iter_state *s = rcu_dereference(seq->private);
rt = rt->u.dst.dn_next;
while(!rt) {
rcu_read_unlock_bh();
if (--s->bucket < 0)
break;... But what happens if seq->private is freed up right here? ... Or what prevents this from happening?
rcu_read_lock_bh(); rt = dn_rt_hash_table[s->bucket].chain; } return rt; }
Similar code is in rt_cache_get_next().
So, what am I missing here?
Thanx, Paul
David Miller
maintainerFrom: "Paul E. McKenney" <[email protected]>
Date: Mon, 29 Oct 2007 14:15:40 -0700
Quoted 14 lines
net/decnet/dn_route.cindn_rt_cache_get_next()is as follows:static struct
dn_route*dn_rt_cache_get_next(structseq_file*seq, structdn_route*rt){ struct dn_rt_cache_iter_state *s = rcu_dereference(seq->private); rt = rt->u.dst.dn_next; while(!rt) { rcu_read_unlock_bh(); if (--s->bucket < 0) break;... But what happens if
seq->privateis freed up right here? ... Or what prevents this from happening?
...
Quoted 3 lines
Similar code is in
rt_cache_get_next().So, what am I missing here?
seq->private is allocated on file open (here via seq_open_private()), and freed up on file close (via seq_release_private).
So it cannot be freed up in the middle of an iteration.
Quoted 18 lines · David Miller
From: "Paul E. McKenney" <[email protected]>
Date: Mon, 29 Oct 2007 14:15:40 -0700Quoted 14 lines
net/decnet/dn_route.cindn_rt_cache_get_next()is as follows:static struct
dn_route*dn_rt_cache_get_next(structseq_file*seq, structdn_route*rt){ struct dn_rt_cache_iter_state *s = rcu_dereference(seq->private); rt = rt->u.dst.dn_next; while(!rt) { rcu_read_unlock_bh(); if (--s->bucket < 0) break;... But what happens if
seq->privateis freed up right here? ... Or what prevents this from happening?...
Quoted 8 lines
Quoted 3 lines
Similar code is in
rt_cache_get_next().So, what am I missing here?
seq->privateis allocated on file open (here viaseq_open_private()), and freed up on file close (viaseq_release_private).So it cannot be freed up in the middle of an iteration.
Thank you for the info!!!
OK, for my next stupid question: why is the rcu_dereference(seq->private) required, as opposed to simply seq->private?
Thanx, Paul
Quoted 7 lines · Paul E. McKenney
Quoted 7 lines
Quoted 7 lines
net/decnet/dn_route.cindn_rt_cache_get_next()is as follows:static struct
dn_route*dn_rt_cache_get_next(structseq_file*seq, structdn_route*rt){ struct dn_rt_cache_iter_state *s = rcu_dereference(seq->private);
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
rt = rt->u.dst.dn_next; while(!rt) { rcu_read_unlock_bh(); if (--s->bucket < 0) break;OK, for my next stupid question: why is the
rcu_dereference(seq->private)required, as opposed to simplyseq->private?
It was put there by someone who went through the code converting all occurances of smp_read_barrier_depends to rcu_dereference. In this instance the rcu_dereference conversion doesn't make much sense so we should probably just revert it.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 14 lines · Herbert Xu
Quoted 13 lines · Paul E. McKenney
Quoted 12 lines
Quoted 12 lines
net/decnet/dn_route.cindn_rt_cache_get_next()is as follows:static struct
dn_route*dn_rt_cache_get_next(structseq_file*seq, structdn_route*rt){ struct dn_rt_cache_iter_state *s = rcu_dereference(seq->private); rt = rt->u.dst.dn_next; while(!rt) { rcu_read_unlock_bh(); if (--s->bucket < 0) break;
Quoted 7 lines
Quoted 2 lines
OK, for my next stupid question: why is the
rcu_dereference(seq->private)required, as opposed to simplyseq->private?It was put there by someone who went through the code converting all occurances of
smp_read_barrier_dependstorcu_dereference. In this instance thercu_dereferenceconversion doesn't make much sense so we should probably just revert it.
Thank you for the info! Stupid question #3: what sequence of events would the smp_read_barrier_depends() be defending against?
Thanx, Paul
Quoted 7 lines · Paul E. McKenney
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
net/decnet/dn_route.cindn_rt_cache_get_next()is as follows:static struct
dn_route*dn_rt_cache_get_next(structseq_file*seq, structdn_route*rt){ struct dn_rt_cache_iter_state *s = rcu_dereference(seq->private);
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
rt = rt->u.dst.dn_next; while(!rt) { rcu_read_unlock_bh(); if (--s->bucket < 0) break;Thank you for the info! Stupid question #3: what sequence of events would the
smp_read_barrier_depends()be defending against?
The reading of rt from the hash bucket and the dereferencing above. We need to make sure that we see the initialised rt.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt