Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp184021rbb; Fri, 23 Feb 2024 17:13:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWi2O3JFjV7qsgWHvt6UDIKV+PTR0u+dqn2rRNN+/d6mTSLXAu4yw+fIYYimxbR7QVhsVVEdx2i58yEwS7Pe6p3ZrpmWHFI5+yOdhyGfg== X-Google-Smtp-Source: AGHT+IGzRuVzAE6jSp3s64UwNttLepPvhKwzH4C7vdHkA+I5rnw0EkyeeA8jSvM3jUnUOKuLu1pz X-Received: by 2002:a05:6a20:9f05:b0:19e:4e58:5026 with SMTP id mk5-20020a056a209f0500b0019e4e585026mr1970368pzb.4.1708737180184; Fri, 23 Feb 2024 17:13:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708737180; cv=pass; d=google.com; s=arc-20160816; b=Bei27vOBFq1gI389GQhhwZGTb70AxWRCmavVl/ooGlLPHO1tXYDu6pZNxwEm31YyJz 58LSaeTSjiqB1WGUze3mDFi6cguZqnH9pZLZJZvK7wAwFNK9xQjW+mCV6vf0D4L5GFYG R1vXRCOVV44lunE3ct6cK+3zoGqER5WZTy1Vq7zGdvzxY7IdS0doZLgAqACv+F4XwKgr 8YKDJeUJA9u0/w+VKAx4SCRMZ7FLYk7lZmEwAo2fkB0hDv0qI9ICXbt3UlhskjBEp+lM Vmb79rlfW3ZkTdPjH/NBnJTfHQ79Fn6j0e6/FSA96N0lKL82zFDhiNNXEwyAlddehY0I NnnA== 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:user-agent:references:in-reply-to :message-id:cc:to:from:subject:date:dkim-signature; bh=FDecWKfvG3Dxdg/2JZIXVwgc/JJoV1FcfsULsUHoCA0=; fh=eGotrG2wUAPCtJbO4MhMKF1jcndrbQy7pSZLLDRnPjs=; b=FUP5aPH0FnocVahfC8o7oJ5I0aht+litl3/NCqwyA/Tm+zhOjh12UwbfmupUZqdy0U J+NYF32D1MFgTv3eJjJ+Gozv6C5Kf617mzxtZ17M8FISFGrm7NyjDG1O/b9cwWlLrV86 uLLGodL7OUM8pnsZt+v/uUCA9Gsb1M3djSImkCeG1DYXMm2kjOFKPzYcQvoNE3Ev6kCY KQkZzXRffsYae1lU5ywFxRZ24aCpjnk5WDx2HKVv2W7a9FZOnsVnNXqujndU5IfZ2z3X VMuhHoIbzGPGP7osXpEuwYeWLpRflDVaUSrGyu54IDY6Rn9lZcKOxhwAsyFZ16w8v/cn zstw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=h2oEJ8za; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79400-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79400-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id o2-20020a635a02000000b005dbd518e89esi141647pgb.761.2024.02.23.17.12.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 17:13:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79400-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=@kernel.org header.s=k20201202 header.b=h2oEJ8za; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79400-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79400-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 DE880281F07 for ; Sat, 24 Feb 2024 01:12:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DEB4B4A3E; Sat, 24 Feb 2024 01:12:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="h2oEJ8za" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0F35C4688; Sat, 24 Feb 2024 01:12:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708737163; cv=none; b=UyEUYoMm43u+huc7Kb8zZ6HEuYYNQbG2YeJSRRiDXQmWlb51PGcgTzXpXrlo6j49SH8WmVb7T9hLqKAdMCkiUQZiBP5sRie/7UlI6k4tH6jO7Dduu8sc4j+NgZeU3y1dDR9o39VMHtRow9FGPYKQ4qKN/iR27/Q0Wyxdhrjtqpc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708737163; c=relaxed/simple; bh=RhYBozOR/vT83f2iUyIcPaS4H6kLQSPsmlviIcctaow=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YiEHz9yL5BkPbgMpgTgSmNEB6tdGm+28tg8unXNHEJU8x8uEtMmNP5h2jwXxhptQf4C/0koHHFdS05PePeAnYfSsXBTrZVeZK2G9mzh6869iCmqqCvA3noLk6Vw0PxxoEQnUFUdEmsqIE22kSNWXKFm97w+MoNelW9A/+E+A4os= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h2oEJ8za; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8701CC433C7; Sat, 24 Feb 2024 01:12:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708737162; bh=RhYBozOR/vT83f2iUyIcPaS4H6kLQSPsmlviIcctaow=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=h2oEJ8zaC+YKy5CgRKbFQx0lMXQlGzNEjspfXJR6hq5ulRxPCZ6SckWUKHw6+0eTO TtGIYKBjDtv6qQV4e/GBHql5tt9/6pXJP/T3M1TmU6oVHWdrG9fwNxWXTLDOoEM3US 7ipzqEFeTVBXDJCemRPIZoiZk4/QVrLZTuWy3wNWQzgyVtWatnF6Wq/E0XXLYv9jy1 pTMAOWwG6hpZXMlrHsUTJGTE/xozmleLVQag3ZMpcnvasAJFL+wNUsJItR6TgOX/cL ugrbPGr+/8HQjpsYmEjxR2IjeXZAnVi2cD33BBV0tOOnYTs/HRjwASugskt0oLT54T Il7reyJ6cB68A== Date: Fri, 23 Feb 2024 17:12:42 -0800 Subject: [PATCH 10/10] time_stats: Kill TIME_STATS_HAVE_QUANTILES From: "Darrick J. Wong" To: akpm@linux-foundation.org, daniel@gluo.nz, kent.overstreet@linux.dev, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: <170873668101.1860949.4100731238233533238.stgit@frogsfrogsfrogs> In-Reply-To: <170873667916.1860949.11027844260383646446.stgit@frogsfrogsfrogs> References: <170873667916.1860949.11027844260383646446.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit From: Kent Overstreet We have 4 spare bytes next to the spinlock, no need for bit stuffing Signed-off-by: Kent Overstreet Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- include/linux/time_stats.h | 19 +++++-------------- lib/time_stats.c | 4 ++-- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/include/linux/time_stats.h b/include/linux/time_stats.h index 4e1f5485ed039..6df2b34aa274b 100644 --- a/include/linux/time_stats.h +++ b/include/linux/time_stats.h @@ -68,6 +68,7 @@ struct time_stat_buffer { struct time_stats { spinlock_t lock; + bool have_quantiles; /* all fields are in nanoseconds */ u64 min_duration; u64 max_duration; @@ -87,12 +88,6 @@ struct time_stats { struct mean_and_variance_weighted freq_stats_weighted; struct time_stat_buffer __percpu *buffer; -/* - * Is this really a struct time_stats_quantiled? Hide this flag in the least - * significant bit of the start time to avoid blowing up the structure size. - */ -#define TIME_STATS_HAVE_QUANTILES (1ULL << 0) - u64 start_time; }; @@ -103,13 +98,9 @@ struct time_stats_quantiles { static inline struct quantiles *time_stats_to_quantiles(struct time_stats *stats) { - struct time_stats_quantiles *statq; - - if (!(stats->start_time & TIME_STATS_HAVE_QUANTILES)) - return NULL; - - statq = container_of(stats, struct time_stats_quantiles, stats); - return &statq->quantiles; + return stats->have_quantiles + ? &container_of(stats, struct time_stats_quantiles, stats)->quantiles + : NULL; } void __time_stats_clear_buffer(struct time_stats *, struct time_stat_buffer *); @@ -169,7 +160,7 @@ static inline void time_stats_quantiles_exit(struct time_stats_quantiles *statq) static inline void time_stats_quantiles_init(struct time_stats_quantiles *statq) { time_stats_init(&statq->stats); - statq->stats.start_time |= TIME_STATS_HAVE_QUANTILES; + statq->stats.have_quantiles = true; memset(&statq->quantiles, 0, sizeof(statq->quantiles)); } diff --git a/lib/time_stats.c b/lib/time_stats.c index c0f209dd9f6dd..0b90c80cba9f1 100644 --- a/lib/time_stats.c +++ b/lib/time_stats.c @@ -164,7 +164,7 @@ static void seq_buf_time_units_aligned(struct seq_buf *out, u64 ns) static inline u64 time_stats_lifetime(const struct time_stats *stats) { - return local_clock() - (stats->start_time & ~TIME_STATS_HAVE_QUANTILES); + return local_clock() - stats->start_time; } void time_stats_to_seq_buf(struct seq_buf *out, struct time_stats *stats, @@ -364,7 +364,7 @@ void time_stats_init(struct time_stats *stats) memset(stats, 0, sizeof(*stats)); stats->min_duration = U64_MAX; stats->min_freq = U64_MAX; - stats->start_time = local_clock() & ~TIME_STATS_HAVE_QUANTILES; + stats->start_time = local_clock(); spin_lock_init(&stats->lock); } EXPORT_SYMBOL_GPL(time_stats_init);