Message ID | 20230913110957.485237-1-andriy.shevchenko@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1093275vqx; Wed, 13 Sep 2023 06:39:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+Efq/mQvyfFsxQ0bnCiY9VpCVwsJVe6+3DQ7XABD6e2NKozC1bckx48nSe24xasyNCPz9 X-Received: by 2002:a05:6870:970c:b0:1c0:d0e8:8ff9 with SMTP id n12-20020a056870970c00b001c0d0e88ff9mr3186606oaq.16.1694612393722; Wed, 13 Sep 2023 06:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694612393; cv=none; d=google.com; s=arc-20160816; b=ibgMgrxodhiEgzLP2fw6W4lAGt1cAMFR5IzM/8Mv4X9FtVVPSNGXAfJcwUFKVXjVJ7 dykCOIBEzVB1M7AKySpX8KyZKJa02OMMXNp1/vRG9BqtW13R4u14axc2Bm8h5aZFPdYi hqXvsGQYQWOkNDytaySHINl0XGFgZI3QYzH77dPtuB3nV1FLYvLDnwE0oTR5aJBNLNbm mp/8S/DRFhN3N+C2NVFSIQkelc3cw/gFb+Bj9o0v3d/GPAIcTQiaTkZkxEVeDvx5HAP+ 5vdx9yun8jKd6eX2vQLOyW0bLb+6LR90wxBFk0xYMZnO/JHFkE5Fb2H9QfcGyPjCFSgM wjoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=mkByeKHrobE0euSKCRy3WU21wvxs+SFOuzrPYHsrB/0=; fh=L3vI1aPamaFMhxAv4NLLkrGRuETD/6PF9MCoTozHY6Y=; b=LraROzpR85tFNyImTtyWHuhK6W12F4SbppaPm4ZzU8AhpgbjjukIJ0frUpWmSLm/qC zKsFD38XZuFNBrtS/HswOYPMEsebl97ycCvRt6sRXAp/T8788IdachvA/CVHTM2XjYn/ HTKY0ktujN4dj4iREbZpvYzT9yYFTulNOTL82Oy91+RBzUkcivNjHOKVluUSHkrLHZOt ykYwVVtkeMhDSxO7aFhWdoTjNLPGERol08ONuTN68CAW3Uu9SBRQgiP8cWY4P34WVtuH 0dCJXL67w/TQIUHiphqatSE5LwhoBev0rvUWYTcUSAvPE4IyFWY8MK4ZC8vpeRxHrCry GsDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lHrL3VeC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id n129-20020a632787000000b00569161a1885si10200728pgn.288.2023.09.13.06.39.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 06:39:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lHrL3VeC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 586C280C65C3; Wed, 13 Sep 2023 04:10:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237605AbjIMLKI (ORCPT <rfc822;pwkd43@gmail.com> + 36 others); Wed, 13 Sep 2023 07:10:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231235AbjIMLKI (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 13 Sep 2023 07:10:08 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BBF719A6; Wed, 13 Sep 2023 04:10:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694603404; x=1726139404; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ibxWhsbZoS6ac7vybC6BlSjsaIyivr2gyS1htHkWXmQ=; b=lHrL3VeCM0czN3vYDt1QoySR0A9SfI284LJwYbMJOYEwKS7xQnObwF2Z wQKmlx93trPBGwzLRE5jhge6BWaS5EyQjA2liltqcLQGFYM0AK7SSS3jO HhJbJNA0DtuScu868p+SpdCYYvMywsk5pBogHXums35bLY2yijQx9fj68 +xSLk+voWrXyIew4KZbI8yTcOIkYkE0fT6cq5vLfzvx6/uL0CFNQK5jJj bu7AEGbvCl/8BBAd9/xbp3V5QiamGUC9Yhmv1sXGZiNipd0u8vuviV6b5 J+q3gPk6rcsbrismZ1XJa43Pc9xBgfjH/fMDSAHsXBr1hb4bQhO2peXZd A==; X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="358899686" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="358899686" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 04:10:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="809639200" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="809639200" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 13 Sep 2023 04:10:01 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id F1D22BC0; Wed, 13 Sep 2023 14:09:59 +0300 (EEST) From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Sergey Ryazanov <ryazanov.s.a@gmail.com>, Simon Horman <horms@kernel.org> Subject: [PATCH v2 1/1] net: core: Use the bitmap API to allocate bitmaps Date: Wed, 13 Sep 2023 14:09:57 +0300 Message-Id: <20230913110957.485237-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 04:10:13 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776929885484458849 X-GMAIL-MSGID: 1776929885484458849 |
Series |
[v2,1/1] net: core: Use the bitmap API to allocate bitmaps
|
|
Commit Message
Andy Shevchenko
Sept. 13, 2023, 11:09 a.m. UTC
Use bitmap_zalloc() and bitmap_free() instead of hand-writing them. It is less verbose and it improves the type checking and semantic. While at it, add missing header inclusion (should be bitops.h, but with the above change it becomes bitmap.h). Suggested-by: Sergey Ryazanov <ryazanov.s.a@gmail.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://lore.kernel.org/r/20230911154534.4174265-1-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- v2: added tags (Simon), sent separately from the series (Paolo) net/core/dev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Comments
On 9/13/23 13:09, Andy Shevchenko wrote: > Use bitmap_zalloc() and bitmap_free() instead of hand-writing them. > It is less verbose and it improves the type checking and semantic. > > While at it, add missing header inclusion (should be bitops.h, > but with the above change it becomes bitmap.h). > > Suggested-by: Sergey Ryazanov <ryazanov.s.a@gmail.com> > Reviewed-by: Simon Horman <horms@kernel.org> > Link: https://lore.kernel.org/r/20230911154534.4174265-1-andriy.shevchenko@linux.intel.com > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > --- > v2: added tags (Simon), sent separately from the series (Paolo) Yeah, in any context it's hard to get people to agree to fix things when they started out of order :~ > net/core/dev.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/net/core/dev.c b/net/core/dev.c > index ccff2b6ef958..85df22f05c38 100644 > --- a/net/core/dev.c > +++ b/net/core/dev.c > @@ -69,7 +69,7 @@ > */ > > #include <linux/uaccess.h> > -#include <linux/bitops.h> > +#include <linux/bitmap.h> > #include <linux/capability.h> > #include <linux/cpu.h> > #include <linux/types.h> > @@ -1080,7 +1080,7 @@ static int __dev_alloc_name(struct net *net, const char *name, char *buf) > return -EINVAL; > > /* Use one page as a bit array of possible slots */ > - inuse = (unsigned long *) get_zeroed_page(GFP_ATOMIC); > + inuse = bitmap_zalloc(max_netdevices, GFP_ATOMIC); > if (!inuse) > return -ENOMEM; > > @@ -1109,7 +1109,7 @@ static int __dev_alloc_name(struct net *net, const char *name, char *buf) > } > > i = find_first_zero_bit(inuse, max_netdevices); > - free_page((unsigned long) inuse); > + bitmap_free(inuse); > } > > snprintf(buf, IFNAMSIZ, name, i); Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Hello: This patch was applied to netdev/net.git (main) by David S. Miller <davem@davemloft.net>: On Wed, 13 Sep 2023 14:09:57 +0300 you wrote: > Use bitmap_zalloc() and bitmap_free() instead of hand-writing them. > It is less verbose and it improves the type checking and semantic. > > While at it, add missing header inclusion (should be bitops.h, > but with the above change it becomes bitmap.h). > > Suggested-by: Sergey Ryazanov <ryazanov.s.a@gmail.com> > Reviewed-by: Simon Horman <horms@kernel.org> > Link: https://lore.kernel.org/r/20230911154534.4174265-1-andriy.shevchenko@linux.intel.com > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > [...] Here is the summary with links: - [v2,1/1] net: core: Use the bitmap API to allocate bitmaps https://git.kernel.org/netdev/net/c/aabb4af9bb29 You are awesome, thank you!
diff --git a/net/core/dev.c b/net/core/dev.c index ccff2b6ef958..85df22f05c38 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -69,7 +69,7 @@ */ #include <linux/uaccess.h> -#include <linux/bitops.h> +#include <linux/bitmap.h> #include <linux/capability.h> #include <linux/cpu.h> #include <linux/types.h> @@ -1080,7 +1080,7 @@ static int __dev_alloc_name(struct net *net, const char *name, char *buf) return -EINVAL; /* Use one page as a bit array of possible slots */ - inuse = (unsigned long *) get_zeroed_page(GFP_ATOMIC); + inuse = bitmap_zalloc(max_netdevices, GFP_ATOMIC); if (!inuse) return -ENOMEM; @@ -1109,7 +1109,7 @@ static int __dev_alloc_name(struct net *net, const char *name, char *buf) } i = find_first_zero_bit(inuse, max_netdevices); - free_page((unsigned long) inuse); + bitmap_free(inuse); } snprintf(buf, IFNAMSIZ, name, i);