Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2811792lqo; Tue, 14 May 2024 09:48:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWBkgivycm0FLvw+T47lrzFKC81/iC0KX0GlQUSw28kBZtoaQ/lKSaV2wIi0r5L4eEUjQB0mnlC5V9yDAQ1scDZ+Nitm4+JRArD1Qvgrg== X-Google-Smtp-Source: AGHT+IFEu+fnv9oReAhRZyigqKG69Bvh2k0xwMto0oix0CtdweOflYQHxZLZSFVA5nF+mlRDYV4d X-Received: by 2002:a05:6a20:12cc:b0:1af:aef6:7261 with SMTP id adf61e73a8af0-1afde0e5fc0mr19739574637.27.1715705284903; Tue, 14 May 2024 09:48:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715705284; cv=pass; d=google.com; s=arc-20160816; b=D+mNyopddqAtzXQFBq6l03zN7Eyimg5dVEUdM6jhoOTbBpFD+Vd4eU41jEtEL4hcnS zx51tJ6Y1pnH+PR/VVHs7hoA//VPqa6NHxf6fzgIhOvCa5u2UXwk8X7JnGQY3VWQmQ/F hV+WqoBY1jhoU4c9QTSYKI/h8TB6n0NVpouM8sx6LdLGM4UtAMI6LDOZkSQ3AaJduuaO Zgl/iSNWxN1E9gxR+kTB+Fxlbslq+IQod/SWo7pBf8P3X2SrVE1nRH5m20c+B3CQ1ytT 3cXTqU4VBMndaHTXOvEAW0gOLlsiNLFXyakeWy9ByFbvZiWNSou3KJJRzOSVBWNd3znl OMAA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=9EeQjuV214QMKCW8+MdYcFTtVImchVTc5aos0uWhYxk=; fh=8JL1/vfbEllbdvv/2wUVpKyJilXEOT96u+fwOVE1AhA=; b=VWK6paxDb9tySvuL1ubAl7ELHi/kognkN29is/D/IxvUgGuN98Ax5UGOV3aZfQrWnT bfPRnz+ppMLEGguACH8ytBBdtXpmx6tFLcWxu6zaoY9pik6vJmAD/0KvlcFGsydwiqt7 DplGGgiLWN+RUmfHpgB+PwPcOfNqvLH95Ufmv8uuUhMBxmyX33boOFDqEz45Qnlo8r+L JbJ68lJ77dD1IKdlz5p1YRBQia/8Dkw/phKj30i99LUL78BbqfWGBcTQFLPEvfdxrui6 oXR/JG6C/NK/6t+WDyNGqRFee/fa/w55c8joWEX7tkF72sd2W8N9vUjCMEO348qTLF+u aKEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lzXyJ0Sp; 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-178964-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178964-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6341180dc88si11678774a12.489.2024.05.14.09.48.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 09:48:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178964-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lzXyJ0Sp; 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-178964-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178964-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 694BCB21534 for ; Tue, 14 May 2024 16:47:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 359F817F37F; Tue, 14 May 2024 16:47:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lzXyJ0Sp" Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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 AAE5AF501; Tue, 14 May 2024 16:47:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715705268; cv=none; b=gBI5/D/YFWM26O+zjI5cKQFOdqTmuAahaP+pBdrts9q54ciLRHVq2PQglamzYINZ81qCKNXhcjiz/UwKZwOERsl9ypt17YGlPblktJMuITponI+kFjmXl0WEYd+aBi4yq3MTEmgp+jQ1BAVg0JOCGVmuoYCGjIw+EyFd6D5kzcA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715705268; c=relaxed/simple; bh=mwFsSf+AWXeVxQSo74iPcsI576htwkDDfmRc0faDOi0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=n9z3I5tU+sYTSqOLUZDutbpRWU3bf8t07SW9HSr898A/hXZgGMguOZE6cRiESml6Rkl7Cv0SZbfqrrP3XP26e2m8h5i+lRmu9g3Y4x+Ce+1b9ZOQdWljpe23FW1dfCFYebnj5ZgaBhcFAUIZjdE7UFksj2uHTULUvvS/6okdNDQ= 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=lzXyJ0Sp; arc=none smtp.client-ip=209.85.167.44 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-lf1-f44.google.com with SMTP id 2adb3069b0e04-51ffff16400so9671394e87.2; Tue, 14 May 2024 09:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715705265; x=1716310065; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=9EeQjuV214QMKCW8+MdYcFTtVImchVTc5aos0uWhYxk=; b=lzXyJ0Sp90TcfO/OHpGTA0ZJCHyVYuXgrPIcL8YS2axoKNDOap2ioFFiMBjVr6IGIO jYeqS1wR4IgNSUm5JHu7MrgHg04+w5o2b8I/NiStJxYgywib77yMX2uko8JEaVSjepJD 0zUKCTEmkWd/Uo69GskpTSUOGgT11gvQjSXSEM2O1JSInRj4JEX9hBT7I9AXfG7afweI xhYoEfEn7UsfP2yzToc3OxEjvg4nfRk8rNCtJnbFCCYMPcPg9Q/KQSdp77RQPaKlzl9z ED+lputB8/VSjYZtlgzfZYKGht3vTf3aR4vRXbdJKTjGN1eosMn8OMpn33DwKLgV0gZy RZcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715705265; x=1716310065; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9EeQjuV214QMKCW8+MdYcFTtVImchVTc5aos0uWhYxk=; b=QnLyCwpd6REiTzUQo7UuqhUfC0mOIOx5MU6OvESNct7j8hK1ph1+NPqukkvadvGhvY 1hFcUPo5uDLAZc8Ft1Az67VbHwHiJ7/Ez1reFp07CtrnTKcpa7E7xp/tvDZMktqeFfrM CklDBp91KOKVPGrVqpSswWWJI8bXvv3FAKXZAJTeNlUDBgAWCUJGcW7SqBsamKNaq59+ 3xGfwyY38ZOcocRAlfY3ZB9D5qGzukgicK9ILyo9irdH5y3p4zBsK3uV/sYhDJBe4ZI+ pVCfqm+jzGIIMut7X28HhvzgKBauC9A1HdNwS/TCnbS0CEBa0bTWyzsxB+1SnJWvYvTz k86A== X-Forwarded-Encrypted: i=1; AJvYcCWc1NEOfUnJ0V0M4KRrS3M/ONOzu8Mrz+Rhel/Xw3vUxqw7u57TvC2j2oqcZvIJULWhoUz9b3KkUZRDml0pSQTycg4sSyYXfg== X-Gm-Message-State: AOJu0YziFUiX3uKb/iGp6buEPYOXHiwYFd8BtQ2d9hbEgqOuY/8skbqQ zaMqgVCqfdy0HwgXaStwKeA0bJdJ1d8eqjs+rNKb9peiaitTchjFaahBI3wW22pIP+w0kDJzYjn mUWlE+LkJri08EN+s066teSQcIGU= X-Received: by 2002:a05:6512:281a:b0:523:8c69:4843 with SMTP id 2adb3069b0e04-5238c694a9amr18263e87.49.1715705264430; Tue, 14 May 2024 09:47:44 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240513220146.1461457-1-yury.norov@gmail.com> <20240513220146.1461457-7-yury.norov@gmail.com> <878r0cn6a5.ffs@tglx> <874jb0n5rt.ffs@tglx> In-Reply-To: <874jb0n5rt.ffs@tglx> From: Yury Norov Date: Tue, 14 May 2024 09:47:32 -0700 Message-ID: Subject: Re: [PATCH 6/6] tick/common: optimize cpumask_equal() usage To: Thomas Gleixner Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "Paul E. McKenney" , "Rafael J. Wysocki" , Anna-Maria Behnsen , Ben Segall , Daniel Bristot de Oliveira , Dietmar Eggemann , Frederic Weisbecker , Imran Khan , Ingo Molnar , Johannes Weiner , Juri Lelli , Leonardo Bras , Mel Gorman , Peter Zijlstra , Rik van Riel , Steven Rostedt , Tejun Heo , Valentin Schneider , Vincent Guittot , Waiman Long , Zefan Li , cgroups@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, May 14, 2024 at 1:42=E2=80=AFAM Thomas Gleixner wrote: > > On Tue, May 14 2024 at 10:31, Thomas Gleixner wrote: > > On Mon, May 13 2024 at 15:01, Yury Norov wrote: > >> Some functions in the file call cpumask_equal() with src1p =3D=3D src2= p. > >> We can obviously just skip comparison entirely in this case. > >> > >> This patch fixes cpumask_equal invocations when boot-test or LTP detec= t > >> such condition. > > > > Please write your changelogs in imperative mood. > > > > git grep 'This patch' Documentation/process/ > > > > Also please see Documentation/process/maintainer-tip.rst > > > >> Signed-off-by: Yury Norov > >> --- > >> kernel/time/tick-common.c | 15 +++++++++++---- > >> 1 file changed, 11 insertions(+), 4 deletions(-) > >> > >> diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c > >> index d88b13076b79..b31fef292833 100644 > >> --- a/kernel/time/tick-common.c > >> +++ b/kernel/time/tick-common.c > >> @@ -253,7 +253,8 @@ static void tick_setup_device(struct tick_device *= td, > >> * When the device is not per cpu, pin the interrupt to the > >> * current cpu: > >> */ > >> - if (!cpumask_equal(newdev->cpumask, cpumask)) > >> + if (newdev->cpumask !=3D cpumask && > >> + !cpumask_equal(newdev->cpumask, cpumask)) > >> irq_set_affinity(newdev->irq, cpumask); > > > > I'm not seeing the benefit. This is slow path setup code so the extra > > comparison does not really buy anything aside of malformatted line > > breaks. > > Instead of sprinkling these conditional all over the place, can't you > just do the obvious and check for ptr1 =3D=3D ptr2 in bitmap_copy() and > bitmap_equal()? I proposed this a while (few years) ago, and it has been rejected. On bitmaps level we decided not to do that for the reasons memcpy() and memcmp() doesn't, and on cpumasks and nodemasks level it hasn't been discussed at all. Now that most of bitmap ops have inline and outline implementation, we technically can move this checks in outline code, as inline bitmap ops are very lightweight already. So I see the following options: - Implement these sanity checks in outline bitmap API (lib/bitmap.c); - Implement them on cpumask and nodemask level; or - add a new family of helpers that do this check, like bitmap_copy_if_needed() (better name appreciated). The argument against #1 and #2 these days was that memcpy() and similarly bitmap_copy() with dst =3D=3D src may be a sign of error, and we don't want to add a code that optimizes for it. Now, I ran the kernel through the LTP test and in practice all the cases that I spot look pretty normal. So I can continue sprinkling the checks once a few years, or do something like described above. Can you / everyone please share your opinion? Thanks, Yury