Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2323488lqo; Mon, 13 May 2024 15:03:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX97/XiyDyig5UQpUGpr4kpSlfUSfb39LoQzSBOno6f64DuuTxP5vkvfwjGe6QE/PqiRc/jl7zyfdgJoC6ypEODScmQSgGPLC/vZH0zbw== X-Google-Smtp-Source: AGHT+IE+eiUIvQSOgkioTa8hzPZL00HMP7ZPSb8pK++lI0WCyKPJYQ2V5GaBB742o8TLhPyiJkdc X-Received: by 2002:a17:90b:1016:b0:2ad:5b69:3ba4 with SMTP id 98e67ed59e1d1-2b6cc76f029mr9777829a91.22.1715637807134; Mon, 13 May 2024 15:03:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715637807; cv=pass; d=google.com; s=arc-20160816; b=CUWXRd0enWO0e7opsiKrTPFzHBBrxGEJe/3vjTbXsUEGj58iXI+Vbk6PzZRk/oK7Pm bhKcIg4dinqiJ5lFfmIzzlZ6XOCMJBdtlvY0r5VvDm4/OfiPGpJVf8kKVXqx34n/cNRM UeMVkoToH+ztsNJTJmpIwEsDxjxlwnCNZ/1s1LgEBN3FBdinJAybxZlDmTMGFXcZ2/ks 6u2H6HJqzL6X4IkNkAzbW5TLc4m/S68aIbEax0yO28XUgTE+5zBvunOx7QcDe4tEJzho KmcpQd5jOh29JImM1TAvQjlSuv/qRFrj+7o7ex2yoA8Twz0VbB1lB3lEo9CIyVIyUzNV Q6ng== 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:to:from:dkim-signature; bh=FHoKk7MW4sbJ1HdpDCTP5sGub4zDeIvETZgNgOMQPec=; fh=LaJI3A39ZmbZ62T1HUOlB4XDzG+ofjBXHVthq70CD2s=; b=x+4J3fuwrPzPShLMw+ZoeGS11bharaCbo8DRnC6mcweBpgVvXeLeh9fboDX8WMqxob FQolsZr/mXqEGnhJQULqiwN5OYj0fef80e6E+xE+5JaAwxSTaznqeLVOk4bT/d+Q1tsT eLftA5oszzpgnyoxaI9ThzIms/x5NO4hAcYu1tuKD3nFA41BKq2XxPEHa5rqrjkbol3a 0oCWRuWlTODfyTsNRqQ22dCIvizCIn0RQ9EPnIlFCYFFs9iBUzm317w/DjXoQW8ruFuW 2gmAotguxGRvgvo0B2Je0P5zu3okYK0Gic/z9soVV706E2IiaN/rkKAqaBTG+qvWKmuX g3tQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dLC5n8OF; 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-178130-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178130-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b671471f38si10112128a91.115.2024.05.13.15.03.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 15:03:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178130-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dLC5n8OF; 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-178130-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178130-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 18C9A2866B6 for ; Mon, 13 May 2024 22:03:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 78526127E12; Mon, 13 May 2024 22:02:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dLC5n8OF" Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (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 498C586263; Mon, 13 May 2024 22:02:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715637721; cv=none; b=USUcUbUfcvX9lFDJJTGxWPmWlnrGqbfW4cBWcY812RBZHLcj6MAWu0wohGkirSo+JAkTHz1QSe75XncWu6qsm5DPVBHB84Cs6u4gL5XyJvu/fA5hWV4Hjo8m2qKWUeIaLkG518tTdm2aGFceQ0FBTQS8BbfYMAYckBFj7mBBfTg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715637721; c=relaxed/simple; bh=5ByyuK9842Nu7izTwGN2VcAUuV2L/M3R2rM7RX17BDM=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sURYTqgcRoPU4QrGgHhftXSLAQy0qexi2VOUfK7jEVLu3GzGQ/xCPEgSYjksFNiupUOs20NT80VXVOEbquGIBkNHW36ZKUAWDbrxieVnZi/nNquLgnXL/zf+mzBf3eeT3ARikeLiQknb3rYZF0cE9HYXEI8lNs5P1ROYStvBEos= 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=dLC5n8OF; arc=none smtp.client-ip=209.85.128.181 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-f181.google.com with SMTP id 00721157ae682-61ae4743d36so48874047b3.2; Mon, 13 May 2024 15:02:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715637719; x=1716242519; 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=FHoKk7MW4sbJ1HdpDCTP5sGub4zDeIvETZgNgOMQPec=; b=dLC5n8OFK7DTaXyOe5SM6ugqKQv4tEZSjFtBNJCs6WMeCEzUPaR3PHHD88WL2pAWA0 K2qImvJ3bcWCUeiu5oWY31q/r00i0Z9pKF3d1olDuC81UQPmAey0prXXbQQ3OcjCWrDu Pi+rQinP313bRJoyoebExTkJYItD347yb5ZJNKmnUJtyZjHu16K99PMfv6HbqVDobTaY v3ARrDeS/8/pyDplUk5DLPcHxYBoC+XAEtFNG/juZirgpC8NiI5BVEmF3aOrAcNYv0/1 keFxgysjJEP+Gdd0lY1kSha/mye/8H7bB+rXVRf2TJBBict+hVMybHwG+imFJQ+mFlf1 KZkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715637719; x=1716242519; 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=FHoKk7MW4sbJ1HdpDCTP5sGub4zDeIvETZgNgOMQPec=; b=bX2gwZ9dVFdQyxl/jqze1JxZG9uYx9AMBAJ2y3GkmLndxE073xoHtSNpMjoeSMA9bU ZvSuv2xiY4v5HVRPYpMZRlOD6qBKf2+pZ21eD881NrBgMWrc1hhkkbLU8tV2nXiXf+8Q ll71sNrKd3sejJthWcIREBvvU3kQdQ39QRWPeH1/Z2q6LxVpcZ0keLbjC+8Oena2sAIm nwf6l/as15Vy48rOO304IiFdmyjAbYoEWyYYzlGIA/YOWCWZ0WpJys6a1aLHxMySKEMj iYhIpCuvgd9RXaJpGtC/M+jODa7lLXA+wtkLn4it4fRzn/9AGOoPZWDnm7TndLSGq7dE L1ZA== X-Forwarded-Encrypted: i=1; AJvYcCWbgxccNMDjNtREmV6lGD2I2BX035ZynT6dtcskjxQv56OOI1yY9R7ZxpzsKgHWuo13zTxpdoOTOWh2DxedDwhtRWq5Vij7Iw== X-Gm-Message-State: AOJu0YwW07NWFDxKc0LnpANpVwePc4sOSJ4CKqNCZEN+iqN7Pf9BY+bV YPlB1C9hJ4nOLpooPc8eQdvuEYNNuSe+3AqwQ/+yqc46ju54/y8Pb1H4Xg== X-Received: by 2002:a81:af1d:0:b0:61b:14d8:a816 with SMTP id 00721157ae682-622afff6a51mr92700237b3.29.1715637719145; Mon, 13 May 2024 15:01:59 -0700 (PDT) Received: from localhost ([2601:344:8301:57f0:8acf:1c06:973:d499]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6209e346810sm22961617b3.95.2024.05.13.15.01.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 15:01:58 -0700 (PDT) From: Yury Norov To: 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 , Thomas Gleixner , Valentin Schneider , Vincent Guittot , Waiman Long , Yury Norov , Zefan Li , cgroups@vger.kernel.org Subject: [PATCH 6/6] tick/common: optimize cpumask_equal() usage Date: Mon, 13 May 2024 15:01:46 -0700 Message-Id: <20240513220146.1461457-7-yury.norov@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240513220146.1461457-1-yury.norov@gmail.com> References: <20240513220146.1461457-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 Some functions in the file call cpumask_equal() with src1p == src2p. We can obviously just skip comparison entirely in this case. This patch fixes cpumask_equal invocations when boot-test or LTP detect such condition. 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 != cpumask && + !cpumask_equal(newdev->cpumask, cpumask)) irq_set_affinity(newdev->irq, cpumask); /* @@ -288,14 +289,19 @@ static bool tick_check_percpu(struct clock_event_device *curdev, { if (!cpumask_test_cpu(cpu, newdev->cpumask)) return false; - if (cpumask_equal(newdev->cpumask, cpumask_of(cpu))) + if (newdev->cpumask == cpumask_of(cpu) || + cpumask_equal(newdev->cpumask, cpumask_of(cpu))) return true; /* Check if irq affinity can be set */ if (newdev->irq >= 0 && !irq_can_set_affinity(newdev->irq)) return false; /* Prefer an existing cpu local device */ - if (curdev && cpumask_equal(curdev->cpumask, cpumask_of(cpu))) + if (!curdev) + return true; + if (curdev->cpumask == cpumask_of(cpu) || + cpumask_equal(curdev->cpumask, cpumask_of(cpu))) return false; + return true; } @@ -316,7 +322,8 @@ static bool tick_check_preferred(struct clock_event_device *curdev, */ return !curdev || newdev->rating > curdev->rating || - !cpumask_equal(curdev->cpumask, newdev->cpumask); + !(curdev->cpumask == newdev->cpumask && + cpumask_equal(curdev->cpumask, newdev->cpumask)); } /* -- 2.40.1