Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1294828pxf; Fri, 12 Mar 2021 06:39:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyMwjEad1s8LisjkzVNP7n1+AFpqVviGwQeM4U6ghG9crFyXwELIwXgDJgJ4I3LDds/GOc X-Received: by 2002:a17:907:77d4:: with SMTP id kz20mr8885455ejc.93.1615559954943; Fri, 12 Mar 2021 06:39:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615559954; cv=none; d=google.com; s=arc-20160816; b=0hljCkGCLyoPmi3BM98UYnS447tF7m6smiCunQZrazwuwR5IlGvXdobB8cJpaIRttw HqefoX6W6Fs4gl4cpvmbDq/VncaAHCQPrF0gEa4Ygz9lXWXJNR+PljkQKerUlRRxYVRl wzTviKCQ+ftHKZKMw89eifPJ83qlIbg56K8vaz9VrQfqMK9jlkGSX1qtK4fOK5TqOft2 8gGTlmMBqDg29aHOXMCS6XH6yGrk7oTq2Rj/REVbKDrMX0V5PI9ABqyQISjwMTXAbnt2 XFmAJONnK7buNYyCgJe7YCguNoIDp+t7yUi5yZZwtHFO5f/D0L2vSzGTwPzR7SOPxKZo 1ROw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=GNaWAC3DABEUbVGxWGplqiDw9dv4NcAFZkElxGgXLyY=; b=GBf+C9cZcT7fPq45SiXkigiUL2a9120JCUMO1DolXinodBGRV9NYLx2hcfFjjhif+O DubpJJdbXACCFfHZ1RXnBtRAQ2/2CLEcJMZdK3Mod5inv96LA76p2EPuKaJWaFjNkWQy S6QvLopFfq4xqE1UvfE47iGVQFx0j6rbckzwLSD2ASNlZJQhBh5NlFCBZKDOxNDz0lf/ fT+vaQ48ArPOrdqDtKFDsviOoq5EcQpMWPw+0gls6IFPbM8cHCOp82dythofvzX7BKn0 uD4rl9/AMFzHxCs6xjpHfLGpGdMgRzPbipfp1S7g8mUbmbqdV+epnBcV53BSF9lOVeah 3TCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Doao8t2c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s5si4158698ejx.287.2021.03.12.06.38.51; Fri, 12 Mar 2021 06:39:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Doao8t2c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230136AbhCLOhz (ORCPT + 99 others); Fri, 12 Mar 2021 09:37:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbhCLOhm (ORCPT ); Fri, 12 Mar 2021 09:37:42 -0500 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69E9DC061574 for ; Fri, 12 Mar 2021 06:37:42 -0800 (PST) Received: by mail-lf1-x136.google.com with SMTP id n16so46145572lfb.4 for ; Fri, 12 Mar 2021 06:37:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=GNaWAC3DABEUbVGxWGplqiDw9dv4NcAFZkElxGgXLyY=; b=Doao8t2c/aKsTmuZTBLh5f5ZSWI1SZppbw7XI1vdCzqbnmJasNh77UUWwwdSd5C585 VtfaV5oqpBcKAav/s3mHQ5mxVYc8TZ7zU+rxAQqVbRgeKDUnGi0UhQk/yLFlzAPf0/nz SGi81siMWgVQ0Ys9SE0dOvP18HhjnL5DEfuYV8A7+fCnqnGTwSqRh5UlD9lAHN0mQY2U syD7Ngg5onbk7VtLALYTcR1/N3Zw8a9iU/iCwiTTBw4IUplY0tJJdathTbhD57W53q98 NTCe0Z1bLpI5vaPSUTF+IcjMQE48/7Y5nfoYdhrE8VJ2rwBeH3ZjSdX5W8/bCpM2zq/s 2RDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=GNaWAC3DABEUbVGxWGplqiDw9dv4NcAFZkElxGgXLyY=; b=BzUvdP+hRTetp9jYeZOAkqMEFDnNsywu6ZAti5BfrTesBQEc3Ptquh6qkH6WfU96/l sCjPSiLoBFRJNayPG8PSZGKXNIiGDIr0/mILmBmwTiLVhCzCv3zvepySJcrvyWp8H/p3 L04SHKFXwUBDA7ZEkGpydgLM6W44ozsoUWPYAOhNE3s3eVVrj6fCeisXPoK2DQOTvDKM w3YJWAQ/2hkVIpfa6mifQ5ALzFbbfd4V0OvjgXZrAET9lAEX8VwhRqcqU5GeGTlrke73 ZJ5PZbILO4yBkHYg20WEhLRwHfj+kUaVxpJ3Zd4zFaRSolz1kUJ9heJxF+pE3I/2Yj2w uvmw== X-Gm-Message-State: AOAM530ObFVJUrZ3CBhwSBVKx8CWIekTyFZqtkrpcpf5WbvIv1+MVsLU 9Y9aZYo/QtxxQY3/VXACSRJotiTK19IzKbdPL1U= X-Received: by 2002:a19:ec1a:: with SMTP id b26mr5257227lfa.610.1615559860904; Fri, 12 Mar 2021 06:37:40 -0800 (PST) MIME-Version: 1.0 References: <20210312122531.2717093-1-daeho43@gmail.com> In-Reply-To: From: Daeho Jeong Date: Fri, 12 Mar 2021 23:37:29 +0900 Message-ID: Subject: Re: [PATCH v4] f2fs: add sysfs nodes to get runtime compression stat To: Greg KH Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com, Daeho Jeong Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As you can see, if we're doing like the below. sbi->compr_written_block +=3D blocks; Let's assume the initial value as 0. sbi->compr_written_block =3D 0; sbi->compr_written_block =3D 0; +blocks(3); + blocks(2); sbi->compr_written_block =3D 3; sbi->compr_written_block =3D 2; Finally, we end up with 2, not 5. As more threads are participating it, we might miss more counting. 2021=EB=85=84 3=EC=9B=94 12=EC=9D=BC (=EA=B8=88) =EC=98=A4=ED=9B=84 11:04, = Greg KH =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > On Fri, Mar 12, 2021 at 10:56:13PM +0900, Daeho Jeong wrote: > > Thanks for suggesting me sysfs_emit(). > > > > For atomic values, actually, those are needed for writer part, not read= er. > > > > +#define add_compr_block_stat(inode, blocks) = \ > > + do { = \ > > + struct f2fs_sb_info *sbi =3D F2FS_I_SB(inode); = \ > > + int diff =3D F2FS_I(inode)->i_cluster_size - blocks; = \ > > + atomic64_add(blocks, &sbi->compr_written_block); = \ > > + atomic64_add(diff, &sbi->compr_saved_block); = \ > > + } while (0) > > > > I needed a protection here, because they might be updated in the race c= ondition. > > Why? What are you trying to protect from "racing" here? > > thanks, > > greg k-h