Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5371662imb; Thu, 7 Mar 2019 14:09:05 -0800 (PST) X-Google-Smtp-Source: APXvYqx8wGX8TEzQVnXJwyxAuu83sAtqgYtdh9HsVAqdnBs9hJkDmNkResRyX9ZjDnxcXdfqO08A X-Received: by 2002:a63:854a:: with SMTP id u71mr13140646pgd.141.1551996545345; Thu, 07 Mar 2019 14:09:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551996545; cv=none; d=google.com; s=arc-20160816; b=WfOyPIep/ok/iakeq8tZbs1sI9trvVRClGCT6iZu3dAwczTCUCacUxku2bJB51BDx+ pEMS2Nb38LF8L75UWC0V4dFansv5vg1YnyrcWEPfYR/56q7mVl0PXWo9VSg+3n4qlN/A aYJubJyaRs03WpgDVfhcNq6dz+xtt9g9gh0Qf32iEX7klRb7aofHFaeVpsA1MrTe1yjq /80EAWlW0843Uj4sm4Rjcg1pRsAviFRg/wmoXkpJLfBPU5jggRTspQsxSh+6gT6yoLyu iQ+Q6ZqhxF4oUioPDdnV02dloNAvJZxYwKHI7Zva0GY5wBt/9LayVKnT6uknCYpry91n zNlg== 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:dkim-signature; bh=5XqGPOhHxWelDgT11+htERfFUnfLr39ckjM2oBzWcuM=; b=eUZ8yxQSixLE9Plzx3vXWTjPCAHdgYemVl3VfqVMdl5+1K3+9p/jBU0cLH42oVYrWD xz6ALMugBbxTB3GHMR1MTeEIJAIRSv6LzYvCuwZTATYMeNqhis4gBaEfGxYm0PomKzwp ox8F1CoqdNcXG/jbczYQFZGM0WNzjlg6E/ZAT4c7/WraRjuuqfRBOThgsiV4KlNdUkvd UE3r15g9J35oKnMZdf70aARNJpqgM1scRZ2CbUvKsUhxN99lpIVPHw2supNCxCH505vt piRenld/MDNq0ddjUdAmhsPPW3h9e2wBvfrTuNPPyIJmKrnICO8zFh9jkHBPez9tRXXe A7ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=hg7NUf0V; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12si4648619pgv.293.2019.03.07.14.08.49; Thu, 07 Mar 2019 14:09:05 -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; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=hg7NUf0V; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726342AbfCGWHF (ORCPT + 99 others); Thu, 7 Mar 2019 17:07:05 -0500 Received: from mail-yw1-f65.google.com ([209.85.161.65]:38178 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726166AbfCGWHE (ORCPT ); Thu, 7 Mar 2019 17:07:04 -0500 Received: by mail-yw1-f65.google.com with SMTP id x20so394760ywd.5 for ; Thu, 07 Mar 2019 14:07:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=5XqGPOhHxWelDgT11+htERfFUnfLr39ckjM2oBzWcuM=; b=hg7NUf0VaR7rWE9ExshFRFdJUBKdlHgyhBWn7fpjNak6rkxf3itb5EAT/yLjZIgs5I PqLKwWBjIsOsCasCwpoEFwHh16ddfXVwzx9FvJOt76zVAt4KwA9lhQLTSvqp5aVi9nfp OLc7ZTSc9ofuBPPFhBVgn/JjmxwiAw9grGfKYve8t2h6dJP3YdzsJykQ137aLgGZcVQQ VrQpJ1IQzv2koxKRIhT5auG+a8z/d8jXn2c446S8wZ18mlVD4GQIa840ydnLLmZDEn/g lEWpO6x46h8n6/oPsjC6Pv+gSDsVjdOI2iSkuv6c3RhQmZsXH5qCpEjvo+HCT7qI+dgu iS0w== 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=5XqGPOhHxWelDgT11+htERfFUnfLr39ckjM2oBzWcuM=; b=K9CIVCJ6aC9bbt/Zlil9sOhI/7S5QXShplEdSKfqopIeJnbiCZ38kYtnrnFsQdqNG/ j8fGyORi+n4ipTUi68vAJAXXeEajAlAsy6ARwhPTjQhjXqHL322AINHYlL2/CY2o2UCk NbXs7yrupj8RQlyhHLyZIxF/lXJIPqgHGmBR0nZ/oPfZ7SJBoDhyXoAuYppM91VZMEHi GP6qygsHMlJajDLFNWJVk7b9PzsdExwSNd+Yx2KduMr6aJZEqJ9phdBJ9tV2bDu7rLdO /fGKV+39UessSjrRxfNDZtHpcYU4QlLUNIA9o5T+5uv98efZlWJDdprimpBVA3VVBXTw ZfdA== X-Gm-Message-State: APjAAAVx7CCbsf1yAL8gy9xp9vf9YcYuZ93beHI7/JjWB020wULxbChf MBdjFeSLTRp5CFApo7pCE+IHxA== X-Received: by 2002:a81:b8d:: with SMTP id 135mr12004691ywl.152.1551996422797; Thu, 07 Mar 2019 14:07:02 -0800 (PST) Received: from localhost ([2620:10d:c091:180::be7f]) by smtp.gmail.com with ESMTPSA id k187sm1953929ywc.47.2019.03.07.14.07.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 14:07:02 -0800 (PST) Date: Thu, 7 Mar 2019 17:07:01 -0500 From: Josef Bacik To: Andrea Righi Cc: Josef Bacik , 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: <20190307220659.5qmye2pxmto7nlei@macbook-pro-91.dhcp.thefacebook.com> References: <20190307180834.22008-1-andrea.righi@canonical.com> <20190307180834.22008-4-andrea.righi@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190307180834.22008-4-andrea.righi@canonical.com> User-Agent: NeoMutt/20180716 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 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