From: David Howells <dhowells@redhat.com>
To: paulmck@linux.vnet.ibm.com
Cc: dhowells@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: Confused by smp_read_barrier_depends() in rxrpc_rotate_tx_window()
Date: Tue, 03 Jun 2008 11:19:51 +0100 [thread overview]
Message-ID: <27030.1212488391@redhat.com> (raw)
In-Reply-To: <20080530124554.GA14312@linux.vnet.ibm.com>
Paul E. McKenney <paulmck@linux.vnet.ibm.com> wrote:
> I confess to being confused by the smp_read_barrier_depends() in
> rxrpc_rotate_tx_window(). It looks like it is ordering the prior
> fetch of tail from call->acks_tail with the subsequent use of
No. call->acks_head vs [tail].
> tail as an index into the call->acks_window[] array, but then the
> code does an assignment to call->acks_tail a few lines later.
>
> If we hold a lock protecting call->acks_tail, why do we need the
> smp_read_barrier_depends()? If we don't hold such a lock, why
> is the assignment to call->acks_tail safe?
We don't hold a lock protecting call->acks_tail. The head insertion and the
tail extraction are only protected by memory barriers.
int tail = call->acks_tail, old_tail;
int win = CIRC_CNT(call->acks_head, tail, call->acks_winsz);
...
smp_read_barrier_depends();
_skb = call->acks_window[tail] & ~1;
In this bit of code, we must protect against seeing the item at '[tail]' set
after 'call->acks_head' itself is updated, hence why we need a barrier here.
Possibly it should be smp_rmb() rather than smp_read_barrier_depends().
_skb = call->acks_window[tail] & ~1;
...
old_tail = tail;
tail = (tail + 1) & (call->acks_winsz - 1);
call->acks_tail = tail;
I believe this does not require a barrier between reading '[tail]' and updating
'tail' because there's no way we can update tail without first reading
'[tail]'.
David
prev parent reply other threads:[~2008-06-03 10:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-30 12:45 Confused by smp_read_barrier_depends() in rxrpc_rotate_tx_window() Paul E. McKenney
2008-06-03 10:19 ` David Howells [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=27030.1212488391@redhat.com \
--to=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.