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=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 9E8C8C47097 for ; Thu, 3 Jun 2021 08:55:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4655A613F3 for ; Thu, 3 Jun 2021 08:55:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4655A613F3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 985216B006C; Thu, 3 Jun 2021 04:55:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9207B6B006E; Thu, 3 Jun 2021 04:55:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 760A76B0070; Thu, 3 Jun 2021 04:55:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0244.hostedemail.com [216.40.44.244]) by kanga.kvack.org (Postfix) with ESMTP id 4081C6B006C for ; Thu, 3 Jun 2021 04:55:35 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D7F912C96 for ; Thu, 3 Jun 2021 08:55:34 +0000 (UTC) X-FDA: 78211804188.12.21DEC38 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf18.hostedemail.com (Postfix) with ESMTP id A14C020010A3 for ; Thu, 3 Jun 2021 08:55:21 +0000 (UTC) Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 64612219C5; Thu, 3 Jun 2021 08:55:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1622710533; h=from:from: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=JIOxNU1duYBfgVuU9mt4p24VirH3+QjG2w2OYJ8d90c=; b=2hpWCslxLLtGCCWtysJ7jRTKBINYmROH9dzl/5wNgZtwi8BbH0WG+bkGYlrMx8Y4KgFjKp gxBonS11D/IuUj77yERwAA1qWIpRnAhGP0RC8EZW1/YKgXWRXDwECCNFeM/ufkBW3rWZvk EiuU4Uv2PbWXIBbsRaNZDlDEk0lrVrc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1622710533; h=from:from: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=JIOxNU1duYBfgVuU9mt4p24VirH3+QjG2w2OYJ8d90c=; b=MXL5tu1JjXvjC9fHdV5Hcah8cj4YgrDkZjMPSRC8nifOFwOkzmg8JLjJtZ05spNTbQvMUo 3Z4xh6HQPPzX0SDw== Received: from quack2.suse.cz (unknown [10.100.200.198]) by relay2.suse.de (Postfix) with ESMTP id 560A4A3B87; Thu, 3 Jun 2021 08:55:33 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 33C101F2C98; Thu, 3 Jun 2021 10:55:33 +0200 (CEST) Date: Thu, 3 Jun 2021 10:55:33 +0200 From: Jan Kara To: Roman Gushchin Cc: Jan Kara , Tejun Heo , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexander Viro , Dennis Zhou , Dave Chinner , cgroups@vger.kernel.org Subject: Re: [PATCH v6 2/5] writeback, cgroup: keep list of inodes attached to bdi_writeback Message-ID: <20210603085533.GE23647@quack2.suse.cz> References: <20210603005517.1403689-1-guro@fb.com> <20210603005517.1403689-3-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210603005517.1403689-3-guro@fb.com> User-Agent: Mutt/1.10.1 (2018-07-13) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=2hpWCslx; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=MXL5tu1J; dmarc=none; spf=pass (imf18.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=jack@suse.cz X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A14C020010A3 X-Stat-Signature: s3hfifmy1s19nf7eytktrequnx6ufr3y X-HE-Tag: 1622710521-633968 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 Wed 02-06-21 17:55:14, Roman Gushchin wrote: > Currently there is no way to iterate over inodes attached to a > specific cgwb structure. It limits the ability to efficiently > reclaim the writeback structure itself and associated memory and > block cgroup structures without scanning all inodes belonging to a sb, > which can be prohibitively expensive. > > While dirty/in-active-writeback an inode belongs to one of the > bdi_writeback's io lists: b_dirty, b_io, b_more_io and b_dirty_time. > Once cleaned up, it's removed from all io lists. So the > inode->i_io_list can be reused to maintain the list of inodes, > attached to a bdi_writeback structure. > > This patch introduces a new wb->b_attached list, which contains all > inodes which were dirty at least once and are attached to the given > cgwb. Inodes attached to the root bdi_writeback structures are never > placed on such list. The following patch will use this list to try to > release cgwbs structures more efficiently. > > Suggested-by: Jan Kara > Signed-off-by: Roman Gushchin Looks good, just one small comment below, with that fixed feel free to add: Reviewed-by: Jan Kara ... > @@ -1014,6 +1024,12 @@ fs_initcall(cgroup_writeback_init); > static void bdi_down_write_wb_switch_rwsem(struct backing_dev_info *bdi) { } > static void bdi_up_write_wb_switch_rwsem(struct backing_dev_info *bdi) { } > > +static void inode_cgwb_move_to_attached(struct inode *inode, > + struct bdi_writeback *wb) > +{ > + list_del_init(&inode->i_io_list); > +} > + I think you miss clearing of I_SYNC_QUEUED here. Also you could add here the lock assertions that are in the other version of inode_cgwb_move_to_attached(). Honza -- Jan Kara SUSE Labs, CR