From patchwork Thu Oct 13 17:14:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 2101 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp389678wrs; Thu, 13 Oct 2022 10:18:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Jjw6Fd7xhZlFMdLGfvxdONARduDBR6O51apQTlq8Xy5386E8BTcAbw47uB4YxblW4CchN X-Received: by 2002:a17:906:9b8e:b0:78c:65a4:af84 with SMTP id dd14-20020a1709069b8e00b0078c65a4af84mr573452ejc.127.1665681499933; Thu, 13 Oct 2022 10:18:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665681499; cv=none; d=google.com; s=arc-20160816; b=gwzR1uomZYlVpMbaZLaX41rVW9F9NxSvDUiDBQkZrBpPNW4nNIyCjeNBZlK/exkL4i Om2CR2uZZ2YPDi7nUzFbOGzxpTVPIqKPJlVPa4mO+1Hgh23ZBxzqdI5Z26r+yRIcTWbR 0S31hcMTo3QH+vKFdTp+D4H9ve9Vh14TiU7npSNRU/N1mlcQA33oc1+p+PmYJoXx7REJ RqKiHzrQBTb6NMZGWy1QJkRhhiEd9gmdBSfQ+yfia0A1bU2E2rgF5Ell2x/iRvzbojr2 uUBLtaauavqt0E3gdC//XCK9ZWeS10xzXlfzXY2Qh1ueJbTBJWne32hkB8rZ1vDpW402 G3Kg== 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=XoKfbvuUnImundHxz/NwSM7XywCZaovh5Tbbt5kbBGU=; b=FV75NWlCPvbMLr5i8goyegiHwz5tafEC2VEkg9am9rGclCto8QUlPCfyypg9fAKCjG SxFbYliWBxTrjQSfJ49fMgVVDnCdnspx4anDhZT0npnat0qUetx1/QE4PejcDvwmGrIj wHDC/FcMyzL7oe/hV30Y4OzgZ/D3LOGUiHu8PWf1aqxmTipuiS6ZRGV746nk0uaNYUJI cSvtdoDbUg334oKkmvPqL0gJ3DUarAOu1P+nLw+wkGUgDfy4ftJjylgXYfq8lD7hTkCx 6tVMTOiJJl6Z9t2fS5hzFUI2Ri9tSeubbGu50CLruM6Iqo9phV0Wka4O6vIZtxQWuhz6 X4Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="YrAaq/Wo"; 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 h2-20020a170906828200b0077b2ad71224si216869ejx.136.2022.10.13.10.17.54; Thu, 13 Oct 2022 10:18:19 -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="YrAaq/Wo"; 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 S229711AbiJMROr (ORCPT + 99 others); Thu, 13 Oct 2022 13:14:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbiJMROq (ORCPT ); Thu, 13 Oct 2022 13:14:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97B8A13EAD; Thu, 13 Oct 2022 10:14:44 -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 33D73618C9; Thu, 13 Oct 2022 17:14:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 491F1C433D7; Thu, 13 Oct 2022 17:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665681283; bh=pDxmcYjitaHRhnAhlXahfQJzdt1gN1EjmnneIPOHL7Y=; h=From:To:Cc:Subject:Date:From; b=YrAaq/Wowtqb7O5Ox6ZHbYdFMzgxDEvdfQ3A9I6RaMVtRIdkz+MduySRi56ir+yU2 g3FjJYq6cQxkRBWEFQLDwGfg/XJ5mKxAEVtPr2rM23b9Jg5Q7PoYvxxSqxOl+WLrjx C84qLg7iV2I8iVFNwRrIfATm9l0Cog5IrIR8e/Z7ED2cGWF8u3j1Xlh3whb3Kkczf3 zl8vbW6M/YZPwdr1IKsPBzoVx21LqJSKWl3MA2N69PcK+wLxAVoB9JtZDjnQsqrQ9I TOznswK7IGqhJJqVVndrkId/dTuzfGdooOLmY5tuDVegUrb0jjVtrrAg37gJudXHQt pPWM7ycGnDbSA== 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 Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Guo Ren , Guo Ren Subject: [PATCH] net: Fixup virtnet_set_affinity() cause cpumask warning Date: Thu, 13 Oct 2022 13:14:34 -0400 Message-Id: <20221013171434.3132854-1-guoren@kernel.org> X-Mailer: git-send-email 2.36.1 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?1746593644255212429?= X-GMAIL-MSGID: =?utf-8?q?1746593644255212429?= From: Guo Ren Don't pass nr_bits-1 as arg1 for cpumask_next_wrap, which would cause warning now. ------------[ 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: 78e5a3399421 ("cpumask: fix checking valid cpu range") 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); }