I noticed the issue with 4.9.1 (in that x86 Linux'es
this_cpu_read_stable() no longer does what the comment preceding
its definition promises), and the example below demonstrates this in
a simplified (but contrived) way. I just now verified that trunk has
the same issue; 4.8.3 still folds redundant ones as expected. Is this
known, or possibly even intended (in which case I'd be curious as to
what the reasons are, and how the functionality Linux wants can be
gained back)?

Thanks, Jan

void dummy(int, int);
extern int m, p;

static inline int read_m(void) {
        int i;

        asm("nop %1" : "=r" (i) : "m" (m));
        return i;
}

static inline int read_p(void) {
        int i;

        asm("nop %P1" : "=r" (i) : "p" (&p));
        return i;
}

void test(void) {
        dummy(read_m(), read_m());
        dummy(read_p(), read_p());
        dummy(read_m(), read_m());
        dummy(read_p(), read_p());
}


Reply via email to