Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3500FC43334 for ; Wed, 15 Jun 2022 21:32:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350134AbiFOVc2 (ORCPT ); Wed, 15 Jun 2022 17:32:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343803AbiFOVcW (ORCPT ); Wed, 15 Jun 2022 17:32:22 -0400 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C273562DB for ; Wed, 15 Jun 2022 14:32:20 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 5EBDB5C00B5; Wed, 15 Jun 2022 17:32:18 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 15 Jun 2022 17:32:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bur.io; h=cc :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm2; t=1655328738; x=1655415138; bh=NIgkZbqnwb f54uyIP8aM29SyQJI7Udr2j2bW9qEecL0=; b=iPOBTje873Wz3RE4lZILFLu/Jo /fv2Ubjc9UyqwA214ZfMz89plwhCaTC/RWPoybUhhUhrTewaRYm/RWhRO6lQ6QL1 x0ppuSIu/rDoIuFo//42RbZm9juOVUlUhRdKuzki2EKn4wNA/4dhryaY+pEhSQ2i JIXjvLKj8eVI1OxnTd9wP2vRaRcNlu/zwGQ2ZjSZM+nyKJYWfyMwABfvwrDBYeQU v81AEMjiCUJ7rsB2K+lDvQiSmO49vhcWYOuxXcT1f0I0pzsIU1kA/YJXmtDcpHFo cvcvWYUSmYbxBC6tG3TjW1jGsT2qWGJKDtM3YExkwIOqCnYHWm6bnwGksrlA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1655328738; x=1655415138; bh=NIgkZbqnwbf54uyIP8aM29SyQJI7 Udr2j2bW9qEecL0=; b=Qp8qit6dcmPxFc/7shJUJdsgDsfRteitfAVhOFZUF7h+ IInaj5T3+2SRLj0I2dtPNbqno/fQDkt0Qz9kGyCPMP19Rm9cZ7mi0qB4vzQExByS +ZO2gAjFlp+N243nrUWIuObEc2jhl8qdemJ4pD+ibKbW+plZidIBJzuvlyq/NJxz P00UC0GEdmU/Yyvh8EndbRbIlpO71PQA82FSCClYx+u3ZmNqD9ixV4xQ7sDeMQ1e ByYEkqgxH56p7C/pZgc6trHZd9/xMyjPwfMQCVhdg4p1SUHijGDlRVla9ITLG/Jz GPuo5DK3rX5sqVETHnXEMZfjRFx/h2uIdCNjPcqSeg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedruddvvdcutefuodetggdotefrodftvfcurf hrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehorhhishcuuehu rhhkohhvuceosghorhhishessghurhdrihhoqeenucggtffrrghtthgvrhhnpeehudevle ekieetleevieeuhfduhedtiefgheekfeefgeelvdeuveeggfduueevfeenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsohhrihhssegsuhhrrd hioh X-ME-Proxy: Feedback-ID: i083147f8:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 15 Jun 2022 17:32:17 -0400 (EDT) Date: Wed, 15 Jun 2022 14:32:48 -0700 From: Boris Burkov To: dsterba@suse.cz, Nikolay Borisov , Ioannis Angelakopoulos , linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH v2 2/2] btrfs: Expose the BTRFS commit stats through sysfs Message-ID: References: <20220614222231.2582876-1-iangelak@fb.com> <20220614222231.2582876-3-iangelak@fb.com> <916ea0a3-d3a0-6c60-1307-7873438286e3@suse.com> <20220615133130.GY20633@twin.jikos.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220615133130.GY20633@twin.jikos.cz> Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On Wed, Jun 15, 2022 at 03:31:30PM +0200, David Sterba wrote: > On Wed, Jun 15, 2022 at 03:47:51PM +0300, Nikolay Borisov wrote: > > > + > > > + return sysfs_emit(buf, > > > + "commits %llu\n" > > > + "last_commit_dur %llu ms\n" > > > + "max_commit_dur %llu ms\n" > > > + "total_commit_dur %llu ms\n", > > > + fs_info->commit_stats.commit_counter, > > > + fs_info->commit_stats.last_commit_dur / NSEC_PER_MSEC, > > > + fs_info->commit_stats.max_commit_dur / NSEC_PER_MSEC, > > > + fs_info->commit_stats.total_commit_dur / NSEC_PER_MSEC); > > > +} > > > + > > > +static ssize_t btrfs_commit_stats_store(struct kobject *kobj, > > > + struct kobj_attribute *a, > > > + const char *buf, size_t len) > > > +{ > > > > Is there really value in being able to zero out the current stats? > > I think it makes sense for the max commit time, one might want to track > that for some workload and then reset. For the other it can go both > ways, eg. a monitoring tool saves the stats completely and resets them. > OTOH long term stats would be lost in case there's more than one > application reading it. As far as I can see, our options are roughly: 1. separate files per stat, only max file has clear 2. clear only max when clearing the joint file 3. clear everything in the joint file (current patch) 4. clear bitmap to control which fields to clear 1 seems the clearest, but is sort of messy in terms of spamming lots of files. There can be a "1b" variant which is one file with count/total/last and a second file with max (rather than one each for all four). 2 is a bit weird, just due to asymmetry. The "multiple separate clearers" problem Dave came up with seems serious for 3: it means if I want to clear max and you want to clear total, we might make each other lose data. 4 would work around that, but is an untuitive interface. One other reason clearing total could be good is if we are counting in nanoseconds, overflow becomes a non-trivial risk. For this reason, I think I vote for 1 (separate files), but 2 (only clear max in a single file) seems like a decent compromise. 4 feels overengineered, but is kind of a souped-up version of 2.