All nitpicks below.
On Wed, Mar 08, 2023 at 02:19:31PM -0800, Axel Rasmussen wrote:
+static inline bool uffd_flags_has_mode(uffd_flags_t flags, enum mfill_atomic_mode expected) +{
- return (flags & MFILL_ATOMIC_MODE_MASK) == ((__force uffd_flags_t) expected);
+}
I would still call it uffd_flags_get_mode() or uffd_flags_mode(), "has" sounds a bit like there can be >1 modes set but it's not.
+static inline uffd_flags_t uffd_flags_set_mode(uffd_flags_t flags, enum mfill_atomic_mode mode) +{
- return flags | ((__force uffd_flags_t) mode);
+}
IIUC this __force mostly won't work in any way because it protects e.g. illegal math ops upon it (to only allow bitops, iiuc) but here it's an OR so it's always legal..
So I'd just drop it and also clear the mode mask to be very clear it sets the mode right, rather than any chance of messing up when set twice:
flags &= ~MFILL_ATOMIC_MODE_MASK; return flags | mode;
But feel free to ignore this if there's no other reason to repost, I don't think it matters a huge deal.
Acked-by: Peter Xu peterx@redhat.com
Thanks,