Kernel Newbies archive on lore.kernel.org
 help / color / Atom feed
* How does [=rcu_dereference_protected(ptr, 1)] differ from simple [=ptr]?
@ 2019-05-15 17:17 Konstantin Andreev
  0 siblings, 0 replies; only message in thread
From: Konstantin Andreev @ 2019-05-15 17:17 UTC (permalink / raw)
  To: kernelnewbies

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-15 17:17 How does [=rcu_dereference_protected(ptr, 1)] differ from simple [=ptr]? Konstantin Andreev

Kernel Newbies archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kernelnewbies/0 kernelnewbies/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernelnewbies kernelnewbies/ https://lore.kernel.org/kernelnewbies \
		kernelnewbies@kernelnewbies.org kernelnewbies@archiver.kernel.org
	public-inbox-index kernelnewbies


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernelnewbies.kernelnewbies


AGPL code for this site: git clone https://public-inbox.org/ public-inbox