Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp4986123rwe; Mon, 17 Apr 2023 23:47:53 -0700 (PDT) X-Google-Smtp-Source: AKy350as0fIh33rejjyteHh0wobGHWWYIu8RynXgTd1pfcOY+i0CkiLG8lv6mUVY3uHbvd+zb0le X-Received: by 2002:a05:6a00:2390:b0:636:e0fb:8c44 with SMTP id f16-20020a056a00239000b00636e0fb8c44mr26024088pfc.12.1681800472729; Mon, 17 Apr 2023 23:47:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681800472; cv=none; d=google.com; s=arc-20160816; b=iDXq8FxZJZqWBQHKZg+9LcN1J5RmrqCxmGivdObSLbfP/wY6rg0FP6y3IwPWkhjD31 YgFNEXdWe6bDh1MOF4o/L7nQrUv/MtFZr/mMgjRtQX/DGta1y4r1k59ek6lBP3ayFGFz OpQZhWAodb+JpVNUnB6J/ec1ozxUKC6jEU4NxOpeAUA9LCxiDP/91+Oa/Rtu0zBZ9P5o dP+xg6y962Jvxx2RHP1by6hMBlFGkAGw4M30l66j0rMK5obVqDuX2LllvfifBTNBEykk 2fhDRdRWfXVpfrBcmSkw3O9O8R8XHHAuQ4QCaAf1DdMsQ5iZa4e1jYrSNyb8nIJuy4ku EMtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=YHZ8IjA608qgaZaYG+mCqlIpCEC9KOgGm1ClgpR3VaA=; b=lYJ2LGu6L8LjCWiG5dNyq/4Z/UIDsKMPWtcGzYm3OqloxIpHtozIGjeFwb6yWWzB3G ePMxnTulXhNx2GZsoNWMSmZfVh4z0i0b14JpcABeViyw2qadtjEL7JTHHSRLPg9C1xs9 9QauaoOMJHc2mk1uoWffEz2HWErLEh9ppxJCoi51cPMAXStewR3HYJ+2PXyTZYf7iP1/ WrbpNMzhVAuKHBtPH74Ie3ls+nJq5z4lZycFvH64cbopLbaVkez2O5oslD2KKTRqdVq3 74M/HkHNV6tZHVFdU49o0zOSCOxomeUAPhFr516DOQ6aTRVJKyGqkzrUg6k+BVwn49BX wUlA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g1-20020aa79f01000000b0063d334beed6si1828494pfr.341.2023.04.17.23.47.39; Mon, 17 Apr 2023 23:47:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230170AbjDRGgx convert rfc822-to-8bit (ORCPT + 99 others); Tue, 18 Apr 2023 02:36:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbjDRGgw (ORCPT ); Tue, 18 Apr 2023 02:36:52 -0400 Received: from outpost1.zedat.fu-berlin.de (outpost1.zedat.fu-berlin.de [130.133.4.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBCB73C20; Mon, 17 Apr 2023 23:36:50 -0700 (PDT) Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.95) with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (envelope-from ) id 1poexH-002CzT-3h; Tue, 18 Apr 2023 08:36:43 +0200 Received: from p5b13a017.dip0.t-ipconnect.de ([91.19.160.23] helo=[192.168.178.81]) by inpost2.zedat.fu-berlin.de (Exim 4.95) with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (envelope-from ) id 1poexG-000nCD-MG; Tue, 18 Apr 2023 08:36:43 +0200 Message-ID: Subject: Re: [PATCH RESEND] sh: sq: Use the bitmap API when applicable From: John Paul Adrian Glaubitz To: Christophe JAILLET , Yoshinori Sato , Rich Felker Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-sh@vger.kernel.org, Geert Uytterhoeven Date: Tue, 18 Apr 2023 08:36:40 +0200 In-Reply-To: <071e9f32c19a007f4922903282c9121898641400.1681671848.git.christophe.jaillet@wanadoo.fr> References: <071e9f32c19a007f4922903282c9121898641400.1681671848.git.christophe.jaillet@wanadoo.fr> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.48.0 MIME-Version: 1.0 X-Original-Sender: glaubitz@physik.fu-berlin.de X-Originating-IP: 91.19.160.23 X-ZEDAT-Hint: PO X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Christophe! Thanks for your patch. The changes look good to me. However, I have one question, see below. On Sun, 2023-04-16 at 21:05 +0200, Christophe JAILLET wrote: > Using the bitmap API is less verbose than hand writing them. > It also improves the semantic. > > Signed-off-by: Christophe JAILLET > --- > This is a resend of [1]. > > Now cross-compile tested with CONFIG_CPU_SUBTYPE_SH7770=y > > [1]: https://lore.kernel.org/all/521788e22ad8f7a5058c154f068b061525321841.1656142814.git.christophe.jaillet@wanadoo.fr/ > --- > arch/sh/kernel/cpu/sh4/sq.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/arch/sh/kernel/cpu/sh4/sq.c b/arch/sh/kernel/cpu/sh4/sq.c > index 27f2e3da5aa2..d289e99dc118 100644 > --- a/arch/sh/kernel/cpu/sh4/sq.c > +++ b/arch/sh/kernel/cpu/sh4/sq.c > @@ -372,7 +372,6 @@ static struct subsys_interface sq_interface = { > static int __init sq_api_init(void) > { > unsigned int nr_pages = 0x04000000 >> PAGE_SHIFT; > - unsigned int size = (nr_pages + (BITS_PER_LONG - 1)) / BITS_PER_LONG; > int ret = -ENOMEM; > > printk(KERN_NOTICE "sq: Registering store queue API.\n"); > @@ -382,7 +381,7 @@ static int __init sq_api_init(void) > if (unlikely(!sq_cache)) > return ret; > > - sq_bitmap = kzalloc(size, GFP_KERNEL); > + sq_bitmap = bitmap_zalloc(nr_pages, GFP_KERNEL); > if (unlikely(!sq_bitmap)) > goto out; > I have look through other patches where k{z,c,m}alloc() were replaced with bitmap_zalloc() and I noticed that in the other cases such as [1], kcalloc() was used instead of kzalloc() in our cases with the element size set to sizeof(long) while kzalloc() is using an element size equal to a byte. Wouldn't that mean that the current code in sq is allocating a buffer that is too small by a factor of 1/sizeof(long) or am I missing something? @Geert: Do you have any idea? > @@ -393,7 +392,7 @@ static int __init sq_api_init(void) > return 0; > > out: > - kfree(sq_bitmap); > + bitmap_free(sq_bitmap); > kmem_cache_destroy(sq_cache); > > return ret; > @@ -402,7 +401,7 @@ static int __init sq_api_init(void) > static void __exit sq_api_exit(void) > { > subsys_interface_unregister(&sq_interface); > - kfree(sq_bitmap); > + bitmap_free(sq_bitmap); > kmem_cache_destroy(sq_cache); > } > Adrian > [1] https://lkml.org/lkml/2021/11/28/155 -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913