From nobody Tue Apr 7 14:03:06 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D71CE31CA50 for ; Wed, 25 Feb 2026 23:31:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772062276; cv=none; b=KNNe8qQy1ZiRsfOPH6kBQ3tZpzMPfPd6q7nv4lkxQqHH6ugs2EStepXKEsyyL0KpLEk3qY7IxSRRi+6Na4ldF1sZkQoZUs2zG7h0KTs4iV/1SQFpVFvqrjfqtX8H9KL7Vandf8sQoxnDDNenBSwUPxT0HcnFDc+b7QkvT44oUHk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772062276; c=relaxed/simple; bh=obkI1FVNxT6sa1JWz7SJNPJ5sUYJoL8uwfx+TuaNXco=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Fu/up004JQy36Vxy7KWe/vRcmGWVxq1QZ447l9qnULmtEDKZZgh15wC6pj0EGWK/6oZ7Qt4UaE/Q1GKNIFfyDAKOIT+w7vSTX1VIgPzDkYnekU+FTKe06FS1TqGwt8X3UPu8yaamoLn3MC5gNADaRGh+wUZ2GQ0s4FRJpS9GOUk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Hts5iko5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Hts5iko5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 862D2C116D0; Wed, 25 Feb 2026 23:31:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772062276; bh=obkI1FVNxT6sa1JWz7SJNPJ5sUYJoL8uwfx+TuaNXco=; h=From:To:Cc:Subject:Date:From; b=Hts5iko5XDHdD4DxAUey78Ja5C7J5OkIO1eyaWzr62jF2EQdR3NDndztOAjzSzxiK 9MamRoetJp73z7YpLt3OLEWESwvnScOcQJGZykDUw0JdbQxyvgBJumGMYACw/VGSBD 7mHpBqfA63Tatx9cdq4igioBo8j2UpAI0vzp0SHtrniX4yFUohLeXIJF0BGrYbeiim rmHlLM3OUl3M4FO3/0KIf5Ghm0qxCohR5B6lJ/hdpyEZTKheGMnFYRZ+z47JcNAX4g w3APT633imujsByWHdI3F02g2ovvf8712ep4bzejIfpOnVmxC905piaLKFvMueNpcI 4wRNew0FMyfMQ== From: Mike Rapoport To: Andrew Morton Cc: David Hildenbrand , Kees Cook , "Liam R. Howlett" , Lorenzo Stoakes , Matthew Wilcox , Mike Rapoport , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH] tools/testing: fix testing/vma and testing/radix-tree build Date: Thu, 26 Feb 2026 01:31:11 +0200 Message-ID: <20260225233111.2760752-1-rppt@kernel.org> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: "Mike Rapoport (Microsoft)" Build of VMA and radix-tree tests is unhappy after the conversion of kzalloc() to kzalloc_obj() in lib/idr.c: cc -I../shared -I. -I../../include -I../../arch/x86/include -I../../../li= b -g -Og -Wall -D_LGPL_SOURCE -fsanitize=3Daddress -fsanitize=3Dundefined = -DNUM_VMA_FLAG_BITS=3D128 -DNUM_MM_FLAG_BITS=3D128 -c -o idr.o idr.c idr.c: In function =E2=80=98ida_alloc_range=E2=80=99: idr.c:420:34: error: implicit declaration of function =E2=80=98kzalloc_ob= j=E2=80=99; did you mean =E2=80=98kzalloc_node=E2=80=99? [-Wimplicit-functi= on-declaration] 420 | bitmap =3D kzalloc_obj(*bitmap, GFP_NOWAI= T); | ^~~~~~~~~~~ | kzalloc_node idr.c:420:32: error: assignment to =E2=80=98struct ida_bitmap *=E2=80=99 = from =E2=80=98int=E2=80=99 makes pointer from integer without a cast [-Wint= -conversion] 420 | bitmap =3D kzalloc_obj(*bitmap, GFP_NOWAI= T); | ^ idr.c:447:40: error: assignment to =E2=80=98struct ida_bitmap *=E2=80=99 = from =E2=80=98int=E2=80=99 makes pointer from integer without a cast [-Wint= -conversion] 447 | bitmap =3D kzalloc_obj(*bitmap, G= FP_NOWAIT); | ^ idr.c:468:15: error: assignment to =E2=80=98struct ida_bitmap *=E2=80=99 = from =E2=80=98int=E2=80=99 makes pointer from integer without a cast [-Wint= -conversion] 468 | alloc =3D kzalloc_obj(*bitmap, gfp); | ^ make: *** [: idr.o] Error 1 Import necessary macros from include/linux to tools/include/linux to fix the compilation. Fixes: 69050f8d6d07 ("treewide: Replace kmalloc with kmalloc_obj for non-sc= alar types") Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Lorenzo Stoakes Tested-by: SeongJae Park --- tools/include/linux/gfp.h | 4 ++++ tools/include/linux/overflow.h | 19 +++++++++++++++++++ tools/include/linux/slab.h | 9 +++++++++ 3 files changed, 32 insertions(+) diff --git a/tools/include/linux/gfp.h b/tools/include/linux/gfp.h index 6a10ff5f5be9..9e957b57b694 100644 --- a/tools/include/linux/gfp.h +++ b/tools/include/linux/gfp.h @@ -5,6 +5,10 @@ #include #include =20 +/* Helper macro to avoid gfp flags if they are the default one */ +#define __default_gfp(a,...) a +#define default_gfp(...) __default_gfp(__VA_ARGS__ __VA_OPT__(,) GFP_KERNE= L) + static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags) { return !!(gfp_flags & __GFP_DIRECT_RECLAIM); diff --git a/tools/include/linux/overflow.h b/tools/include/linux/overflow.h index dcb0c1bf6866..3427d7880326 100644 --- a/tools/include/linux/overflow.h +++ b/tools/include/linux/overflow.h @@ -68,6 +68,25 @@ __builtin_mul_overflow(__a, __b, __d); \ }) =20 +/** + * size_mul() - Calculate size_t multiplication with saturation at SIZE_MAX + * @factor1: first factor + * @factor2: second factor + * + * Returns: calculate @factor1 * @factor2, both promoted to size_t, + * with any overflow causing the return value to be SIZE_MAX. The + * lvalue must be size_t to avoid implicit type conversion. + */ +static inline size_t __must_check size_mul(size_t factor1, size_t factor2) +{ + size_t bytes; + + if (check_mul_overflow(factor1, factor2, &bytes)) + return SIZE_MAX; + + return bytes; +} + /** * array_size() - Calculate size of 2-dimensional array. * diff --git a/tools/include/linux/slab.h b/tools/include/linux/slab.h index 94937a699402..6d8e9413d5a4 100644 --- a/tools/include/linux/slab.h +++ b/tools/include/linux/slab.h @@ -202,4 +202,13 @@ static inline unsigned int kmem_cache_sheaf_size(struc= t slab_sheaf *sheaf) return sheaf->size; } =20 +#define __alloc_objs(KMALLOC, GFP, TYPE, COUNT) \ +({ \ + const size_t __obj_size =3D size_mul(sizeof(TYPE), COUNT); \ + (TYPE *)KMALLOC(__obj_size, GFP); \ +}) + +#define kzalloc_obj(P, ...) \ + __alloc_objs(kzalloc, default_gfp(__VA_ARGS__), typeof(P), 1) + #endif /* _TOOLS_SLAB_H */ --=20 2.51.0