と の違いを説明できる人はいrcu_dereference()
ますrcu_dereference_protected()
か?
rcu_dereference()
バリアコードをrcu_dereference_protected()
含み、含まない。
いつrcu_dereference()
、いつ使用するのrcu_dereference_protected()
ですか?
と の違いを説明できる人はいrcu_dereference()
ますrcu_dereference_protected()
か?
rcu_dereference()
バリアコードをrcu_dereference_protected()
含み、含まない。
いつrcu_dereference()
、いつ使用するのrcu_dereference_protected()
ですか?
要するに:
rcu_dereference()
read-sideで使用する必要があります、protected byrcu_read_lock()
または同様のもの。rcu_dereference_protected()
単一のライターによって書き込み側( update-side )で使用されるか、複数のライターが参照解除されたポインターを同時に変更するのを防ぐロックによって保護される必要があります。このような場合、ポインタは現在のスレッドの外では変更できないため、コンパイラバリアも CPU バリアも必要ありません。疑問がある場合は、 を使用することrcu_dereference
は常に安全であり、そのパフォーマンス ペナルティは ( と比較してrcu_dereference_protected
) 低いです。
カーネル 4.6 での正確な説明:rcu_dereference_protected
/**
* rcu_dereference_protected() - fetch RCU pointer when updates prevented
* @p: The pointer to read, prior to dereferencing
* @c: The conditions under which the dereference will take place
*
* Return the value of the specified RCU-protected pointer, but omit
* both the smp_read_barrier_depends() and the READ_ONCE(). This
* is useful in cases where update-side locks prevent the value of the
* pointer from changing. Please note that this primitive does -not-
* prevent the compiler from repeating this reference or combining it
* with other references, so it should not be used without protection
* of appropriate locks.
*
* This function is only for update-side use. Using this function
* when protected only by rcu_read_lock() will result in infrequent
* but very ugly failures.
*/