Re: [PATCH] Modified XArray entry bit flags as macro constants

From: Matthew Wilcox
Date: Thu May 23 2024 - 23:06:14 EST


On Fri, May 24, 2024 at 11:49:45AM +0900, Jung-JaeJoon wrote:
> From: Jung-JaeJoon <rgbi3307@xxxxxxxxx>
>
> It would be better to modify the operation on the last two bits of the entry
> with a macro constant name rather than using a numeric constant.
>
> #define XA_VALUE_ENTRY 1UL
> #define XA_INTERNAL_ENTRY 2UL
> #define XA_POINTER_ENTRY 3UL
>
> In particular, in the xa_to_node() function, it is more consistent and efficient
> to perform a logical AND operation as shown below than a subtraction operation.
>
> - return (struct xa_node *)((unsigned long)entry - 2);
> + return (struct xa_node *)((unsigned long)entry & ~XA_INTERNAL_ENTRY);
>
> Additionally, it is better to modify the if condition below
> in the mas_store_root() function of lib/maple_tree.c to the xa_is_internal() inline function.
>
> - else if (((unsigned long) (entry) & 3) == 2)
> + else if (xa_is_internal(entry))
>
> And there is no reason to declare XA_CHECK_SCHED as an enum data type.
> -enum {
> - XA_CHECK_SCHED = 4096,
> -};
> +#define XA_CHECK_SCHED 4096

Thank you for your patch. I agree with none of this. Rejected.