From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 121AAC433E9 for ; Fri, 12 Mar 2021 14:46:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D136965005 for ; Fri, 12 Mar 2021 14:46:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231519AbhCLOqK (ORCPT ); Fri, 12 Mar 2021 09:46:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:35902 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230302AbhCLOpv (ORCPT ); Fri, 12 Mar 2021 09:45:51 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4536A64FD6; Fri, 12 Mar 2021 14:45:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615560350; bh=5OcUS67DMAnxCxpF2YhrDjA4ZH7gotBBF3aF5cp7VAo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OGrTW2c5kQMZqDLHOuPubJDXsH5iNNl9G1C8bABPxHyPcm06lamlCYPxjL/7xokSu 6xqdQEaz0tP0k8l4U3D3jCYKk3PxisKyYJ9L5pw2AdXmglGrmAxermQHLMydovsQSS IA2wUtJS7RrAgy28DpmknVJbOyZw2fAvOZcmmZbs= Date: Fri, 12 Mar 2021 15:45:48 +0100 From: Greg KH To: Daeho Jeong Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com, Daeho Jeong Subject: Re: [PATCH v4] f2fs: add sysfs nodes to get runtime compression stat Message-ID: References: <20210312122531.2717093-1-daeho43@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A: http://en.wikipedia.org/wiki/Top_post Q: Were do I find info about this thing called top-posting? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail? A: No. Q: Should I include quotations after my reply? http://daringfireball.net/2007/07/on_top On Fri, Mar 12, 2021 at 11:37:29PM +0900, Daeho Jeong wrote: > As you can see, if we're doing like the below. > > sbi->compr_written_block += blocks; > > Let's assume the initial value as 0. > > > sbi->compr_written_block = 0; > > sbi->compr_written_block = 0; > +blocks(3); > + blocks(2); > sbi->compr_written_block = 3; > > sbi->compr_written_block = 2; > > Finally, we end up with 2, not 5. > > As more threads are participating it, we might miss more counting. Are you sure? Isn't adding a number something that should happen in a "safe" way? And if you miss 2 blocks, who cares? What is so critical about these things that you take the cache flush of 2 atomic writes just for a debugging statistic? Why not just take 1 lock for everything if it's so important to get these "correct"? What is the performance throughput degradation of adding 2 atomic writes to each time you write a block? But really, will you ever notice missing a few, even if that could be possible on your cpu (and I strongly doubt most modern cpus will miss this...) But this isn't my code, I just hate seeing atomic variables used for silly things like debugging stats when they do not seem to be really needed. So if you want to keep them, go ahead, but realize that the number you are reading has nothing to do with being "atomic" at all. thanks, greg k-h