From patchwork Sun Dec 11 22:20:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 13070673 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97D7EC4167B for ; Sun, 11 Dec 2022 22:21:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B4CA48E0006; Sun, 11 Dec 2022 17:21:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AFF098E0002; Sun, 11 Dec 2022 17:21:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C8C78E0006; Sun, 11 Dec 2022 17:21:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6C62D8E0002 for ; Sun, 11 Dec 2022 17:21:16 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4BD53160969 for ; Sun, 11 Dec 2022 22:21:16 +0000 (UTC) X-FDA: 80231447352.13.968B092 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id C59D0160016 for ; Sun, 11 Dec 2022 22:21:14 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ASonaym8; spf=pass (imf08.hostedemail.com: domain of longman@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670797274; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=s3VQJPU/3HC+t8N1wzyewiUON5nIdBJkilNRlkYPV+o=; b=mNDNcHEP1hud70enKK3tvFaRfxk9ZuU6XLq/sbt8Se06463FUiS31u4VM4QpboFdsx227n Tp/xIcHifI3jjDdIVUaYJCc4F8WRBc/gbFGDXnVWkV7VPef0Td0DpSmdgi03s12P4JIDEP 2vonBQUwFK8QTivCWYzbto9PKcZ1LlU= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ASonaym8; spf=pass (imf08.hostedemail.com: domain of longman@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670797274; a=rsa-sha256; cv=none; b=xouMooYLrMVYxRUy+cP5upQvBqqxye3gmQmUEyJg/CqfxdDWpEUA+U5LzBiO9NgoCXzYNO 5scnwD2zAuu4eVKFeVzhq+qhr612x4hrABU41eZFg8jY3X+fR5M2mWeVLR8fd3jUViwgvx 2dY8fesLhoXfC+GJ0n+MJZFHCyvj+yo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670797274; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s3VQJPU/3HC+t8N1wzyewiUON5nIdBJkilNRlkYPV+o=; b=ASonaym88z1O3xWD+IMdxPvAG73bznBKHsiGXT1guUu9vqYUAF/psi1bNgq20/otfAOqVH ELggW5NCDzZKV/+vkwCggctSKcc7jp13ipCisSf85T82WwSmd80t6lmoyQloScPVuhbQ6y 7I+SqpsxkfWcFQZUCW+Fd9VYDJQOyiw= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-624-uncOj-fSOjS8G7ZSnT3xYg-1; Sun, 11 Dec 2022 17:21:08 -0500 X-MC-Unique: uncOj-fSOjS8G7ZSnT3xYg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 28D7F1C05138; Sun, 11 Dec 2022 22:21:08 +0000 (UTC) Received: from llong.com (unknown [10.22.16.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id A25191121331; Sun, 11 Dec 2022 22:21:07 +0000 (UTC) From: Waiman Long To: Jens Axboe , Tejun Heo , Josef Bacik , Zefan Li , Johannes Weiner , Andrew Morton Cc: cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, =?utf-8?q?Michal_Koutn?= =?utf-8?q?=C3=BD?= , "Dennis Zhou (Facebook)" , Waiman Long Subject: [PATCH-block v2 2/3] blk-cgroup: Don't flush a blkg if destroyed Date: Sun, 11 Dec 2022 17:20:57 -0500 Message-Id: <20221211222058.2946830-3-longman@redhat.com> In-Reply-To: <20221211222058.2946830-1-longman@redhat.com> References: <20221211222058.2946830-1-longman@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspamd-Queue-Id: C59D0160016 X-Stat-Signature: tkt8ebfnc1yk88d8rxb93wyadxw4m4oj X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1670797274-825514 X-HE-Meta: U2FsdGVkX19bbqi+P8e4HraIsDxNffG00syfX3RSKThsUqeJ9jnV8m7wMheBT+7uTumJqNDC7674GfGHiqODgx9TFhSCrbuU0/Fz1+kRnmd8Ywu9d1UcZUNBveyOoG/LkVllaEV8GcbPAJzg+g4b6aMdbFUqCFJrRRIopqwUqxxwJU23AViXrjeuyOzGNre4vmvsW3qRWLXF6pGT7+g52ivraOgNdLFvYjfulDSUNuQlMvwQpcePbm8k5Wmro0HPnozAvhmBNO+CclJMVBjRk9xf4CJiKqcALuRoPmUL0AnU4V9A5kAIiVs5zmBDtcNYavh1/GHVTnJqdjAbfGLCrmYUzv+FFjHc7uzqVo8tZjDG0KZIsXxsU33lLHTNwwfqHj+p3aphhqEqnrIj64CuJ2swEzSOAmJXIldEccUqQfp1Vzo8qa+N+pIuBHihdJ6T7Sow7xnWTuzGlqXG4rJHz/HlYm00G8mnS3kp3Iigjh0yfkwKoSlrsMB0/9tlAuKa62V7HQTehrGVT0G1T8peSVh67K+Dmu8Ut0R3nF3vTeUrRHXqJ2APICi06G3RFweYoWcbGhh1KZ9Md7s+3r7yUrBreQJTIk+1oL8pFfsH7dflPM1WwN0zSstLKPvskTil9mMQpT3SEr8lZwZPZgwf5N64vNZzgQY1fGG179lLPok3nC6C3fydK+cTfedXekOFhpF2RmRoNf8acl4bhackZuOLdAcYmjCO51qXjZXcQU8hIrJ6F0gOiztEkERPINGBHTvIpkcsFII4LnBHpRASLl3AejUfj/Z11SnsC3s5k4b+tmTUeY2uR1bmjFPRzm1kbIDBfNqPd7QS4dPJYbNqkH3T2eenqmtAHO29/t5hrElRYIjDUO0vzqhjeyPR6nJU+ob0r7xNAqi2Gzt6dm4BXVdBk3TN1iIi X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Before commit 3b8cc6298724 ("blk-cgroup: Optimize blkcg_rstat_flush()"), blkg's stats is only flushed if they are online. In addition, the stat flushing of blkgs in blkcg_rstat_flush() includes propagating the rstat data to its parent. However, if a blkg has been destroyed (offline), the validity of its parent may be questionable. For safety, revert back to the old behavior by ignoring offline blkg's. Signed-off-by: Waiman Long --- block/blk-cgroup.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 21cc88349f21..c466aef0d467 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -885,6 +885,12 @@ static void blkcg_rstat_flush(struct cgroup_subsys_state *css, int cpu) WRITE_ONCE(bisc->lqueued, false); + /* Don't flush its stats if blkg is offline */ + if (unlikely(!blkg->online)) { + percpu_ref_put(&blkg->refcnt); + continue; + } + /* fetch the current per-cpu values */ do { seq = u64_stats_fetch_begin(&bisc->sync);