Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp396363rdb; Thu, 5 Oct 2023 08:59:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEiIXAXQBhkEVVm9lvx/Dzo2PW7S4qvr7nJIVA/yvFGz7EA5xJM6l53N2xO/c5936k2H6ng X-Received: by 2002:a05:6a20:974f:b0:133:b3a9:90d with SMTP id hs15-20020a056a20974f00b00133b3a9090dmr5076195pzc.36.1696521552721; Thu, 05 Oct 2023 08:59:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696521552; cv=none; d=google.com; s=arc-20160816; b=o/MUjHjUQS0ok0k5263mFWZPL6TTaxdzmiCTJ/M99PDCJQ5Kd7libAcVrEJM3Yhmq2 uXhHm3il0y7JfSNkeTQBlMPOcMq+st/xI34BVYOQEqEXZw41NjY/r1bqqzBYdPl3kUka guixm03Y26Ix33xIZbhBDtAQLNMSVDYzW350KhYl6M85Fuc63nmgGAvH2ro6txHh0MnO zbblnShxZEbnZ/BmVKCWkjXHC73bCF9derR4PgYN2Wk3nk/EWqZO28ZhWrj05sF4sRrG o7aY54TLmfqrr8KVoM9UQQm1C4FBycPp8LgKvzvc+hez7IbH14Dmygcaf+jVhWx0R2cH wpJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=4A+AOn6eDur2qdmvAOu50KlzBQi3rKdVRpuy1V1tYXg=; fh=DFJk2AGWnaNoivu4MucUSFEp1R3AuOa4WmqOYgIbja4=; b=ExQihhCw6unXE9Ybd4jVAVwlgsJlM6fACpAb6j66ptDoN64JY9JQyuy701RTS4fOUR Y96LdXOhtZ/SEnh5VAouR+791NR5UloiiaWdTTROWrk5KQIPHdTQL7o8jVJZAWyPGf0C REw2Zy9g1jLnJfcARJ1uqcKEuBr5tktivBdStn8mPxjJ1eHhVSyJIrqVEO05DUjbO1zq G72mC9+DkCUcBpWAhX7suoI3iIhlN6JqFThSpJv+9xLFik0ujXe9dsuQkAEizR8V3ihe Ftz3FnqqbSxNHs9xVGrE7j9CgvVYvcflrlDCtesNVL8nkLu31ysOgomz5XQ9lMwGbgvR hyWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B9todMOz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id f20-20020aa782d4000000b0069014d63f21si1529349pfn.148.2023.10.05.08.59.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 08:59:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B9todMOz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id D331D8354400; Thu, 5 Oct 2023 08:59:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236620AbjJEP6h (ORCPT + 99 others); Thu, 5 Oct 2023 11:58:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234383AbjJEP4o (ORCPT ); Thu, 5 Oct 2023 11:56:44 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BA964ED1; Thu, 5 Oct 2023 06:52:31 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58683C4AF6C; Thu, 5 Oct 2023 13:36:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696512998; bh=sVHgjs6j2i0PqaWsD1fHp1pWIXfooJQLvDVkOSizDRo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=B9todMOzpojr4eNnVkY1o+43vbZ0Ou5vRXv4rFd2b8w/37BOQaJk97eggchBkCC19 UN+L5Gt0jHx9w8YgUI8f3q2g5RX1WMn5gjL1VAiiBmtb+Db1CqxrN9OWsixX+8txSq gFs4hXcYCkba1IkaJLzxcNWyw2uWtAVsMjzOrD4AaAFBdqvL4FKmXzFadFQ+hZeOZ+ uugzOSLPuZOosiCIKjjYUwsCefhTmGaNOi2ZpZ9O14Lwyj4YkwxDYm5s20+SNcTguT 1+RpOLM2U2qshZExjYBnizARZvVb7AYTpDvPhPNVwS/hdZ5lmrf5vGLzy+0RMfxGwi II3IoEvqllq8g== Date: Thu, 5 Oct 2023 15:36:33 +0200 From: Simon Horman To: =?utf-8?B?S8O2cnk=?= Maincent Cc: Michal Kubecek , "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Maxime Chevallier , stable@vger.kernel.org, thomas.petazzoni@bootlin.com, Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: Re: [PATCH net 1/1] ethtool: Fix mod state of verbose no_mask bitset Message-ID: References: <20231003085653.3104411-1-kory.maincent@bootlin.com> <20231005100349.113f3bf1@kmaincent-XPS-13-7390> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231005100349.113f3bf1@kmaincent-XPS-13-7390> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 05 Oct 2023 08:59:11 -0700 (PDT) On Thu, Oct 05, 2023 at 10:03:49AM +0200, Köry Maincent wrote: > Hello Simon, > > Thank for your review. > > On Wed, 4 Oct 2023 13:07:14 +0200 > Simon Horman wrote: > > > On Tue, Oct 03, 2023 at 10:56:52AM +0200, Köry Maincent wrote: > > > From: Kory Maincent > > > > > @@ -448,8 +450,11 @@ ethnl_update_bitset32_verbose(u32 *bitmap, unsigned > > > int nbits, } > > > > > > no_mask = tb[ETHTOOL_A_BITSET_NOMASK]; > > > - if (no_mask) > > > - ethnl_bitmap32_clear(bitmap, 0, nbits, mod); > > > + if (no_mask) { > > > + tmp = kcalloc(nbits, sizeof(u32), GFP_KERNEL); > > > + memcpy(tmp, bitmap, nbits); > > > > Hi Köry, > > > > I'm no expert on etnhl bitmaps. But the above doesn't seem correct to me. > > Given that sizeof(u32) == 4: > > > > * The allocation is for nbits * 4 bytes > > * The copy is for its for nbits bytes > > * I believe that bitmap contains space for the value followed by a mask. > > So it seems to me the size of bitmap, in words, is > > DIV_ROUND_UP(nbits, 32) * 2 > > And in bytes: DIV_ROUND_UP(nbits, 32) * 16 > > But perhaps only half is needed if only the value part of tmp is used. > > > > If I'm on the right track here I'd suggest helpers might be in order. > > You are right I should use the same alloc as ethnl_update_bitset with tmp > instead of bitmap32: > > u32 small_bitmap32[ETHNL_SMALL_BITMAP_WORDS]; > u32 *bitmap32 = small_bitmap32; > if (nbits > ETHNL_SMALL_BITMAP_BITS) { > unsigned int dst_words = DIV_ROUND_UP(nbits, 32); > > bitmap32 = kmalloc_array(dst_words, sizeof(u32), GFP_KERNEL); > if (!bitmap32) > return -ENOMEM; > } > > But I am still wondering if it needs to be double as you said for the size of > the value followed by the mask. Not sure about it, as ethnl_update_bitset does > not do it. If you only need the value, then I don' think you need to x2 the allocation. But I could be wrong.