Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1594238iog; Thu, 16 Jun 2022 09:27:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t1RpuFudD93WAsGDJDJ/ZO5ufQWNd0vm7h5gzaH8a6H9gDyGAosXzQdJxSqqDxkZLXX/+g X-Received: by 2002:a05:6402:32a6:b0:42d:ed8b:3d8 with SMTP id f38-20020a05640232a600b0042ded8b03d8mr7369173eda.225.1655396878249; Thu, 16 Jun 2022 09:27:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655396878; cv=none; d=google.com; s=arc-20160816; b=lyAaINC9FfLBVFCV4CXIF04ziVlCXkLcNEO103WisX/UwyGvgF91TBkGat1tM3QCNS IBI8FYh5BVPW4+fBw50/vT9TFOYuVxjvFyAyTpdjqGEp7I9AA7iewgJUQFPUeLLJNUYL lwwa06QrcUYkm6hBeDK4cuRcVvjq2211Fz7bs4hRABZJ8SnEPeLkqV6ePpjIJQs9CiLE Twy7AcU8AR32y3mVq7kTTh6S62WTZSdr3xBoHgIpxgCe2NhkOpG4ZaSpLjsrz3RDOwWa b8DR0qkvFI8tv6QrHB4Fxlx9o+zJgSkHGBS40sRMIfwztC5IFCSerioPXmDyRIfV8Lkk EsPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=v6FfXbWa/7Elc9KXi+8CH7HtvYik+hxxt87OEuM5s6Q=; b=DiOyH9O5D1lCR3KAAqmVgc16WNtYuzQNrcQe+ZroBhrHX6Zg5qjVQSTGCBXnnq86bA e2EVPMvEFIvCNFF25j8swWEos9tz2nk/SktJBs/NnMTotvjAQVQhDP1OW1x+ZVotzx0S t7NxE5UTCbW99iRTDppIz3Acw8irdqirLUJvH+NGXEZJDSVpgpip7+9JnX53WTFH3yOP +1PejFrNh35d3EB/Dk8X9j61J5ahDPPRtN3p+Gq+8XXdCRVSL6dI3BGh1kY78OfarPn8 JTyCxvm6/Wivy2ZxryVLNMKqWhLILwwJ7eUDKRVpOs2jDLCN0M4Qnt1Tddv8QL5fqQmU 9yNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MTC+Btps; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g16-20020aa7dc50000000b0042dafda4703si2254008edu.437.2022.06.16.09.27.33; Thu, 16 Jun 2022 09:27:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MTC+Btps; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233404AbiFPQX3 (ORCPT + 99 others); Thu, 16 Jun 2022 12:23:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377211AbiFPQXE (ORCPT ); Thu, 16 Jun 2022 12:23:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F17C213F5C for ; Thu, 16 Jun 2022 09:23:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 47B5DB8246F for ; Thu, 16 Jun 2022 16:23:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 937C5C3411A; Thu, 16 Jun 2022 16:22:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655396579; bh=mguZBL6f1Fziq9Z7oqGYEunQDJVzg7RVCkmlYDJkdhI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MTC+BtpsoIs7NVyouu1btYFhz6bacAUmQl6UAVV4PHU0CwopRD/HtAqENjt4mVoz3 /ij2KkpteDMz7MGOd5Tu87Tpo994v5KRWfvEroei9E1oVbNqCS1tAk9Hp+csb9MHaG uyUnZAO4BXfgTQZJSHnelFVLCMCE8WICf51TRCqUNbXLth83zFaH7hC42/xeuEWMUW yJlYnWgQ9S4oUtqUzxZoB40LgAaKh0+KiA0l2LFghD0kkxfJl0o8BKlvNc9Aq33qel mhdgvuWCbo59GPhS53iMU+weGcChc8W2JvQRQwUeED9htzdahTcDrB32YFzm/gNMV1 GyS3F0UX9qA9w== Date: Thu, 16 Jun 2022 09:22:57 -0700 From: Jaegeuk Kim To: Chao Yu Cc: Daeho Jeong , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com, Daeho Jeong Subject: Re: [f2fs-dev] [PATCH] f2fs: fix iostat related lock protection Message-ID: References: <20220610183240.2269085-1-daeho43@gmail.com> <1815f3c2-0802-5b3f-7e98-9f89c5b9e07d@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/16, Chao Yu wrote: > On 2022/6/16 0:54, Jaegeuk Kim wrote: > > On 06/15, Chao Yu wrote: > > > On 2022/6/11 2:32, Daeho Jeong wrote: > > > > From: Daeho Jeong > > > > > > > > Made iostat related locks safe to be called from irq context again. > > > > > > > > > > Will be better to add a 'Fixes' line? > > > > Added some tags. Thanks, > > > > https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev&id=f8ed39ad779fbc5d37d08e83643384fc06e4bae4 > > It looks there are several patches not in mailing list? > Which one doe you mean? > Thanks, > > > > > > > > > > > Thanks, > > > > > > > Signed-off-by: Daeho Jeong > > > > --- > > > > fs/f2fs/iostat.c | 31 ++++++++++++++++++------------- > > > > 1 file changed, 18 insertions(+), 13 deletions(-) > > > > > > > > diff --git a/fs/f2fs/iostat.c b/fs/f2fs/iostat.c > > > > index be599f31d3c4..d84c5f6cc09d 100644 > > > > --- a/fs/f2fs/iostat.c > > > > +++ b/fs/f2fs/iostat.c > > > > @@ -91,8 +91,9 @@ static inline void __record_iostat_latency(struct f2fs_sb_info *sbi) > > > > unsigned int cnt; > > > > struct f2fs_iostat_latency iostat_lat[MAX_IO_TYPE][NR_PAGE_TYPE]; > > > > struct iostat_lat_info *io_lat = sbi->iostat_io_lat; > > > > + unsigned long flags; > > > > - spin_lock_bh(&sbi->iostat_lat_lock); > > > > + spin_lock_irqsave(&sbi->iostat_lat_lock, flags); > > > > for (idx = 0; idx < MAX_IO_TYPE; idx++) { > > > > for (io = 0; io < NR_PAGE_TYPE; io++) { > > > > cnt = io_lat->bio_cnt[idx][io]; > > > > @@ -106,7 +107,7 @@ static inline void __record_iostat_latency(struct f2fs_sb_info *sbi) > > > > io_lat->bio_cnt[idx][io] = 0; > > > > } > > > > } > > > > - spin_unlock_bh(&sbi->iostat_lat_lock); > > > > + spin_unlock_irqrestore(&sbi->iostat_lat_lock, flags); > > > > trace_f2fs_iostat_latency(sbi, iostat_lat); > > > > } > > > > @@ -115,14 +116,15 @@ static inline void f2fs_record_iostat(struct f2fs_sb_info *sbi) > > > > { > > > > unsigned long long iostat_diff[NR_IO_TYPE]; > > > > int i; > > > > + unsigned long flags; > > > > if (time_is_after_jiffies(sbi->iostat_next_period)) > > > > return; > > > > /* Need double check under the lock */ > > > > - spin_lock_bh(&sbi->iostat_lock); > > > > + spin_lock_irqsave(&sbi->iostat_lock, flags); > > > > if (time_is_after_jiffies(sbi->iostat_next_period)) { > > > > - spin_unlock_bh(&sbi->iostat_lock); > > > > + spin_unlock_irqrestore(&sbi->iostat_lock, flags); > > > > return; > > > > } > > > > sbi->iostat_next_period = jiffies + > > > > @@ -133,7 +135,7 @@ static inline void f2fs_record_iostat(struct f2fs_sb_info *sbi) > > > > sbi->prev_rw_iostat[i]; > > > > sbi->prev_rw_iostat[i] = sbi->rw_iostat[i]; > > > > } > > > > - spin_unlock_bh(&sbi->iostat_lock); > > > > + spin_unlock_irqrestore(&sbi->iostat_lock, flags); > > > > trace_f2fs_iostat(sbi, iostat_diff); > > > > @@ -145,25 +147,27 @@ void f2fs_reset_iostat(struct f2fs_sb_info *sbi) > > > > struct iostat_lat_info *io_lat = sbi->iostat_io_lat; > > > > int i; > > > > - spin_lock_bh(&sbi->iostat_lock); > > > > + spin_lock_irq(&sbi->iostat_lock); > > > > for (i = 0; i < NR_IO_TYPE; i++) { > > > > sbi->rw_iostat[i] = 0; > > > > sbi->prev_rw_iostat[i] = 0; > > > > } > > > > - spin_unlock_bh(&sbi->iostat_lock); > > > > + spin_unlock_irq(&sbi->iostat_lock); > > > > - spin_lock_bh(&sbi->iostat_lat_lock); > > > > + spin_lock_irq(&sbi->iostat_lat_lock); > > > > memset(io_lat, 0, sizeof(struct iostat_lat_info)); > > > > - spin_unlock_bh(&sbi->iostat_lat_lock); > > > > + spin_unlock_irq(&sbi->iostat_lat_lock); > > > > } > > > > void f2fs_update_iostat(struct f2fs_sb_info *sbi, > > > > enum iostat_type type, unsigned long long io_bytes) > > > > { > > > > + unsigned long flags; > > > > + > > > > if (!sbi->iostat_enable) > > > > return; > > > > - spin_lock_bh(&sbi->iostat_lock); > > > > + spin_lock_irqsave(&sbi->iostat_lock, flags); > > > > sbi->rw_iostat[type] += io_bytes; > > > > if (type == APP_BUFFERED_IO || type == APP_DIRECT_IO) > > > > @@ -172,7 +176,7 @@ void f2fs_update_iostat(struct f2fs_sb_info *sbi, > > > > if (type == APP_BUFFERED_READ_IO || type == APP_DIRECT_READ_IO) > > > > sbi->rw_iostat[APP_READ_IO] += io_bytes; > > > > - spin_unlock_bh(&sbi->iostat_lock); > > > > + spin_unlock_irqrestore(&sbi->iostat_lock, flags); > > > > f2fs_record_iostat(sbi); > > > > } > > > > @@ -185,6 +189,7 @@ static inline void __update_iostat_latency(struct bio_iostat_ctx *iostat_ctx, > > > > struct f2fs_sb_info *sbi = iostat_ctx->sbi; > > > > struct iostat_lat_info *io_lat = sbi->iostat_io_lat; > > > > int idx; > > > > + unsigned long flags; > > > > if (!sbi->iostat_enable) > > > > return; > > > > @@ -202,12 +207,12 @@ static inline void __update_iostat_latency(struct bio_iostat_ctx *iostat_ctx, > > > > idx = WRITE_ASYNC_IO; > > > > } > > > > - spin_lock_bh(&sbi->iostat_lat_lock); > > > > + spin_lock_irqsave(&sbi->iostat_lat_lock, flags); > > > > io_lat->sum_lat[idx][iotype] += ts_diff; > > > > io_lat->bio_cnt[idx][iotype]++; > > > > if (ts_diff > io_lat->peak_lat[idx][iotype]) > > > > io_lat->peak_lat[idx][iotype] = ts_diff; > > > > - spin_unlock_bh(&sbi->iostat_lat_lock); > > > > + spin_unlock_irqrestore(&sbi->iostat_lat_lock, flags); > > > > } > > > > void iostat_update_and_unbind_ctx(struct bio *bio, int rw) > > > > > > > > > _______________________________________________ > > > Linux-f2fs-devel mailing list > > > Linux-f2fs-devel@lists.sourceforge.net > > > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel