From: Jan Kara <jack@suse.cz> To: Roman Gushchin <guro@fb.com> Cc: Jan Kara <jack@suse.cz>, Tejun Heo <tj@kernel.org>, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexander Viro <viro@zeniv.linux.org.uk>, Dennis Zhou <dennis@kernel.org>, Dave Chinner <dchinner@redhat.com>, cgroups@vger.kernel.org Subject: Re: [PATCH v7 5/6] writeback, cgroup: support switching multiple inodes at once Date: Mon, 7 Jun 2021 11:00:50 +0200 [thread overview] Message-ID: <20210607090050.GB30275@quack2.suse.cz> (raw) In-Reply-To: <20210604013159.3126180-6-guro@fb.com> On Thu 03-06-21 18:31:58, Roman Gushchin wrote: > Currently only a single inode can be switched to another writeback > structure at once. That means to switch an inode a separate > inode_switch_wbs_context structure must be allocated, and a separate > rcu callback and work must be scheduled. > > It's fine for the existing ad-hoc switching, which is not happening > that often, but sub-optimal for massive switching required in order to > release a writeback structure. To prepare for it, let's add a support > for switching multiple inodes at once. > > Instead of containing a single inode pointer, inode_switch_wbs_context > will contain a NULL-terminated array of inode pointers. > inode_do_switch_wbs() will be called for each inode. > > To optimize the locking bdi->wb_switch_rwsem, old_wb's and new_wb's > list_locks will be acquired and released only once altogether for all > inodes. wb_wakeup() will be also be called only once. Instead of > calling wb_put(old_wb) after each successful switch, wb_put_many() > is introduced and used. > > Signed-off-by: Roman Gushchin <guro@fb.com> Looks good except for one small issue: > + for (inodep = isw->inodes; *inodep; inodep++) { > + WARN_ON_ONCE((*inodep)->i_wb != old_wb); > + if (inode_do_switch_wbs(*inodep, old_wb, new_wb)) > + nr_switched++; > + iput(*inodep); > + } You have to be careful here as iput() can be dropping last inode reference and in that case it can sleep and do a lot of heavylifting (which cannot happen under the locks you hold). So you need another loop after dropping all the locks to do iput() on all inodes. After fixing this feel free to add: Reviewed-by: Jan Kara <jack@suse.cz> Honza -- Jan Kara <jack@suse.com> SUSE Labs, CR
WARNING: multiple messages have this Message-ID (diff)
From: Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org> To: Roman Gushchin <guro-b10kYP2dOMg@public.gmane.org> Cc: Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org>, Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, Alexander Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>, Dennis Zhou <dennis-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>, Dave Chinner <dchinner-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Subject: Re: [PATCH v7 5/6] writeback, cgroup: support switching multiple inodes at once Date: Mon, 7 Jun 2021 11:00:50 +0200 [thread overview] Message-ID: <20210607090050.GB30275@quack2.suse.cz> (raw) In-Reply-To: <20210604013159.3126180-6-guro-b10kYP2dOMg@public.gmane.org> On Thu 03-06-21 18:31:58, Roman Gushchin wrote: > Currently only a single inode can be switched to another writeback > structure at once. That means to switch an inode a separate > inode_switch_wbs_context structure must be allocated, and a separate > rcu callback and work must be scheduled. > > It's fine for the existing ad-hoc switching, which is not happening > that often, but sub-optimal for massive switching required in order to > release a writeback structure. To prepare for it, let's add a support > for switching multiple inodes at once. > > Instead of containing a single inode pointer, inode_switch_wbs_context > will contain a NULL-terminated array of inode pointers. > inode_do_switch_wbs() will be called for each inode. > > To optimize the locking bdi->wb_switch_rwsem, old_wb's and new_wb's > list_locks will be acquired and released only once altogether for all > inodes. wb_wakeup() will be also be called only once. Instead of > calling wb_put(old_wb) after each successful switch, wb_put_many() > is introduced and used. > > Signed-off-by: Roman Gushchin <guro-b10kYP2dOMg@public.gmane.org> Looks good except for one small issue: > + for (inodep = isw->inodes; *inodep; inodep++) { > + WARN_ON_ONCE((*inodep)->i_wb != old_wb); > + if (inode_do_switch_wbs(*inodep, old_wb, new_wb)) > + nr_switched++; > + iput(*inodep); > + } You have to be careful here as iput() can be dropping last inode reference and in that case it can sleep and do a lot of heavylifting (which cannot happen under the locks you hold). So you need another loop after dropping all the locks to do iput() on all inodes. After fixing this feel free to add: Reviewed-by: Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org> Honza -- Jan Kara <jack-IBi9RG/b67k@public.gmane.org> SUSE Labs, CR
next prev parent reply other threads:[~2021-06-07 9:00 UTC|newest] Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-06-04 1:31 [PATCH v7 0/6] cgroup, blkcg: prevent dirty inodes to pin dying memory cgroups Roman Gushchin 2021-06-04 1:31 ` Roman Gushchin 2021-06-04 1:31 ` [PATCH v7 1/6] writeback, cgroup: do not switch inodes with I_WILL_FREE flag Roman Gushchin 2021-06-04 1:31 ` Roman Gushchin 2021-06-07 8:48 ` Jan Kara 2021-06-07 8:48 ` Jan Kara 2021-06-04 1:31 ` [PATCH v7 2/6] writeback, cgroup: switch to rcu_work API in inode_switch_wbs() Roman Gushchin 2021-06-04 1:31 ` Roman Gushchin 2021-06-04 1:31 ` [PATCH v7 3/6] writeback, cgroup: keep list of inodes attached to bdi_writeback Roman Gushchin 2021-06-04 1:31 ` Roman Gushchin 2021-06-04 1:31 ` [PATCH v7 4/6] writeback, cgroup: split out the functional part of inode_switch_wbs_work_fn() Roman Gushchin 2021-06-04 1:31 ` Roman Gushchin 2021-06-04 1:31 ` [PATCH v7 5/6] writeback, cgroup: support switching multiple inodes at once Roman Gushchin 2021-06-04 1:31 ` Roman Gushchin 2021-06-07 9:00 ` Jan Kara [this message] 2021-06-07 9:00 ` Jan Kara 2021-06-04 1:31 ` [PATCH v7 6/6] writeback, cgroup: release dying cgwbs by switching attached inodes Roman Gushchin 2021-06-04 1:31 ` Roman Gushchin 2021-06-04 15:51 ` Tejun Heo 2021-06-04 15:51 ` Tejun Heo 2021-06-05 21:34 ` Dennis Zhou 2021-06-08 0:20 ` Roman Gushchin 2021-06-08 0:20 ` Roman Gushchin 2021-06-07 9:24 ` Jan Kara 2021-06-07 9:24 ` Jan Kara 2021-06-04 15:53 ` [PATCH v7 0/6] cgroup, blkcg: prevent dirty inodes to pin dying memory cgroups Tejun Heo 2021-06-04 15:53 ` Tejun Heo 2021-06-04 22:24 ` Roman Gushchin 2021-06-04 22:24 ` Roman Gushchin 2021-06-04 23:31 ` Tejun Heo 2021-06-04 23:31 ` Tejun Heo 2021-06-05 21:37 ` Dennis Zhou 2021-06-05 21:37 ` Dennis Zhou
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210607090050.GB30275@quack2.suse.cz \ --to=jack@suse.cz \ --cc=cgroups@vger.kernel.org \ --cc=dchinner@redhat.com \ --cc=dennis@kernel.org \ --cc=guro@fb.com \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=tj@kernel.org \ --cc=viro@zeniv.linux.org.uk \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.