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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76844C6FA82 for ; Mon, 12 Sep 2022 15:33:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 003088D0001; Mon, 12 Sep 2022 11:33:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF6676B0073; Mon, 12 Sep 2022 11:33:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBBC28D0001; Mon, 12 Sep 2022 11:33:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id CD54F6B0071 for ; Mon, 12 Sep 2022 11:33:54 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9E137AB71B for ; Mon, 12 Sep 2022 15:33:54 +0000 (UTC) X-FDA: 79903828788.16.81A0ED6 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf17.hostedemail.com (Postfix) with ESMTP id 4FC1E40094 for ; Mon, 12 Sep 2022 15:33:53 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E8E1B203C4; Mon, 12 Sep 2022 15:33:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1662996831; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=eRpjiBTXPA34slJCEVvqta+I3LTtT85gBwO0gzk+thc=; b=VWyqSWKbD8LfsNkEZC6EfWdMhvQPVUdRjk4fuYRSvzsQEKrce6OwrVOAdkzMBS+wiq2JY5 akEn052RhfK8DuSDzFpXLpel3PV/i3bgfauRV9s3y5tv1gP4xqAGKyh0U3fHMHaJXaMA0+ qSbhiUWWNwPX7E4t4wrz8TraWqGJA7A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1662996831; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=eRpjiBTXPA34slJCEVvqta+I3LTtT85gBwO0gzk+thc=; b=hwTtR/8JTQzhvO35pkm4yWhMWS+i/ViXhcrAXDNSu6OFhBd2TME2kaufjoQXSL7nbHj4M7 lJhly5+/lT1fk1AA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7D94F139E0; Mon, 12 Sep 2022 15:33:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MKGgHV9RH2OaYgAAMHmgww (envelope-from ); Mon, 12 Sep 2022 15:33:51 +0000 Date: Mon, 12 Sep 2022 17:28:25 +0200 From: David Sterba To: Christoph Hellwig Cc: Jens Axboe , Matthew Wilcox , Johannes Weiner , Suren Baghdasaryan , Andrew Morton , Chris Mason , Josef Bacik , David Sterba , Gao Xiang , Chao Yu , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-mm@kvack.org Subject: Re: [PATCH 3/5] btrfs: add manual PSI accounting for compressed reads Message-ID: <20220912152825.GH32411@suse.cz> Reply-To: dsterba@suse.cz References: <20220910065058.3303831-1-hch@lst.de> <20220910065058.3303831-4-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220910065058.3303831-4-hch@lst.de> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662996834; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eRpjiBTXPA34slJCEVvqta+I3LTtT85gBwO0gzk+thc=; b=bpE6Bu1KG9SmrDkpIvKdeKkIgeEr7vqPJYDXKTRTDnFgdWLtzb6jiPuVWUaWGN/n+v1MtP y062iUZRjscAsQCKo/PVrRQzUtO5y7tr+OtWuC+I1qIti4ivxWRkgGDGCwDHU1kWI75sf5 9H3OrCFbn1nby7c+Fscn910PRrdPSo0= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=VWyqSWKb; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="hwTtR/8J"; spf=pass (imf17.hostedemail.com: domain of dsterba@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=dsterba@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662996834; a=rsa-sha256; cv=none; b=OaaVaPUkEGMIrFMLyp6qF+I3NnwlKdPfaAG2MeuQp6c+xXHlNXKwGRhOE1zGgJfInOQvGQ 7/xg7TJ/lWCe1IV9zaWiBLjhmhKQLS1sBSjx5QjCApqDVMtR+veyZDUtsLA3p6Hs34d0Qt 8kJbjsKsvQVLtz341adjc+3sZVASQsA= X-Stat-Signature: bwf6rcqjuc7o9orih7srugh4ghrkhwsr X-Rspamd-Queue-Id: 4FC1E40094 X-Rspam-User: Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=VWyqSWKb; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="hwTtR/8J"; spf=pass (imf17.hostedemail.com: domain of dsterba@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=dsterba@suse.cz; dmarc=none X-Rspamd-Server: rspam03 X-HE-Tag: 1662996833-371832 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, Sep 10, 2022 at 08:50:56AM +0200, Christoph Hellwig wrote: > btrfs compressed reads try to always read the entire compressed chunk, > even if only a subset is requested. Currently this is covered by the > magic PSI accounting underneath submit_bio, but that is about to go > away. Instead add manual psi_memstall_{enter,leave} annotations. > > Note that for readahead this really should be using readahead_expand, > but the additionals reads are also done for plain ->read_folio where > readahead_expand can't work, so this overall logic is left as-is for > now. > > Signed-off-by: Christoph Hellwig With some small fixups, Acked-by: David Sterba > fs/btrfs/compression.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c > index e84d22c5c6a83..f7889a00e0055 100644 > --- a/fs/btrfs/compression.c > +++ b/fs/btrfs/compression.c > @@ -15,6 +15,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -519,7 +520,8 @@ static u64 bio_end_offset(struct bio *bio) > */ > static noinline int add_ra_bio_pages(struct inode *inode, > u64 compressed_end, > - struct compressed_bio *cb) > + struct compressed_bio *cb, > + unsigned long *pflags) > { > struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); > unsigned long end_index; > @@ -588,6 +590,9 @@ static noinline int add_ra_bio_pages(struct inode *inode, > continue; > } > > + if (unlikely(PageWorkingset(page))) Please drop the 'unlikely', in this case it does not seem to make much sense. > + psi_memstall_enter(pflags); > + > ret = set_page_extent_mapped(page); > if (ret < 0) { > unlock_page(page); > @@ -674,6 +679,8 @@ void btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, > u64 em_len; > u64 em_start; > struct extent_map *em; > + /* initialize to 1 to make skip psi_memstall_leave unless needed */ First letter in comment should be upper case unless it's an identifier. > + unsigned long pflags = 1; > blk_status_t ret; > int ret2; > int i; > @@ -729,7 +736,7 @@ void btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, > goto fail; > } > > - add_ra_bio_pages(inode, em_start + em_len, cb); > + add_ra_bio_pages(inode, em_start + em_len, cb, &pflags); > > /* include any pages we added in add_ra-bio_pages */ > cb->len = bio->bi_iter.bi_size; > @@ -810,6 +817,9 @@ void btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, > } > } > > + if (!pflags) > + psi_memstall_leave(&pflags); > + > if (refcount_dec_and_test(&cb->pending_ios)) > finish_compressed_bio_read(cb); > return; > -- > 2.30.2 >