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 6F491C433FE for ; Thu, 6 Oct 2022 21:34:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D7BE46B0072; Thu, 6 Oct 2022 17:34:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D2B836B0073; Thu, 6 Oct 2022 17:34:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C19A28E0001; Thu, 6 Oct 2022 17:34:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id AFC166B0072 for ; Thu, 6 Oct 2022 17:34:36 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7408A1A11FE for ; Thu, 6 Oct 2022 21:34:36 +0000 (UTC) X-FDA: 79991828952.21.580A238 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 873B9180022 for ; Thu, 6 Oct 2022 21:34:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665092074; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=z5KDkZsZZPUp3zvan69x4fPFamZUOxTgDM1WYdBR6n4=; b=Wvczv2oH7fLN19KGQNqGoXZdg+dSD1fJ+uzVRVmzFkiZE5e6+9orU7G/o3YcGLH+87M2G3 TxPBxT66cVEe+G9lw9FQrqZnc6vq4N7va1vYywJi6Qt4S14I2VJut6huOXUutKANdrhw6t frm6W4/2MLNu8/N42S3YT5J+afzo+Zw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-90-2nL_g01_N-q1EyxGH75tzQ-1; Thu, 06 Oct 2022 17:34:32 -0400 X-MC-Unique: 2nL_g01_N-q1EyxGH75tzQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0EFFD85A59D; Thu, 6 Oct 2022 21:34:32 +0000 (UTC) Received: from [10.22.8.198] (unknown [10.22.8.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id 800ED404705D; Thu, 6 Oct 2022 21:34:30 +0000 (UTC) Message-ID: <5125cfc1-7710-9145-bf42-1826a30514e9@redhat.com> Date: Thu, 6 Oct 2022 17:34:30 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH v8 3/3] blk-cgroup: Optimize blkcg_rstat_flush() Content-Language: en-US To: Hillf Danton 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 References: <20221004151748.293388-1-longman@redhat.com> <20221006101141.1832-1-hdanton@sina.com> From: Waiman Long In-Reply-To: <20221006101141.1832-1-hdanton@sina.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665092076; a=rsa-sha256; cv=none; b=F4Je6d+4g8aObK3vNd/U665Cb305ieEWLbXxoC9urmk8kuFW5dLJeg0Idg6ouJQb1MnQp1 r8HUx9LgBskxK0L/dR1VnsJNCa507cBc53GOrrbToPVliy5Inc8YFp8lX7GjHDsbOCClE0 0Obj1uo0S2o8g5B7EppITjIqCSi6cBY= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wvczv2oH; spf=pass (imf24.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=1665092076; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=z5KDkZsZZPUp3zvan69x4fPFamZUOxTgDM1WYdBR6n4=; b=N7r41eNM7Sie2ssNqwq8WAK/V6WML8PFSVb0wXLhNbvQ+suAI2nbixBvO5AHIw+gKz1GRk iBUffY6IjEDllD/rR7CMzKy/tMlS5IMNK6D1NxU5wd5XopwVGe+8VB/OyCBMQDC4P9MTQE TLL8BSVqcM/9M9Ir8wMIskW8Yac1YoM= X-Rspamd-Queue-Id: 873B9180022 X-Rspam-User: Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wvczv2oH; spf=pass (imf24.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 X-Stat-Signature: ebb8b4r95ytnkbpad5g61gkjiwxgd88q X-Rspamd-Server: rspam04 X-HE-Tag: 1665092075-17063 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 10/6/22 06:11, Hillf Danton wrote: > 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; >> }; Yes, by introducing a flag to record the lockless list state, it is possible to just use the current llist implementation. Maybe I can rework it for now without the sentinel variant and post a separate llist patch for that later on. Cheers, Longman