[Devel] [VZ8 PATCH] lib/radix-tree: fixup for BUG_ON in __radix_tree_insert()

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jun 7 19:14:53 MSK 2021


Valera, please recheck if we need it in vz8.
i guess - no.

--
Best regards,

Konstantin Khorenko,
Virtuozzo Linux Kernel Team

On 06/04/2021 04:01 PM, Valeriy Vdovin wrote:
> From: Vasily Averin <vvs at virtuozzo.com>
>
> __radix_tree_insert() triggers BUG_ON if root have set any prev tag
> bits. Let's ignore prev tag bits.
>
> Fixes: c68ade41961d4 ("radix-tree: save previous gfp_t tags in radix tree
> for dirty memory accounting")
>
> https://jira.sw.ru/browse/PSBM-100579
> Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
> (cherry-picked from 5ddc0f15746712d643895dd4756e330f4a26ffeb)
> https://jira.sw.ru/browse/PSBM-127849
> Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
> ---
>  include/linux/radix-tree.h | 2 ++
>  lib/radix-tree.c           | 2 +-
>  2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
> index d9f3cf0a4c4d..fe681dd5c06b 100644
> --- a/include/linux/radix-tree.h
> +++ b/include/linux/radix-tree.h
> @@ -75,6 +75,8 @@ static inline bool radix_tree_is_internal_node(void *ptr)
>  #define RADIX_TREE_TAG_LONGS	XA_MARK_LONGS
>  #endif
>
> +#define RADIX_ROOT_TAG_MASK    (((1<<RADIX_TREE_MAX_TAGS)-1) << __GFP_BITS_SHIFT)
> +
>  #define RADIX_TREE_INDEX_BITS  (8 /* CHAR_BIT */ * sizeof(unsigned long))
>  #define RADIX_TREE_MAX_PATH (DIV_ROUND_UP(RADIX_TREE_INDEX_BITS, \
>  					  RADIX_TREE_MAP_SHIFT))
> diff --git a/lib/radix-tree.c b/lib/radix-tree.c
> index 310e89cc0f92..28591214be53 100644
> --- a/lib/radix-tree.c
> +++ b/lib/radix-tree.c
> @@ -167,7 +167,7 @@ static inline int root_tag_get(const struct radix_tree_root *root, unsigned tag)
>
>  static inline unsigned root_tags_get(const struct radix_tree_root *root)
>  {
> -	return (__force unsigned)root->xa_flags >> ROOT_TAG_SHIFT;
> +	return (__force unsigned)(root->xa_flags & RADIX_ROOT_TAG_MASK) >> __GFP_BITS_SHIFT;
>  }
>
>  static inline bool is_idr(const struct radix_tree_root *root)
>


More information about the Devel mailing list