From patchwork Fri Oct 14 03:04:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 2468 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp589926wrs; Thu, 13 Oct 2022 20:09:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5+gsBCKrnQcScQ4d5TFnyZSBC/nQn0MYXLBexn8JKzjc/Xs2sCgSDuqzF7M1+AUyVJhDx6 X-Received: by 2002:aa7:88d6:0:b0:565:5fc2:78ec with SMTP id k22-20020aa788d6000000b005655fc278ecmr3048379pff.78.1665716966136; Thu, 13 Oct 2022 20:09:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665716966; cv=none; d=google.com; s=arc-20160816; b=vpWKdomYvamj95xjaSIx8tVqMMa3V9kpD0DHzhVDWsTukEw6mqZGTqIFAgi5hGgEqE HpIvPjnAfShGbzSwz92yHCA60nVn6zQgIXXNbuR5/IPOLRt/v63ehHLT2qF78QedSRE4 N7Q0DMm6z0mxM4VDphckjGjMD3KWEiMD/OASTCdr1kw7LZ/kEJBfBJZOdlAWpDNkvjN8 Aj6skua+9frkHI65IxsLCP998jiZ2X2pi7EBxmFFTp90IU8tXueqBMf2y41CYwYz7ZKz msPMRCjfWVnsAGBSSqNAJs+MOoxubhFkdUseQ+l9r49kOXc3eR1fwSuXFPDsM6EbjSg7 Q8QA== 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=4hE9Tna1hQylZKgfkRjkJII/HXKzBhy7abi8vdg7KbM=; b=VOIMkJ05L4FfftrF6babCzU+LXdE+JsiD/eRLjsqnoVyrc7sYPiyjXzKoB44qoj65I Pte27w1WK0UmUVQz+M8EPsNgtx35gZwVwj3hl+kvD+FKDguVya/pX34q9qfct6c0wKyA AwmSNCsoVXwGlchohLfNxDXAuJVXBmN+uMdHLQvIUukeaSW/SEs04oauv0t5cmvC2VZT 7Buh1FUlxx624S2btuGwcaPRjGgOv4j217edZIHg56VWx10HbOte+6Nq7GPzn9HRkj6G s214O2/zMLmQdg1UFRQPOdV8Qh7xV19NSYGwTEiTveTx0dLEY0H/Io+EW03r39mREkeC n3rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ul+bewFb; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s3-20020a170902ea0300b001853a1fddecsi1735292plg.403.2022.10.13.20.09.13; Thu, 13 Oct 2022 20:09:26 -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=@kernel.org header.s=k20201202 header.b=ul+bewFb; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229714AbiJNDF1 (ORCPT + 99 others); Thu, 13 Oct 2022 23:05:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229540AbiJNDFV (ORCPT ); Thu, 13 Oct 2022 23:05:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9815250B94; Thu, 13 Oct 2022 20:05:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6CFF861950; Fri, 14 Oct 2022 03:05:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 589B1C433C1; Fri, 14 Oct 2022 03:05:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665716714; bh=8ZkOpKNVxr4UPbjHuNQIfezV4h/BZySFsoWb9a9aUu4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ul+bewFbEjXzIvKzavEZOsA5STj/hvv0RYN90VZjOdc8xaHk/TGWx6VO9aAXmAtCT 7az8Y09YrE9vIfRX4tgOMo0BlWGrqUJSsb25mC2ju2ohVYwFhWEJUe+2eZXR4rQjZF dKiP6PaoNx6T+1wQC56iD/y9XfjZrOVmmqEmS8f66eDhihSSUmE1KQK7bV5QVOPQhK XApWvWVQr6dM8V1z5cIOwpiW8Kyioema0X9EC4GNQvqtGqXr7sJLa0sF2TqhKKQO1d oQXz+hMq8NYTtetp5y9k3ucv6sE09TPaGyGoeGo0rWYE7d/QwXdtPcgojqpw9/egzE 1IobgkrbyrmIA== From: guoren@kernel.org To: andriy.shevchenko@linux.intel.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux@rasmusvillemoes.dk, yury.norov@gmail.com, caraitto@google.com, willemb@google.com, jonolson@google.com, amritha.nambiar@intel.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Guo Ren , Guo Ren Subject: [PATCH V2 1/2] net: Fixup netif_attrmask_next_and warning Date: Thu, 13 Oct 2022 23:04:58 -0400 Message-Id: <20221014030459.3272206-2-guoren@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221014030459.3272206-1-guoren@kernel.org> References: <20221014030459.3272206-1-guoren@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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?1746630833470011465?= X-GMAIL-MSGID: =?utf-8?q?1746630833470011465?= From: Guo Ren Don't pass nr_bits as arg1, cpu_max_bits_warn would cause warning now 854701ba4c39 ("net: fix cpu_max_bits_warn() usage in netif_attrmask_next{,_and}"). ------------[ cut here ]------------ WARNING: CPU: 2 PID: 1 at include/linux/cpumask.h:110 __netif_set_xps_queue+0x14e/0x770 Modules linked in: CPU: 2 PID: 1 Comm: swapper/0 Not tainted 6.0.0-rc4-00018-g854701ba4c39 #324 Hardware name: riscv-virtio,qemu (DT) epc : __netif_set_xps_queue+0x14e/0x770 ra : __netif_set_xps_queue+0x552/0x770 epc : ffffffff806fe448 ra : ffffffff806fe84c sp : ff600000023279d0 gp : ffffffff815fff88 tp : ff600000023a0000 t0 : ff6000000308ab40 t1 : 0000000000000003 t2 : 0000000000000000 s0 : ff60000002327a90 s1 : 0000000000000000 a0 : ff6000000308ab00 a1 : ff6000000308ab00 a2 : ff6000000308a8e8 a3 : 0000000000000004 a4 : 0000000000000000 a5 : 0000000000000000 a6 : 0000000000000000 a7 : 0000000000000000 s2 : 0000000000000000 s3 : 0000000000000000 s4 : ff60000002327aa0 s5 : ffffffff816031c8 s6 : 0000000000000000 s7 : 0000000000000001 s8 : 0000000000000000 s9 : 0000000000000004 s10: ff6000000308a8c0 s11: 0000000000000004 t3 : 0000000000000000 t4 : 0000000000000014 t5 : 0000000000000000 t6 : 0000000000000000 status: 0000000200000120 badaddr: 0000000000000000 cause: 0000000000000003 [] virtnet_set_affinity+0x14a/0x1c0 [] virtnet_probe+0x7fc/0xee2 [] virtio_dev_probe+0x164/0x2de [] really_probe+0x82/0x224 [] __driver_probe_device+0x5a/0xaa [] driver_probe_device+0x2c/0xb8 [] __driver_attach+0x76/0x108 [] bus_for_each_dev+0x4a/0x8e [] driver_attach+0x1a/0x28 [] bus_add_driver+0x13c/0x1a6 [] driver_register+0x4a/0xfc [] register_virtio_driver+0x1c/0x2c [] virtio_net_driver_init+0x7a/0xb0 [] do_one_initcall+0x66/0x2e4 [] kernel_init_freeable+0x28a/0x304 [] kernel_init+0x1e/0x110 [] ret_from_exception+0x0/0x10 ---[ end trace 0000000000000000 ]--- Fixes: 80d19669ecd3 ("net: Refactor XPS for CPUs and Rx queues") Signed-off-by: Guo Ren Signed-off-by: Guo Ren --- net/core/dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index fa53830d0683..9ec8b10ae329 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2589,8 +2589,8 @@ 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 (j = -1; j < nr_ids; + j = netif_attrmask_next_and(j, online_mask, mask, nr_ids)) { if (!new_dev_maps) { new_dev_maps = kzalloc(maps_sz, GFP_KERNEL); if (!new_dev_maps) { From patchwork Fri Oct 14 03:04:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 2469 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp589993wrs; Thu, 13 Oct 2022 20:09:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7TL95FknbephmSMIkghpre/wFy8tdYxxMendkN4PA9aQU9al8+hn4jR7J1tCwx2zz7G25p X-Received: by 2002:a17:90b:1644:b0:20d:459b:9d81 with SMTP id il4-20020a17090b164400b0020d459b9d81mr3241933pjb.196.1665716983237; Thu, 13 Oct 2022 20:09:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665716983; cv=none; d=google.com; s=arc-20160816; b=SC+BkXwoiPnxxD7h6N97VWlWZgG3IOWnPstUfXGljPnWkGd+v40SfQ2rXSDoEnY/Ah A3PJGM42BRjKgCCueKW7Q6Rx5hfM7fztsmdpVDTnFaF09lVof1e3R7H0tuDom74GEIcH PIZM2+pZ0E6Rfyk451vbLzpsa//7sjXITcHDva8xQPY7QbRYc/QfkvGAznbZuZ2k2r2A gYqYgmjYbhinU5ctTOt9YJQjt4LuAwOutLYUbD+mZ91IveLedLKT0JyZ1WRiG7LugQ0m nFHwEcTYpUKn6Vouf9UNBKYlaBi7OMpZm/YwY/ZrdeI7MeEkicagk4CD/gsesbn+z5+p 2LtA== 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=fxAqPbzJqLQ6r1fizE7qfvTpncFCNibK4yaUidRMFsk=; b=lRS8AFvcJKSJlIIZHyobAxWy8yu0xukR5NLTCzVjW7aOQg7QxKf0+Am+DPzuQbTxic b6SQwTJ7zZrx5RNb1kcNuLoD4dEPvTrtMn8g0mtp/0UJRS9WQJ3qT55BfyzMu8jZX7B9 P+X1qufbXWSJwVtMwcpnB3JYdKhC3KEYC5p/rY+0f9GXFmHaNbG2s7up5c0yJQxz7cfn 61lBOqD/m3nuZzKmWzMYmUVzSnz/0C/n6H/3Pj0rWwkJvTKeE5sWepc9NWqQtthMEDL9 TE/pddmFbegAI/krYMWqR02I3nnBn6non+l7i4LS3PTjKv2jv/OoPUS/WjH0gQL5Z4m8 jirA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t2J+6Xx5; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x18-20020a056a00189200b0053840181203si1485903pfh.117.2022.10.13.20.09.26; Thu, 13 Oct 2022 20:09:43 -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=@kernel.org header.s=k20201202 header.b=t2J+6Xx5; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229838AbiJNDFx (ORCPT + 99 others); Thu, 13 Oct 2022 23:05:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229646AbiJNDFZ (ORCPT ); Thu, 13 Oct 2022 23:05:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD9525A2DC; Thu, 13 Oct 2022 20:05:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 49C04B821BD; Fri, 14 Oct 2022 03:05:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78680C433B5; Fri, 14 Oct 2022 03:05:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665716720; bh=jcOAb17nQhKMFlp6op1wJtpKh/mTJQ4vvofAV6VMd94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t2J+6Xx5wHV528SmBxs5wwM2mexweWFCybwkvdBWoe3BcegNnCR1dG2MKYdTFVi7D kpkhRlgO9TXORLB+4+mBlPT5buUKoj9O0w+wr+IhOm0rivq52uVt6Xsr0BpMd7UEro aXffKvQRoHEmlA0n/klCENDl72XtdZZygyWRwmpexI6tcCIhiOqO7UOFnNBAOYVhcI ZYe3VHrkG4f7bqkxH4O4Kk55Y0IrgSvStPY8n9xhjmcxqGQlonF2iEJZaxjD7tFU+d +tvgz503VWdFXB9MMjPLQJ7yuWnaEgIX7o9i3YynM57ONyNw5SzmBD7IXbXBNf3OfI OkyEptjElzFBw== From: guoren@kernel.org To: andriy.shevchenko@linux.intel.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux@rasmusvillemoes.dk, yury.norov@gmail.com, caraitto@google.com, willemb@google.com, jonolson@google.com, amritha.nambiar@intel.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Guo Ren , Guo Ren Subject: [PATCH V2 2/2] net: Fixup virtnet_set_affinity() cause cpumask warning Date: Thu, 13 Oct 2022 23:04:59 -0400 Message-Id: <20221014030459.3272206-3-guoren@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221014030459.3272206-1-guoren@kernel.org> References: <20221014030459.3272206-1-guoren@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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?1746630851275597071?= X-GMAIL-MSGID: =?utf-8?q?1746630851275597071?= From: Guo Ren Don't pass nr_bits-1 as arg1 for cpumask_next_wrap, which would cause warning now 78e5a3399421 ("cpumask: fix checking valid cpu range"). ------------[ cut here ]------------ WARNING: CPU: 0 PID: 1 at include/linux/cpumask.h:110 cpumask_next_wrap+0x5c/0x80 Modules linked in: CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.0.0-11659-ge7e38f6cce55-dirty #328 Hardware name: riscv-virtio,qemu (DT) epc : cpumask_next_wrap+0x5c/0x80 ra : virtnet_set_affinity+0x1ba/0x1fc epc : ffffffff808992ca ra : ffffffff805d84ca sp : ff60000002327a50 gp : ffffffff81602390 tp : ff600000023a0000 t0 : 5f74656e74726976 t1 : 0000000000000000 t2 : 735f74656e747269 s0 : ff60000002327a90 s1 : 0000000000000003 a0 : 0000000000000003 a1 : ffffffff816051c0 a2 : 0000000000000004 a3 : 0000000000000000 a4 : 0000000000000000 a5 : 0000000000000004 a6 : 0000000000000000 a7 : 0000000000000000 s2 : 0000000000000000 s3 : ffffffff816051c0 s4 : ffffffff8160224c s5 : 0000000000000004 s6 : 0000000000000004 s7 : 0000000000000000 s8 : 0000000000000003 s9 : ffffffff810aa398 s10: ffffffff80e97d20 s11: 0000000000000004 t3 : ffffffff819acc97 t4 : ffffffff819acc97 t5 : ffffffff819acc98 t6 : ff60000002327878 status: 0000000200000120 badaddr: 0000000000000000 cause: 0000000000000003 [] virtnet_set_affinity+0x1ba/0x1fc [] virtnet_probe+0x832/0xf1e [] virtio_dev_probe+0x164/0x2de [] really_probe+0x82/0x224 [] __driver_probe_device+0x5a/0xaa [] driver_probe_device+0x2c/0xb8 [] __driver_attach+0x76/0x108 [] bus_for_each_dev+0x52/0x9a [] driver_attach+0x1a/0x28 [] bus_add_driver+0x154/0x1c2 [] driver_register+0x52/0x108 [] register_virtio_driver+0x1c/0x2c [] virtio_net_driver_init+0x7a/0xb0 [] do_one_initcall+0x66/0x2e4 [] kernel_init_freeable+0x28a/0x304 [] kernel_init+0x1e/0x110 [] ret_from_exception+0x0/0x10 ---[ end trace 0000000000000000 ]--- Fixes: 2ca653d607ce ("virtio_net: Stripe queue affinities across cores.") Signed-off-by: Guo Ren Signed-off-by: Guo Ren --- drivers/net/virtio_net.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 7106932c6f88..e4b56523b2b5 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -2300,6 +2300,8 @@ static void virtnet_set_affinity(struct virtnet_info *vi) for (j = 0; j < group_size; j++) { cpumask_set_cpu(cpu, mask); + if (cpu == (nr_cpu_ids - 1)) + break; cpu = cpumask_next_wrap(cpu, cpu_online_mask, nr_cpu_ids, false); }