Re: Section 9.5: Nobody expects the Spanish Acquisition!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Akira,

I think this is mostly covered in Section 9.5.2.1 "Publish-Subscribe
Mechanism" and Figure 9.10 "Publication/Subscription Constraints".

I don't believe it is. I think you can infer that from reading sections 9.5 and chapter 15, but it is never made explicit.

Sub-section 9.5.2.1 talks about the use of rcu_dereference() to obtain a pointer, but it doesn't go very deep into how that's implemented. You would think that the writer's use of store-release semantics would necessitate the reader's use of load-acquire semantics, but the discussion here, the previous examples, and a quick inspection of how rcu_dereference() is implemented, suggest that a READ_ONCE() is sufficient (or some less Linux-kernel-specific equivalent).

If I am a naive reader (and a lazy one, who haven't read chapter 15 and made the necessary connection), I could write something like:

    struct foo_s {
        int a;
    } foo;
    int b;
    struct foo_s *g_foop = &foo;

    // Reader
    rcu_read_lock();
    struct foo *l_foop = rcu_dereference(g_foop);
    use(l_foop->a);
    use(b);
    rcu_read_unlock();

    // Writer
    struct foo *l_foop = malloc(sizeof(struct foo));
    l_foop->a = 1;
    b = 2;
    // Release semantics ensure previous stores are observed
    rcu_assign_pointer(g_foop, l_foop);

But since b has no address dependency to g_foop and since neither rcu_read_lock() nor rcu_dereference() impose acquire semantics, then the reader may not observe the new value of b.

Again, I may be missing something, but this seems to be a major point that needs to be explained and emphasized.

BTW, I couldn't figure out what you meant by "the Spanish
Acquisition"...
It's a reference to an old Monty Python skit. Apologies for the silly pun...

--Elad



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux