From patchwork Sat Dec 28 18:49:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 2028277 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=kBpUNeXl; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev+bounces-4506-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4YLBJ25jRJz1yT1 for ; Sun, 29 Dec 2024 05:50:10 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4YLBHv2jXnz2xJ5; Sun, 29 Dec 2024 05:50:03 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::b2d" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1735411803; cv=none; b=Qys02l02o7KiDJv43fTRFdcebYSC8oBFBC44sQ6hLuPtYEoAB7eivxp6QMKG7Wa1tWEodo5QYtCPEGBhS7Ohx4r3fhGAY0Fov3Fvt2n7GmLQ29y/PSC0NRfok9K2zh+2m0uijkvRqhzL1cx3xJqUcFuU2+W4rzkhXi9tJ9DTu7DqLFhu7RRBIG1jdLgksTj2n6Lp71J92Y8+fdA6Vb41VbBFmdOg+wGOLqrbCQP8L6HzmsVl6lIRVZ1Umi1l3fiab3BzZlI0t7VePUozkFixo5x0h+6jCBxkyfJWC46fxHjTspNkUx0HbSXy7OzqcWflx6j7niTu6vD1wPuqus7p9Q== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1735411803; c=relaxed/relaxed; bh=lL8rNecoxrOgRuhpm+UkLZuLqFEtoRoNCimf/pNjqjs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SPNqm/4Q6ksLzV23YOXVeMxdj3uXQwxO+DEJyl/8IOE7/SkRgAU4v0P9vMIs3asHGaaKRTvRtKzWalUiZDCXeMW1IXC+4xiMe+cLF2oY5zibbP7vLypIivRohYC+LbcXNuXPsawnpyvou3Eiz8BFn/vWZYkEJR5K0ZfGMgl494OOpqozznOwiS6AnMpdVxlZF9fSvDkD+38ubSBrd07KDRdQzI4LDkPskSLN/KecdzVRHq8SZtPxaD7UlrEtWXfxU/mxqeABUP5nIQni2QA1pB8M3Z1KGi69r4MF0D9YTfftoIbf1dI5fr7zGwlM+GcOvfbS1u718rOEWjwPJh5EqA== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=kBpUNeXl; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::b2d; helo=mail-yb1-xb2d.google.com; envelope-from=yury.norov@gmail.com; receiver=lists.ozlabs.org) smtp.mailfrom=gmail.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=kBpUNeXl; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::b2d; helo=mail-yb1-xb2d.google.com; envelope-from=yury.norov@gmail.com; receiver=lists.ozlabs.org) Received: from mail-yb1-xb2d.google.com (mail-yb1-xb2d.google.com [IPv6:2607:f8b0:4864:20::b2d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4YLBHt1x9zz2xJ8 for ; Sun, 29 Dec 2024 05:50:01 +1100 (AEDT) Received: by mail-yb1-xb2d.google.com with SMTP id 3f1490d57ef6-e4a6b978283so10107375276.0 for ; Sat, 28 Dec 2024 10:50:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735411799; x=1736016599; darn=lists.ozlabs.org; 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=lL8rNecoxrOgRuhpm+UkLZuLqFEtoRoNCimf/pNjqjs=; b=kBpUNeXljA3gJLUNlo7a2qgLcanBrJa7plmErT7FaymXn/79R9mpN3pUirorbZM3SV BFU58BxbHVGDKZm3FlL0nZAPNuVrDdxtaqWFY1JRfknnOTiBYvkXFCaCHKDRXy+LHNIw NWh6UgIgrV/bfyJwwNJiXOXJODCLTLtI2MzYbRKeuxoHwuPCr8I4Aph7DQMFvys4M3dN GLw9lQx5cswW10PD7dYhYOkbsMke4EduOXTgmbYVKE6RdxvWPVkOKGMZA1s+xk5QDeR5 bkSLcfuvsyjGT+PaTdgkqMIu4By8+p+r10YJYRHgN1myVA++TBWTGQVx7SW00FjLL49C ZW7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735411799; x=1736016599; 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=lL8rNecoxrOgRuhpm+UkLZuLqFEtoRoNCimf/pNjqjs=; b=mn3zif/KV5ugMlBtOCG/FeuSp9iiXBvcvgupoXw6Cy3jCY+j0cqnguH4bNO4Np1beE y3cs+nXZOwSqA9INlGnquwVT+yYRTxtgLDiRU2iTFnxW2JK8l1dNY6xPCAietwtwRNSq czTmRRvimJJjgvw8JnGE8eBz5slEGB9Qolj0WMOnWvw+61KHoB7cHJlRB5MPlsLa3OSu supZsIqhx8NRNw0zD8ZayheNSFe5zHf+3or/3q12e4XF7CsW+SlmNFUryi3DTL10ZeN7 ZqsEu6s2b+11MJYGvYOP+UAuiJWX6o8WeU6CMJE2CTofAtde6OrVMAJwrv/mDPA4MmZH 5X+w== X-Forwarded-Encrypted: i=1; AJvYcCWp2AoylQsA4HaVWt4lezLxvwIEhckNPSCsDfpA+WE5WeYqGVOfGsdr9xhND9zBJulYLT5BmPB1DVlHqD0=@lists.ozlabs.org X-Gm-Message-State: AOJu0YzLxXCuTOlh2xucP6sVOQfu2rKG5bbcfAQAiSNGbrz8nrnrbLVk Gp5/OFU5jl/Zzej0s9NMhbPHYy3tjaHFiw0zle7DQd3S2BXLeRUN X-Gm-Gg: ASbGncsplXxoWseOvT2kBPxggmWirhyTW39XRL1ZAQxeP31ZatOx+utD1HRQJNTs9o9 /gg0nv3J1jJvh43WF6nqWz0JnBOKZFjqHwf70IShW1z3SVzpgmowpfOncJjkYxjV2kAJbBCAEuE yg66Q7PGGNBe5qThzYArwGyAS5/ET3raHRjUNgzsU0s1EAll5fsj2wMbsYxYQWoYqWBYi3oLk4d tNG6e/dSRGnUpnP6cvPCZQISGed/YEoPPojSKjOUQ4aKVdtExc8sSpRPktmEA/OtB3yIs4Rg/Ck e4pQA3KQQ/Of/qFg X-Google-Smtp-Source: AGHT+IGzd+E2S8x2gXxoaCvAStSmkZ51igXj24qQWSN3ZW4n/H7SUeu2mKOPhIyoM4H12slkJ1LXvQ== X-Received: by 2002:a05:690c:4a0a:b0:6ee:5104:f43a with SMTP id 00721157ae682-6f3e2b8aeffmr257339587b3.20.1735411799162; Sat, 28 Dec 2024 10:49:59 -0800 (PST) Received: from localhost (c-24-129-28-254.hsd1.fl.comcast.net. [24.129.28.254]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e71a8d26sm47945657b3.0.2024.12.28.10.49.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Dec 2024 10:49:58 -0800 (PST) From: Yury Norov To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Haren Myneni , Rick Lindsley , Nick Child , Thomas Falcon , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Madhavan Srinivasan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Yury Norov , Rasmus Villemoes Subject: [PATCH 03/14] ibmvnic: simplify ibmvnic_set_queue_affinity() Date: Sat, 28 Dec 2024 10:49:35 -0800 Message-ID: <20241228184949.31582-4-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241228184949.31582-1-yury.norov@gmail.com> References: <20241228184949.31582-1-yury.norov@gmail.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on lists.ozlabs.org A loop based on cpumask_next_wrap() opencodes the dedicated macro for_each_online_cpu_wrap(). Using the macro allows to avoid setting bits affinity mask more than once when stride >= num_online_cpus. This also helps to drop cpumask handling code in the caller function. Signed-off-by: Yury Norov --- drivers/net/ethernet/ibm/ibmvnic.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c index e95ae0d39948..4cfd90fb206b 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -234,11 +234,16 @@ static int ibmvnic_set_queue_affinity(struct ibmvnic_sub_crq_queue *queue, (*stragglers)--; } /* atomic write is safer than writing bit by bit directly */ - for (i = 0; i < stride; i++) { - cpumask_set_cpu(*cpu, mask); - *cpu = cpumask_next_wrap(*cpu, cpu_online_mask, - nr_cpu_ids, false); + for_each_online_cpu_wrap(i, *cpu) { + if (!stride--) + break; + cpumask_set_cpu(i, mask); } + + /* For the next queue we start from the first unused CPU in this queue */ + if (i < nr_cpu_ids) + *cpu = i + 1; + /* set queue affinity mask */ cpumask_copy(queue->affinity_mask, mask); rc = irq_set_affinity_and_hint(queue->irq, queue->affinity_mask); @@ -256,7 +261,7 @@ static void ibmvnic_set_affinity(struct ibmvnic_adapter *adapter) int num_rxqs = adapter->num_active_rx_scrqs, i_rxqs = 0; int num_txqs = adapter->num_active_tx_scrqs, i_txqs = 0; int total_queues, stride, stragglers, i; - unsigned int num_cpu, cpu; + unsigned int num_cpu, cpu = 0; bool is_rx_queue; int rc = 0; @@ -274,8 +279,6 @@ static void ibmvnic_set_affinity(struct ibmvnic_adapter *adapter) stride = max_t(int, num_cpu / total_queues, 1); /* number of leftover cpu's */ stragglers = num_cpu >= total_queues ? num_cpu % total_queues : 0; - /* next available cpu to assign irq to */ - cpu = cpumask_next(-1, cpu_online_mask); for (i = 0; i < total_queues; i++) { is_rx_queue = false; From patchwork Sat Dec 28 18:49:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 2028278 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=f+mZXf3b; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev+bounces-4507-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4YLBJ93SXTz1yT1 for ; Sun, 29 Dec 2024 05:50:17 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4YLBHw719cz2xJ8; Sun, 29 Dec 2024 05:50:04 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::b33" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1735411804; cv=none; b=KiGuT0iXMA3IlS6Lcjsq16So1bLbuZhdppeWe79Iw7bfItBHHLAMaYU+wjUdv8Sd29hqjhW73CMD40Dx5LuaTRdZFXwL2M/9olQmQ7zKkfvHVq5PBeXEQpAvHmltrFhC05+ACGSz5eIzXURmuplmz36TUzB515rHGyxB6oxKm/lKus7GkHDZuE+wB00VD8q+UxNFu+BYuA7F7GT+H+WlPsEm39SZ0kkbebU4CaQ6HLapPjrm1ppp42ejRIDcgelW7DyxWJwin3PxVzC77zRQylCWc9xSjL1Fiufwk/KPvysjiLNWqPksRdsdUFYv17SphVWYAnGKH58EqMxRTW7eHw== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1735411804; c=relaxed/relaxed; bh=a3EcwrJaj13JFWV94S06ao9wKNfTeeg6w6xP84y4x0M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YCkqP0fx/jNeRLLWLq36XkqpmNFpJ9YBAwJsicgdbBBOMvKSO8I+qNscA3TsvEnHnvBux19Qcfd6+Y12tUT4gj8Fa0iS7XnIqUWumNGlVR/o9GKygePmKCCMpHL4P7/jasf0HKUnrFCzZJACWwNk4hYQ9nN2+yyyRzbG4KsODeAHg5oXXTojFZIaW78XgbTJUeXbD2BkXkD5A88Po8OIjBGhM+/214P4CDGxJ35WacYiLPaNJSwlWwxX1cUW5r02AqLEt2b6MxwTnohr0/XCWYfXDhz6/AlAeR/lFj8mjytspzBt5iJY3W01TQehmLdNsKOn4OBJBXldrLbAfdy89A== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=f+mZXf3b; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::b33; helo=mail-yb1-xb33.google.com; envelope-from=yury.norov@gmail.com; receiver=lists.ozlabs.org) smtp.mailfrom=gmail.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=f+mZXf3b; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::b33; helo=mail-yb1-xb33.google.com; envelope-from=yury.norov@gmail.com; receiver=lists.ozlabs.org) Received: from mail-yb1-xb33.google.com (mail-yb1-xb33.google.com [IPv6:2607:f8b0:4864:20::b33]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4YLBHv646zz2yhM for ; Sun, 29 Dec 2024 05:50:03 +1100 (AEDT) Received: by mail-yb1-xb33.google.com with SMTP id 3f1490d57ef6-e455bf1f4d3so7767350276.2 for ; Sat, 28 Dec 2024 10:50:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735411800; x=1736016600; darn=lists.ozlabs.org; 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=a3EcwrJaj13JFWV94S06ao9wKNfTeeg6w6xP84y4x0M=; b=f+mZXf3btiTO4nX++rThLMtCyHxZ5Lr5jg4+NBvRlgknXYZ7Ruw546HP+K32LZ2V3O 2ZdcRGPnaoTQCishJm6dnpvs+K7K121jMOpXzhdBGQz8ZgQx2/jqQsEeTK8aEL9AUrnZ l4youH/Rh72TMXhE/lepKoZOFfZTjXrfGsTHIofKI31pWm/86rAiZp3z3sc/4WMKhJ6o Hn780nDTZvV/5bZn1uJJn9TREy929DZFcwL4/cp+3z4IeK7HbV3UcG4zdFZEE1bitYnW O6ROM8TnyrylWDwVmwW0792HwBinmFUrb3hiuQ1qR2I6Z+XDHDLvams9/2hg2Q9rqMF9 uWUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735411800; x=1736016600; 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=a3EcwrJaj13JFWV94S06ao9wKNfTeeg6w6xP84y4x0M=; b=YjKGSwlEftlUJVz627N4/oV7qtSTKGaiPC6GgXKjL71xCoiG4sh0dmbLppI9i1ED3Q YJ9lcv1+zNM+ecopFystT4/XlAJIiA5Ws1eEzw++L41qE5wfnfH4jr3cOG2mTT0GqtdJ 1Jz4WKbXZwVmuMxvmlvK5OhtQqXbEnd4dhGswuhUCY4qtuMh815E3o/4R/6Mk70f9PBm zf1tgGQ/5fany05SJs7jlnI3zXM46t0cJlTrFSYJ4QCfpgvAx60tQ+iUoG9T5CQzUraD u3+B8UKiXNHgbV7SFNY0a4g8vSo4ebb6OeFuQYyaWIlE3mEme0sDPDc1m+y/pA85AZtV 6JsQ== X-Forwarded-Encrypted: i=1; AJvYcCXC0By97iapA7Q0ADA8+/f+lsdsL1pZnM8Gw4MRhcf6LQdN/jOvdX7mKY/aiEJEN84C4V09/PxvV1uWafs=@lists.ozlabs.org X-Gm-Message-State: AOJu0YxcIkN38zhzLftKe+r/HTqLJPMngtIHrPf9lsD9pytiUBi25yVd Dmf2VCXpyRTqtSyQx75PJk5u5+s2ELeHn+029ql20eC0C7UVSls2 X-Gm-Gg: ASbGncvZu2ZSEUGyt7FhVIVcO8EAOsfoQqMMgZzmYniRBAtdHz8CG41XLRPFUT4biJF nJzUa/aSMmsa37anZGVYlNq5UKODaMgQEZI7i3LoD6yyv0UEujXqcNmFj5w0LRmbL2Oqb2HQtV3 uatDJdxjbdQJ+iF8RPkm++B9MeMCjU7ObVpy0zgk07BJ7B9gSh1aPDER0DHRrBXvLgjRkULWYuS qm//m/STpo6EqqcVo0YP6mDtKa2Ayg0b3atMP3rc9K+ehWD5L2IS0RDxHgBGi3oxOPxbm/pjGag arjqGuNdG5KSIuhy X-Google-Smtp-Source: AGHT+IHYxhV9z9c0TqaYoIc8tNJTOYJG9vJKS/fH54wKJcOX0hcp4pjTSDHzZiDSWaq/zIaFUgVQ0g== X-Received: by 2002:a05:690c:f0f:b0:6ef:698a:1f02 with SMTP id 00721157ae682-6f3f8219d18mr230627707b3.32.1735411800391; Sat, 28 Dec 2024 10:50:00 -0800 (PST) Received: from localhost (c-24-129-28-254.hsd1.fl.comcast.net. [24.129.28.254]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e745648asm47410067b3.52.2024.12.28.10.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Dec 2024 10:50:00 -0800 (PST) From: Yury Norov To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Madhavan Srinivasan Cc: Yury Norov , Rasmus Villemoes Subject: [PATCH 04/14] powerpc/xmon: simplify xmon_batch_next_cpu() Date: Sat, 28 Dec 2024 10:49:36 -0800 Message-ID: <20241228184949.31582-5-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241228184949.31582-1-yury.norov@gmail.com> References: <20241228184949.31582-1-yury.norov@gmail.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on lists.ozlabs.org The function opencodes for_each_cpu_wrap() macro. As a loop termination condition it uses cpumask_empty(), which is O(N), and it makes the whole algorithm O(N^2). Switching to for_each_cpu_wrap() simplifies the logic, and makes the algorithm linear. Signed-off-by: Yury Norov --- arch/powerpc/xmon/xmon.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c index f4e841a36458..d7809f15dc68 100644 --- a/arch/powerpc/xmon/xmon.c +++ b/arch/powerpc/xmon/xmon.c @@ -1271,11 +1271,7 @@ static int xmon_batch_next_cpu(void) { unsigned long cpu; - while (!cpumask_empty(&xmon_batch_cpus)) { - cpu = cpumask_next_wrap(smp_processor_id(), &xmon_batch_cpus, - xmon_batch_start_cpu, true); - if (cpu >= nr_cpu_ids) - break; + for_each_cpu_wrap(cpu, &xmon_batch_cpus, xmon_batch_start_cpu) { if (xmon_batch_start_cpu == -1) xmon_batch_start_cpu = cpu; if (xmon_switch_cpu(cpu)) From patchwork Sat Dec 28 18:49:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 2028279 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=SZaOJqwr; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev+bounces-4508-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4YLBJJ5d3Nz1yT1 for ; Sun, 29 Dec 2024 05:50:24 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4YLBHy5hfpz2ynR; Sun, 29 Dec 2024 05:50:06 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::b2f" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1735411806; cv=none; b=HBHDaphP8jGfV/+9elg67rQK7/xQ3qg4+T9dbBWr6i+Z4qsSMiOTuXFezHTEcXNaq6SDw+sc7hwSSsd1gaaMMa6XHxwHz2ENToKO7zzm+8HMhY4TmcRDZ9QITDwyqUgNgdObQiBWi2IPKLVDMJ7fBAgQqkJN79c6LJbKdD5sthQ7uIcLDLGvH6HBhUSBL4vdBr+awUB//Wj1CH5NW9U9eYcJLUeF3/ljMPeZ4h2b3vxIvn936TScU5B+Zr8bRDDKsMNUxJVLEuCaKhUo7CW+MeMObREpAGiug+7LxQIfIugpYJrHsMtx0g8AXbhYHNQha1voum3oWuK8ka0dTPPY2g== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1735411806; c=relaxed/relaxed; bh=0bA6qa5mRtLx/JNJepZMf5RGZWm5ti1ameVb2qE56fE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j6TF03aHdkh37yWiKUkPlzhhe/Ql3m9eFxKw/bkEEDs6SxnWWyzg6l2YX951X4yFuAB37CYIly0w7vvefHsWFBn7erZwAhgrQG4pJLEY/8rTVJ9BLQkqtXeGwI2+/oRTQN+fNemvn1QcgMLJcXSZKqhp4Fd4ZrzbVj63msi0OGfOZZL5hiathpO5FhoYoG+Sqp5VEqKUtPtOg0JnKAzIrdFExWdz6YbSmro/RYPLFNIWqihxhVy1f0dfulPPH5EWs3VxXBv5M8TGhwXKsTARUbJ/fbDw21qfChJM7NYsn+Lrqw+QjLzLYcqLHRsPVQ/ZcJEn+PFtMPhAVx8/L+EPxA== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=SZaOJqwr; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::b2f; helo=mail-yb1-xb2f.google.com; envelope-from=yury.norov@gmail.com; receiver=lists.ozlabs.org) smtp.mailfrom=gmail.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=SZaOJqwr; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::b2f; helo=mail-yb1-xb2f.google.com; envelope-from=yury.norov@gmail.com; receiver=lists.ozlabs.org) Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4YLBHx5HsSz2yhM for ; Sun, 29 Dec 2024 05:50:05 +1100 (AEDT) Received: by mail-yb1-xb2f.google.com with SMTP id 3f1490d57ef6-e3978c00a5aso9233608276.1 for ; Sat, 28 Dec 2024 10:50:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735411803; x=1736016603; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=0bA6qa5mRtLx/JNJepZMf5RGZWm5ti1ameVb2qE56fE=; b=SZaOJqwr2D80KY7gzpQI6pjk9ZW/tjNQFyNy4ZiMOCtl/d6f3s7WXigD7SbvxEVbaz N/+DzTGybflbFRQi/A28qPJ2Yj83hgl2TD5JIKbalXwAOBBRL1fiDdGAj17W/PiqGFOp vF2K493oo8/AK8SeCEjo19lMs2MDEmmzTp8i9PpIlf8dz7oWNpox04O7t7Pw8E6iTc4P La7vgvNRxhtFKajN6wP2oyLWC9EupBVqRJzLcpC04AUT4oRH+8qvLOeAr4W2ZKPZa9RK Mw7qB5VcIThv1H+Zxm+VUt1axtsBmyWt63kYBP2/uVKEuTyjW0ZDPaiTaDylcwEvrfEK Pr9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735411803; x=1736016603; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0bA6qa5mRtLx/JNJepZMf5RGZWm5ti1ameVb2qE56fE=; b=b36DO4+lwxWjTkhZxIBwu63o6OR+GDhxh9/nAERpp4ZB2ABdrnHLCzakdxhYwdvAnP Ow9dQPQrCpWjVy+9bzp+oVRI9uUT3os94rUyKFgzj8dWuUcKvHS96ARKGUhbajQfzk6f +IS2J1x2vgbeBxm8z+KRxX+tolqdIEZfrcjXmcRWYMegIw9ea/iXSWxje3nPBovx+tmF gLMV8oa5DGPp1J4PnYU/RLyDZLyChkDgoM6ocCyTQNtaA192IL2P3dYbH7JcZ3AViJ4C 4IeZj3R+nYxdyIc+GnWg/SxYW4x6guNlWjrWjFP8bxm7KlGPfxJDefJsmqRElN7ob2an w4rQ== X-Forwarded-Encrypted: i=1; AJvYcCWEKKLlJmyBTt8EQTgBsfZwK0CvtPAB473KtM6Zr0xPaXzpvDVcYPsRFAKxGv1JjPv1RUtjQbWaCLmYU1E=@lists.ozlabs.org X-Gm-Message-State: AOJu0Yzi7LOoxcThNE5nyK/GaVUHuMoUJL4jbvLdPv4SPlDSjVzCI0yT NKR50eE2C4PO7mmLhJE4MoNSDPEBSM73zNybMh/WUTxzFuLylc+u X-Gm-Gg: ASbGnctuZDVzOW93+xJP7QGsLlc7lsptR56Hl91Ms9qcCV0HYIXakPN2STaQT7cULsE Yi0zfJFPIL5GrDSbAbcWVlI9qZ+GFzJ/pVeg5r/aLj7iIk7cVhs51YXrK+LacSTAg20Lrx5P26I IRudgakqaV8NvgJqOVD6VKZ5MsKm4eABVdY2Kd1iEeU8f2OKTUpvntNO94xUDLhw89ai1nBaC5U vPScS7IdbbRGSmsVrAS0pV3Re+5/FFGF0Tb2+1r0QWtGDfHAZ5MPrhqlgh6nzFbDZE66JPelSI8 jFhRBwmSWPJK8Icy X-Google-Smtp-Source: AGHT+IEdltlfo7VoM/K9Hx3CK/leMoimfCHWr7pfYR9wsJX7DjblcCmfKrexz0jlZQgTcU9bnrqr/g== X-Received: by 2002:a05:6902:1a48:b0:e49:5f2d:e71d with SMTP id 3f1490d57ef6-e538c267d16mr23706682276.21.1735411803005; Sat, 28 Dec 2024 10:50:03 -0800 (PST) Received: from localhost (c-24-129-28-254.hsd1.fl.comcast.net. [24.129.28.254]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e537cbeba44sm5051923276.7.2024.12.28.10.50.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Dec 2024 10:50:02 -0800 (PST) From: Yury Norov To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org, virtualization@lists.linux.dev, linux-nvme@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-scsi@vger.kernel.org, linux-crypto@vger.kernel.org, Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Madhavan Srinivasan , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Haren Myneni , Rick Lindsley , Nick Child , Thomas Falcon , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas , James Smart , Dick Kennedy , "James E.J. Bottomley" , "Martin K. Petersen" , Yury Norov , Rasmus Villemoes , Matt Wu , Steffen Klassert , Daniel Jordan , Andrew Morton , Greg Kurz , Peter Xu , Shrikanth Hegde , Hendrik Brueckner Subject: [PATCH 05/14] cpumask: deprecate cpumask_next_wrap() Date: Sat, 28 Dec 2024 10:49:37 -0800 Message-ID: <20241228184949.31582-6-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241228184949.31582-1-yury.norov@gmail.com> References: <20241228184949.31582-1-yury.norov@gmail.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on lists.ozlabs.org The next patche aligns implementation of cpumask_next_wrap() with the generic version in find.h which changes function signature. To make the transition smooth, this patch deprecates current implementation by adding an _old suffix. The following patches switch current users to the new implementation one by one. No functional changes were intended. Signed-off-by: Yury Norov --- arch/s390/kernel/processor.c | 2 +- drivers/nvme/host/tcp.c | 2 +- drivers/pci/controller/pci-hyperv.c | 2 +- drivers/scsi/lpfc/lpfc_init.c | 2 +- include/linux/cpumask.h | 4 ++-- kernel/padata.c | 2 +- lib/cpumask.c | 6 +++--- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c index 5ce9a795a0fe..42ca61909030 100644 --- a/arch/s390/kernel/processor.c +++ b/arch/s390/kernel/processor.c @@ -72,7 +72,7 @@ void notrace stop_machine_yield(const struct cpumask *cpumask) this_cpu = smp_processor_id(); if (__this_cpu_inc_return(cpu_relax_retry) >= spin_retry) { __this_cpu_write(cpu_relax_retry, 0); - cpu = cpumask_next_wrap(this_cpu, cpumask, this_cpu, false); + cpu = cpumask_next_wrap_old(this_cpu, cpumask, this_cpu, false); if (cpu >= nr_cpu_ids) return; if (arch_vcpu_is_preempted(cpu)) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 28c76a3e1bd2..054904376c3c 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -1578,7 +1578,7 @@ static void nvme_tcp_set_queue_io_cpu(struct nvme_tcp_queue *queue) if (wq_unbound) queue->io_cpu = WORK_CPU_UNBOUND; else - queue->io_cpu = cpumask_next_wrap(n - 1, cpu_online_mask, -1, false); + queue->io_cpu = cpumask_next_wrap_old(n - 1, cpu_online_mask, -1, false); } static void nvme_tcp_tls_done(void *data, int status, key_serial_t pskid) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index cdd5be16021d..86d1c2be8eb5 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -1757,7 +1757,7 @@ static int hv_compose_multi_msi_req_get_cpu(void) spin_lock_irqsave(&multi_msi_cpu_lock, flags); - cpu_next = cpumask_next_wrap(cpu_next, cpu_online_mask, nr_cpu_ids, + cpu_next = cpumask_next_wrap_old(cpu_next, cpu_online_mask, nr_cpu_ids, false); cpu = cpu_next; diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 7f57397d91a9..31622fb0614a 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -12876,7 +12876,7 @@ lpfc_irq_rebalance(struct lpfc_hba *phba, unsigned int cpu, bool offline) if (offline) { /* Find next online CPU on original mask */ - cpu_next = cpumask_next_wrap(cpu, orig_mask, cpu, true); + cpu_next = cpumask_next_wrap_old(cpu, orig_mask, cpu, true); cpu_select = lpfc_next_online_cpu(orig_mask, cpu_next); /* Found a valid CPU */ diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 30042351f15f..b267a4f6a917 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -296,7 +296,7 @@ unsigned int cpumask_next_and(int n, const struct cpumask *src1p, #if NR_CPUS == 1 static __always_inline -unsigned int cpumask_next_wrap(int n, const struct cpumask *mask, int start, bool wrap) +unsigned int cpumask_next_wrap_old(int n, const struct cpumask *mask, int start, bool wrap) { cpumask_check(start); if (n != -1) @@ -312,7 +312,7 @@ unsigned int cpumask_next_wrap(int n, const struct cpumask *mask, int start, boo return cpumask_first(mask); } #else -unsigned int __pure cpumask_next_wrap(int n, const struct cpumask *mask, int start, bool wrap); +unsigned int __pure cpumask_next_wrap_old(int n, const struct cpumask *mask, int start, bool wrap); #endif /** diff --git a/kernel/padata.c b/kernel/padata.c index d51bbc76b227..454ff2fca40b 100644 --- a/kernel/padata.c +++ b/kernel/padata.c @@ -274,7 +274,7 @@ static struct padata_priv *padata_find_next(struct parallel_data *pd, if (remove_object) { list_del_init(&padata->list); ++pd->processed; - pd->cpu = cpumask_next_wrap(cpu, pd->cpumask.pcpu, -1, false); + pd->cpu = cpumask_next_wrap_old(cpu, pd->cpumask.pcpu, -1, false); } spin_unlock(&reorder->lock); diff --git a/lib/cpumask.c b/lib/cpumask.c index e77ee9d46f71..c9a9b451772a 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c @@ -8,7 +8,7 @@ #include /** - * cpumask_next_wrap - helper to implement for_each_cpu_wrap + * cpumask_next_wrap_old - helper to implement for_each_cpu_wrap * @n: the cpu prior to the place to search * @mask: the cpumask pointer * @start: the start point of the iteration @@ -19,7 +19,7 @@ * Note: the @wrap argument is required for the start condition when * we cannot assume @start is set in @mask. */ -unsigned int cpumask_next_wrap(int n, const struct cpumask *mask, int start, bool wrap) +unsigned int cpumask_next_wrap_old(int n, const struct cpumask *mask, int start, bool wrap) { unsigned int next; @@ -37,7 +37,7 @@ unsigned int cpumask_next_wrap(int n, const struct cpumask *mask, int start, boo return next; } -EXPORT_SYMBOL(cpumask_next_wrap); +EXPORT_SYMBOL(cpumask_next_wrap_old); /* These are not inline because of header tangles. */ #ifdef CONFIG_CPUMASK_OFFSTACK From patchwork Sat Dec 28 18:49:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 2028280 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=QSOL16VW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev+bounces-4509-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4YLBJP4VqXz1yT1 for ; Sun, 29 Dec 2024 05:50:29 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4YLBJ02B2cz2ytp; Sun, 29 Dec 2024 05:50:08 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::b31" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1735411808; cv=none; b=iTJC0Hvg2eFnsJqM1RmGo+giA1h+zEmEhtt1Vokwju0OvoZK8K6GbjfT1YuPzENjFjhl4i5Eh8uTeBE4KsY93Tr4i/+12xv9ucKr4HPxnrGtimzMDC3PQriy276wWUjt4luY+22iTeYZ1nvmuXsiDaQJLgt7OjTY30dCWLZNtBbCUVBKEIU2fnlsMpxPYNWRmr0VJ1YwIiBU66CHdPge90rfkmxEkidhxZqQ11/IJFjKH6A3tuZMgT1QQ00WfCzzqxaRch6n5z65hTa8kY0EzQ6pt2l0CHr0RIt6qA8alczxKj51b69+gNTrrrUoICcU4RmyjOozW+V3RbwrF/iaVg== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1735411808; c=relaxed/relaxed; bh=S9g5yzfm32qCCSZ9hYX8RFrDFECwqUd1W8h8dBnaZOA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=osOK9jDS7K1BVOopPJwvEuD4EuGY1K1WsNYzyQEcLIyFbKWovXJ7heGLTb2f/IUVf3c4bjI5mlHHZh6adIcnCH7LYLACLXroecyxSi/GPwPN+KXKlcR08P0mGPhN7yxBvftPJ1EEnHgku3mvXVARA33sTk1fLpF7KBwnwN4FR4eZi3t+YaHJeM5PE+sdZOxE4F/k43Ft9S0kpnws073ysXKQpWN9tdqwU7d+/eO9u7z1YU3qMeOuraOBjCWPaJo42nkfOzRxKuf64H/IPKlz9w59AiF0WcPrpezI08uzt39DaDGzFCHFFwFt6BRKvHxpc/uZrhjeqFbMNCbSUNBmuA== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=QSOL16VW; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::b31; helo=mail-yb1-xb31.google.com; envelope-from=yury.norov@gmail.com; receiver=lists.ozlabs.org) smtp.mailfrom=gmail.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=QSOL16VW; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::b31; helo=mail-yb1-xb31.google.com; envelope-from=yury.norov@gmail.com; receiver=lists.ozlabs.org) Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4YLBHz2Q2Tz2yhM for ; Sun, 29 Dec 2024 05:50:07 +1100 (AEDT) Received: by mail-yb1-xb31.google.com with SMTP id 3f1490d57ef6-e3990bbe22cso8902418276.1 for ; Sat, 28 Dec 2024 10:50:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735411804; x=1736016604; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=S9g5yzfm32qCCSZ9hYX8RFrDFECwqUd1W8h8dBnaZOA=; b=QSOL16VWI1UkeSORn1OIuoXxxYPOMuZef3jjB109fKVTM860myebTQHFU52tkrWrJO 5ctbZXdRkIQRhenjYflD+Jih8f6LC6wvDJ0u1SuZYWit6Q+z3kN7viacDIok7X45SLFn D5mdQwAkBbPEF4HUGAYvBTsDwUi6EgxPg/O7VP3Bn8tPsobQ38bdcZYw7ZpID3tRhv/n U+QVNANMnpWZG/XPb1dfQw9Ukr5eAOjbgizQ+Yyn0heRKhIwQtJ46XFVtXCPOutxa2MN 9hpoue0gsWRieutFozFEwzKxDRC+4d9BFZ+qhRp239hAHEDxkVqo2riYNvHVu/UH0nx6 qmbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735411804; x=1736016604; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S9g5yzfm32qCCSZ9hYX8RFrDFECwqUd1W8h8dBnaZOA=; b=VI3gvumLk5IWV3zSH42wjQPwIWsEAIFFEjQ81Q8XwgnRueXB9RLMytWqz0k7V3Jmpk 0wOWobIK4XNQNu1A6fEdonBSjKXu6e3BHR3gv8O7ScribgYhZIvosayGs143YzK1ZpmZ 83Xs7Nz5rota8rmDUllAirITwtaTIDO0gP0F05PQkHNzc/lgGMXa5hUgEg7bIR+gZIjb S6Hc8vssDK1o92ktvIqI97jib+OUsITp7g/GuHlFg/aQMfG1ReNNP9LqkCX/dMjQ5qyg /my2mWOX3rM5O5H0Vw6lGSnorzztM7OJGx1kddgmovapYtynqkgkkHLGHMHjK2CJ4vei OCbw== X-Forwarded-Encrypted: i=1; AJvYcCXOxU/NjunUWGcAFoAMZpOj/40ZEcpNnabdFFlFGPMUZs56ctAYZbja5q0CQw/r4PRMpYZ9LCFBp5uQE7Y=@lists.ozlabs.org X-Gm-Message-State: AOJu0YxWAHubc5hLZUkesmhndo47DW4nXTEc7DLTO8kr1jMT4Avzuu9j l+x/j40lc3TkVthOm/NyWjIOpMAQTxXlZEtUt2aS7m4iU1aLZAmG X-Gm-Gg: ASbGncuVocfwKzdlCw6LL8htVkkvPcVqxhVHlzzk09x6sxBhXbEyrcT470zpxV1gBnw GPe6I3Ifq+L3p5EpeG1hCc5SDIFvCN0iy0j1wtp0JQsWExRpUNaztbe6Rwx06Xt79/I/J8EB5Ut L4d9v5lDf2lusPegVVvXo//uWHUXUQNALAlfxAJhAK+LhUVQPUfyii74HeU1/lk1REv5OkuQorJ oNAjHQvSw7aHgD6srGnhwCdvHxcu7v6n3VpAlpZ4C0q2qtLER6jLcbxz1G+229Ag+8bAhpsGnyq VWfSM2hm3ZOeXhhP X-Google-Smtp-Source: AGHT+IFRAv4ES1nGe5GZzQSCr0JvuQEh3E1vBTb1UadMisfKYeWtlE6qWVQlRiPBMv3C59QKs6b8rQ== X-Received: by 2002:a25:cc1:0:b0:e53:4d98:7459 with SMTP id 3f1490d57ef6-e538c3cfd9dmr14310782276.40.1735411804331; Sat, 28 Dec 2024 10:50:04 -0800 (PST) Received: from localhost (c-24-129-28-254.hsd1.fl.comcast.net. [24.129.28.254]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e537cf73675sm5102193276.51.2024.12.28.10.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Dec 2024 10:50:03 -0800 (PST) From: Yury Norov To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org, virtualization@lists.linux.dev, linux-nvme@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-scsi@vger.kernel.org, linux-crypto@vger.kernel.org, Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Madhavan Srinivasan , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Haren Myneni , Rick Lindsley , Nick Child , Thomas Falcon , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas , James Smart , Dick Kennedy , "James E.J. Bottomley" , "Martin K. Petersen" , Yury Norov , Rasmus Villemoes , Matt Wu , Steffen Klassert , Daniel Jordan , Andrew Morton , Greg Kurz , Peter Xu , Shrikanth Hegde , Hendrik Brueckner Subject: [PATCH 06/14] cpumask: re-introduce cpumask_next{,_and}_wrap() Date: Sat, 28 Dec 2024 10:49:38 -0800 Message-ID: <20241228184949.31582-7-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241228184949.31582-1-yury.norov@gmail.com> References: <20241228184949.31582-1-yury.norov@gmail.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on lists.ozlabs.org cpumask_next_wrap_old() has two additional parameters, comparing to it's analogue in linux/find.h find_next_bit_wrap(). The reason for that is historical. Before 4fe49b3b97c262 ("lib/bitmap: introduce for_each_set_bit_wrap() macro"), cpumask_next_wrap() was used to implement for_each_cpu_wrap() iterator. Now that the iterator is an alias to generic for_each_set_bit_wrap(), the additional parameters aren't used and may confuse readers. All existing users call cpumask_next_wrap() in a way that makes it possible to turn it to straight and simple alias to find_next_bit_wrap(). In a couple places kernel users opencode missing cpumask_next_and_wrap(). Add it as well. Signed-off-by: Yury Norov --- include/linux/cpumask.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index b267a4f6a917..18c9908d50c4 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -284,6 +284,43 @@ unsigned int cpumask_next_and(int n, const struct cpumask *src1p, small_cpumask_bits, n + 1); } +/** + * cpumask_next_and_wrap - get the next cpu in *src1p & *src2p, starting from + * @n and wrapping around, if needed + * @n: the cpu prior to the place to search (i.e. return will be > @n) + * @src1p: the first cpumask pointer + * @src2p: the second cpumask pointer + * + * Return: >= nr_cpu_ids if no further cpus set in both. + */ +static __always_inline +unsigned int cpumask_next_and_wrap(int n, const struct cpumask *src1p, + const struct cpumask *src2p) +{ + /* -1 is a legal arg here. */ + if (n != -1) + cpumask_check(n); + return find_next_and_bit_wrap(cpumask_bits(src1p), cpumask_bits(src2p), + small_cpumask_bits, n + 1); +} + +/* + * cpumask_next_wrap - get the next cpu in *src, starting from + * @n and wrapping around, if needed + * @n: the cpu prior to the place to search + * @src: cpumask pointer + * + * Return: >= nr_cpu_ids if no further cpus set in both. + */ +static __always_inline +unsigned int cpumask_next_wrap(int n, const struct cpumask *src) +{ + /* -1 is a legal arg here. */ + if (n != -1) + cpumask_check(n); + return find_next_bit_wrap(cpumask_bits(src), small_cpumask_bits, n + 1); +} + /** * for_each_cpu - iterate over every cpu in a mask * @cpu: the (optionally unsigned) integer iterator