From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Michalis Kokologiannakis <mixaskok@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] doc: Update the comparisons rule in rcu_dereference.txt
Date: Tue, 21 Mar 2017 11:09:50 -0700 [thread overview]
Message-ID: <20170321180950.GN3637@linux.vnet.ibm.com> (raw)
In-Reply-To: <1490045915-18759-1-git-send-email-mixaskok@gmail.com>
On Mon, Mar 20, 2017 at 10:38:35PM +0100, Michalis Kokologiannakis wrote:
> When an RCU-protected pointer is fetched but never dereferenced
> rcu_access_pointer() should be used in place of rcu_dereference().
> This commit explicitly records this very fact in Documentation/
> RCU/rcu_dereference.txt, in order to prevent the usage of
> rcu_dereference() in comparisons.
>
> Signed-off-by: Michalis Kokologiannakis <mixaskok@gmail.com>
Queued for review, thank you!
Thanx, Paul
> ---
> Documentation/RCU/rcu_dereference.txt | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/Documentation/RCU/rcu_dereference.txt b/Documentation/RCU/rcu_dereference.txt
> index c0bf244..b2a613f 100644
> --- a/Documentation/RCU/rcu_dereference.txt
> +++ b/Documentation/RCU/rcu_dereference.txt
> @@ -138,6 +138,15 @@ o Be very careful about comparing pointers obtained from
> This sort of comparison occurs frequently when scanning
> RCU-protected circular linked lists.
>
> + Note that if checks for being within an RCU read-side
> + critical section are not required and the pointer is never
> + dereferenced, rcu_access_pointer() should be used in place
> + of rcu_dereference(). The rcu_access_pointer() primitive
> + does not require an enclosing read-side critical section,
> + and also omits the smp_read_barrier_depends() included in
> + rcu_dereference(), which in turn should provide a small
> + performance gain in some CPUs (e.g., the DEC Alpha).
> +
> o The comparison is against a pointer that references memory
> that was initialized "a long time ago." The reason
> this is safe is that even if misordering occurs, the
> --
> 2.1.4
>
prev parent reply other threads:[~2017-03-21 18:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-20 21:38 [PATCH] doc: Update the comparisons rule in rcu_dereference.txt Michalis Kokologiannakis
2017-03-21 18:09 ` Paul E. McKenney [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=20170321180950.GN3637@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mixaskok@gmail.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.