Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1301018pxf; Fri, 12 Mar 2021 06:46:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1536zngipMBeMKUfErbgx+evnxoD/386m6H1nzqrc4dy2fF8QCpPfO8rbA3Fqfn+cVmNP X-Received: by 2002:a05:6402:50c8:: with SMTP id h8mr14306330edb.360.1615560395339; Fri, 12 Mar 2021 06:46:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615560395; cv=none; d=google.com; s=arc-20160816; b=bneX/XWjAOC6cAxqLle/ql6cwGvy7ns6WcucdgLHvQd5cA7Lwat9WGuH2rKgX1YCjF ZP0haxboWC229vjAxDuYMvpyQ/vrTUjF6Ph4xLQyAi64IB+UhIUl+ETfoywTigJTX4gu Yihwo5mTp6n9jCvW+mumXczNTCGbLM0SKm4KJ8JW7sYRJYOAi2/X50PROHGPZgydpldR tzT7OW+I7M7hqPbi3MtGUo8jtQwnJrzEHbON9wvxGZ2Y5FKRDXiAeeaSV9qrnXCOLHI8 CRmX+97cmFy3G+LoEC+M7p5NrxEq3asIWXauNF9171GRvhUGWa/1c5QKdEqitllDmHEZ Swow== 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=/ZgtvRUCOeB2tes232V28vaR4drPg6AkuyiMBwt7N/Q=; b=o6lF7SyY5+OK3crFwXyPZLqHUPyzXZ4/m4cYUP5xtyuzJvA53pn5C5gsy5nNKQx6rm QhsW2H33ILagDQcPHYhKVvM69JzIQjkj7e+5iFG83pVvgw+nz6PNSzcvt4PJXv4JGIG4 7AK3jxY/jXX3e/Ev0gqncvAFmq5OibpspB74fjGDLDz0Pl0EdnwwEaKeRMnWv4+W+/gF T4Abe5kvKajGMzhVCUfY/h8h+sdIj64ULURaMk91Mj86RI5NU+OHl1K1Ds6fpm2cQBkw H3lmzQLWjygvo8iPwEDW+rqTqk161lmnh6XHpwnRWZQkqB8ySkCKFg3Jya5UNo9nnTRh 9zng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TT4sNAbE; 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 s19si4394199ejb.327.2021.03.12.06.46.11; Fri, 12 Mar 2021 06:46:35 -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=TT4sNAbE; 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 S231371AbhCLOmz (ORCPT + 99 others); Fri, 12 Mar 2021 09:42:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231321AbhCLOmR (ORCPT ); Fri, 12 Mar 2021 09:42:17 -0500 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B3F3C061574 for ; Fri, 12 Mar 2021 06:42:17 -0800 (PST) Received: by mail-lj1-x235.google.com with SMTP id r20so7042202ljk.4 for ; Fri, 12 Mar 2021 06:42:17 -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=/ZgtvRUCOeB2tes232V28vaR4drPg6AkuyiMBwt7N/Q=; b=TT4sNAbE++eXFwV/kLG3OLxZb9hyTRXOGfbo6NPgoa2hdLLMENGShbvPYOMDArP8C5 RKlPk5VVpXNLF5blZeOdwAjGPqVXpFNPgjYYrVb6O7GTSkRB+Fyx4O0pa1l1kOsnNznE xFQvIUZJl9uQGXJCjQKizXLGUUTlD0HXVt/Jj+aRfi07o21cJzRKvEb8KZXWulKHg8zG cYjle+Zze0D4cKdNB230Q6aco2pQXDIaERXcL6iiXjVMaecRViWLROHlXHGW5L3Y96Iw lxE1WH3xyR63B64hekFbsHI2M4laMPJAcwNUXM8c15Kdw4Xwvmqb+4R3WaP2XCRHxlrc GyKw== 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=/ZgtvRUCOeB2tes232V28vaR4drPg6AkuyiMBwt7N/Q=; b=A/MVtu5Y6AjybuqoEEkt+x8JMFy7HACRyAZDJ2j60go3Ud9gNJ9l2sgDg52hjVjvDP jfjXDqyga67WqsqkMgVJaSubQHGNsx9gGfuSbOpUp48gp9/s6nY94oqLbQaM8cNvIbNU IFw8gqMFzGjWec73UEYXdyoBBy4WWSNCvN28lcq7a6grZRUNgV/s4Tqsar8w4a55MpEU HK+wFd8y4KnhMl8yxZI1VkVO/MCbAlI6k+Lg7NwG9XBLyNO8ceDVEY0TaRYpFiYkMbaD wiEk9ZaYjmglbIjimP00Y2xr2/hYGdLarkWdvi/9A79RWSFyAG6MSSSBFiJxAH7gbIuY EMFQ== X-Gm-Message-State: AOAM532QSXx/94Z9re2AIIi7gIhTWjvXWGiLQQlcWIn3RhVmXVxFTa8+ Ml8OCazPvrMx/wPSgw8LhxU+JYB0rL/YuIwTbF4= X-Received: by 2002:a2e:b606:: with SMTP id r6mr2573928ljn.327.1615560135802; Fri, 12 Mar 2021 06:42:15 -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:42:04 +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 So, do you want we protect the values here with spin_lock and just read without spin_lock in sysfs read part? 2021=EB=85=84 3=EC=9B=94 12=EC=9D=BC (=EA=B8=88) =EC=98=A4=ED=9B=84 11:37, = Daeho Jeong =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > 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 re= ader. > > > > > > +#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= condition. > > > > Why? What are you trying to protect from "racing" here? > > > > thanks, > > > > greg k-h