lkml.org 
[lkml]   [2013]   [May]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRE: [PATCH v2] rcu: fix a race in hlist_nulls_for_each_entry_rcu macro
    Date
    From
    > Here this loops begin by
    >
    > someptr = rcu_dereference(somelocation);
    >
    > May claim is rcu_dereference() should force the compiler to read again
    > somelocation. Its done thanks to ACCESS_ONCE(). But apparently in the
    > specific case of &hslot->head, it doesnt work.

    Hmmm....
    #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
    That might be doomed to fail for much the same reason as:
    void x(struct foo *unaligned_ptr)
    {
    char *p = (void *)unaligned_ptr;
    memcpy(tgt, p, sizeof *p);
    }
    generates alignment faults.
    And that casts to a union type don't get around 'strict aliasing'.

    Basically the compiler makes use of the fact that you should
    cast addresses back to their original type before dereferencing them.

    So I'm not sure you can use a cast to add a type qualifier.
    The front-end lets you remove 'const', but I suspect the optimiser
    is using the original types.

    David

    \
     
     \ /
      Last update: 2013-05-22 17:01    [W:2.171 / U:0.476 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site