Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5696164imb; Thu, 7 Mar 2019 23:41:59 -0800 (PST) X-Google-Smtp-Source: APXvYqwL50FPqh3KdNvTTSASXzMSTnAV1rHmbkCKH2piQRcMXSUcFE04/ufOXXC6X10uL/7CmWXe X-Received: by 2002:aa7:9143:: with SMTP id 3mr17131034pfi.238.1552030919162; Thu, 07 Mar 2019 23:41:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552030919; cv=none; d=google.com; s=arc-20160816; b=0xgUHpr0XhjestwLgkH1fbuXYa1QGIfYeFdMKTl8FevZ4LkoDdm+CAKoaUT2Y9MbMl LrTVkL5FEaZWJ3CEV9BGLJFELdHNTPPceY4VrAdVL5Sqv5K8vBjdF2hHPYHncAneyrVh WOdi7yz/TNcJsTBgmo+vsBUTjypGCoYCfYLd+S3eyIO2m19Yne4cW28q6a1nhxilbWul CYqzWfXGsiGfNevwgcqI+8dKMeuEJFIVxDDtbucDnrGlZ20tznqafFf5vJSo8Tw+bN5u rNLMTZX/dlHfisucezvnCiaq6B8mtuEVTFPqWtbQeb0qMUY0jF4x+V7ZEBiVZ2rAxdjw 0D1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=JJc0aaYe86uBtyFNHwS97nDpP6ya73K7Xpte85VT6jM=; b=ShneCudqhd2D/SjuLGaUzkFTP2xQ/Xk582siaxxl5LbnGlYCxTTErvsLbzN5caR8Pg IQvzI0A/WKDIg1MP+SKfwbjTTBelgEtnt7an0as4rDPa1vxyuHctTkdFP/RDT4f6UINC aLZsI0u7d8F/EVu5XSWFXT7t/FJGa90HloO86a9w8hjhfoV75gTiD5h41t253XB5Ejix 5JkM1pTgSheFeVKmiR89Q8Kzg+COAkmf0c+yOO9nGGkVnZy+c6Gq4TF28mI2Y4GaAgFC xTq43WfnehGJVgmanN6/qIX3OIZOF2B+L5EpqPtE2oFP9We+cHg1ZRXVfFMLvF3wf+B+ V0cw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y2si6232346plp.203.2019.03.07.23.41.43; Thu, 07 Mar 2019 23:41:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726340AbfCHHjz (ORCPT + 99 others); Fri, 8 Mar 2019 02:39:55 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:37248 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725308AbfCHHjy (ORCPT ); Fri, 8 Mar 2019 02:39:54 -0500 Received: from mail-wm1-f71.google.com ([209.85.128.71]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1h2A6j-000348-3L for linux-kernel@vger.kernel.org; Fri, 08 Mar 2019 07:39:53 +0000 Received: by mail-wm1-f71.google.com with SMTP id t133so3866279wmg.4 for ; Thu, 07 Mar 2019 23:39:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=JJc0aaYe86uBtyFNHwS97nDpP6ya73K7Xpte85VT6jM=; b=eBHEeMRX4Gbtv0wWS60Vd+tNQRJ+Ud7r+Ka0tOz8SNeHcQ++UhAgFBkyh1VUDZD874 jpQuaz12eNFjXNd6w7tnKhdUxP4bxcHdgee59We/pY0/xEd5XvMWRQocZlfQ62YfWu4G RnrI/mtKg1K6P3YZxfuJArr51pIJsXzuF3sFXQm3/buBaFTq4bnSi5WZLeIZ+44pjruT i+wWugNJkwbDoa8L0cyZkZijzvAM/4WcdtjmICiokb4HcqKLkuJTccsCd9gRTXsyOb7G /e6an35rPXGAMCn0PgmNYQSDDGhZbvgDYAcsedc5BsS11d7kyesmr55A3nnVnY8ev5Ea QJ2g== X-Gm-Message-State: APjAAAWf3KVRJk74yGs18ekpdXY1eG+OgwbBxL5zyddHnlJEMZns3X5f yagenD/kQSdJTqK5E4vCFHJ14l+S5FhF58vxb5alQQFsVZcK5WgtWzrPT12QApPVfJ2YwQ/obXC z1RO5dvXeOFhaTbYDoPU/x4jYGJZX5WqV4heRSqfJFg== X-Received: by 2002:a05:600c:246:: with SMTP id 6mr8339779wmj.150.1552030792771; Thu, 07 Mar 2019 23:39:52 -0800 (PST) X-Received: by 2002:a05:600c:246:: with SMTP id 6mr8339760wmj.150.1552030792587; Thu, 07 Mar 2019 23:39:52 -0800 (PST) Received: from localhost (host22-124-dynamic.46-79-r.retail.telecomitalia.it. [79.46.124.22]) by smtp.gmail.com with ESMTPSA id 203sm9224529wme.30.2019.03.07.23.39.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2019 23:39:52 -0800 (PST) Date: Fri, 8 Mar 2019 08:39:50 +0100 From: Andrea Righi To: Josef Bacik Cc: Tejun Heo , Li Zefan , Paolo Valente , Johannes Weiner , Jens Axboe , Vivek Goyal , Dennis Zhou , cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/3] blkcg: implement sync() isolation Message-ID: <20190308073950.GA6087@xps-13> References: <20190307180834.22008-1-andrea.righi@canonical.com> <20190307180834.22008-4-andrea.righi@canonical.com> <20190307220659.5qmye2pxmto7nlei@macbook-pro-91.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190307220659.5qmye2pxmto7nlei@macbook-pro-91.dhcp.thefacebook.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 07, 2019 at 05:07:01PM -0500, Josef Bacik wrote: > On Thu, Mar 07, 2019 at 07:08:34PM +0100, Andrea Righi wrote: > > Keep track of the inodes that have been dirtied by each blkcg cgroup and > > make sure that a blkcg issuing a sync() can trigger the writeback + wait > > of only those pages that belong to the cgroup itself. > > > > This behavior is applied only when io.sync_isolation is enabled in the > > cgroup, otherwise the old behavior is applied: sync() triggers the > > writeback of any dirty page. > > > > Signed-off-by: Andrea Righi > > --- > > block/blk-cgroup.c | 47 ++++++++++++++++++++++++++++++++++ > > fs/fs-writeback.c | 52 +++++++++++++++++++++++++++++++++++--- > > fs/inode.c | 1 + > > include/linux/blk-cgroup.h | 22 ++++++++++++++++ > > include/linux/fs.h | 4 +++ > > mm/page-writeback.c | 1 + > > 6 files changed, 124 insertions(+), 3 deletions(-) > > > > diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c > > index 4305e78d1bb2..7d3b26ba4575 100644 > > --- a/block/blk-cgroup.c > > +++ b/block/blk-cgroup.c > > @@ -1480,6 +1480,53 @@ void blkcg_stop_wb_wait_on_bdi(struct backing_dev_info *bdi) > > spin_unlock(&blkcg_wb_sleeper_lock); > > rcu_read_unlock(); > > } > > + > > +/** > > + * blkcg_set_mapping_dirty - set owner of a dirty mapping > > + * @mapping: target address space > > + * > > + * Set the current blkcg as the owner of the address space @mapping (the first > > + * blkcg that dirties @mapping becomes the owner). > > + */ > > +void blkcg_set_mapping_dirty(struct address_space *mapping) > > +{ > > + struct blkcg *curr_blkcg, *blkcg; > > + > > + if (mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK) || > > + mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) > > + return; > > + > > + rcu_read_lock(); > > + curr_blkcg = blkcg_from_current(); > > + blkcg = blkcg_from_mapping(mapping); > > + if (curr_blkcg != blkcg) { > > + if (blkcg) > > + css_put(&blkcg->css); > > + css_get(&curr_blkcg->css); > > + rcu_assign_pointer(mapping->i_blkcg, curr_blkcg); > > + } > > + rcu_read_unlock(); > > +} > > + > > +/** > > + * blkcg_set_mapping_clean - clear the owner of a dirty mapping > > + * @mapping: target address space > > + * > > + * Unset the owner of @mapping when it becomes clean. > > + */ > > + > > +void blkcg_set_mapping_clean(struct address_space *mapping) > > +{ > > + struct blkcg *blkcg; > > + > > + rcu_read_lock(); > > + blkcg = rcu_dereference(mapping->i_blkcg); > > + if (blkcg) { > > + css_put(&blkcg->css); > > + RCU_INIT_POINTER(mapping->i_blkcg, NULL); > > + } > > + rcu_read_unlock(); > > +} > > #endif > > > > Why do we need this? We already have the inode_attach_wb(), which has the > blkcg_css embedded in it for whoever dirtied the inode first. Can we not just > use that? Thanks, > > Josef I'm realizing only now that inode_attach_wb() also has blkcg embedded in addition to the memcg. I think I can use that and drop these blkcg_set_mapping_dirty/clean().. Thanks, -Andrea