From patchwork Thu Oct 13 23:43:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 2446 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp534437wrs; Thu, 13 Oct 2022 16:56:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6+tgAHAl44UB8ZlrIy4oQPa9PgUldhBnhbaDijZCu0ILmu6pMZMhncPwEuP3og4C6UzIFl X-Received: by 2002:a05:6402:524a:b0:45c:e2c6:6ef7 with SMTP id t10-20020a056402524a00b0045ce2c66ef7mr1875279edd.421.1665705401923; Thu, 13 Oct 2022 16:56:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665705401; cv=none; d=google.com; s=arc-20160816; b=vhBlefVff0JWjTGHAKnWNwL1UeCF7rtutWfz6HY+p/J22J6PkmrA+WeJK8SPzcNb3M n2ue4AteHPfEDQ/JMBnJvvQGyxrx8Do1/76kUriJaMjuxaVgBQIenwLUX53nyneE9q1n Q3hRKVYQfLu0gusRrg3EnpHR1KmR322rCnykNU0pnUAnMsrcPTKPWBB6WuPiAoVXMOke whZMKTPAceJm6VrHuXgizCOGRbNuxEmxZs/pawOH6SdYA1Ubxs2B/YQMy9sTDz2DE2P8 ZjFj3+lbO3+1XnEJhjDjscx8Vw79Kp3tYEQKZZO1IsR2eof4c9hxH8Pg54GtqVJN62O+ gTnA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=G18TrD4h2uU6xMEPcn2BmBrOSK5xUMCgwUorehbNn3E=; b=tdt59guLdeOWsjGxOWGjcNRbKVjAiRzjEnrhCvdcP2nybez1hvF7ApAbglYUO00AAC xmHjxKKPQwAdlzRkJiHQO6eWx1wiSUTSioPpYikq3dS1YrEEc+nlyLsNJ/55y+pqhxVp QgCA1jVX284Pw7+AQaufQauvgk9JGOxMBVcdlQzwQXtGLKTYX7v/AHjsQpr+YobSjGpq SHgzI+u9vX88dT0Do+G+2zBd7OAOKQxJuYk9i7E8M2jy3jgJcoT/5Uhojo/Lakmo2Rd7 K+IZO/pY0vrho6eWA6M0vZWGcvDsP7Ow8Ce9avRdXvbcfTnGjSDdx/+codefll6f7LSf 1IqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hV7m+Nkb; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id du16-20020a17090772d000b0078d2d7c0904si1005978ejc.903.2022.10.13.16.56.16; Thu, 13 Oct 2022 16:56:41 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hV7m+Nkb; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229783AbiJMXn6 (ORCPT + 99 others); Thu, 13 Oct 2022 19:43:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229567AbiJMXnx (ORCPT ); Thu, 13 Oct 2022 19:43:53 -0400 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5F4018C432; Thu, 13 Oct 2022 16:43:52 -0700 (PDT) Received: by mail-qt1-x82c.google.com with SMTP id s3so2747816qtn.12; Thu, 13 Oct 2022 16:43:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=G18TrD4h2uU6xMEPcn2BmBrOSK5xUMCgwUorehbNn3E=; b=hV7m+NkbyGPgklf1+F/DT1pwowFUEIzGPV+HojphrU4JWEjDGD77e3CsoEfEsEGpD3 sGMgx0IUVx48mJwTNlN9xSwqnLG/YgHLLNgkpkKjlvkBP1UzcVx9yn/Niu3xCzFo6k+9 FR/ZKm9Ks+ycqm6iSlE4yWFmzBTTdSr0FI/B2CAqdQGBpZ3CgApBQbbBd4c0OeFS+ZgN lmmk0Jv/294mbF08MjFXuMNrPqvR283fWg58K2IgwilDxCdWIvWYoL3C3VMTQVC0/Lcd rV5lwKq9Db87iL/DplecX/Dz9fd8H4sgL85ks0oOwh8XrWeguXT6zNqfVDK7Dbvze5c0 EjaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G18TrD4h2uU6xMEPcn2BmBrOSK5xUMCgwUorehbNn3E=; b=4xCkm0B+kY5UUz02lY58D0aF5H9OjjLOBQeuhGUFPWjXgGvDSgHA3Zw08X8tbUDAA+ XM4gkNMoGqmRRUqQJ2KnMEQg92N2UMp5UDEMqPzfe5U03q+wQWlpB7iie6eys5VcqfbL TAx6AQ9qzQM+ZUsNMN6r0KFORFtNoxBHBCTxLZxWrk9A003PJjhj831nam1FZUOsKEcp M5zwhARk2loyWBJPP4WbaSijOO0VgFiAPAOVBtUJt9JV1bO2hxbooScLz3z2o08wV/L7 /h2C1Nae+rjGs9ZyE9zHKmhKLxtAzPeuA/8d2Tgo6nn4mxZlaROsgSmGbxKqPHorC2AF 8Idg== X-Gm-Message-State: ACrzQf22yKEczTthuYLgpe/EEcsgRXen5zteUUhOntjP7BB82mfDim9Z EInLhfE8FCe8/eqnFz5AkVdWBnG1jVI= X-Received: by 2002:a05:622a:10a:b0:39c:c4fd:4c6e with SMTP id u10-20020a05622a010a00b0039cc4fd4c6emr2032962qtw.441.1665704631669; Thu, 13 Oct 2022 16:43:51 -0700 (PDT) Received: from localhost ([2601:4c1:c100:2270:ec49:7545:4026:a70a]) by smtp.gmail.com with ESMTPSA id o16-20020a05620a2a1000b006e6a7c2a269sm1106212qkp.22.2022.10.13.16.43.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 16:43:51 -0700 (PDT) From: Yury Norov To: netdev@vger.kernel.org, "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Sebastian Andrzej Siewior , Menglong Dong , Kuniyuki Iwashima , Petr Machata , Guo Ren , "Michael S . Tsirkin" Cc: Yury Norov , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/4] net: move setup code out of mutex in __netif_set_xps_queue() Date: Thu, 13 Oct 2022 16:43:45 -0700 Message-Id: <20221013234349.1165689-2-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221013234349.1165689-1-yury.norov@gmail.com> References: <20221013234349.1165689-1-yury.norov@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746618707936031142?= X-GMAIL-MSGID: =?utf-8?q?1746618707936031142?= maps_sz, nr_ids and online_mask may be set out of the mutex. Signed-off-by: Yury Norov --- net/core/dev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index fa53830d0683..70fa12c6551c 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2563,9 +2563,6 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask, return -EINVAL; } - mutex_lock(&xps_map_mutex); - - dev_maps = xmap_dereference(dev->xps_maps[type]); if (type == XPS_RXQS) { maps_sz = XPS_RXQ_DEV_MAPS_SIZE(num_tc, dev->num_rx_queues); nr_ids = dev->num_rx_queues; @@ -2579,6 +2576,10 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask, if (maps_sz < L1_CACHE_BYTES) maps_sz = L1_CACHE_BYTES; + mutex_lock(&xps_map_mutex); + + dev_maps = xmap_dereference(dev->xps_maps[type]); + /* The old dev_maps could be larger or smaller than the one we're * setting up now, as dev->num_tc or nr_ids could have been updated in * between. We could try to be smart, but let's be safe instead and only From patchwork Thu Oct 13 23:43:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 2443 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp533951wrs; Thu, 13 Oct 2022 16:54:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM48iShUCK6PeUqjKE96KdtKEF8iQpO3gtX0zyQgMNbR9gv9KKWipydj2JW8u3BHuSAC3zVc X-Received: by 2002:a17:907:31c7:b0:740:e3e5:c025 with SMTP id xf7-20020a17090731c700b00740e3e5c025mr1558329ejb.341.1665705292568; Thu, 13 Oct 2022 16:54:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665705292; cv=none; d=google.com; s=arc-20160816; b=D8/dCddLEjkz7kbw8ICET/9magw+fcJliuGWq+kHWUvPbqdqS/+sL5Px63jek7ph7B yTnSdJcY3oz9bEne+QnGnppkXpAgMSfg+W5qmj/HKcNc0L/fgVIGZSW5+RzC6WVw98fV s8RdVW2QHft1+jGYhF7Gi/zJrushWtCH63hW2mF1JXyEB+2Tsjl+18GuoFScMPbmJ/Hd gCEKGaO+8gmo0hfmUV4g7VYZBUFO8WJ7jjAjZj/FZFruM7DyE28MCbMoR8eLjCewFkfq 9So2+7Oojh4CHm5NeJUXQzi9rL0S9bDmiXjBDXwdzoKGOrQL51LQiTusVRjLK+MPtNYl wi6w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZQAqY2iBEAF+eHjrg4p1Q7JBNhxxMmTUjqoLxsrSWas=; b=IJW9eAXknNlHtpvdWXp43DBta3LNbOkzoOcGgLtGO6hlOG1BrwzMFBhyLvVOLBpXc0 mZgsaIcVLgFCLk0S8erlFs3ndXUX9P+MauWawoq+Gi6mHi6w4Y7GxKSPARt/WaLkwWOI x2AtNXzTmqgDcjTDo+NkRlKP8MEhFWF2gAmMJ2DIsDWqvKYfJB5NWrLKVT4Fs46eNLJo iZR3qTr9aLALoCaEn0Fuao//ueMmTbkoGTxsJvZEwwIVBMZ6NuQ78w9u19j7VobmJ4eL xeTHMUTMc581Nqdq4RoKO/MO5EGWp6/AKVTukfwaMi6ZRpG7gflE0RF1U08w6a6bDDeJ zghA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aznCgpDP; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg12-20020a170907970c00b00781a47397b1si970169ejc.502.2022.10.13.16.54.27; Thu, 13 Oct 2022 16:54: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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aznCgpDP; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229823AbiJMXoE (ORCPT + 99 others); Thu, 13 Oct 2022 19:44:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbiJMXny (ORCPT ); Thu, 13 Oct 2022 19:43:54 -0400 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BF1D18C420; Thu, 13 Oct 2022 16:43:53 -0700 (PDT) Received: by mail-qv1-xf30.google.com with SMTP id i9so2334046qvo.0; Thu, 13 Oct 2022 16:43:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZQAqY2iBEAF+eHjrg4p1Q7JBNhxxMmTUjqoLxsrSWas=; b=aznCgpDPTh35a7GcoUgO1SyOcJ08mbe2AMMouLB+ymCrGnO2LK3l8RLG3Jne2HwKem 1/EH6fj8XeH6BqxSWclUUusYc5WaTd5wmEuEM49rJn7XVnpdRilUcejawkOQjCNmnZHz 9KC7VTcXx5o+tBja51juWpavfI1qptDviM/Ou73nCyTX0hCjyB6feboCr+cpJoMcAhkz qQORGbNEF+sHddZd+7+JBDHLZqIa5KcWJbX6sx4oEwnaG1u9xQfWRYy4ksKQojazOoNj Wx5RQpVA8NEPqY3DCghc4Gvo/gBVUv6dqDy3kcptztvxORbtJxF8yuS5bSjBeWaAh09e rrhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZQAqY2iBEAF+eHjrg4p1Q7JBNhxxMmTUjqoLxsrSWas=; b=RvICdhfPbh78lYX0FoHuvPV9aqrSyxpSCnPnyvnGPMYKAV3fUF45/XlUAxuq+X8r2e 7IJ93s2AWuyNeinT37v9vXOz5fVjZkGu/0SCkTRu/2rx9HVEj6HRJ3+pHuYNvSo+0sjX bxcl+IwbFN1i/UMMLcy9aTnVV4u+RTraQ51Cawr9h7yxFC5ALM2ag0+jrNNkyUdPSHWo azYjYa2gHtYZBwmLVP3SZWSx1++3t6dVVsxxweNlK7NGcPPSONtpxeCBwDGf7HSnjE9n 6D8u18Uork4T+WAAFN7czIsT/Qt77310v9e/cVMozBcE0cL0X4sTF+fqrU2GAKZ5q760 7F3w== X-Gm-Message-State: ACrzQf35CinxiFQbCXQeivHeyiD1grORRMUHlBv5aBbeooUSf/rP6l2m H8kD0N+RPbiIDztDCYOjk2y9M9N4RNI= X-Received: by 2002:a05:6214:1c47:b0:4b1:8ee7:9fb0 with SMTP id if7-20020a0562141c4700b004b18ee79fb0mr2228838qvb.42.1665704632492; Thu, 13 Oct 2022 16:43:52 -0700 (PDT) Received: from localhost ([2601:4c1:c100:2270:ec49:7545:4026:a70a]) by smtp.gmail.com with ESMTPSA id y11-20020ac8524b000000b0039bde72b14asm876687qtn.92.2022.10.13.16.43.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 16:43:52 -0700 (PDT) From: Yury Norov To: netdev@vger.kernel.org, "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Sebastian Andrzej Siewior , Menglong Dong , Kuniyuki Iwashima , Petr Machata , Guo Ren , "Michael S . Tsirkin" Cc: Yury Norov , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] net: merge XPS_CPU_DEV_MAPS_SIZE and XPS_RXQ_DEV_MAPS_SIZE macros Date: Thu, 13 Oct 2022 16:43:46 -0700 Message-Id: <20221013234349.1165689-3-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221013234349.1165689-1-yury.norov@gmail.com> References: <20221013234349.1165689-1-yury.norov@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746618592829264345?= X-GMAIL-MSGID: =?utf-8?q?1746618592829264345?= The macros are used in a single place, and merging them would simplify the code. Signed-off-by: Yury Norov --- include/linux/netdevice.h | 7 ++----- net/core/dev.c | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index a36edb0ec199..53d738f66159 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -825,11 +825,8 @@ struct xps_dev_maps { struct xps_map __rcu *attr_map[]; /* Either CPUs map or RXQs map */ }; -#define XPS_CPU_DEV_MAPS_SIZE(_tcs) (sizeof(struct xps_dev_maps) + \ - (nr_cpu_ids * (_tcs) * sizeof(struct xps_map *))) - -#define XPS_RXQ_DEV_MAPS_SIZE(_tcs, _rxqs) (sizeof(struct xps_dev_maps) +\ - (_rxqs * (_tcs) * sizeof(struct xps_map *))) +#define XPS_DEV_MAPS_SIZE(_tcs, nr) (sizeof(struct xps_dev_maps) +\ + ((nr) * (_tcs) * sizeof(struct xps_map *))) #endif /* CONFIG_XPS */ diff --git a/net/core/dev.c b/net/core/dev.c index 70fa12c6551c..9dc6fcb0d48a 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2564,15 +2564,14 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask, } if (type == XPS_RXQS) { - maps_sz = XPS_RXQ_DEV_MAPS_SIZE(num_tc, dev->num_rx_queues); nr_ids = dev->num_rx_queues; } else { - maps_sz = XPS_CPU_DEV_MAPS_SIZE(num_tc); if (num_possible_cpus() > 1) online_mask = cpumask_bits(cpu_online_mask); nr_ids = nr_cpu_ids; } + maps_sz = XPS_DEV_MAPS_SIZE(num_tc, nr_ids); if (maps_sz < L1_CACHE_BYTES) maps_sz = L1_CACHE_BYTES; From patchwork Thu Oct 13 23:43:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 2444 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp534205wrs; Thu, 13 Oct 2022 16:55:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6T5HTIPP2EEMCxu8Dz1v8w+29JfIZIVpNSyCXgyoJ7Oy99l1F1grRi1kN7OFwH0NsV/cP+ X-Received: by 2002:a17:902:8bc1:b0:17a:a61:ce68 with SMTP id r1-20020a1709028bc100b0017a0a61ce68mr2226937plo.66.1665705346280; Thu, 13 Oct 2022 16:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665705346; cv=none; d=google.com; s=arc-20160816; b=YQtqkaMaS4/by80j1ZedyZHrbeg1YE5ffqE+Vsw2dCOm1N9mM3m1SwrXxfGBW4NzdJ u9S4p1KzB4TlcgZKCZb4PiN0Ou5FOm/dg5u9ZbyMgMEwxknxaRuwfadTfUWYbWXX22aO sdXrKmsZaBek08rRZ+RKu5X96Z8qsK4cKlDZzvPLXu5ZHOdd+AlShAadPqKFOoJDDvfK PzO1ih5gMgrPuLmveKJCCb5QGH+48KiZD3DXIzSeuzgr66VeIZe74NZQbvsomecsfaQu hzSVn5Ag4ypxBNLKjWRSzrbKrghXL4VPRXcwgWZgVGEFMQ03syv3cYtJWkcd65RTQuS5 wCEw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kwG+9wq4H/ajQFHnHol/XkFDuB13Bjyau0OIo4dYrHg=; b=eqWOK5mQhsJDvjnNQTCQZQFLifGoI8HoXLibmhr6yAG0aKp0Y+ukv+PoW6Z73cGYSl ReERhMOHNqSsbY3XrE1U/uPNr2IC+xEUxvr8xIEXMAtzcmM/yAQsit++uPD6uUBaCV/f ZNqht9XMMbffAXRZStpIU1A0sxUYeLbSQeOO4CEllDU2fgE9H9wITAfrifBm0/4ZMd+g ZkcX+PTsnVtVgTCt6mInGsSBTa7SMGKUoHg0wilWB4AxAoYYfQYSOt2wobdMKJ70XInA 6imitHfM6Ox8TBWHYFrfbu2DHOcyNFMWxvyqTJbxVlcNVaUuWu7SpUwRwugHphvb9Y2B 1MQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=CMIHpFdU; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v71-20020a63894a000000b0046040a8c036si792016pgd.804.2022.10.13.16.55.33; Thu, 13 Oct 2022 16:55:46 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=CMIHpFdU; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229829AbiJMXoI (ORCPT + 99 others); Thu, 13 Oct 2022 19:44:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229661AbiJMXnz (ORCPT ); Thu, 13 Oct 2022 19:43:55 -0400 Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DA0818C434; Thu, 13 Oct 2022 16:43:54 -0700 (PDT) Received: by mail-qv1-xf31.google.com with SMTP id i9so2334060qvo.0; Thu, 13 Oct 2022 16:43:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kwG+9wq4H/ajQFHnHol/XkFDuB13Bjyau0OIo4dYrHg=; b=CMIHpFdUR5W6pPnxGWURT78iCHQoH6PUNtbjbZYwupfb38uVFND/cuhtNztdDo8kJ4 +5D0M69jODJpBkPsZs6GC0ChV6mzglk9MdkVdqjs2iMUSgqrpRrRk/0EnyfulQtqBUrK 4gBvyNT+XTNha8hIp9vT+Jwl0gcl23OEymTG2vp+wQF3tC3HC/tYLMGT7FKmhxSz+s3R 9LxTdZU0pFCkF+V/ymL3HomjKs3d9hLWBAeUx70yp2EUKZTlvfAdyLKFRi4snRMUzq07 ArWW15Y43sDZGFzCG1KpW5F0pzOWQHazvSmFebjutnHNwIggm/uJ6Q4LNyze8keS1IWK mNzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kwG+9wq4H/ajQFHnHol/XkFDuB13Bjyau0OIo4dYrHg=; b=ayhZ5WynPYwXRXwbU173SGbOGOJS3y5SNVHw6r8/FIByydoHf/m71gaF4i7ietccKa 945Y/A9aie2Josc2wBDZw+YnfcZobPnLyKRzSphmsF83fcMFt9P8Z9OWYNZ7a9+gRtag eDFIgtDVhZ6ojt3fPVVkeb1BIfnDLxDVptsNtRaLDbH/Nr2Ke5Dv9I2yQPFo04jC0cQR c4LwhQIYV/Wk3fVg4BD1tA+LUjthVvB1yLctiqf8P5SjvFAt15Fvp75A6mHdIDSNL3jY nooaGtitK+uMZ2GUSGvnqUIoJ07aux0OL8+KT5dhIcQzZGkvFvfX0nwgOkVUR6KqSsyP 0T6A== X-Gm-Message-State: ACrzQf0Xq4eHxk7j9DTFd96LwlnTpKPWWf1Svf3/n3FxDQLh0C+BHcpw VAxr85nnNtgxkTlCwNaOhEz3nEu5lcM= X-Received: by 2002:ad4:5dee:0:b0:4b4:b8a:78db with SMTP id jn14-20020ad45dee000000b004b40b8a78dbmr1976060qvb.12.1665704633224; Thu, 13 Oct 2022 16:43:53 -0700 (PDT) Received: from localhost ([2601:4c1:c100:2270:ec49:7545:4026:a70a]) by smtp.gmail.com with ESMTPSA id x5-20020ac84a05000000b0039a08c0a594sm952928qtq.82.2022.10.13.16.43.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 16:43:53 -0700 (PDT) From: Yury Norov To: netdev@vger.kernel.org, "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Sebastian Andrzej Siewior , Menglong Dong , Kuniyuki Iwashima , Petr Machata , Guo Ren , "Michael S . Tsirkin" Cc: Yury Norov , linux-kernel@vger.kernel.org Subject: [PATCH v2 3/4] net: initialize online_mask unconditionally in __netif_set_xps_queue() Date: Thu, 13 Oct 2022 16:43:47 -0700 Message-Id: <20221013234349.1165689-4-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221013234349.1165689-1-yury.norov@gmail.com> References: <20221013234349.1165689-1-yury.norov@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746618649328745888?= X-GMAIL-MSGID: =?utf-8?q?1746618649328745888?= If the mask is initialized unconditionally, it's possible to use bitmap API to traverse it, which is done in the following patch. Signed-off-by: Yury Norov --- net/core/dev.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 9dc6fcb0d48a..8049e2ff11a5 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2542,7 +2542,7 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask, u16 index, enum xps_map_type type) { struct xps_dev_maps *dev_maps, *new_dev_maps = NULL, *old_dev_maps = NULL; - const unsigned long *online_mask = NULL; + const unsigned long *online_mask; bool active = false, copy = false; int i, j, tci, numa_node_id = -2; int maps_sz, num_tc = 1, tc = 0; @@ -2565,9 +2565,12 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask, if (type == XPS_RXQS) { nr_ids = dev->num_rx_queues; + online_mask = bitmap_alloc(nr_ids, GFP_KERNEL); + if (!online_mask) + return -ENOMEM; + bitmap_fill(online_mask, nr_ids); } else { - if (num_possible_cpus() > 1) - online_mask = cpumask_bits(cpu_online_mask); + online_mask = cpumask_bits(cpu_online_mask); nr_ids = nr_cpu_ids; } @@ -2593,10 +2596,8 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask, j < nr_ids;) { if (!new_dev_maps) { new_dev_maps = kzalloc(maps_sz, GFP_KERNEL); - if (!new_dev_maps) { - mutex_unlock(&xps_map_mutex); - return -ENOMEM; - } + if (!new_dev_maps) + goto err_out; new_dev_maps->nr_ids = nr_ids; new_dev_maps->num_tc = num_tc; @@ -2718,7 +2719,8 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask, out_no_maps: mutex_unlock(&xps_map_mutex); - + if (type == XPS_RXQS) + bitmap_free(online_mask); return 0; error: /* remove any maps that we added */ @@ -2733,8 +2735,10 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask, } } +err_out: mutex_unlock(&xps_map_mutex); - + if (type == XPS_RXQS) + bitmap_free(online_mask); kfree(new_dev_maps); return -ENOMEM; } From patchwork Thu Oct 13 23:43:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 2445 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp534302wrs; Thu, 13 Oct 2022 16:56:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4vV96387Fey176AL6X4//aao5aKBTRlYfjqUUqknkvjtzlqtJ2HSc338Sr0QQYZRxjVhAy X-Received: by 2002:a17:906:844c:b0:78d:ce8f:fc81 with SMTP id e12-20020a170906844c00b0078dce8ffc81mr1617211ejy.128.1665705369710; Thu, 13 Oct 2022 16:56:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665705369; cv=none; d=google.com; s=arc-20160816; b=tCj+avgwT1EI+yawHkwRwmzy10RabP3FidOFDbqOOQHd3S7ti7IiVxZt0tUY8nlIx0 aG43coTGWfL7fvf4tw9T9n5UwvTSvUmWj7DPoQQJifed1lCIElZDYK1x2oelK6m57b9I CNGropm0dQm+CcDBMc6bTI2IIxTjF1IJcfqi2IEAj3KQgsQXjDFV9zw2etwDGd97S2AT +qsfaUoAn1EsCjWGg+LDG5P7Bj7hbtdGhhvGqSE7yKBbaEd0TiwcFbFYOwzJTQgKYqHL 52sS285QTp3FFMZi0FRuQUIaAi83CURtMipWK9fihCwEV4zcR/XmKDqqmsSM2jUAK09U ouaA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/YPjj/+mYMhRlZ2E9EjM0QB8fHYgSe8UWol/kOphzlw=; b=BfbBViOsaJ/ODbuFzD2ef2hGm56qakTX58i+QPjbUHvo8ymUvKxDueS1Zgahd+/d8W PwaxiEhu6hpOWcXSfBZ8b6zL304td1iMsXNM3nOhStwIY6xb8kIRrjV8hTVkUJopAoFp DItK0F7CDfefYR4hYw8y2u89ATg3xkpZ6+KeBWTu1m7RaqD/H6L1rcOsPKnO4hZpo9OZ MewmqtASqsO5IvRJ1+gxsa+rEZ8xFlVQfmMvjdsmiT2gL1k173CTrrwe0doj7D6Wa1+y ejSczNgnocwmMQyK6aRQyDwnX1OQQ371VT/8WX5I5T0UEU+W0mrG/XmXe2oH7mS6zzUu h+Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=O4quyDE2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qb5-20020a1709077e8500b0078cdba56108si970263ejc.296.2022.10.13.16.55.44; Thu, 13 Oct 2022 16:56:09 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=O4quyDE2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229845AbiJMXoK (ORCPT + 99 others); Thu, 13 Oct 2022 19:44:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229727AbiJMXn4 (ORCPT ); Thu, 13 Oct 2022 19:43:56 -0400 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECD0318C43F; Thu, 13 Oct 2022 16:43:54 -0700 (PDT) Received: by mail-qv1-xf2b.google.com with SMTP id de14so2300623qvb.5; Thu, 13 Oct 2022 16:43:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/YPjj/+mYMhRlZ2E9EjM0QB8fHYgSe8UWol/kOphzlw=; b=O4quyDE29K+3M6oNzJuBdcA5bA7uqLpZc9RUDQsHZBKDIkSrlZw4vANQ3w1jDzorpz 7WKe9j3ny5ZwMaJDh4yukguMAjUkF947Hmv26iCLnCcO4j8nXuHr8DrHOH1oOKQhMS71 Ky9CBYJKPchchJjRSZjjcp5pe1nFU7f7jiR9vx9wyqeKbi1hMIIOAHPjDk5/NaOiTPzK Y3rinmaKwkWzuIwwMrNxDmEUjobbXyF3Rf4wdCh8olJeTX5iF1nN1I7zLhcGmgug3DjN DEr7PlRaik7R1GntS6ZtakVVuEUp3GoBLTYjKjZqDHGRnVWPyoWhBZ7N78d/ZR5perIy TfAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/YPjj/+mYMhRlZ2E9EjM0QB8fHYgSe8UWol/kOphzlw=; b=HWJbXT1B9Jz6FNxJ16rW22/r2R8vQ9NOtpfgIu4cVO4MzFSaEIJ0jf5yXgnPDt2f6G Y3vT+pI0e53kZ5T6b0v8tawW+Jg+rq9NWKxftFmDFjrJwQJVTIZwWuC1rfPH43WvQZMW DOrqdaVFKY91xFc5MYyicZXnyqFPrPbR7zRQUmCJSFYujcd049VEVDVUtosx2IxUHFjD kSwWvTOfommq6FNe5PYHAwq3q8q45G48jwAGVoHSAjym4byxYDrw5ZAcpcH/KvDVCuMC 9nJhId+4it7k7FBlI8LJmmoBWYmXNBYAxleYVJqtyP1QuqtKLeIVZnL4wli5rx3gsXon 1Knw== X-Gm-Message-State: ACrzQf2wUuNP4zNiXN6A+fUW81jG9/GDMrgNPzHhAElAUFoSi1mDX0De BC3E5ALpHa5Nuwzh5Ui86N4VDrl0SJg= X-Received: by 2002:a0c:ab12:0:b0:4b1:9467:1948 with SMTP id h18-20020a0cab12000000b004b194671948mr2213318qvb.80.1665704633897; Thu, 13 Oct 2022 16:43:53 -0700 (PDT) Received: from localhost ([2601:4c1:c100:2270:ec49:7545:4026:a70a]) by smtp.gmail.com with ESMTPSA id l4-20020a37f904000000b006ced5d3f921sm925793qkj.52.2022.10.13.16.43.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 16:43:53 -0700 (PDT) From: Yury Norov To: netdev@vger.kernel.org, "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Sebastian Andrzej Siewior , Menglong Dong , Kuniyuki Iwashima , Petr Machata , Guo Ren , "Michael S . Tsirkin" Cc: Yury Norov , linux-kernel@vger.kernel.org Subject: [PATCH v2 4/4] net: fix opencoded for_each_and_bit() in __netif_set_xps_queue() Date: Thu, 13 Oct 2022 16:43:48 -0700 Message-Id: <20221013234349.1165689-5-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221013234349.1165689-1-yury.norov@gmail.com> References: <20221013234349.1165689-1-yury.norov@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746618674051351389?= X-GMAIL-MSGID: =?utf-8?q?1746618674051351389?= Replace opencoded bitmap traversing and drop unused netif_attrmask_next*() functions Signed-off-by: Yury Norov --- include/linux/netdevice.h | 46 --------------------------------------- net/core/dev.c | 3 +-- 2 files changed, 1 insertion(+), 48 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 53d738f66159..5db2b6de7308 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3648,52 +3648,6 @@ static inline bool netif_attr_test_online(unsigned long j, return (j < nr_bits); } - -/** - * netif_attrmask_next - get the next CPU/Rx queue in a cpu/Rx queues mask - * @n: CPU/Rx queue index - * @srcp: the cpumask/Rx queue mask pointer - * @nr_bits: number of bits in the bitmask - * - * Returns >= nr_bits if no further CPUs/Rx queues set. - */ -static inline unsigned int netif_attrmask_next(int n, const unsigned long *srcp, - unsigned int nr_bits) -{ - /* n is a prior cpu */ - cpu_max_bits_warn(n + 1, nr_bits); - - if (srcp) - return find_next_bit(srcp, nr_bits, n + 1); - - return n + 1; -} - -/** - * netif_attrmask_next_and - get the next CPU/Rx queue in \*src1p & \*src2p - * @n: CPU/Rx queue index - * @src1p: the first CPUs/Rx queues mask pointer - * @src2p: the second CPUs/Rx queues mask pointer - * @nr_bits: number of bits in the bitmask - * - * Returns >= nr_bits if no further CPUs/Rx queues set in both. - */ -static inline int netif_attrmask_next_and(int n, const unsigned long *src1p, - const unsigned long *src2p, - unsigned int nr_bits) -{ - /* n is a prior cpu */ - cpu_max_bits_warn(n + 1, nr_bits); - - if (src1p && src2p) - return find_next_and_bit(src1p, src2p, nr_bits, n + 1); - else if (src1p) - return find_next_bit(src1p, nr_bits, n + 1); - else if (src2p) - return find_next_bit(src2p, nr_bits, n + 1); - - return n + 1; -} #else static inline int netif_set_xps_queue(struct net_device *dev, const struct cpumask *mask, diff --git a/net/core/dev.c b/net/core/dev.c index 8049e2ff11a5..b0fb592d51da 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2592,8 +2592,7 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask, copy = true; /* allocate memory for queue storage */ - for (j = -1; j = netif_attrmask_next_and(j, online_mask, mask, nr_ids), - j < nr_ids;) { + for_each_and_bit(j, online_mask, mask ? : online_mask, nr_ids) { if (!new_dev_maps) { new_dev_maps = kzalloc(maps_sz, GFP_KERNEL); if (!new_dev_maps)