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