From patchwork Tue Jan 28 16:46:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 13952809 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB7B31ACECE; Tue, 28 Jan 2025 16:46:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738082818; cv=none; b=HlSrwqWUME4JMYIp6UreWbTMYlRYHthZV59elWUg4XSy5aHVLd12j0H7ftScurI+QZYogg9N7G45mC0pii154v6A1aHYwEkZ+aIB10vPK04UZZ5+afKfIPff5ze18aLjlu0dDFXAaKd8qCDeIImddUqvouasspXPG1W2q4+rRqM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738082818; c=relaxed/simple; bh=fY1Ht0lNOAKw8K5OedtmKPz5PbDJBPdWABo+iz3tz/E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sWWutrQjhP1KzMMV4Ck7KXzL8my11Jh/Ut4oljUSZlDKJsFy7Ms+d1g4R+n7i3Eix/OFNb5LXgGB4tqjRr8WpBGnxmUBMFCNeZQxQPO/7ik68nsbmh3Diqgli94/ppTh6M5G02kA8y6he2gleHKTQ1qkWtqQutrIo+xCe7l+6BU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=X1TAWdvZ; arc=none smtp.client-ip=209.85.219.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X1TAWdvZ" Received: by mail-yb1-f177.google.com with SMTP id 3f1490d57ef6-e3c8ae3a3b2so8106006276.0; Tue, 28 Jan 2025 08:46:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738082815; x=1738687615; darn=vger.kernel.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=izBUo6HsqfmU6F4r4wLj8SjU7ULP/X7gCkrYK1n4Pjw=; b=X1TAWdvZvEmSq8O+R8nGaOHzciU2ZHi2ckJnhAw0L50ukgebW3HesnyJ8xk33mZYip apOchJFozQNJpf1DDYGR2Gb5Kp4tFiV4jkI2lbhZn3ElIkNv2V/yafMiMkEmXbzOaJWL gNlq6zChGxvxisU3SRKQ1jgNleJF9mwgUTT/A0fLYOL9ckh4f0RMXTGguX0fHr+cpTVq ReHbxWU9mFnReLQmHE2G4hrydFGrqm1u9wzvCG8odQiGBHodC3Ylt3TCxr3QmGjAgFi5 FFSkMhXhmgzyd+7bfRQqFAxi4V1QHG2KiT46adsI3jziUZxHiDIxSDnD38sWn8kfZJDe h/1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738082815; x=1738687615; 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=izBUo6HsqfmU6F4r4wLj8SjU7ULP/X7gCkrYK1n4Pjw=; b=dTzCRmXC3lmwtT8G4+eNPZh+wPq0gZG2CJWuKTmAx0qUiVbeQG6iMX2cd8FIHkwXjg Ska+aeWWQFMHYDtpXmxNZIXZUUD24JrPr4D6uMh05H89362dMkHKFRWAj+iTrNja2vSS onFmxOVc/GuXJinKzJm6UPTbJ4LmxhHci1PQ21J8NRmCDG4Pxscs9YvNY6nOamFheBN2 LBo8deR2cMsnaD8yAEZZ9O772E1DAQPYkEnmpV4blzQLVfUlPpy7Pa46limBS0Nnk2BN 8iBlNtJTRvFJrSmg/S61nwhJhTytDIxVTY0povCkiYrW1q1AtLzmsS3p6eqWaW7lhfFt eXew== X-Forwarded-Encrypted: i=1; AJvYcCVoUpg2MHFLHTkUAVaf05AfKfgwhCYpUma25XoG2Btq3zTYhZBA9NRI0jpzJhlOL5Ghtovebz0=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9q+RnwnfxEIxrN8jk6DgZHRqIdCzYB2C2/jXXfEUWeSxhLMui XOy/DHVlW9Z7hPzcEwNz/27tpCxcEqVtyry+9sKTF9Rr4WHtkbo4fPCSl4Ab X-Gm-Gg: ASbGncsRVkmfJPy0ldxGq/BCxwQxBIOiUJr0qa4EA+kU6cZ7GH9icvZeQftzX/6a5Sh 8PvjWZerdLckQuaFZ6GL/ZVWSll89R2rHgMiWV8iX+RV88loKgDz3F3Jy5qj0LPsOQJwobgKES+ z3BvMQwHGYOJjibedw2mhPX3OsyeDiTPmqDZRr9BhAS2UorRzIvq64jbUgKbUwgOa8b4oSVvaKi g4E5wDgCK+8IDZRqqeT7wN6WSE6AyR/rCi/KVu/GIaxrBWCHcx3xjHVUuI1PI9XVWQH59YVUtxE 1KklREPqJruTmHWpLHXwyQGo4ocyaFAKUk1vmVI335xxma0IR6Q= X-Google-Smtp-Source: AGHT+IHc113oUWa4lQB5S7fsBtzpiuhJaSRgwEzNaVPqu/U+wdu2NqhKKZn6+Jf4YhXOVOV+JKbd/g== X-Received: by 2002:a05:690c:9681:b0:6f5:393f:cf48 with SMTP id 00721157ae682-6f6eb684324mr340143727b3.21.1738082814734; Tue, 28 Jan 2025 08:46:54 -0800 (PST) Received: from localhost (c-73-224-175-84.hsd1.fl.comcast.net. [73.224.175.84]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f757a00e4asm19752577b3.73.2025.01.28.08.46.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jan 2025 08:46:54 -0800 (PST) From: Yury Norov To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, virtualization@lists.linux.dev, "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Nick Child Cc: Yury Norov , Christoph Hellwig , Rasmus Villemoes Subject: [PATCH v2 02/13] virtio_net: simplify virtnet_set_affinity() Date: Tue, 28 Jan 2025 11:46:31 -0500 Message-ID: <20250128164646.4009-3-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250128164646.4009-1-yury.norov@gmail.com> References: <20250128164646.4009-1-yury.norov@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The inner loop may be replaced with the dedicated for_each_online_cpu_wrap. It helps to avoid setting the same bits in the @mask more than once, in case of group_size is greater than number of online CPUs. CC: Nick Child Signed-off-by: Yury Norov --- drivers/net/virtio_net.c | 12 +++++++----- include/linux/cpumask.h | 4 ++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 7646ddd9bef7..9d7c37e968b5 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -3826,7 +3826,7 @@ static void virtnet_set_affinity(struct virtnet_info *vi) cpumask_var_t mask; int stragglers; int group_size; - int i, j, cpu; + int i, start = 0, cpu; int num_cpu; int stride; @@ -3840,16 +3840,18 @@ static void virtnet_set_affinity(struct virtnet_info *vi) stragglers = num_cpu >= vi->curr_queue_pairs ? num_cpu % vi->curr_queue_pairs : 0; - cpu = cpumask_first(cpu_online_mask); for (i = 0; i < vi->curr_queue_pairs; i++) { group_size = stride + (i < stragglers ? 1 : 0); - for (j = 0; j < group_size; j++) { + for_each_online_cpu_wrap(cpu, start) { + if (!group_size--) { + start = cpu; + break; + } cpumask_set_cpu(cpu, mask); - cpu = cpumask_next_wrap(cpu, cpu_online_mask, - nr_cpu_ids, false); } + virtqueue_set_affinity(vi->rq[i].vq, mask); virtqueue_set_affinity(vi->sq[i].vq, mask); __netif_set_xps_queue(vi->dev, cpumask_bits(mask), i, XPS_CPUS); diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 5cf69a110c1c..30042351f15f 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -1036,6 +1036,8 @@ extern const DECLARE_BITMAP(cpu_all_bits, NR_CPUS); #define for_each_possible_cpu_wrap(cpu, start) \ for ((void)(start), (cpu) = 0; (cpu) < 1; (cpu)++) +#define for_each_online_cpu_wrap(cpu, start) \ + for ((void)(start), (cpu) = 0; (cpu) < 1; (cpu)++) #else #define for_each_possible_cpu(cpu) for_each_cpu((cpu), cpu_possible_mask) #define for_each_online_cpu(cpu) for_each_cpu((cpu), cpu_online_mask) @@ -1044,6 +1046,8 @@ extern const DECLARE_BITMAP(cpu_all_bits, NR_CPUS); #define for_each_possible_cpu_wrap(cpu, start) \ for_each_cpu_wrap((cpu), cpu_possible_mask, (start)) +#define for_each_online_cpu_wrap(cpu, start) \ + for_each_cpu_wrap((cpu), cpu_online_mask, (start)) #endif /* Wrappers for arch boot code to manipulate normally-constant masks */ From patchwork Tue Jan 28 16:46:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 13952810 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com [209.85.219.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F6A11DE4D2; Tue, 28 Jan 2025 16:46:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738082819; cv=none; b=ea8wSi72SH573GM4ittjnUXHzQho7beoKx/uXAMyAJD7ydV15WZBz1T0wWQu7xs/WmDctaCTLYqNWTW47BAsXJWl4i0lVb50uj8HUSNF0fDWso4CYFG0WrUf5ExpoOxMOVP6nwvdzDH2mPqlLk0vRW2f7Az6YDfC62l0u0HXzKE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738082819; c=relaxed/simple; bh=glHKOapZIwcwFFnizpd/vqC6g/9VM+x0Bg4In7uX6fM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SQtogdwcAX3cmzC4DgcS2QePsc8lkfqMLfDdd0aPm1Or3UYqjHBTe7WiNo1kj40DsCcCIQ7byEJeV3C5FK6maRUM7g2f8AdXUh2vEoZG4lL5UsnstL8+aZcQafZKZdwFAKwW06T0ue2iZncAea+qAGEXdIkiyK/Pq4gmYdbdWPY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=b+YlJExe; arc=none smtp.client-ip=209.85.219.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b+YlJExe" Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-e4419a47887so8021738276.0; Tue, 28 Jan 2025 08:46:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738082816; x=1738687616; darn=vger.kernel.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=9jlrAcgdlcuse8iCe0f260piXpVGsuWUSordlnIs6v8=; b=b+YlJExeCkjlSnCHura1ZigcukgpQtML27Taap95aBOT7amGH+poy3Yssum+i20efZ I6Iw5v87+1lG9TsLf8oc/SATFSUqkf/MzkIur/UYs2NKatIL3M+ihaoj6uh+jweeZAXs +GZbWdTU2kbA5k7AHQ9kLLBsJGPUs59DjKwdqkXWVfsxeUlV3w28Oo32KizwIrKY6s4q eqXSxQ/6ia0VYTMJWP6Fx/k0IRuoj/XLESNgQouwOhox14MR9XA9m92LA53uTFAXUrAY jlgpOgjHzT1kOXf+FPqwZ7V7icfzmmlm+gWackYPzqIt8NhjBXUf4mbXzyvsfbteEH4s ESKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738082816; x=1738687616; 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=9jlrAcgdlcuse8iCe0f260piXpVGsuWUSordlnIs6v8=; b=b1VAbAUeIOszgokpX5g9Y4SjlEU9T4FJ7Zs0iqhopYYuhrTXmIvKJGFvhoF6o14dp/ vPppTUW3gnbZn9NnzACwbwbAYjEH1zNW/fZhERHd0TTMGuoCH30qwV1IXOlpVf+jD8ZQ zmvEscT8lsNOHQwzNYaGUObMUql0f/mN/zF7ay9SnwToTU2VO+5hIMQhcaVaftYEGHjb JEzmA1xIqyIhb0Exj9SF/mVtREup73gYdhCGOD2YyvXuetAJL0ArznKhqNxT7FgByGMS S97I1MuUeqdejyn8WQPmfPLxHGvrgalTgtcCia3Q8xunXEG+OH9lhdP434NSB8OWP28r 2Lag== X-Forwarded-Encrypted: i=1; AJvYcCUuOvpbAtj4xYrauS3P+3dX+UoSI37ndSbDsHeqmY8jr0iaJrZawBnBS4IYNGG79quh8NExzzo=@vger.kernel.org X-Gm-Message-State: AOJu0YzV2meHoKgkVwISGCkqnEKA5saEnpA9Ke49EuTVBYJ0EWyrfcBf NqqCM0/oB9LQYS6bK9ra1kBA2VADkW4b+1240kxeGXwnC1CEPpl8LyCDE/LJ X-Gm-Gg: ASbGncvp1jY/j3zAWtVNWtbAHfKIR+XPtOatCg1iBlQFNHGurgRl8RUhcsrMppJpMez kI32tDAuB8kLNMfCnQVq6zLsEw7W+avmUrwzz08CE3KJRM8aQ5xWZMCuzYDxr4x3loVjO0VfngA s361R7kZ7Wos0ajEKCKoQhLaeRvYOae8l5AnzCm0g+bLBLQpMmlaK8WmQfxZklUrKnKWV5B/iMc 6BKYQa557/Z7MAZWPcI7iMWkvV2c5m+O/p8i0Oud56G4D6fynNm7Civ1W2CvtxGae57VAR1f/LF AKkXY3nz6YH6U1xLWoykfEVBigaCZWhIeuArmzGjSFLWLmFM2z4rHRoOltVreg== X-Google-Smtp-Source: AGHT+IHgsJ3cSZTT2IUcyxNcM0FxGg/w0v9YU63CYMxP8tpt4cmfiPqHRC1Hgkmpm4IjqQ+OplZzew== X-Received: by 2002:a05:690c:46c2:b0:6f0:237e:fc4c with SMTP id 00721157ae682-6f6eb677db4mr335746597b3.12.1738082816017; Tue, 28 Jan 2025 08:46:56 -0800 (PST) Received: from localhost (c-73-224-175-84.hsd1.fl.comcast.net. [73.224.175.84]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f75788d7d9sm19386767b3.27.2025.01.28.08.46.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jan 2025 08:46:55 -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 , Christoph Hellwig , Rasmus Villemoes Subject: [PATCH v2 03/13] ibmvnic: simplify ibmvnic_set_queue_affinity() Date: Tue, 28 Jan 2025 11:46:32 -0500 Message-ID: <20250128164646.4009-4-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250128164646.4009-1-yury.norov@gmail.com> References: <20250128164646.4009-1-yury.norov@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.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. CC: Nick Child Signed-off-by: Yury Norov --- drivers/net/ethernet/ibm/ibmvnic.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c index e95ae0d39948..bef18ff69065 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -234,11 +234,17 @@ 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--) { + /* For the next queue we start from the first + * unused CPU in this queue + */ + *cpu = i; + break; + } + cpumask_set_cpu(i, mask); } + /* set queue affinity mask */ cpumask_copy(queue->affinity_mask, mask); rc = irq_set_affinity_and_hint(queue->irq, queue->affinity_mask); @@ -256,7 +262,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 +280,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 Tue Jan 28 16:46:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 13952811 Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com [209.85.219.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A4B21DE89D; Tue, 28 Jan 2025 16:46:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738082821; cv=none; b=rXvtA1vkiheUR/mjh5kQXO1v4IIE3mRRDRMNdEBD79pmn6fqu8t4SaftSbTEX+VUevvSlLrgSH5+Z0wV8f+8ex/kVRTlqamS+C+aOm5iwWOVHepJZeIWazyBGlJyzj0FDrHlen//H/l9fyc7mrV6hsV87Uza3EOYjmZxHGAQfB8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738082821; c=relaxed/simple; bh=ZLbaWScI820HBD006hMz3NNgEber6YTKJOKCgmSkmLs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J7VOFPLJg6iy/jEla/v+7r1swoP63DuZAeO8uDFs02F+8hAJ7zGdhP2cvzUnb6PLuRrlMrxIszIWUN86jDUfowsbiUMKRreUu9Bk/VDDqbHXAfgJ3wa2X7v2nnefcZshFy0D3CEJ9thfnWch3pERTdyAjp5eRSrPaTBs6ED/dlA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kc9X5FxV; arc=none smtp.client-ip=209.85.219.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kc9X5FxV" Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-e3a26de697fso8810984276.3; Tue, 28 Jan 2025 08:46:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738082818; x=1738687618; darn=vger.kernel.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=rCckKKNOPT0GHbl/F3PRHzvVHT9Q6qmCcPDx48VRDmE=; b=kc9X5FxVafYyw/xVty1V4ERNz05ClGQINcQ/EvA3MEuCtpwzjSwNPHdBVWsMulktMN 0lg++oJXbqvG6UfsHutK6ZSLysW/c2+HedvyMd6WOmKq1U5L3M8ogTTW9X+4f34YU8Jg 1T601YIiPdINKHC3hI2/lx4ohGdRmGjLrPpAIHF6rmcVemHC7+NUiRLzxHXButgUZI2h qB0nS5W95DDdvO6lnuC3y+DNqOBOdMpsFj+GmmvzcFgSHUyILmJ4Wa5y+nLxv/JmVplf kOdGEwYZwHOxHVX61UaqdZCtsOg7qAcVdOdJ+ouiMrGWnghG4uRxpX5pMK1yAcdw80wO 2eng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738082818; x=1738687618; 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=rCckKKNOPT0GHbl/F3PRHzvVHT9Q6qmCcPDx48VRDmE=; b=M4c5ym4Wzfz78CQxxBIIor1ARq44xlbJnbgMkSndfVgHFjn/EDXpB+GK7AKdFZZtBF DOgwsQx02LGqSLNepmm+U8Z8Wm/c+4IH6uvmZ2NCukdC+hMOXRwj58d+G5sYItJHm2fu 1pNi4mX4oL2xkI5ML90+ZSpxoC/h8dP/eNsvXpmuBaE3XRmRC7as9p4Ynr+kU+CYkz4F UJs7qH7BNXvlRF2hLSNhb3cN6aleTZJeIJ3DEp00rwLIV+2RfBUQwKT4nz4MWdg1yvoE PaTM3YHOwKSZWYt5h+ujwSrJWPyTmlsqri8A90e1yVnxCdRHhz5/uPbDk8jDHkMn18zs 34Ww== X-Forwarded-Encrypted: i=1; AJvYcCV+Tnl1eH49YhU0vRYYCXAnF9ukgqduaObeEic7C6ihO+drmArU61uEQ4TNdUi2bjE8nXx5XNrRoWiT72Q=@vger.kernel.org, AJvYcCVPX13fpkil+VbVBgS8IjNiF6gjxhhHc2SutQTeaIjiVptIRtzteZzNcI+qEzHupftCh9Gp+RIWI3zM@vger.kernel.org, AJvYcCVR/b93I8vu3sTkEA9xMl/QJJeXLaZjdXJI+C846Qnw5nadYsDHJEtmznusAq56Mwltd43/ceKOYUuZdUWG@vger.kernel.org, AJvYcCWfnKSGgk5/GJwuHIhFwfqQPwvje/fkxIFDIGk197gGhBJdgLlJzZsDrUDht7XU92+xH5PNO+eF@vger.kernel.org, AJvYcCXWwUAIU72o6hUtls33NOP/I04MxVZ64g+GJQtLPVg1BYxF3sGBvjIfnqDC9/cJUpPqzeL1w0oPyst7ig==@vger.kernel.org, AJvYcCXiB+LBCmf1O+zidOUhwoDzXc2HZu5vGB7GB3nqKn0W2p7Kq2xU2g/J7n4WHSt7DEXYpuoJEYuZ9PwtNg==@vger.kernel.org X-Gm-Message-State: AOJu0YxCudxGHkqcobTjDhWYXCU7vWQ0TZGKW+6t4Z4aWg/uSpWmSS1l 3ztnAjH2K5AHYk+RhBna6kyM8bfJDbo8IHR8yzcJrtLjy3OZYoqAjTBc4+brCNQ= X-Gm-Gg: ASbGnctg1oS7JEpht4vO57bvWKvXGaB7pjtwxfrXANOrNu3jRxYVc5+A+M/CJIoQdsv MGU8pSI9EfxLTrC6UoZGmPw8KSZHYRCihnV6boI4hPTPNhdgP/MDdcdsXebXL35OCrz+uUhzj+V asYIB5juMFWB7Pfi1yB370MEEtSyMZLmQkNmoH6iDw8MQp30rwIcStQK+sPhnC+N1c2DsZQlv8X HaC0BBjMR1Y34O+5qL+miX94LN6hb/6cc1PDbbz/vXXdDg7BzMmc6xvV0IJn7oL9464L3yagW0i PRRxFmeGRkJ1yC1xGgwsEK1ztqrRfDQjBQuOxL9DYzSF51NwnWY= X-Google-Smtp-Source: AGHT+IFBJfNymvCDO315tC4xVxs+zkZuQynCdmKqW3cIaAkZSV4RPPUZkZxV0shs/Si+4edVpo1BeA== X-Received: by 2002:a05:690c:c8b:b0:6ef:ac8b:529b with SMTP id 00721157ae682-6f6eb90589fmr351241927b3.26.1738082818497; Tue, 28 Jan 2025 08:46:58 -0800 (PST) Received: from localhost (c-73-224-175-84.hsd1.fl.comcast.net. [73.224.175.84]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f75bf90de2sm17571157b3.70.2025.01.28.08.46.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jan 2025 08:46:58 -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 v2 05/13] cpumask: deprecate cpumask_next_wrap() Date: Tue, 28 Jan 2025 11:46:34 -0500 Message-ID: <20250128164646.4009-6-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250128164646.4009-1-yury.norov@gmail.com> References: <20250128164646.4009-1-yury.norov@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The next patch aligns implementation of cpumask_next_wrap() with the find_next_bit_wrap(), and it 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/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 +++--- 6 files changed, 9 insertions(+), 9 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/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index 6084b38bdda1..c39316966de5 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 418987056340..78e202fabf90 100644 --- a/kernel/padata.c +++ b/kernel/padata.c @@ -290,7 +290,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 Tue Jan 28 16:46:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 13952812 Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA5721DF99C; Tue, 28 Jan 2025 16:47:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738082823; cv=none; b=WFwDjGWpJJijYx06C79e5tRQaCt8aTILtYlUQDlU5HAsFhzdkz/lPyo5Yje/cV92IL51Aufhrnz65pkWiASdq8sAVdL3kYeJOi4qpZmn8jtesIeAtxTbM1GcLYrGRIKALQXg4NwKwR4i91S44HzCrBfCkzaK/Eb8KAfxzlcfcI4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738082823; c=relaxed/simple; bh=3Nw6u6TcLstz84UwM+gUpBPEmbRa4zVJY8ONgf+AwsI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FSodrBO7wUU8MMBnzDDgQ8O5zQcCaxu06VVJmCICdBZJa6tYuvrQokHLGfG4z0qt8rIdX/K5nqdahid0quFQUb45Jrq5ln3vmiAbijzUvS9FLHj+/LIj33wIwTlLwDAgaaoBL3u8vjHPjzyHBhyKBCI/OLo7m0Qfqa3ESfzL288= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=a9UGeBZ+; arc=none smtp.client-ip=209.85.219.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a9UGeBZ+" Received: by mail-yb1-f177.google.com with SMTP id 3f1490d57ef6-e46ac799015so7740234276.0; Tue, 28 Jan 2025 08:47:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738082821; x=1738687621; darn=vger.kernel.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=mPo0Qmhd/LgFOJoY/TurPrp2onCgGxY+Z0rc3zytFz4=; b=a9UGeBZ+Dno0Hqv6IasDiD8ZD+hk+4MOxDk3m+WeFm1wxfhE5xgXERj2DscxD48/tE f4csOBOmqyCeRDC78ibzKgcISvJXKb3PlH6KlTMl8zqubgyYhoIBdgdmPN3BeKhc1k9V QbQvLREla2BJvVYxY4Q1H7c59f51E5IYoBLwzrVx66dYq+IR4Lnz1nd0hLXSRJQ9mHRO PcPhq/v+zlJzjM1SOysIwyVXqjGA3Xz8YCCPSu35GhgPd8UFNQQ8oL3ax5MqDNtwYrsQ wsb9KahlQRPsog/F4MSXnGiH+tywFandzovmbnh33AipmXyg7rvPKcQpsS7XejQAexWk rOCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738082821; x=1738687621; 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=mPo0Qmhd/LgFOJoY/TurPrp2onCgGxY+Z0rc3zytFz4=; b=X5Yx5FIeR/f66E47J9vlGznyqpCct5m5+6680xg0oT3DxQUfQgTGdnlYCuA+pK54KS tKV0AxhCdrMcfSClax2nLvCStE6pSGDuD4/1DHBoMRhaUiL1Kfq8Llt7/x6lOM52NYkB ieQ9NieY4qlWF+x85EgRmcoyMJxbI03/NqCKLJO1HOVlinOpx2kDz7eOQawhTLLfMkhp rqbuzkhYmaotO2KFxTO/MC72MnY1jxbe6HZdC35aqr7LOqPRFmqlrJpKqryO+33yCM4g OJvYRufgqWGlc2KhYrVcJfYDDFJG7zRKDmmFcoABgWL/F4QUWcChTKGxndtVxrvxPmuI dYQg== X-Forwarded-Encrypted: i=1; AJvYcCU35hHcfnlqtpJEN+O82UN1Brf/72LZZES5UQ8NqQqRa42xCOz30RQGwEs1dKEZ9HlEd9iuGGR9sTkZIQ==@vger.kernel.org, AJvYcCUbtpxn7lrnLe6Dpme+arpijr8w8fEqPXB0LpCcAkFA/5N281DO+F8YSo1LuEfZMZkmr8rYwNAM3uYa9Xo=@vger.kernel.org, AJvYcCUweCNvy0SPTZueHpesRX2m1V31u2Mtq55GL7Y7jiyJpyLEvJvPKz5zKddlG4GxBFxgzN48t9Tql1Wk@vger.kernel.org, AJvYcCVId/NIazBXfhFUus7mfEy/ZTmbRNO1txa7gNAUbYeTIH9qSvIF7XCodXkdNf1AiHC5tINVZI9AnoJp+Q==@vger.kernel.org, AJvYcCWdG9M1jPa6XgtUmzP3bqTeBP1GT8g1vBXB+v+LfHMzjo9x1WvEg8cb8xQ+9VsbpI2HwohxNGpc9KV1w+XT@vger.kernel.org, AJvYcCWo10fMyNYOIks7POrIMPkp1V70sJ58XVW1uJnMYzN7kOg9AEnVFep4jJvKGAIz9rhS6vgCfZco@vger.kernel.org X-Gm-Message-State: AOJu0Yz5BMayPiOFo3C4dq+VfFf940YiItomgLLzAA6tiFWet8x/yR2D isbqe3smHuij6MtzK/YlmbtdaoSYvKnI+Tj+IAjuKnxhDWgOSRHxlWEhXPx22PI= X-Gm-Gg: ASbGnctZcQmlHAnxbsOmglEk6+8wErnieRp6d9hRtPRo3oMoDC1bYmNky0vyBkq2uBc r/QSa+xWkNffp+0tIxbmm+ljoJMYM6WmFhEU6elVR/D3KzKzKbJKdXXcunNI/Bs0kDCQoFVMxnt SzxBQAfHtlv1hMg9AdmTN2zzTB6qWqNkK3E7PcIO3tfiQW99CIsMQH5v2ggOLVbeM1uMiMyaeJE Su48iNgP9yqt/S3/UiH0tP3VV/hTCdbZWCXLNcw5gzz7U6gjvTrCPFxLV7cdMFHnb+/YxxzYd6/ 4nOjyOZAjBAulHqSNaygHC3QFQSO3tB/68kr1fEthufr/L9EIXA= X-Google-Smtp-Source: AGHT+IEbCDwztaXs4775wdhVhgVxaydy6EUMlQBUSRYIasXW3lx4ypNqxsjWkznwG36W84zpcNPfgw== X-Received: by 2002:a05:6902:982:b0:e58:306f:e83a with SMTP id 3f1490d57ef6-e58306fe89cmr14077851276.29.1738082820769; Tue, 28 Jan 2025 08:47:00 -0800 (PST) Received: from localhost (c-73-224-175-84.hsd1.fl.comcast.net. [73.224.175.84]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e589a2260a9sm196205276.37.2025.01.28.08.46.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jan 2025 08:47:00 -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 Cc: Bjorn Helgaas Subject: [PATCH v2 06/13] cpumask: re-introduce cpumask_next{,_and}_wrap() Date: Tue, 28 Jan 2025 11:46:35 -0500 Message-ID: <20250128164646.4009-7-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250128164646.4009-1-yury.norov@gmail.com> References: <20250128164646.4009-1-yury.norov@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 cpumask_next_wrap_old() has two additional parameters, comparing to its generic counterpart 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 of places kernel users opencode missing cpumask_next_and_wrap(). Add it as well. CC: Alexander Gordeev CC: Bjorn Helgaas Signed-off-by: Yury Norov --- include/linux/cpumask.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index b267a4f6a917..4f3d8d66e86e 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -284,6 +284,44 @@ 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+1. If nothing found, wrap around and start from + * the beginning + * @n: the cpu prior to the place to search (i.e. search starts from @n+1) + * @src1p: the first cpumask pointer + * @src2p: the second cpumask pointer + * + * Return: next set bit, wrapped if needed, or >= nr_cpu_ids if @src1p & @src2p is empty. + */ +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+1. If nothing + * found, wrap around and start from the beginning + * @n: the cpu prior to the place to search (i.e. search starts from @n+1) + * @src: cpumask pointer + * + * Return: next set bit, wrapped if needed, or >= nr_cpu_ids if @src is empty. + */ +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