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=unavailable 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 66D89C47082 for ; Thu, 3 Jun 2021 10:11:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 105D4613E6 for ; Thu, 3 Jun 2021 10:11:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 105D4613E6 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 649AE6B0072; Thu, 3 Jun 2021 06:11:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5FA206B0073; Thu, 3 Jun 2021 06:11:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 473526B0074; Thu, 3 Jun 2021 06:11:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0147.hostedemail.com [216.40.44.147]) by kanga.kvack.org (Postfix) with ESMTP id 156F06B0072 for ; Thu, 3 Jun 2021 06:11:00 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A9CEE181AC9C6 for ; Thu, 3 Jun 2021 10:10:59 +0000 (UTC) X-FDA: 78211994238.27.DCC2B6D Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf08.hostedemail.com (Postfix) with ESMTP id 6E4538019370 for ; Thu, 3 Jun 2021 10:10:45 +0000 (UTC) Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 045A21FD56; Thu, 3 Jun 2021 10:10:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1622715058; 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=dl1cSFiS5eKqztKERplBtFE3q8X+b7XPT0PQ/DFNCvM=; b=tPuCzD1fQp7yP6anCTvYzIYNpUk9tc3LVokNr+FsYzOzm74PZesjrtCYB8WUDID5WbX6lb Eh1+21542gh0yxrTadXYt2VbTT5S0myebYY0wbrvIkodTZMSVCFALWL/WxzoUsO2luaJ1a 3l4cCvlm8BgUKgQd4xaj4JkkJG2sVJE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1622715058; 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=dl1cSFiS5eKqztKERplBtFE3q8X+b7XPT0PQ/DFNCvM=; b=rGD56/LecjA4ecN9EDCJM0AZenCGGzEQBAm2KixEVmJVBebVq3OzFJkGR0UI7gz9tau0ce aetK6i7QWZCzUJCw== Received: from quack2.suse.cz (unknown [10.100.200.198]) by relay2.suse.de (Postfix) with ESMTP id E934CA3B85; Thu, 3 Jun 2021 10:10:57 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id C765C1F2C98; Thu, 3 Jun 2021 12:10:57 +0200 (CEST) Date: Thu, 3 Jun 2021 12:10:57 +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 4/5] writeback, cgroup: support switching multiple inodes at once Message-ID: <20210603101057.GH23647@quack2.suse.cz> References: <20210603005517.1403689-1-guro@fb.com> <20210603005517.1403689-5-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210603005517.1403689-5-guro@fb.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Queue-Id: 6E4538019370 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=tPuCzD1f; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="rGD56/Le"; dmarc=none; spf=pass (imf08.hostedemail.com: domain of jack@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=jack@suse.cz X-Rspamd-Server: rspam03 X-Stat-Signature: rcidzosimg7qoqzs43og7egrpa4nb5iq X-HE-Tag: 1622715045-587840 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:16, 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. > > Signed-off-by: Roman Gushchin Two small comments below: > @@ -473,10 +473,14 @@ static void inode_switch_wbs_work_fn(struct work_struct *work) > { > struct inode_switch_wbs_context *isw = > container_of(to_rcu_work(work), struct inode_switch_wbs_context, work); > + struct inode **inodep; > + > + for (inodep = &isw->inodes[0]; *inodep; inodep++) { ^^^^ why not just isw->inodes? > + inode_do_switch_wbs(*inodep, isw->new_wb); > + iput(*inodep); > + } I was kind of hoping that we would save the repeated locking of bdi->wb_switch_rwsem, old_wb->list_lock, and new_wb->list_lock for multiple inodes. Maybe we can have 'old_wb' as part of isw as well and assert that all inodes are still attached to the old_wb at this point to make this a bit simpler. Or we can fetch old_wb from the first inode and then just lock & assert using that one. Honza -- Jan Kara SUSE Labs, CR