From mboxrd@z Thu Jan 1 00:00:00 1970 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 E86B5C433F5 for ; Thu, 6 Oct 2022 10:11:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E73CB8E0002; Thu, 6 Oct 2022 06:11:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E22F38E0001; Thu, 6 Oct 2022 06:11:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D11E48E0002; Thu, 6 Oct 2022 06:11:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id BF3558E0001 for ; Thu, 6 Oct 2022 06:11:57 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 79C76402ED for ; Thu, 6 Oct 2022 10:11:57 +0000 (UTC) X-FDA: 79990108674.30.F9BF49C Received: from r3-21.sinamail.sina.com.cn (r3-21.sinamail.sina.com.cn [202.108.3.21]) by imf09.hostedemail.com (Postfix) with ESMTP id 1706B14000B for ; Thu, 6 Oct 2022 10:11:54 +0000 (UTC) Received: from unknown (HELO localhost.localdomain)([114.249.60.223]) by sina.com (172.16.97.32) with ESMTP id 633EA97A0003599D; Thu, 6 Oct 2022 18:10:04 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com X-SMAIL-MID: 504264628930 From: Hillf Danton To: Waiman Long Cc: Tejun Heo , Jens Axboe , cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Ming Lei , linux-mm@kvack.org, Andrew Morton Subject: Re: [PATCH v8 3/3] blk-cgroup: Optimize blkcg_rstat_flush() Date: Thu, 6 Oct 2022 18:11:41 +0800 Message-Id: <20221006101141.1832-1-hdanton@sina.com> In-Reply-To: <20221004151748.293388-4-longman@redhat.com> References: <20221004151748.293388-1-longman@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665051117; 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; bh=+YD2VGMMbfgJRboW8XPESOF4uNXziZf8adG9h4ToUs8=; b=SfcxwtLVsoGkZtBoCNX1OpJFApYryYcK/2varDK1Z0gKg92Cz2/njUQUhmTn2SKqA8oLQU 0ddBLUKYtPlB7V/6Z/hs/nFFowYUUmNBH9olQqB+XnG8o9r6P0JezB4fmM1sSGHkZh9w5M btB/V4ti6bQ0P+ZLOXkbGjutGSaar5k= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of hdanton@sina.com designates 202.108.3.21 as permitted sender) smtp.mailfrom=hdanton@sina.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665051117; a=rsa-sha256; cv=none; b=jyIV4bf1Nz4Z/368TZCQrtT/36HosNDgdm8vKoeRiA9//VZlZN9Ci+rdlbyJ0OLuDGSxCn u7nPD7vl96yBNbZciJ3exspaDVWNa6SUJV1vxLaniXjaFnaBRx++tX4OIcfZiSd9ADasPq uetqslvAFPvyvnQnxOk0YlK3ZTmDTG4= X-Rspamd-Queue-Id: 1706B14000B Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of hdanton@sina.com designates 202.108.3.21 as permitted sender) smtp.mailfrom=hdanton@sina.com; dmarc=none X-Rspamd-Server: rspam06 X-Rspam-User: X-Stat-Signature: w6o9azj8cqkqkc6yf4ej8k7wzqp34bzb X-HE-Tag: 1665051114-135344 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: On 4 Oct 2022 11:17:48 -0400 Waiman Long > For a system with many CPUs and block devices, the time to do > blkcg_rstat_flush() from cgroup_rstat_flush() can be rather long. It > can be especially problematic as interrupt is disabled during the flush. > It was reported that it might take seconds to complete in some extreme > cases leading to hard lockup messages. > > As it is likely that not all the percpu blkg_iostat_set's has been > updated since the last flush, those stale blkg_iostat_set's don't need > to be flushed in this case. This patch optimizes blkcg_rstat_flush() > by keeping a lockless list of recently updated blkg_iostat_set's in a > newly added percpu blkcg->lhead pointer. > > The blkg_iostat_set is added to a sentinel lockless list on the update > side in blk_cgroup_bio_start(). It is removed from the sentinel lockless > list when flushed in blkcg_rstat_flush(). Due to racing, it is possible > that blk_iostat_set's in the lockless list may have no new IO stats to > be flushed, but that is OK. So it is likely that another flag, updated when bis is added to/deleted from llist, can cut 1/3 off without raising the risk of getting your patch over complicated. > > struct blkg_iostat_set { > struct u64_stats_sync sync; > + struct llist_node lnode; > + struct blkcg_gq *blkg; + atomic_t queued; > struct blkg_iostat cur; > struct blkg_iostat last; > };