From patchwork Sun Oct 2 15:16:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12996854 X-Patchwork-Delegate: kuba@kernel.org 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 A64D8C4332F for ; Sun, 2 Oct 2022 15:17:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229458AbiJBPRM (ORCPT ); Sun, 2 Oct 2022 11:17:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229830AbiJBPRL (ORCPT ); Sun, 2 Oct 2022 11:17:11 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AAB733864; Sun, 2 Oct 2022 08:17:10 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id s9so5436090qkg.4; Sun, 02 Oct 2022 08:17:10 -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; bh=fV1Ona2rkqeX6csTC7RYzdntmz4GfbK8LbfIp3z1Fs8=; b=G/zMplfp0K57ITzf+XaN07ra+ZH4RZPd7WO+CnXqFCTTQjpL5UlSLRhShBj+tnkwRo FE3VkiOiXCvg3FCqVhN1Dvo9VFkbBDSR1OT0xx9iQHU2jUrn7ur+b9etPVAOXt/6QplM /O5ablA+T0kDaB+sMx2xoB6pNolB2ITeayWBHRU2iQmn/qVoXMnSB1btQpcxhVGUIw0M vD2WvRxmw1OWVHV5gRvH1NG+mPkOrq0XREDNqT0+bpPtz/LwyqlV62tFBNxrJtgVJD4/ sWhCXwqzJiclBV2Ybi256f5S/+w0HWc/7Y8D1Mdnw/SHVS46bbQqe8EPAkoHLEPxpvU2 0d2Q== 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; bh=fV1Ona2rkqeX6csTC7RYzdntmz4GfbK8LbfIp3z1Fs8=; b=xOv5T7YBW9JwqzADQ2QQMC0dMrN8aI/9AR3vbzSNlkjhj9Y0EugYOHY8V7dmfDj1K2 9EKN7DHg6ODWpJ8GXcJIcQ45dubHREeQV5uTOql4cDBV/BrZFrDXMPPPPbeuThcR82H6 lr8LcmXJJONlvhn08CazIiiFcXKoJ1uDq8t6cDR5mK5iS5FVCNb5Y3GpIHdFvTUVyOlU YMFr6I1c0sfQVNFlOKx7uIjUkO8rCTMqar9WjsF7EcywSQg70tSaxfuCh8tbC0sF7xU+ e3gGZ8riyDFLNRIBjtZuHRpKc6JrK1xdkztt4cuZedvoS1XeMQMnr27/J59AujAbMlt5 WAkQ== X-Gm-Message-State: ACrzQf3JJfFSODiuIGaS32QZ5MS+m0XFg1CLr0pQzjHu10TszquTuBL9 rOaqO7yDYfdNKDkQbvfdnpPRx7Vv+rw= X-Google-Smtp-Source: AMsMyM4xA5XUE9ryqOCcdY+Mc/qGE6Qf5J1Txjl2rd7wequShwf/kPe8S+zdfbEGEhidQL7Ib638Xg== X-Received: by 2002:a37:e116:0:b0:6cf:4dbd:18f1 with SMTP id c22-20020a37e116000000b006cf4dbd18f1mr11500782qkm.120.1664723829575; Sun, 02 Oct 2022 08:17:09 -0700 (PDT) Received: from localhost ([2601:4c1:c100:2270:ec09:fca7:de7a:72aa]) by smtp.gmail.com with ESMTPSA id q34-20020a05620a2a6200b006b8d1914504sm8865459qkp.22.2022.10.02.08.17.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Oct 2022 08:17:09 -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 , linux-kernel@vger.kernel.org Cc: Yury Norov Subject: [PATCH 1/4] net: move setup code out of mutex in __netif_set_xps_queue() Date: Sun, 2 Oct 2022 08:16:59 -0700 Message-Id: <20221002151702.3932770-2-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221002151702.3932770-1-yury.norov@gmail.com> References: <20221002151702.3932770-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 56c8b0921c9f..b848a75026c4 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 Sun Oct 2 15:17:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12996856 X-Patchwork-Delegate: kuba@kernel.org 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 EF2D3C433FE for ; Sun, 2 Oct 2022 15:17:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229953AbiJBPRX (ORCPT ); Sun, 2 Oct 2022 11:17:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbiJBPRM (ORCPT ); Sun, 2 Oct 2022 11:17:12 -0400 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B991333366; Sun, 2 Oct 2022 08:17:11 -0700 (PDT) Received: by mail-qk1-x72d.google.com with SMTP id i17so5423363qkk.12; Sun, 02 Oct 2022 08:17:11 -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; bh=Cdmdvt4PzUIP4O/wQczynlHDCFpHnvAILdyowmLgLfQ=; b=KE4v1rHkhqaIYZH0QZ8JwRyjiiYgTu/A5lcPsR/qEthJVBUcNJepq24wY+8eCJt6Bi TW/c647QIlbIOVVOrvJTcUdke4iKdqqyIrRSacWwVCmqqQr1Ej4H/da4NXd+pa30FOAT KTsfZ36+Yr/Vwz/T+bRevORqABCI5aZT0PMEDZ/GKstX9uDl5IH5DW9OXzO2HDzIPL2u CXHDV1YOtg/0tvVAYw62J5tF4yALebbJhzm2IEjIT227VflqGI9wAW9r0QHUPYlJWh0D 8ELrjEJGO/XBSAubLZH2iUYFGQmKlfoWEy+4zYyaEQbAioB8qtEWzXi28cB2jKkYsLhW syNQ== 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; bh=Cdmdvt4PzUIP4O/wQczynlHDCFpHnvAILdyowmLgLfQ=; b=KQtG+ELWaALQsBdutv/D+AEuAEadipgaVTyUq7EjwnG+LK+NeoGaFW3U+e1Mb6Guuw k8MhZ+L0MVsPq3UVyXPLEbpPUSVIritLQ2FDILU8FHGqT/EtlfXVdiCAJ8HpijFBPsjI aWBA0MMinXEGlq1GLLyzDB1j+EzMr+jZfd7UKoVp2lmi5pBI0eC51WQa/KKM+pUXPNua v+imSJo2rK1rIl7lTUFakF/KruK7Z1zF/IjtNB2CDvQAQzKv5XwbSWfUVpSp9C1cs533 HVTBuAIK8ZnsgRVOf/8Pz9LOvXkYXu0SQeVglAbGNagQSLMXSybF1djMeOY63EEefb67 ou3g== X-Gm-Message-State: ACrzQf3TWCbuAKujQtV0VjtgKurcX2HNPNApxSnbkscEYi51FfR+eTjg wUztlPacdkZOPXjSPcd5JtssBkaRhn8= X-Google-Smtp-Source: AMsMyM7uqw9j4c0A1Zszx7WqKUWTUZifHxOIE/pSsQn6jKy8zvFgFRgTZbMI+fBWsp3LyRXzQDaakw== X-Received: by 2002:a05:620a:38a:b0:6cd:ecc8:e84 with SMTP id q10-20020a05620a038a00b006cdecc80e84mr11380724qkm.692.1664723830719; Sun, 02 Oct 2022 08:17:10 -0700 (PDT) Received: from localhost ([2601:4c1:c100:2270:ec09:fca7:de7a:72aa]) by smtp.gmail.com with ESMTPSA id z13-20020ac8454d000000b0035a7070e909sm6918358qtn.38.2022.10.02.08.17.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Oct 2022 08:17:10 -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 , linux-kernel@vger.kernel.org Cc: Yury Norov Subject: [PATCH 2/4] net: merge XPS_CPU_DEV_MAPS_SIZE and XPS_RXQ_DEV_MAPS_SIZE macros Date: Sun, 2 Oct 2022 08:17:00 -0700 Message-Id: <20221002151702.3932770-3-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221002151702.3932770-1-yury.norov@gmail.com> References: <20221002151702.3932770-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 4d6d5a2dd82e..6f8cdd5c7908 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -819,11 +819,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 b848a75026c4..39a4cc7b3a06 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 Sun Oct 2 15:17:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12996855 X-Patchwork-Delegate: kuba@kernel.org 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 115F1C433F5 for ; Sun, 2 Oct 2022 15:17:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229939AbiJBPRV (ORCPT ); Sun, 2 Oct 2022 11:17:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229820AbiJBPRN (ORCPT ); Sun, 2 Oct 2022 11:17:13 -0400 Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF5F433A2C; Sun, 2 Oct 2022 08:17:12 -0700 (PDT) Received: by mail-qk1-x732.google.com with SMTP id d17so5416950qko.13; Sun, 02 Oct 2022 08:17:12 -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; bh=v6a6DRCa6+7GM1dDKtrznVaScx2fxL9jqYJ4uc5IddA=; b=RcWIsHwbHxpmzTE+KuiP/b0RY9NMf27VkavA4Rv3fr7af1bLt5nBX2fG7uZZ15qaO/ O1ZkGZHqy4Ae6CdCkkLlWDTyyvBylKcAJRs7Q+TJByCBusNaEJXxkGqw3FZFX9SmuGkb RbXHq+AkRaxz1JN7F5QHqCncmclDeX9qHKdTWTu40qX6WkRXFktVxky0xbCPuDpJ/bLD vHspnAez93fmMLhhbBK7E+SQGRwbSheChk+jEGqU1nzLGNPUOV3015O6yABgzseD8//g nbsHNNSd72NKuTXR5R7sTe8DUROVbzrLu4+L58UWG9siriLyY/JcPr9xC5mgUbY+jRjC j+oA== 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; bh=v6a6DRCa6+7GM1dDKtrznVaScx2fxL9jqYJ4uc5IddA=; b=Ekb6W8IvXmeIjXcA3NFyT5xJQVDgryUKXyRwcD0+KEzpoyen979LJpPzYvtIFr9Svt sMUBzS3v7FTFJCAbsaBu3des91xIqKNo6KTzbZAlJVJ66NeOleOGKYz7kspxhC9UoY7A g3HPTyg+k4PzQn9pc3kamUOYfV98ffkx8wB2GgVo3WTQIZBijyQUPOwoUdsIPUxz34Ho Tg7x0jtztR3tk9ikcl7+lKhWFdlM1J93TQU6aoQzqtACl1LNJ4J2vVnYl0T8JzmaYhLs RT5qPNyj0EGtq5WvVQfI4ZjU8MSshP7nGgDM255/rRcoTjf03LUUTH5QTzpZLroIPd7X FYMg== X-Gm-Message-State: ACrzQf08FnlqzI+OQ3EriVSwtULXNJEobu+GaQalr8uqehBIhFXhz2uM TiyI0rkTcS9q14gua8BKa3g31DirZZk= X-Google-Smtp-Source: AMsMyM41WmNcD7britNlLCIoBnkou7CqstNQEqZR7Erqo+NgLl9MMqhqml4WA++cSo+kr92o0Vufqg== X-Received: by 2002:a05:620a:4143:b0:6ce:87a7:77cb with SMTP id k3-20020a05620a414300b006ce87a777cbmr11715660qko.230.1664723831746; Sun, 02 Oct 2022 08:17:11 -0700 (PDT) Received: from localhost ([2601:4c1:c100:2270:ec09:fca7:de7a:72aa]) by smtp.gmail.com with ESMTPSA id fc20-20020a05622a489400b00346414a0ca1sm7263250qtb.1.2022.10.02.08.17.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Oct 2022 08:17:11 -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 , linux-kernel@vger.kernel.org Cc: Yury Norov Subject: [PATCH 3/4] net: initialize online_mask unconditionally in __netif_set_xps_queue() Date: Sun, 2 Oct 2022 08:17:01 -0700 Message-Id: <20221002151702.3932770-4-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221002151702.3932770-1-yury.norov@gmail.com> References: <20221002151702.3932770-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 39a4cc7b3a06..266378ad1cf1 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,11 @@ 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; } 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 +2595,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 +2718,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 +2734,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 Sun Oct 2 15:17:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12996857 X-Patchwork-Delegate: kuba@kernel.org 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 1CF34C433F5 for ; Sun, 2 Oct 2022 15:17:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229961AbiJBPRZ (ORCPT ); Sun, 2 Oct 2022 11:17:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229904AbiJBPRO (ORCPT ); Sun, 2 Oct 2022 11:17:14 -0400 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C823133A32; Sun, 2 Oct 2022 08:17:13 -0700 (PDT) Received: by mail-qv1-xf33.google.com with SMTP id i9so2194927qvu.1; Sun, 02 Oct 2022 08:17:13 -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; bh=yU9cN/+uqBVB1dXNbr75Y5YkzMpkVLSP66bVAusnii4=; b=PopAKlMxrvfPEOuH+8QT8WPKSRyja9JPsjHnQA0hhfoXJUTyAApAcWsDMQvMqwWYPJ t0e9kf6zJFRH+bd7E6w89ouvhY7buL14A/Wxvrzk1S6MOw41Tpe9tW7NgHfGCVy5OlW0 rNg5tMHZpkeIhdLf8zKf2HIVKewbtp/Upfv/rKpLLCGlL/Y879jHJtMTXgQNVvzyGEeN +HKfYOuw/uUX3nJ1HtYKqv6IbV5kwlZY+IjB5vf3Tc0CSI4xv8kT9FvEu/OeOcs1h+q2 4WH+PZNAxoNEUkPggqkDzyenUvY+JP7rzJMz2L2wuwcbPykMLY1uIfEfBqZPMDpfP2+M B/ig== 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; bh=yU9cN/+uqBVB1dXNbr75Y5YkzMpkVLSP66bVAusnii4=; b=RFll5UPjFmPRWiJoFBy9NEpVGpL5c6qQTcA9aGAS3/GRFhWPYqxOor+/RoS+JekZDZ AI38LQFePw9VAL8Lvk31FmrOiBnqbpGY9DScW2UIF1VR0x1dAmapkRAEIIOVCtUCDRo5 ZFL3q/2pBNz/LPpTawVmOKFfi0etGLLKBV76czlYgs6BVhvKK/vkrAAuJCNfc/kdcDW/ fedHtBFkWp19vC5w3ITUPB68BfZxQZ9eblSALDvZqHS8bn/N3AZqMUnrh2n693nDuIvy Y/R/S0u2wUXzoJlFyxqRyo0GY9yprso6vsIvqQz1JqkQINVpXqOtOIGrdCNTUfwLPB0y /JzA== X-Gm-Message-State: ACrzQf2erhUCepHF2AuUZ3yDm0ZUNd+zhB1I1c2Pn2eQwzm+sftbItfA PTS1ppZUEZPE6Jh7Myl98Csz3h+/ayQ= X-Google-Smtp-Source: AMsMyM7m7sf2PXIIcSxRceXMge9XN/NAM+cmhOPzNh8308Qu8DgZu9Kk6l1gtUcoupcWli+H/1Pleg== X-Received: by 2002:a05:6214:212c:b0:4af:8572:4255 with SMTP id r12-20020a056214212c00b004af85724255mr14137289qvc.16.1664723832733; Sun, 02 Oct 2022 08:17:12 -0700 (PDT) Received: from localhost ([2601:4c1:c100:2270:ec09:fca7:de7a:72aa]) by smtp.gmail.com with ESMTPSA id y15-20020a05620a25cf00b006ce515196a7sm8968655qko.8.2022.10.02.08.17.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Oct 2022 08:17:12 -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 , linux-kernel@vger.kernel.org Cc: Yury Norov Subject: [PATCH 4/4] net: fix opencoded for_each_and_bit() in __netif_set_xps_queue() Date: Sun, 2 Oct 2022 08:17:02 -0700 Message-Id: <20221002151702.3932770-5-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221002151702.3932770-1-yury.norov@gmail.com> References: <20221002151702.3932770-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 6f8cdd5c7908..41c94e5854e8 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3628,52 +3628,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 266378ad1cf1..e3da6cb1e7ee 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2591,8 +2591,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)