Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3670388imj; Tue, 19 Feb 2019 07:29:51 -0800 (PST) X-Google-Smtp-Source: AHgI3IY62xzD9HIFiWbnZwtEI4YLArsECWg/LqlcSBxdsnUTwSg6TVfgC+yu5kWG594jzCX7ejzB X-Received: by 2002:a62:1b83:: with SMTP id b125mr30994773pfb.42.1550590191518; Tue, 19 Feb 2019 07:29:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550590191; cv=none; d=google.com; s=arc-20160816; b=QP5UxroU9hDnqjx/OO0KjUUXGfg6ccoP9bmH0O3ldt01YGVSGNPGFHppuxTjlW/yvg 1oShxPENPJSf/eHs76n+y3FsyQlzBA1TbrNVht6vqBDmI++fRyrdiiYpgMmMoGI2wbn3 /uYzjxx9HJCqL11ByfYrmWp2zZ+IRgCSvKg4ct+geXVZb6grhGTJBRJzIrZX9Pf6ZtCk O+FV9CJxtTypcK6H9Yj8WEoS7KfDmuOAQYeyTEHB6IdqqyWLfu15kzjhggo948DCZ2r8 9L269lsCQm8Tab5YjhgO5/AcocgEp8zgsRfUPZaU6r0oWX106UHu+ffE4jvraVCxvnH5 /15Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=2q6fbrSJpEIdLncW4UFN3mJBQ17i3z8yQuQeSIDg2n4=; b=Zptq82adYjsnkJdnraXW55cjLX12sBPVU/ECb+UUYD1m5AxWsD/GoiyDDeM59TgZDQ 48pnbnb3pL6I3lIkhXt2PGCRhc1JJaUNyR4FGjoDuFwe542izrcyMghrqGn6Q0/DT1jM isUY3wruFx45F682cQ+16+SGlg5xYmoP0ZQ6vt+4qx1yQXTrGZ5juUCAxt/tID3DDJFK +Iox5R66xXQx9KjDY10QBhhOBKhf6Sdfahcb2VD3cvT62coTf7HcnBq6RclygkhesmTc hXzv6VFuXYQUIhBL0FgEM5EVtNJy3q5/XlBwLw9BM//vuEpvTVSOJ8xAHcUonWu8xzUw Nr3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Hc7yKF8Q; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r18si7217181pls.374.2019.02.19.07.29.35; Tue, 19 Feb 2019 07:29:51 -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=@gmail.com header.s=20161025 header.b=Hc7yKF8Q; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729009AbfBSP17 (ORCPT + 99 others); Tue, 19 Feb 2019 10:27:59 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43776 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726110AbfBSP1q (ORCPT ); Tue, 19 Feb 2019 10:27:46 -0500 Received: by mail-wr1-f67.google.com with SMTP id d17so8015087wre.10; Tue, 19 Feb 2019 07:27:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2q6fbrSJpEIdLncW4UFN3mJBQ17i3z8yQuQeSIDg2n4=; b=Hc7yKF8Q0KWei9jPYZqwtPGUg6enGpDzAb3GPtEE+uGJT2GIltg9n8oYO6EmU47dnm +wYlQ647qj51UGlYZNKeCAdC/Pk0mmoluTHFpcgfSvyMEmQeUgq4AKiVejeZ6dfnPl4m rMc4yjeoJI8TOMezjLRVtcmIiw5XFWC3QpxlfLZ8teQOFbg4AbFQwkGBp+rnIwRF3/on D/79xbnlJeVugNzjBBwnaDqvY/giTuukLGhCR5ATHdj0LlJe2WxnNXvk35VkbBIHm6jG uWEuO55gt+o6aMnwdIRi0a3mwOkcjPyWJl8raBZDs8rP2AGQwOL0p2GaLPU8i5ndeUIc /Sog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2q6fbrSJpEIdLncW4UFN3mJBQ17i3z8yQuQeSIDg2n4=; b=nwPnDSwsbYO2EmCoZItAGVw02eQ76mUe2OrXqUrIiVXR/yud4CbGAyz04wXPRT7u2U cCHCPKXmsw4T2zOlkwSiJruJNhrOg2cA/ZZmjFL4i/oM+WEGEbLBbOcCFGUOoZMemxab d1Rc8P/RJXmhEyIuF8IikWl3cH2wZuvRCULLjTVAUKaEcfD71z7kq8J5TdacCdhTmFQ4 8x8bBf/iVOTf8oAVfJl69RRelGisAka+pBiZjN7PIW4ZCifvfeh7RTH4RS/TZxy7Fyzn EJDJ+32S/+CVK4nvNz3OG1MueueBlYT8MHlu4jnff0WR40ZpICeH+qZmJehShUTK/v+a X7oA== X-Gm-Message-State: AHQUAuY65Z5VgL+KT45cuK3dWd3DBZqNLp9V8ipwoWr/6pHOBKP3nY8E VRO8bli5UqNB3XnjSX1TfA== X-Received: by 2002:adf:f786:: with SMTP id q6mr4734864wrp.125.1550590063818; Tue, 19 Feb 2019 07:27:43 -0800 (PST) Received: from xps-13.homenet.telecomitalia.it (host117-125-dynamic.33-79-r.retail.telecomitalia.it. [79.33.125.117]) by smtp.gmail.com with ESMTPSA id v6sm29029503wrd.88.2019.02.19.07.27.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Feb 2019 07:27:43 -0800 (PST) From: Andrea Righi To: Josef Bacik , Tejun Heo Cc: 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: [PATCH 2/3] blkcg: introduce io.sync_isolation Date: Tue, 19 Feb 2019 16:27:11 +0100 Message-Id: <20190219152712.9855-3-righi.andrea@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190219152712.9855-1-righi.andrea@gmail.com> References: <20190219152712.9855-1-righi.andrea@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a flag to the blkcg cgroups to make sync()'ers in a cgroup only be allowed to write out pages that have been dirtied by the cgroup itself. This flag is disabled by default (meaning that we are not changing the previous behavior by default). When this flag is enabled any cgroup can write out only dirty pages that belong to the cgroup itself (except for the root cgroup that would still be able to write out all pages globally). Signed-off-by: Andrea Righi --- Documentation/admin-guide/cgroup-v2.rst | 9 ++++++ block/blk-throttle.c | 37 +++++++++++++++++++++++++ include/linux/blk-cgroup.h | 7 +++++ 3 files changed, 53 insertions(+) diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst index 7bf3f129c68b..f98027fc2398 100644 --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -1432,6 +1432,15 @@ IO Interface Files Shows pressure stall information for IO. See Documentation/accounting/psi.txt for details. + io.sync_isolation + A flag (0|1) that determines whether a cgroup is allowed to write out + only pages that have been dirtied by the cgroup itself. This option is + set to false (0) by default, meaning that any cgroup would try to write + out dirty pages globally, even those that have been dirtied by other + cgroups. + + Setting this option to true (1) provides a better isolation across + cgroups that are doing an intense write I/O activity. Writeback ~~~~~~~~~ diff --git a/block/blk-throttle.c b/block/blk-throttle.c index da817896cded..4bc3b40a4d93 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -1704,6 +1704,35 @@ static ssize_t tg_set_limit(struct kernfs_open_file *of, return ret ?: nbytes; } +#ifdef CONFIG_CGROUP_WRITEBACK +static int sync_isolation_show(struct seq_file *sf, void *v) +{ + struct blkcg *blkcg = css_to_blkcg(seq_css(sf)); + + seq_printf(sf, "%d\n", test_bit(BLKCG_SYNC_ISOLATION, &blkcg->flags)); + return 0; +} + +static ssize_t sync_isolation_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, loff_t off) +{ + struct blkcg *blkcg = css_to_blkcg(of_css(of)); + unsigned long val; + int err; + + buf = strstrip(buf); + err = kstrtoul(buf, 0, &val); + if (err) + return err; + if (val) + set_bit(BLKCG_SYNC_ISOLATION, &blkcg->flags); + else + clear_bit(BLKCG_SYNC_ISOLATION, &blkcg->flags); + + return nbytes; +} +#endif + static struct cftype throtl_files[] = { #ifdef CONFIG_BLK_DEV_THROTTLING_LOW { @@ -1721,6 +1750,14 @@ static struct cftype throtl_files[] = { .write = tg_set_limit, .private = LIMIT_MAX, }, +#ifdef CONFIG_CGROUP_WRITEBACK + { + .name = "sync_isolation", + .flags = CFTYPE_NOT_ON_ROOT, + .seq_show = sync_isolation_show, + .write = sync_isolation_write, + }, +#endif { } /* terminate */ }; diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h index 0f7dcb70e922..6ac5aa049334 100644 --- a/include/linux/blk-cgroup.h +++ b/include/linux/blk-cgroup.h @@ -44,6 +44,12 @@ enum blkg_rwstat_type { struct blkcg_gq; +/* blkcg->flags */ +enum { + /* sync()'ers allowed to write out pages dirtied by the blkcg */ + BLKCG_SYNC_ISOLATION, +}; + struct blkcg { struct cgroup_subsys_state css; spinlock_t lock; @@ -55,6 +61,7 @@ struct blkcg { struct blkcg_policy_data *cpd[BLKCG_MAX_POLS]; struct list_head all_blkcgs_node; + unsigned long flags; #ifdef CONFIG_CGROUP_WRITEBACK struct list_head cgwb_wait_node; struct list_head cgwb_list; -- 2.17.1