Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5213048imb; Thu, 7 Mar 2019 10:10:39 -0800 (PST) X-Google-Smtp-Source: APXvYqzi14hN48DCPYZqiHF3kXVv+vcxNpVxtit4Uvn6qIwJpd6RymhjstgXDGN/TZDFmPtg4k5n X-Received: by 2002:a65:46cd:: with SMTP id n13mr12407183pgr.221.1551982239205; Thu, 07 Mar 2019 10:10:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551982239; cv=none; d=google.com; s=arc-20160816; b=FTija1vyI9niK1W+QlZk/c0IuvDY59Wgd4ZWYtMB/Ky5yoEtWktvXj/T8S+uOGQBYO 5XoPnY9k8oXqEqfO5f/1PxI7cPNGmelaY93WvOT+Bjp41RZYinO/CqLdzR3EY4wWNW5T 3X8DRAmhWWn6b6+ZlwqoJgaYdUpC09le4w1IEYYDH7I1wip3t9E2LRV0rB7D/xyEJqUr xio+KIgTYvaWdL/peo04u7KEF8LPKc0H0A7rYEzij6S4B0XJ9yDkIJRchC1TZ+EFjkKU ur2lY7TO/vsBIbpipevDJa+v4aOoBTErQtbLeSsjmnOnd4f8p64cUdX67Lkjh9Ecr5tj XrvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=msHBAipTtijk0UwIEQstQw/a0b7WTAeEuEqzcOHunh8=; b=EIbOnihDgBJWsiUU2rryiZunReQ50LYobvFaXqWgZx36XuCRBcohUy3a9IN45pk8VA lV5aWTe4DqQ/tTBx9v7dkYjIPTMRB01WWCYZe/jggYBU3PsOx+N17DC6hDatlDQGnfWt SRaWa3b9fXonc1Apb5Xhbipf5V877QlX+tIS3TH5AS/ZSDA/Sdq57pit4zYcNNR+ZsTv 5O1+ngVBSTgiPms0BEmpgKhyhGYvG+Drw0fv23f05ZNjTNLh8a29zmQ1b6o16sKHYG0i E+/fpElI9cCnGFquTiKYifIMqPYgBjKNjR0dkgE8t+s06rYNpGOPUT/POrnm7y4vi5fI Q2tg== 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 b11si4912764pla.195.2019.03.07.10.10.23; Thu, 07 Mar 2019 10:10:39 -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 S1726628AbfCGSJo (ORCPT + 99 others); Thu, 7 Mar 2019 13:09:44 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:51191 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726243AbfCGSJc (ORCPT ); Thu, 7 Mar 2019 13:09:32 -0500 Received: from mail-wr1-f71.google.com ([209.85.221.71]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1h1xST-0001ku-S8 for linux-kernel@vger.kernel.org; Thu, 07 Mar 2019 18:09:29 +0000 Received: by mail-wr1-f71.google.com with SMTP id y1so8911508wrh.21 for ; Thu, 07 Mar 2019 10:09:29 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=msHBAipTtijk0UwIEQstQw/a0b7WTAeEuEqzcOHunh8=; b=jDDn87GzLd/SAK8O9Pi0gyGRwfag66AaO4n21kTkRxiE43Dlc0/Qyh59jNbRKGhhEs zeRSm8op7VCYdZo0WQ/2MrkzJQy1h5lbx2xHJU4AnbOa8/S7xeQJEcQvbUFg64F9WoEa vVatHPIDXbOU4bv9hfbbeXrn31Aj1QPQAUmfIH8Pqrg80UoI5yX1EIZwX3bRGH270VK2 wTwSqDUI1oxgIr5GqZ8r1iPxC3Bv+tVpCkFlA+zwIk6pl5QccHpe7MHZt0C/BADt3OyJ SEyey+w0m6+PAvLTycPwB6J2gDhNkf7wkHPDgr4yjFdjeCCDSEXvwYPmckxdhjDYVfq8 LTuQ== X-Gm-Message-State: APjAAAXGxY3tQ8GEKok2bfuvFIjXfoR1fdYBwzjPAFFZEB+c/fxgWQxl bBlitYlxF0VB+W0NKFQmm4Jqvr3jYA+6LWa1BM8/dRVczsHP3+8nWHF3FNDDVq1/ZWBX55BGInH VfIZe6Xmm7JKiS2GNf4CWah+VQWqg+oike/DrHcnIjw== X-Received: by 2002:a1c:48f:: with SMTP id 137mr6282803wme.21.1551982169513; Thu, 07 Mar 2019 10:09:29 -0800 (PST) X-Received: by 2002:a1c:48f:: with SMTP id 137mr6282785wme.21.1551982169309; Thu, 07 Mar 2019 10:09:29 -0800 (PST) Received: from localhost.localdomain (host22-124-dynamic.46-79-r.retail.telecomitalia.it. [79.46.124.22]) by smtp.gmail.com with ESMTPSA id a74sm7872747wma.22.2019.03.07.10.09.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 10:09:28 -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 v2 2/3] blkcg: introduce io.sync_isolation Date: Thu, 7 Mar 2019 19:08:33 +0100 Message-Id: <20190307180834.22008-3-andrea.righi@canonical.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190307180834.22008-1-andrea.righi@canonical.com> References: <20190307180834.22008-1-andrea.righi@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 53d3288c328b..17fff0ee97b8 100644 --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -1448,6 +1448,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.19.1