Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2926103lqo; Tue, 14 May 2024 13:48:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUsRNRZdSSH62a2ikc/yCFrsJTdkYHGSxvba58qiqNd1YsO+i1JXAYDbuKyyCS6dDfveu7+dNIwdAmksOUdeyx+ujUvMABN1fbWpCxd0A== X-Google-Smtp-Source: AGHT+IH5ADlInMapjA2vlrlhHEzy7AZ3Cl/p1Bb6lIQqxAsQoLn+wSc1CSy9GEcKjiboKN4VtGNM X-Received: by 2002:a05:6214:4a03:b0:6a0:e6a6:773f with SMTP id 6a1803df08f44-6a16824c58amr198495456d6.52.1715719690754; Tue, 14 May 2024 13:48:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715719690; cv=pass; d=google.com; s=arc-20160816; b=WpjxvS0YiJj2qParBbDEYyS9zhG/BwXYUEOuchIaWzC3f7gpO2cZ5sfq3nBJR/8OMF M5B/460JV+izw0fJNqEQB/iNqFE85kl+crcsYJyUZcarEU7+kiQwss1ZGV4xj8bgs38O BHEfCLjgaJLI3OMlF/+ANgsW5uWotWjcXkQi87HuVCTwnpA/r2Q8jH6UrdsMsWSxfqz/ YiFX8I/B1CIyZ9BmNsW2zCIoP94nDZYUGfob2Yrnu1nSb9vS0lcvpMQb7crrCRx/Qjlu xWdod+MmAAJxBxT+jRDkTWAelIK9lxv+JPbbzWwfLWm7kGgscBCRloOw5FrER5x2pnKe 1/Tw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=YWGGR9WNQtfowXxmZrt+1GRML6oRarKOdd0NAWuZUm8=; fh=CJpEgwUoVCRdsAnbE+6hnkbOfrW/8Mrobnfo2id+IXE=; b=E9KX9X8vhLjlYQYh2c1MJf9JRu3DwO5fj86zcJJvgRk3Kt4sMJXwejgVKK9CiOGXNy HI7RmWgsyessknWAc2nSyVZxbIvAAjOzd0ey1E4YTM6/57IBxb9/QRATs6x2d9HiQ05V vVcu5u+RDA6D/l+DbPODRsLTLBxUGKvJ8sP2PeBVhY+NNcC9bpMcnniCYSgZq43oiGba ypLQjH/hADKrnVxixLWbYvSM5QtSSeZLJyAkgbN4QtZzmpudzrDSjqkZmji/j9CDfYWQ rgibdX8k+SSw9u/Vww/TQ+LIO0TYaPJ5jC3PHIgKKWOwODIv1t8edFlKQMOp5pRJfzDm b6QA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=G8PUNoqv; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-179154-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179154-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-792dcd2392fsi567194785a.737.2024.05.14.13.48.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 13:48:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179154-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=G8PUNoqv; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-179154-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179154-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 61EE81C211C4 for ; Tue, 14 May 2024 20:48:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CEDFC180A96; Tue, 14 May 2024 20:48:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="G8PUNoqv"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="8NACxmF7" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 956851DFD1; Tue, 14 May 2024 20:48:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715719682; cv=none; b=slEYcqx9QcY6dPcnbn3lTPM5h5mm7+Z4OO2RropY2CXjfBKSWU+Lm4/2OxgJtxVCzrVUR4OVrq5awTJ4TbHQMtT7aVHTTFRupSxw0cHqUeYlesGrRK9Y8wxrYm6D5j5LEwySW5fJuddA7M6AS9an4iusrapcjczfectfaMX2tms= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715719682; c=relaxed/simple; bh=voK/yZS/mI07lLRJzdQ3NNqRzfZtfnrJUYswFWYYp1Q=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=Rk2I1eL7MtSa2dNHgccvAm3bzaCyZB72l2lMWwUm7SHqVGKKW8gijhWdkLqRvlUMvry8N9AdMtYmzeT7qUc9+822dDLqk6SHk7mI17ks2qpsWmmdJ5L3Ou8HIIXdXSsb7HK2J2MgFhn6zCO0oyqZ51wmRPFBivWot4YmL/dDDZ4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=G8PUNoqv; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=8NACxmF7; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1715719678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YWGGR9WNQtfowXxmZrt+1GRML6oRarKOdd0NAWuZUm8=; b=G8PUNoqvKv4z1tIWxNeqOsG3FMX1YDcJSgi7g6DYWHRfxiHx3UQ9KkpdD7HeVJE/wiDCmW if50fXqsOQz8m5tg0xSHvNH69j5kR/0fJcx4IQ/GECKUJoK9KFDrC4NN9TbJEwS15CxiIX aj+VVvsm+c5T8aagiUDFTzo//JPp0aVUrBGGJkFQLT7CvDiW3gYjGOIuyAIkmMTf5NIF1A xq1fTqu19AJtDtnW/8RRjk4cERR9iRuHZMFGBtPyPQqOXiDkt/PZ3yxOVDqBfmP7tKWE/h BV0KTSdUPe0ho8HGiorZ2flBt9ozRPnCra7sY8YJhdRdp4tcZhK3ziS256NJLg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1715719678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YWGGR9WNQtfowXxmZrt+1GRML6oRarKOdd0NAWuZUm8=; b=8NACxmF7BQjmO6dBW+VOwCq0qcvrezGzRoN8f+svY9p4Q0Ha3mUgMqzEkAvreHWjQABzUL TChXfM4eivuek5Dw== To: Yury Norov 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 Subject: Re: [PATCH 6/6] tick/common: optimize cpumask_equal() usage In-Reply-To: References: <20240513220146.1461457-1-yury.norov@gmail.com> <20240513220146.1461457-7-yury.norov@gmail.com> <878r0cn6a5.ffs@tglx> <874jb0n5rt.ffs@tglx> Date: Tue, 14 May 2024 22:47:57 +0200 Message-ID: <87msosktmq.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Tue, May 14 2024 at 09:47, Yury Norov wrote: >> Instead of sprinkling these conditional all over the place, can't you >> just do the obvious and check for ptr1 == 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 == src may be a sign of error, and > we don't want to add a code that optimizes for it. That's a fair argument. > 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. I don't see these checks as valuable in most cases and I detest them as they make the code harder to read. Except for smp_call_function_many_cond() and to a lesser extent irq_do_set_affinity() none of them you added really matters. Though it might be worth to have helper functions which make it obvious that the src == dst case is intentional. Thanks, tglx