[Top] [All Lists]

structs with bitfields and spinlocks/atomics

To: xfs@xxxxxxxxxxx
Subject: structs with bitfields and spinlocks/atomics
From: Damian Lukowski <damian@xxxxxxxxxxxxxxxxxx>
Date: Tue, 11 Dec 2012 12:48:19 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20121027 Icedove/3.0.11

I would like to point out that xfs-code may need a review, whether it is affected by compiler issues as described in [1]. There has been a patch [2] for btrfs this year summarizing the problem as follows:

On ia64, powerpc64 and sparc64 the bitfield is modified through a RMW cycle and current gcc rewrites the adjacent 4B word, which in case of a spinlock or atomic has disaterous effect.

In xfs_aops.h we have
typedef struct xfs_ioend {
        struct xfs_ioend        *io_list;
        unsigned int            io_type;
        int                     io_error;
        atomic_t                io_remaining;
        unsigned int            io_isasync : 1;
        unsigned int            io_isdirect : 1;

where atomic_t, io_isasync and io_isdirect presumably share a common 8B word. I only found this occurrence so far.

Thanks to Dave Chinner for pointing out the correct mailing list.

Best regards
 Damian Lukowski

[1] https://lkml.org/lkml/2012/2/1/220
[2] btrfs: fix structs where bitfields and spinlock/atomic share 8B word (commit c08782dacd7a098f2b8bca7f4a57a5b402e9e1e5)

<Prev in Thread] Current Thread [Next in Thread>
  • structs with bitfields and spinlocks/atomics, Damian Lukowski <=