From patchwork Thu Jun 13 22:30:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 10993711 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A25B1398 for ; Thu, 13 Jun 2019 22:31:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AFE426E76 for ; Thu, 13 Jun 2019 22:31:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F58226E98; Thu, 13 Jun 2019 22:31:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD21026E76 for ; Thu, 13 Jun 2019 22:31:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726369AbfFMWau (ORCPT ); Thu, 13 Jun 2019 18:30:50 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:40756 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725616AbfFMWat (ORCPT ); Thu, 13 Jun 2019 18:30:49 -0400 Received: by mail-pf1-f196.google.com with SMTP id p184so126533pfp.7; Thu, 13 Jun 2019 15:30:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=U7FQmFFF1Z7fbd/otHz8+BUYJEJIQONwHFEy1+lWias=; b=ou8LjWlocAo0l+AbBD2K8zqOXdHKtUJiuOKET9r4w2rYN8FTmJm9/rkEcRYxxwarXU SEhyPscTnAzXgCFIJWK5iLd9z+cvsmGhefs5JnhaUZGL9BA8PHvNxLll/3vFK914D+aW YGV19T8nfi1N1oex58KP07rbT7j9pfn6UcpSyu47NmD8gMfAXs/OLD0dEbr+6KXZApfn 9xJjEGAZFGRBbJsJHRclDWUgaQ8d47vAEY+fTE39qpMdFepfOyy/IMgrMnJnhI7qaIFX xazIFmZect8aSvQjduAHe4T3bW2Cigb1rVqdbJXzALIsWIPv5JtGZVMBqhXqNL8WfmBs zMAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=U7FQmFFF1Z7fbd/otHz8+BUYJEJIQONwHFEy1+lWias=; b=HlZiktsagTB1eqWmovDjAJoxYYvEzXWFwRbBzPA7txh9LohiA+BmWU6BYcfaLSOxDp 1IZmCGB/9ytBQZaiIM7kPIYfHKOKfTtbFwevvcacEdShzphUMSXGXrM4/M0oH1xHF0Mx j562ZFTO0TpF+q4cVP1bzkpEqV1gMEZjjuoykJQ64VsFc2D88fa6Xz+B2eL2d8/P1HYs 1UbjI983WY9/tvlmhav0t8jXNE3o4HNd1t5Hf2EnG75nZ73PcV7ZR/PH56fl4eMJsyJk n3XQz+HPz9fsSB/A4jWS0mWvC+FDv2vHBpOcQMmbviG+MY0L8vT8OCbYxXCYOqu4ch98 kLJA== X-Gm-Message-State: APjAAAXPRWg3z2hmT0c6FbucaIuivI0DIst+2l2DocwzjhEJLXvTDW3l LYrio054McDnamMFTnzh1wi+aCYK X-Google-Smtp-Source: APXvYqzcZ+KeeCn26qjrgyY2X4mTd17aLheAHsEdaxp8KdwvnigyJg/XaRKDKq9XFJgvCS02qH5ksg== X-Received: by 2002:a17:90a:d681:: with SMTP id x1mr7614682pju.13.1560465048467; Thu, 13 Jun 2019 15:30:48 -0700 (PDT) Received: from localhost ([2620:10d:c091:500::2:9d14]) by smtp.gmail.com with ESMTPSA id 5sm610910pfh.109.2019.06.13.15.30.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 15:30:47 -0700 (PDT) From: Tejun Heo To: axboe@kernel.dk, jbacik@fb.com Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, kernel-team@fb.com, dennis@kernel.org, jack@suse.cz, Tejun Heo , stable@vger.kernel.org Subject: [PATCH 1/5] blk-iolatency: clear use_delay when io.latency is set to zero Date: Thu, 13 Jun 2019 15:30:37 -0700 Message-Id: <20190613223041.606735-2-tj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190613223041.606735-1-tj@kernel.org> References: <20190613223041.606735-1-tj@kernel.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If use_delay was non-zero when the latency target of a cgroup was set to zero, it will stay stuck until io.latency is enabled on the cgroup again. This keeps readahead disabled for the cgroup impacting performance negatively. Signed-off-by: Tejun Heo Cc: Josef Bacik Fixes: d70675121546 ("block: introduce blk-iolatency io controller") Cc: stable@vger.kernel.org # v4.19+ --- block/blk-iolatency.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index d22e61bced86..17896bb3aaf2 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -778,8 +778,10 @@ static int iolatency_set_min_lat_nsec(struct blkcg_gq *blkg, u64 val) if (!oldval && val) return 1; - if (oldval && !val) + if (oldval && !val) { + blkcg_clear_delay(blkg); return -1; + } return 0; } From patchwork Thu Jun 13 22:30:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 10993709 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 853261398 for ; Thu, 13 Jun 2019 22:31:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7628926E76 for ; Thu, 13 Jun 2019 22:31:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A81526E98; Thu, 13 Jun 2019 22:31:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AF1426E76 for ; Thu, 13 Jun 2019 22:31:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726993AbfFMWax (ORCPT ); Thu, 13 Jun 2019 18:30:53 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:40763 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725616AbfFMWaw (ORCPT ); Thu, 13 Jun 2019 18:30:52 -0400 Received: by mail-pf1-f196.google.com with SMTP id p184so126627pfp.7; Thu, 13 Jun 2019 15:30:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=le87mSroNc/vpZ1PXB7D9b7oXP9bRIOE/1No2nrz140=; b=TcNfVaI7zCKBSfPScGJNIbpJxSZMkEGhfWZEvUL+iAPHzoim0WMMPifT02p1UMxqqJ Nfk7NxYIuorNrCC/+A4aDXTVhvfAMXnicEKOQay0xtQayKkKPxxsg9F6Lolf1x6YMmQD KnGOoP7L6tfcW3x2+i5l31yhe07mc9c1FNaYX6JC/dQ+h+yIXIkaGkxH1q4eAGoQLb69 NhhAqkIOn+H1/H0O+SsmXYGSN6to3fdZ/78WCSJkpx3+lHw1p3G39B3EiemW/D7fW4c+ UmA885xXs9ZEzMcGGsEiR5PWaoC07HZ63WfPntuz+sXaxrA2oH35tB2PpEbCXAqqbPpD YP+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=le87mSroNc/vpZ1PXB7D9b7oXP9bRIOE/1No2nrz140=; b=rd8pyvEbdx1ClTjxBEWqC7TvNto7jhNQ2ZhdcUgcNGSleSCKrvotpUpnJcLz+VeQZ9 eHJ9UrFarHeBk59T8ivgEeO4JHtnGrSn/bqCO/duevaeBG/HZoPfVtRXD2TKjWhUn/Bz HBtqL2kdwvTy60BV4b7wHGOpX749gaIXAOLHgy6QdVDEC4GsSNyhXYBlopooXs1YlNa5 UOCQcYYbuizVx0JHgeE/y2TxoIiVlS3CtlAnY1MRFvWctH1i4hJBjhSPyO58qt7y4QsV vi8Jhygg1VI1ObSukfe+ulTyGQK21tJKqA2uvBodoncicnDASFCjzNuk1Zwx4Z7M0BWb kVNA== X-Gm-Message-State: APjAAAWzBXu8ZXlewSvCQVC6ZZ3Ar9wvbfK+qPHnUEg8qeRHohpFEtD+ m2PpLOIqm8X4n7kQOSBVUpHBYJhy X-Google-Smtp-Source: APXvYqw4UvG2QfxpxlErOC18JBYhV4p5wHAymu+oqJ3TOV56Pu9bzZR+wv9jIIHxuWMpe9E0shGh+w== X-Received: by 2002:a63:511b:: with SMTP id f27mr16922684pgb.135.1560465051357; Thu, 13 Jun 2019 15:30:51 -0700 (PDT) Received: from localhost ([2620:10d:c091:500::2:9d14]) by smtp.gmail.com with ESMTPSA id g5sm785427pfm.54.2019.06.13.15.30.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 15:30:50 -0700 (PDT) From: Tejun Heo To: axboe@kernel.dk, jbacik@fb.com Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, kernel-team@fb.com, dennis@kernel.org, jack@suse.cz, Tejun Heo , stable@vger.kernel.org Subject: [PATCH 2/5] blkcg: update blkcg_print_stat() to handle larger outputs Date: Thu, 13 Jun 2019 15:30:38 -0700 Message-Id: <20190613223041.606735-3-tj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190613223041.606735-1-tj@kernel.org> References: <20190613223041.606735-1-tj@kernel.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Depending on the number of devices, blkcg stats can go over the default seqfile buf size. seqfile normally retries with a larger buffer but since the ->pd_stat() addition, blkcg_print_stat() doesn't tell seqfile that overflow has happened and the output gets printed truncated. Fix it by calling seq_commit() w/ -1 on possible overflows. Signed-off-by: Tejun Heo Fixes: 903d23f0a354 ("blk-cgroup: allow controllers to output their own stats") Cc: stable@vger.kernel.org # v4.19+ Cc: Josef Bacik --- block/blk-cgroup.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 1f7127b03490..e4715b35d42c 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -1006,8 +1006,12 @@ static int blkcg_print_stat(struct seq_file *sf, void *v) } next: if (has_stats) { - off += scnprintf(buf+off, size-off, "\n"); - seq_commit(sf, off); + if (off < size - 1) { + off += scnprintf(buf+off, size-off, "\n"); + seq_commit(sf, off); + } else { + seq_commit(sf, -1); + } } } From patchwork Thu Jun 13 22:30:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 10993707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8731D924 for ; Thu, 13 Jun 2019 22:31:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79D7026E76 for ; Thu, 13 Jun 2019 22:31:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6BEEA26E98; Thu, 13 Jun 2019 22:31:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EE8526E76 for ; Thu, 13 Jun 2019 22:31:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727166AbfFMWa4 (ORCPT ); Thu, 13 Jun 2019 18:30:56 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:47091 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725616AbfFMWaz (ORCPT ); Thu, 13 Jun 2019 18:30:55 -0400 Received: by mail-pg1-f193.google.com with SMTP id v9so290548pgr.13; Thu, 13 Jun 2019 15:30:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ATSPMY1LycdMuuen2+FGO8unSu2r280Z+V2tABkqPms=; b=jd4bLITKkEvMA8EMVkFOd9Ei4BxXWQzDCuwF62Q8ZBCnX0Mk2AgZ6mXhMpphlt5gai 9+m+18b0dpK42LncKcfIVTRr+OZXfr6RjfPx78oCyVZpJ0ZuDU6vU38kEnzVHTD/M+Td b+7Qx8HWfW4ETnpyfylVcf/RWC0pTQKEUb25HfUhhntRDuLMzbmfvLKuHhxS5dSSmLnX lpxAicyhV8QJWZ5lQU19bkCDYaxIftr5AJM2U4pitEmiZwd2HRnQrP3559QxCwNF/3UM EeDu1oZRlfb0V4Mk380crYwB2gp6EJV86S1vmrpT0DwW/PvbHGGGN9EF8dFIIp17KpDq IoMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ATSPMY1LycdMuuen2+FGO8unSu2r280Z+V2tABkqPms=; b=KTxa2AEtvxL/VtWHYOl2CsDfZ3z91dZrsB3VcE7l6EBV3b37zdnX/boZKnO18EvMUP 3nBSbXegO4lC6hoek/MlhYYMRGbrpFm+RuMyHs+vYk/fzHtrqKox5abV42kOVvsJtQ7G TwYIdrAGFAA6Mvlv9Zcg92Vggq+dKMNxK/15vbHxVbUCudGQmpGUmUomuBXyy84/q+KP 5ObDnGLC54p4Ms/DglytCZc9uUiIASSQBxl6g5RIj9eWRn8HkTn+UNWjOIyIfPer9wLd Iu6MJzJMI/NklH7GrKY23bOlfFXdoY8Y/RpsjfuY1stfbQ+FzeLU1MtQxxKpRnp25uN7 hirA== X-Gm-Message-State: APjAAAUa1LqtCj6e/sK77aTZaV5/JztOc0VA3CmWzE8cVgwLlU/mbxH8 QFz6XW8fDfDJz1hEGh8XUbbA/F9u X-Google-Smtp-Source: APXvYqyK2zbQUJL2C2z9RaburcdsweakiappBQN09wYA5twY4SnBy5L+EqyxVwbbPtSjyAmS/XOxxQ== X-Received: by 2002:a63:fc61:: with SMTP id r33mr32782404pgk.294.1560465054306; Thu, 13 Jun 2019 15:30:54 -0700 (PDT) Received: from localhost ([2620:10d:c091:500::2:9d14]) by smtp.gmail.com with ESMTPSA id f3sm740516pjo.31.2019.06.13.15.30.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 15:30:53 -0700 (PDT) From: Tejun Heo To: axboe@kernel.dk, jbacik@fb.com Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, kernel-team@fb.com, dennis@kernel.org, jack@suse.cz, Tejun Heo Subject: [PATCH 3/5] blkcg: perpcu_ref init/exit should be done from blkg_alloc/free() Date: Thu, 13 Jun 2019 15:30:39 -0700 Message-Id: <20190613223041.606735-4-tj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190613223041.606735-1-tj@kernel.org> References: <20190613223041.606735-1-tj@kernel.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP blkg alloc is performed as a separate step from the rest of blkg creation so that GFP_KERNEL allocations can be used when creating blkgs from configuration file writes because otherwise user actions may fail due to failures of opportunistic GFP_NOWAIT allocations. While making blkgs use percpu_ref, 7fcf2b033b84 ("blkcg: change blkg reference counting to use percpu_ref") incorrectly added unconditional opportunistic percpu_ref_init() to blkg_create() breaking this guarantee. This patch moves percpu_ref_init() to blkg_alloc() so makes it use @gfp_mask that blkg_alloc() is called with. Also, percpu_ref_exit() is moved to blkg_free() for consistency. Signed-off-by: Tejun Heo Fixes: 7fcf2b033b84 ("blkcg: change blkg reference counting to use percpu_ref") Cc: Dennis Zhou --- block/blk-cgroup.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index e4715b35d42c..04d286934c5e 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -79,6 +79,7 @@ static void blkg_free(struct blkcg_gq *blkg) blkg_rwstat_exit(&blkg->stat_ios); blkg_rwstat_exit(&blkg->stat_bytes); + percpu_ref_exit(&blkg->refcnt); kfree(blkg); } @@ -86,8 +87,6 @@ static void __blkg_release(struct rcu_head *rcu) { struct blkcg_gq *blkg = container_of(rcu, struct blkcg_gq, rcu_head); - percpu_ref_exit(&blkg->refcnt); - /* release the blkcg and parent blkg refs this blkg has been holding */ css_put(&blkg->blkcg->css); if (blkg->parent) @@ -132,6 +131,9 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct request_queue *q, if (!blkg) return NULL; + if (percpu_ref_init(&blkg->refcnt, blkg_release, 0, gfp_mask)) + goto err_free; + if (blkg_rwstat_init(&blkg->stat_bytes, gfp_mask) || blkg_rwstat_init(&blkg->stat_ios, gfp_mask)) goto err_free; @@ -244,11 +246,6 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg, blkg_get(blkg->parent); } - ret = percpu_ref_init(&blkg->refcnt, blkg_release, 0, - GFP_NOWAIT | __GFP_NOWARN); - if (ret) - goto err_cancel_ref; - /* invoke per-policy init */ for (i = 0; i < BLKCG_MAX_POLS; i++) { struct blkcg_policy *pol = blkcg_policy[i]; @@ -281,8 +278,6 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg, blkg_put(blkg); return ERR_PTR(ret); -err_cancel_ref: - percpu_ref_exit(&blkg->refcnt); err_put_congested: wb_congested_put(wb_congested); err_put_css: From patchwork Thu Jun 13 22:30:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 10993705 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A6D291398 for ; Thu, 13 Jun 2019 22:31:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9919226E76 for ; Thu, 13 Jun 2019 22:31:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D62B26E98; Thu, 13 Jun 2019 22:31:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4388826E76 for ; Thu, 13 Jun 2019 22:31:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727280AbfFMWbB (ORCPT ); Thu, 13 Jun 2019 18:31:01 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:40348 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725616AbfFMWbA (ORCPT ); Thu, 13 Jun 2019 18:31:00 -0400 Received: by mail-pl1-f196.google.com with SMTP id a93so121294pla.7; Thu, 13 Jun 2019 15:31:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=SW004P2kUZFhq26joJF3aZTb2ovRGvIncM6yZ2HqmDc=; b=P3TDFl+tAqBFM8496Jwc336A96WWau7dy/XVEIlZt5uRlyL8jReC6uRnXOtBTEtBGT AgxpjF5YqLRTfJFqIJ2hPPY16H6j9W5GXZbwJXWYZC/Sh74zdh6drtw+KZ2R1d461//C rXicRohQ9x8UbJGoALL5SyMAtjIpwxyx08qqFK65Q/lycd2Zm1jhzNbxWW9LCUoaI+v/ FlwButjb3nUeNM9LDeIUiQqY4JxSQ/lC4icM01OHYueUdPbMETf1KSIEdjHTJN6ITeEb N4kB5rdx3yUrPpeEj24Qo/PEu87UFBJdXtRHSJkk9LfNjVy/0cakDcpT9OgmKMBByXV3 d2kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=SW004P2kUZFhq26joJF3aZTb2ovRGvIncM6yZ2HqmDc=; b=JwO4vKoaMtC2xCr7wpSw7vt7L4H+4QUeUwZ8ZNNc2NEZTLIkj8v759zp8fe0uVtyDA wrQAPI8tYjNVuzRIMQeJPkC1bTBDSWNUvNJInVP4MNL8GSCONJ1ELR9EBtow2FTgHPGy 6Y7tOZAsRapml1Wri40/BIZv8lTnYjwqPGV1iz6iY7tTtqDOBUr5J+LLi716MtCLs7jc /wq2VAsMIhmAHPAgf2GYYhGFqtsHLF8yHolPsD/nkth5yD2lIkY+VDXarwqO+wLuxwE8 Mq+gUOnNbVpXBmeWZafIqUlePwggirpt/SVsMiA7kK1hwpAAY2L4vDkYPIvIXEjgETFI mgNA== X-Gm-Message-State: APjAAAVyRNt1bWXlfUxoczLUWkIRj5lxXw1CQX+axhh4ogz2U00Xud/H Pk4NBGl5JlKJi4Thx512xF0= X-Google-Smtp-Source: APXvYqxnao7H/n6B+XShXOd03Mre/F8ZkzymGqNfNyfhgt472pOZPOSkN6RMgpDo2hoDy4nf+DuENg== X-Received: by 2002:a17:902:9041:: with SMTP id w1mr76775412plz.132.1560465059545; Thu, 13 Jun 2019 15:30:59 -0700 (PDT) Received: from localhost ([2620:10d:c091:500::2:9d14]) by smtp.gmail.com with ESMTPSA id l8sm749127pgb.76.2019.06.13.15.30.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 15:30:59 -0700 (PDT) From: Tejun Heo To: axboe@kernel.dk, jbacik@fb.com Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, kernel-team@fb.com, dennis@kernel.org, jack@suse.cz, Tejun Heo Subject: [PATCH 4/5] blkcg: blkcg_activate_policy() should initialize ancestors first Date: Thu, 13 Jun 2019 15:30:40 -0700 Message-Id: <20190613223041.606735-5-tj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190613223041.606735-1-tj@kernel.org> References: <20190613223041.606735-1-tj@kernel.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When blkcg_activate_policy() is creating blkg_policy_data for existing blkgs, it did in the wrong order - descendants first. Fix it. None of the existing controllers seem affected by this. Signed-off-by: Tejun Heo --- block/blk-cgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 04d286934c5e..440797293235 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -1390,7 +1390,8 @@ int blkcg_activate_policy(struct request_queue *q, spin_lock_irq(&q->queue_lock); - list_for_each_entry(blkg, &q->blkg_list, q_node) { + /* blkg_list is pushed at the head, reverse walk to init parents first */ + list_for_each_entry_reverse(blkg, &q->blkg_list, q_node) { struct blkg_policy_data *pd; if (blkg->pd[pol->plid]) From patchwork Thu Jun 13 22:30:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 10993703 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E955213AD for ; Thu, 13 Jun 2019 22:31:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D921826E76 for ; Thu, 13 Jun 2019 22:31:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC00B26E98; Thu, 13 Jun 2019 22:31:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77C5226E76 for ; Thu, 13 Jun 2019 22:31:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727431AbfFMWbE (ORCPT ); Thu, 13 Jun 2019 18:31:04 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:46729 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725616AbfFMWbD (ORCPT ); Thu, 13 Jun 2019 18:31:03 -0400 Received: by mail-pl1-f194.google.com with SMTP id e5so109143pls.13; Thu, 13 Jun 2019 15:31:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=pn6FoQj1OV+3veGcFFuI7q+QIhanANL13Ea2EhicKdc=; b=tDAAA9SolkB8v/oQKfNQ7t4VItoqGQohn6jP+x/n3pBnyAHAprJ+/IyM118W4fGX3v mK2gETGo6syJWy2tjwtp5zGTHQcUm2NcynTwvV3D5GNS8+j8A66/e+JTdRIOLrqfoDFz kSal6iVATIoQUv9ur8BcCNJo1qgZ64DoA34unsHFHycJDAuQjR5HrUcSUdgRjmPd1+yK xv0HtOtmrB+qOLL/GMz35DpBkY3oDa9j0ATlZ/yTztjTNBAIn3ic6UnaMPPorS/Y0L9C +w39487+Cpx/36NaT4rcfTKgv1BqUqDJ935hfAd3tGDCwlA1nUafBET7P1CYwKAgG3kv 2EPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=pn6FoQj1OV+3veGcFFuI7q+QIhanANL13Ea2EhicKdc=; b=p8R/8ikFuF4YjGawE1FUBetZN2HLPTvT+yIPoP2KKo3ODv5iSo0cx2MZ7ojSVlecj7 x/dXczPXo1EL6w8ArsD2ii6RhJrdJMS+bFJu1z/sDH9IVI9xk52bwmjLaTpb3a2KteTu sQnYbIoUuETqko9SRvNP/6y7ng25ZTZMoUhSre5MxAG0ZLZH8Ui82ahTpwWqwnddBG57 hU3RlWHxzcYF8n6+jK+ZaL+0w29HFXlJs8CJnESenq+Y3GxF2DQsrpllxPd2OtPxqM3M GwRToS4Y8BGs23ChBnEFQVjIiNr5Hh35zZcNcegjheggh+JuqFa3qBXhCkZ/Ud0NmnlP 3kww== X-Gm-Message-State: APjAAAVtDyi5M5oNhdnZMwPLr6ERkEzLM0TYj8vCcZEY1sbTbHeL7g4G dhklTgmIVkjfxcQcSEp7cIk+S8li X-Google-Smtp-Source: APXvYqzHp7kwq8cKJu/ri6EQs4IyPKGsNOnNM+CAqSIoaRYwx42mfdrLi2XckORtM/2X666CADD3EA== X-Received: by 2002:a17:902:7591:: with SMTP id j17mr90628227pll.200.1560465062493; Thu, 13 Jun 2019 15:31:02 -0700 (PDT) Received: from localhost ([2620:10d:c091:500::2:9d14]) by smtp.gmail.com with ESMTPSA id x6sm778796pgr.36.2019.06.13.15.31.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 15:31:01 -0700 (PDT) From: Tejun Heo To: axboe@kernel.dk, jbacik@fb.com Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, kernel-team@fb.com, dennis@kernel.org, jack@suse.cz, Tejun Heo Subject: [PATCH 5/5] blkcg, writeback: dead memcgs shouldn't contribute to writeback ownership arbitration Date: Thu, 13 Jun 2019 15:30:41 -0700 Message-Id: <20190613223041.606735-6-tj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190613223041.606735-1-tj@kernel.org> References: <20190613223041.606735-1-tj@kernel.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP wbc_account_io() collects information on cgroup ownership of writeback pages to determine which cgroup should own the inode. Pages can stay associated with dead memcgs but we want to avoid attributing IOs to dead blkcgs as much as possible as the association is likely to be stale. However, currently, pages associated with dead memcgs contribute to the accounting delaying and/or confusing the arbitration. Fix it by ignoring pages associated with dead memcgs. Signed-off-by: Tejun Heo Cc: Jan Kara --- fs/fs-writeback.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index e41cbe8e81b9..9ebfb1b28430 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -715,6 +715,7 @@ void wbc_detach_inode(struct writeback_control *wbc) void wbc_account_io(struct writeback_control *wbc, struct page *page, size_t bytes) { + struct cgroup_subsys_state *css; int id; /* @@ -726,7 +727,12 @@ void wbc_account_io(struct writeback_control *wbc, struct page *page, if (!wbc->wb) return; - id = mem_cgroup_css_from_page(page)->id; + css = mem_cgroup_css_from_page(page); + /* dead cgroups shouldn't contribute to inode ownership arbitration */ + if (!(css->flags & CSS_ONLINE)) + return; + + id = css->id; if (id == wbc->wb_id) { wbc->wb_bytes += bytes;