From nobody Sun Apr 19 05:33:37 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7255CCA47B for ; Tue, 5 Jul 2022 19:01:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233067AbiGETBo (ORCPT ); Tue, 5 Jul 2022 15:01:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230205AbiGETBl (ORCPT ); Tue, 5 Jul 2022 15:01:41 -0400 Received: from smtp.smtpout.orange.fr (smtp02.smtpout.orange.fr [80.12.242.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E61AE12AC9 for ; Tue, 5 Jul 2022 12:01:39 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id 8nniozMgNgoLG8nnioHgwV; Tue, 05 Jul 2022 21:01:37 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Tue, 05 Jul 2022 21:01:37 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-perf-users@vger.kernel.org Subject: [PATCH] uprobes: Use the bitmap API to allocate bitmaps Date: Tue, 5 Jul 2022 21:01:33 +0200 Message-Id: <90858b515127a99d0bcb989a16b5d88829abfce2.1657047672.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use bitmap_zalloc()/bitmap_free() instead of hand-writing them. It is less verbose and it improves the semantic. Signed-off-by: Christophe JAILLET --- Out of curiosity, is it normal to have __free_page() in the error handling path of __create_xol_area() and put_page() in uprobe_clear_state()? uprobe_clear_state() seems to release the resources allocated in __create_xol_area(), but the implementation of __free_page() and of put_page() look quite different. This is maybe perfectly correct, but looks odd to me. --- kernel/events/uprobes.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 401bc2d24ce0..83fb62eed9c6 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -1485,8 +1485,7 @@ static struct xol_area *__create_xol_area(unsigned lo= ng vaddr) if (unlikely(!area)) goto out; =20 - area->bitmap =3D kcalloc(BITS_TO_LONGS(UINSNS_PER_PAGE), sizeof(long), - GFP_KERNEL); + area->bitmap =3D bitmap_zalloc(UINSNS_PER_PAGE, GFP_KERNEL); if (!area->bitmap) goto free_area; =20 @@ -1510,7 +1509,7 @@ static struct xol_area *__create_xol_area(unsigned lo= ng vaddr) =20 __free_page(area->pages[0]); free_bitmap: - kfree(area->bitmap); + bitmap_free(area->bitmap); free_area: kfree(area); out: @@ -1551,7 +1550,7 @@ void uprobe_clear_state(struct mm_struct *mm) return; =20 put_page(area->pages[0]); - kfree(area->bitmap); + bitmap_free(area->bitmap); kfree(area); } =20 --=20 2.34.1