Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp1383145rdb; Fri, 19 Jan 2024 18:51:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHw2nBIDOI9g4aP7c7C6LRUMbZhV8B8O6u8SZWeGC9dUnDxJRXP1KF9Pc8iLFFB4cdKRGiQ X-Received: by 2002:a05:6402:1501:b0:55a:ccb4:ae25 with SMTP id f1-20020a056402150100b0055accb4ae25mr37311edw.42.1705719105974; Fri, 19 Jan 2024 18:51:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705719105; cv=pass; d=google.com; s=arc-20160816; b=pmcQNUecUeAkbSjeivWTgD2N2M6mlOqZWDf2MdI29gCOIaW7Wn2QGCdc4IfqdZd45G S9uG4gv08COQqnozeo9Wtjlp6dPcRjsgbV8toOjqQEI7kALVppUuFH6Axpgn/nL17u2G vL3552RKrmGwnCr2Ni8pacNWYjTAIriL1MB41MUNhl0JXl41JBpTR+4dzFSuYbmKDwrk N7JXAEz+3uPVjfMHSDz7U1ndcD2yfvXWWm7bdR9icPb9qINRDTdOOvOCsfzlcw0vfFv8 JWX43Q/Uhn6zQ4/nNVERRM9N4PJ7RT8+lJdZseG0yy0RYLuabTFM0R0C0spNJ8qcNFm4 Z50Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NLcBksejFtB67CxPfS8EreSpNvKNv16Sj+tueH02QvE=; fh=XBn6QOxXmd+a21rfOzAv6TsGVH//lL1yHr3TAnHgMoo=; b=IWEv5Cokl5XLlLDPC4pPBfS/5q/869zFwe3R0CVhmvqTE813IPxhjIJ3h2jO5VXtcf xIKtfVS12LqXw7H/Rq39/JOOduGMeSKrzxcKUgaIVaLPvrQ/YxwAKwg3J3EGfxsw4j/Y CA0zH67b5ufT7I2RCwbf1rnI36SJ3Bm0hkwloYnpx8PL+3BUCI8rcudz0PSs9ccbTLx3 nYqrfjUkpvK3oDEXB/j90e0fccOLP063G0wgncfVNIrRhxTHSNjz1NOVj0Y/cysFSOh3 mm9bpJRJ0T0Mpa2bBptePZVl66SpD5MezS6zjPe/A8nUMfk9FShKsP7Hr2RJjkymjUdh 4mXQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bXMMWiVM; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-31686-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31686-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id d11-20020a056402516b00b00559c8e657d3si3723200ede.512.2024.01.19.18.51.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 18:51:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31686-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bXMMWiVM; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-31686-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31686-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 94DC51F22BBB for ; Sat, 20 Jan 2024 02:51:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7F09D46BA; Sat, 20 Jan 2024 02:51:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bXMMWiVM" Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (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 3FA1020FA for ; Sat, 20 Jan 2024 02:51:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705719063; cv=none; b=T281k4NrWBZCP8iFRW0hhw9EvQou0UlYIaEWkC1ZEY902PwMNQjp6bGn88Ldrd9jHQcWH4deaRAogC+wkIggNcqIwvwJJYe7hD0J8WkKJD3PxH88ypTrR6K5zbAPWwFjON38azox+l8RRpgIDmQJx7OP8nX804esofpZHsYcTPE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705719063; c=relaxed/simple; bh=OMBbdYX8nOdWmRvXvgL49m4b2eYizvAW2/Ifazlfivo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=i3I+bM9dkeC1dLT4FHGNvPLqGqeTUhXruhzW7ysrk/AaoKJucUwSq9HTKACJxqYg3JLvQXwSr1RA/PqGlZGvCn3mXY/Qnz+zzppsCAGYpvGxcrU6P6t0fUcc7IsZDB7RHsfZW988hWFMtl8sjXO9ejLXZGLp+b0L3FD7Uim8QTw= 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=bXMMWiVM; arc=none smtp.client-ip=209.85.128.179 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 Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-5ffaabdcccbso4277367b3.0 for ; Fri, 19 Jan 2024 18:51:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705719061; x=1706323861; 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=NLcBksejFtB67CxPfS8EreSpNvKNv16Sj+tueH02QvE=; b=bXMMWiVM/zLsvQKhRVgfCi+oyjBFOnfnbJ1UVQraiOHWyfpbsb5UQ66s50gc7Mhudy Po/YLi0sMFbztX+VFA6guFg3MrsTQgCBiSEaE5lAAURL9H6ehM0rg6eoRY9lv0MaaNYp VCfiAHomXYB4GxRi9JVDI4gT5uPM/ROrLOLKTImtPXNHJEPcIbpLJhxwsjmuG5kizWgN /kV29pGRVRqiqxhkVA13f65neecDiyT7c6rgtnH2UfUl4Qa5v5ocRflV/lBa6k01I4IB 5UMTBCC7km/GzCuBckqQ9BUwoA9BZXc09DOXYBZy3SaLDC1zPvdTaY5YX01xpBcXSsLp 6/ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705719061; x=1706323861; 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=NLcBksejFtB67CxPfS8EreSpNvKNv16Sj+tueH02QvE=; b=ekEhCcEo1F7VpnPk1TjNSFDx+sdd8ImWyHY5N9ES06ClU8BK9XyOqGEcsn+L0GlY7a /ikm4sjUxkaRLZZJZ9IQ8MVvAUM3UFPxOnpejIav/Dj68Rp1gU/d6cR5tJTIZ34WGSM+ NfcjDexYAmTXpxRs1lWLMRKF2AVhqekeQ7L1/yo/6w/rt44xojDepDJH+B06LiiVCoFo sO5gjq7mKqiggZ/pVRWzyzaeIotlXRLcvuhXUXT2NiqOlbx+zuQChG3znxVeF0tlzfIl XdEo1yNqdivRNiinCz6AoIJP5CVYryQXQZdGDCDeZjPQisK00Z/LnGZUi/yvX3cBOlCD 6N1w== X-Gm-Message-State: AOJu0Yxc4bS/BFOlR7TjVcabTX3z54b6O4zZPRdhb8ELPPt1s+P7/FkE GheNthdvhPXhkm51tK6q6LrD1dQX8LY+6gHczHEp6jfGl8WafPy+ X-Received: by 2002:a0d:e747:0:b0:5ff:9f17:654e with SMTP id q68-20020a0de747000000b005ff9f17654emr760006ywe.94.1705719060684; Fri, 19 Jan 2024 18:51:00 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:2288:782e:a717:678d]) by smtp.gmail.com with ESMTPSA id r124-20020a819a82000000b005e92fd632e0sm7897419ywg.24.2024.01.19.18.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 18:50:59 -0800 (PST) From: Yury Norov To: Andrew Morton , Thomas Gleixner , Ming Lei , linux-kernel@vger.kernel.org Cc: Yury Norov , Andy Shevchenko , Breno Leitao , Nathan Chancellor , Rasmus Villemoes , Zi Yan Subject: [PATCH 3/9] lib/group_cpus: relax atomicity requirement in grp_spread_init_one() Date: Fri, 19 Jan 2024 18:50:47 -0800 Message-Id: <20240120025053.684838-4-yury.norov@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240120025053.684838-1-yury.norov@gmail.com> References: <20240120025053.684838-1-yury.norov@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Because nmsk and irqmsk are stable, extra atomicity is not required. Signed-off-by: Yury Norov NAKed-by: Ming Lei --- Regarding the NAK discussion: > > > > I think this kind of change should be avoided, here the code is > > > > absolutely in slow path, and we care code cleanness and readability > > > > much more than the saved cycle from non atomicity. > > > > > > Atomic ops have special meaning and special function. This 'atomic' way > > > of moving a bit from one bitmap to another looks completely non-trivial > > > and puzzling to me. > > > > > > A sequence of atomic ops is not atomic itself. Normally it's a sing of > > > a bug. But in this case, both masks are stable, and we don't need > > > atomicity at all. > > > > Here we don't care the atomicity. > > > > > > > > It's not about performance, it's about readability. > > > > __cpumask_clear_cpu() and __cpumask_set_cpu() are more like private > > helper, and more hard to follow. > > No that's not true. Non-atomic version of the function is not a > private helper of course. > > > [@linux]$ git grep -n -w -E "cpumask_clear_cpu|cpumask_set_cpu" ./ | wc > > 674 2055 53954 > > [@linux]$ git grep -n -w -E "__cpumask_clear_cpu|__cpumask_set_cpu" ./ | wc > > 21 74 1580 > > > > I don't object to comment the current usage, but NAK for this change. > > No problem, I'll add you NAK. You can add the following words meantime: __cpumask_clear_cpu() and __cpumask_set_cpu() are added in commit 6c8557bdb28d ("smp, cpumask: Use non-atomic cpumask_{set,clear}_cpu()") for fast code path( smp_call_function_many()). We have ~670 users of cpumask_clear_cpu & cpumask_set_cpu, lots of them fall into same category with group_cpus.c(doesn't care atomicity, not in fast code path), and needn't change to __cpumask_clear_cpu() and __cpumask_set_cpu(). Otherwise, this way may encourage to update others into the __cpumask_* version. lib/group_cpus.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/group_cpus.c b/lib/group_cpus.c index 063ed9ae1b8d..0a8ac7cb1a5d 100644 --- a/lib/group_cpus.c +++ b/lib/group_cpus.c @@ -24,8 +24,8 @@ static void grp_spread_init_one(struct cpumask *irqmsk, struct cpumask *nmsk, if (cpu >= nr_cpu_ids) return; - cpumask_clear_cpu(cpu, nmsk); - cpumask_set_cpu(cpu, irqmsk); + __cpumask_clear_cpu(cpu, nmsk); + __cpumask_set_cpu(cpu, irqmsk); cpus_per_grp--; /* If the cpu has siblings, use them first */ @@ -36,8 +36,8 @@ static void grp_spread_init_one(struct cpumask *irqmsk, struct cpumask *nmsk, if (cpus_per_grp-- == 0) return; - cpumask_clear_cpu(sibl, nmsk); - cpumask_set_cpu(sibl, irqmsk); + __cpumask_clear_cpu(sibl, nmsk); + __cpumask_set_cpu(sibl, irqmsk); } } } -- 2.40.1