Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3040732imj; Mon, 11 Feb 2019 12:47:19 -0800 (PST) X-Google-Smtp-Source: AHgI3IaU+vvjSCpPFj8aTkDaaAxch4OeItBJo7PPnBeImxYf3wo2JYaerUS4c7VvFGL3jTqGrZ14 X-Received: by 2002:a63:1a5f:: with SMTP id a31mr97231pgm.335.1549918038938; Mon, 11 Feb 2019 12:47:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549918038; cv=none; d=google.com; s=arc-20160816; b=ebIXEQ+tHBoZ2Emx40UiSByVfWZ3h0I4+zl6oOq1EeDralanFxOeD5X0X5JIJE4xwB 5pXDz3X1R0eeVKzZWB+6wBcIJdNiq1bivjzQ2Ad4jba94qLRZdpdi8bgQWwZeU4rBeVU MByw8JEpE60pu4UjOrXAJ4St8BR42XkgDSq+nzS/phf2aDqz0fTWOJipMZOXc7JQf3mU 6XNJlMlqAoJ0eUr71Jg4tSeIj2kXttBuAHXOH+TWlPoodN6nb0Swfasge0qKEjX/VS7i iT//g6mHLTnp2fOhMj7AbAMbyY9x1ME9+LaraAYCCl1QT4Omv1q2A5skvjwsVNeaLssg us5Q== 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=aRRtjcrcVo+Gfaj/zX8Bw1iJ3MLE2kmxEDTa4rlrB10=; b=R9inho6kFbqrpIlGfeGdOQRGWireQCVE5e2/O5+DPVefYHP5NgHwv+OaOyI1uSx3DE 7DIwre2oCA92ike+SxC0Y7IXuOSCXYuDHSZi/OO++6GLofA6X5W4AGUV9MjuL2A+iJwr +0iFUk2F7IlGPQBnCkcIb7H99x5yqBHZ6wpsI/JeDhNVZSuC0z/zwkksImWc9DcwHaWL dQbzQS9xreqZoGQE7yeQVg4XEgUUzLEuTEfknIfhtWaJ/f7nEa/wtW8WCUY107hhPMkd 4foJFUn97J0Y0GUj+DM+mvLSjHPGyl0qrW+yS3dMbEtbcmqoTM6SH5EhylwWmYJFazb2 wsdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=c8Dpw+3t; 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 t5si9527375pgu.52.2019.02.11.12.47.02; Mon, 11 Feb 2019 12:47:18 -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=c8Dpw+3t; 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 S1727581AbfBKUkd (ORCPT + 99 others); Mon, 11 Feb 2019 15:40:33 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:34990 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726892AbfBKUkd (ORCPT ); Mon, 11 Feb 2019 15:40:33 -0500 Received: by mail-wr1-f68.google.com with SMTP id t18so284967wrx.2; Mon, 11 Feb 2019 12:40:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=aRRtjcrcVo+Gfaj/zX8Bw1iJ3MLE2kmxEDTa4rlrB10=; b=c8Dpw+3tPDH4dqPl8avgxjKxKfbxB7sXLA1eCltNVPmOgXV49okHrFlPpvJiBkUJOU CVYJyM/WWWE95z+5t1CscflAI3ljDt7nltAPQlUSDZIFc5t/AWddrIWKXEM9hH27Kdjq jdjkv7NcUJmEqxDJCg8LtVbyj7seo/r96FOuqwMvPlCY3RoyuPX6htWxj1KYM14PDxTy mSZhMDVKDx8rIFLr+GnLXOsSJSvGRfJpiPZHRLyuOdwsslNOI2fR3CcyBkhnwxNhvUNA 2xLzXdhYPWsMcKwxYMl5P9Aub8MGdL9ZtQ7d334VMYiJgAqT3/4Rrumi2lxnQpiwtU+E oGQA== 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=aRRtjcrcVo+Gfaj/zX8Bw1iJ3MLE2kmxEDTa4rlrB10=; b=DKcs11v17xDSgz3Swb7/Co0G7XlUyJcKZSc+VsRWdKsn750FoE2MxdPuM0DMBXRlrv pQvwVVDmtEMEhBU+3n1k/75jQfQfiI81hwv+7CUgWFNHy6Q7tSGvQxzW70ewL4GosIaq XDOEKT22NFW59yr3xPWeQ1cdxaw/nRwHRto4ui7YsJoTPU8qw+CmAb1W1aLEYpeIf2vu AS4jFSVxRj+YyExlrT4fy8xScDTnSGTDM/fGm4xY+lVltJK7wohDoOQ+lC55++XzXN7d WpogTdVM5EI657zwzenrpuSadyO6O5ql2i8nRrWw9GXzMCjdFbu0IXI6wrbvPvTD6Vg3 H9GQ== X-Gm-Message-State: AHQUAua41+JeRoLjjEMY3mkLepKbsQjbmM9iaMCsRgcoq2ZoH/JxwxKy /1yjZhTXkLRjI7D3eJCDWw== X-Received: by 2002:adf:ee82:: with SMTP id b2mr57625wro.185.1549917630648; Mon, 11 Feb 2019 12:40:30 -0800 (PST) Received: from localhost ([95.238.120.247]) by smtp.gmail.com with ESMTPSA id e4sm10742811wrt.53.2019.02.11.12.40.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Feb 2019 12:40:30 -0800 (PST) Date: Mon, 11 Feb 2019 21:40:29 +0100 From: Andrea Righi To: Josef Bacik Cc: Paolo Valente , Tejun Heo , Li Zefan , 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: [RFC PATCH v2] blkcg: prevent priority inversion problem during sync() Message-ID: <20190211204029.GB1520@xps-13> References: <20190209140749.GB1910@xps-13> <20190211153933.p26pu5jmbmisbkos@macbook-pro-91.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190211153933.p26pu5jmbmisbkos@macbook-pro-91.dhcp.thefacebook.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 11, 2019 at 10:39:34AM -0500, Josef Bacik wrote: > On Sat, Feb 09, 2019 at 03:07:49PM +0100, Andrea Righi wrote: > > This is an attempt to mitigate the priority inversion problem of a > > high-priority blkcg issuing a sync() and being forced to wait the > > completion of all the writeback I/O generated by any other low-priority > > blkcg, causing massive latencies to processes that shouldn't be > > I/O-throttled at all. > > > > The idea is to save a list of blkcg's that are waiting for writeback: > > every time a sync() is executed the current blkcg is added to the list. > > > > Then, when I/O is throttled, if there's a blkcg waiting for writeback > > different than the current blkcg, no throttling is applied (we can > > probably refine this logic later, i.e., a better policy could be to > > adjust the throttling I/O rate using the blkcg with the highest speed > > from the list of waiters - priority inheritance, kinda). > > > > This topic has been discussed here: > > https://lwn.net/ml/cgroups/20190118103127.325-1-righi.andrea@gmail.com/ > > > > But we didn't come up with any definitive solution. > > > > This patch is not a definitive solution either, but it's an attempt to > > continue addressing this issue and handling the priority inversion > > problem with sync() in a better way. > > > > Signed-off-by: Andrea Righi > > Talked with Tejun about this some and we agreed the following is probably the > best way forward First of all thanks for the update! > > 1) Track the submitter of the wb work to the writeback code. Are we going to track the cgroup that originated the dirty pages (or maybe dirty inodes) or do you have any idea in particular? > 2) Sync() defaults to the root cg, and and it writes all the things as the root > cg. OK. > 3) Add a flag to the cgroups that would make sync()'ers in that group only be > allowed to write out things that belong to its group. So, IIUC, when this flag is enabled a cgroup that is doing sync() would trigger the writeback of the pages that belong to that cgroup only and it waits only for these pages to be sync-ed, right? In this case writeback can still go at cgroup's speed. Instead when the flag is disabled, sync() would trigger writeback I/O globally, as usual, and it goes at full speed (root cgroup's speed). Am I understanding correctly? > > This way we avoid the priority inversion of having things like systemd or random > logged in user doing sync() and having to wait, and we keep low prio cgroups > from causing big IO storms by syncing out stuff and getting upgraded to root > priority just to avoid the inversion. > > Obviously by default we want this flag to be off since its such a big change, > but people/setups really worried about this behavior (Facebook for instance > would likely use this flag) can go ahead and set it and be sure we're getting > good isolation and still avoiding the priority inversion associated with running > sync from a high priority context. Thanks, > > Josef Thanks, -Andrea