All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konstantin Andreev <andreev@swemel.ru>
To: kernelnewbies@kernelnewbies.org
Subject: How does [=rcu_dereference_protected(ptr, 1)] differ from simple [=ptr]?
Date: Wed, 15 May 2019 20:17:30 +0300	[thread overview]
Message-ID: <5CDC49AA.6090201@swemel.ru> (raw)

Hi,

according to the documentation, [rcu_dereference_protected( ptr, condition )] is the "update-side primitive" that reads the ptr, "allowing the code to verify that the required locks really are held".

Given that, I expect that literal `1' as `condition' would imply just "reading the ptr".

Indeed, the macro expansion of

     = rcu_dereference_protected( ptr, 1 )

is roughly equals to just

     = ({ (typeof(*ptr) *)ptr; })

i.e. simple

     = ptr

that agrees with my expectation. So, coding [rcu_dereference_protected( ..., 1 )] looks like a waste of key presses.

However, expression [rcu_dereference_protected( ..., 1 )] routinely appears in the kernel sources, many times.

Why? Did I miss something?

Regards, Konstantin.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

                 reply	other threads:[~2019-05-15 19:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=5CDC49AA.6090201@swemel.ru \
    --to=andreev@swemel.ru \
    --cc=kernelnewbies@kernelnewbies.org \
    /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.