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 B1D1EC00145 for ; Tue, 13 Dec 2022 00:19:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F22D78E0003; Mon, 12 Dec 2022 19:19:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ED2FA8E0002; Mon, 12 Dec 2022 19:19:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D73658E0003; Mon, 12 Dec 2022 19:19:17 -0500 (EST) 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 C35888E0002 for ; Mon, 12 Dec 2022 19:19:17 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 961B3C0C7A for ; Tue, 13 Dec 2022 00:19:17 +0000 (UTC) X-FDA: 80235373554.30.E163465 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 BF9D0160002 for ; Tue, 13 Dec 2022 00:19:15 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Tu1dO6it; 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=1670890756; 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=gI+6HXmXS35AZXXUiiiCAtaTnfFzC0toG7xNuA9nRrA=; b=IiGznTkMeduwDJ7aj+RXh/qNtI1BoNQg8I2CssGPiBkwb/rbPST69SQZcSD11LdcKPMkhD shk2xf9stqGeGEV/xL6RxGyoYXxlimrF8Q2r85wICtjnwRZXpMaP4VJPdTb51i8a7/1ac5 7LBFTj0HR+tjJawDr9iFAi5/VwDaDBs= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Tu1dO6it; 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=1670890756; a=rsa-sha256; cv=none; b=sELzOOKDCYUF4JZgGLvVEfCdnMD9tzwqPWcV4o0UvLORE+nQsPU66ILPL+Ox3082W78Pyn 9Sq2Vep29Dj8BIKYpOrtHiy3t6r8kIlfryBeuJ7nkWHuKdd2AKjh8OmC8teSPVb+LiRrse CO6inOJX5j1UGo3xUBLM+RnLJtq9IQ4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670890755; 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=gI+6HXmXS35AZXXUiiiCAtaTnfFzC0toG7xNuA9nRrA=; b=Tu1dO6itKgbnEFFelRlVXxzPTq6mFmu4Rkftw5zqg0dbH/wmNWUDRwKJuZ3pr+/bmC0Ntt 2VeIX0t8BbBPXKo3i3Q+qQ2AuHxBpwaQz2B0X1yZjeXEW/z2448yAmdVBxvlRuLl3la4r6 gTHD/he75AoLPDslFvC6u7WYNVFl6pw= 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-244-vE5xQ8OyP5a4p8qoy9ut0A-1; Mon, 12 Dec 2022 19:19:11 -0500 X-MC-Unique: vE5xQ8OyP5a4p8qoy9ut0A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A4248185A78B; Tue, 13 Dec 2022 00:19:10 +0000 (UTC) Received: from [10.22.11.98] (unknown [10.22.11.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0B6414152F4; Tue, 13 Dec 2022 00:19:09 +0000 (UTC) Message-ID: <81f14365-a153-44aa-8ee7-4910f6988d7c@redhat.com> Date: Mon, 12 Dec 2022 19:19:05 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH-block v2 3/3] blk-cgroup: Flush stats at blkgs destruction path Content-Language: en-US To: Tejun Heo Cc: Jens Axboe , Josef Bacik , Zefan Li , Johannes Weiner , Andrew Morton , cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, =?UTF-8?Q?Michal_Koutn=c3=bd?= , "Dennis Zhou (Facebook)" References: <20221211222058.2946830-1-longman@redhat.com> <20221211222058.2946830-4-longman@redhat.com> From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: BF9D0160002 X-Rspam-User: X-Stat-Signature: d7i73kkkqfy7hqm8tyxq8zwgsite9sbh X-HE-Tag: 1670890755-637887 X-HE-Meta: U2FsdGVkX18jaZbeCv48btz3rYAOUhFmh8NzhngBItbnR61TjWkzXAimDNY37lKPqWrzCp5SfDZfIL82+92gCnvkl6AQBxg2LtgMzJMGQ4AqMPIap0tJx7KKB4gUaE5fsafh2GwwOi8z4AxI9NsH7afuoM4VShpFBHJrcjbTplJlMu61hRCbg9VWTjIzRnbVfXWNdXcQth27sU5Bp+q+O6vDiX5DphE18lV5/1SqJWisCmWsZrVHpW8cYbAa7fVaKueovJwbYY1y7gJJsrVEPHmcwtS3Ph+kms0S4um68wv8ir1cMdFPDd6CqthAmJ90hHrMacUHUdM4KKx3Wv1Vhcz6ue9KIyjt3+AiFnysxuuflRFZjaf6aJv6ZRMtzptJKvp1eQlizRkHICP2axPjdl6kQQDFvRlNMMsG2+bKUvmrxXSbT1809d+LInl7pHvtls/B37yyoM2PKFJVNYTiJRv2ie3trNEYbNssZrN3BkxLcXP5F8Yy4cr9Lo4ZgTGbkprrMqm1gjPiADMmK2BwzOAlXXOgktlPNkpvOr/g4u3xX2ZVyNgJYSNlL/PGMoPTy2Ss+ZwqK3n+AqJOVdjgZXxem/P9ayl0zy1fH/YNnL1MkSrdRCdlY/g18prz+kUbBGKNvq1SVUT9S77RWZX3TcqGhhb7DYxCjDCNkH8MrdEr3TkxJtQ90O5xoHlVhO/aBV/vL1+6OXFqF4n3aZRTJAAoHemzhkSGILG5HaLSJZawa6tX64DvGk68uBNDC9LImgDOQcxeejAtvF8ohbG13y/Fqxz6pz7rWX309i7mOh7+ejLKNeS/kJrXz2GWLuE+8YHz9979ZHtyxSOYfLh8e6D5Rohjw27pvqKDG74Hh5713Pupih6NXTGMPk99s/pD 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 12/12/22 17:24, Tejun Heo wrote: > On Sun, Dec 11, 2022 at 05:20:58PM -0500, Waiman Long wrote: >> As noted by Michal, the blkg_iostat_set's in the lockless list >> hold reference to blkg's to protect against their removal. Those >> blkg's hold reference to blkcg. When a cgroup is being destroyed, >> cgroup_rstat_flush() is only called at css_release_work_fn() which is >> called when the blkcg reference count reaches 0. This circular dependency >> will prevent blkcg from being freed until some other events cause >> cgroup_rstat_flush() to be called to flush out the pending blkcg stats. >> >> To prevent this delayed blkcg removal, add a new cgroup_rstat_css_flush() >> function to flush stats for a given css and cpu and call it at the blkgs >> destruction path, blkcg_destroy_blkgs(), whenever there are still some >> pending stats to be flushed. This will ensure that blkcg reference >> count can reach 0 ASAP. >> >> Signed-off-by: Waiman Long > Acked-by: Tejun Heo > > But a nit below > >> + /* >> + * Flush all the non-empty percpu lockless lists. >> + */ > Can you please explain the deadlock that's being avoided in the above > comment? ie. it should say why this flush is necessary. Sure. I will expand the comment to elaborate a bit more. Cheers, Longman > >> + for_each_possible_cpu(cpu) { >> + struct llist_head *lhead = per_cpu_ptr(blkcg->lhead, cpu); >> + >> + if (!llist_empty(lhead)) >> + cgroup_rstat_css_cpu_flush(&blkcg->css, cpu); >> + }