Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7557945rwb; Mon, 12 Dec 2022 16:48:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf5xK5FwQhRSqT3isdA9VMTk4khCNpQ6bBsovQEYgAGPaKypD+UEnnQ9Rr+HJIcervqHi4jR X-Received: by 2002:a17:906:8c4:b0:7b1:316c:38f8 with SMTP id o4-20020a17090608c400b007b1316c38f8mr20605681eje.42.1670892505802; Mon, 12 Dec 2022 16:48:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670892505; cv=none; d=google.com; s=arc-20160816; b=vGt/aZZQgA/cLbw+bJ/jT6wRS4rcXgZRtQ/0jhkpxW+dGyC0C5bZNcAkn4ny7fySy7 IZG7Kkbo+S3xZU021csdz8axfmdU+dNjSuDmcBW5P/2aHXtzg+9516A2YMXbQ90nJdsq 1tUm/f+mqxcoAI4x368sK0LBJtkWwfBgAM0UopMSyHJbQV7oaMnOQycmf5kZ9+I9Xsej YgAyco8ppV4FL4uPF26NdoN+/k3HlOKbrCOlNaypEQqO/4EJJnNsz54wZnyxMKNkv4o9 LLhX46X75YOyILGH9SEc22lrzMltIePz9r+OrSS7gplnrnevZ3OvoVe87ucylYjaj5YS 8rig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=gI+6HXmXS35AZXXUiiiCAtaTnfFzC0toG7xNuA9nRrA=; b=oOJyLgtHqouDZ2+NOik4xpsPLdTz1FlMxotunMGHrOUcapfzEc4vxx323Kd0W/+2wB BxMaW10usOXKu3Mw1lyDPuREX8k/MUc5fib+FPEuyxodXpZZ4h9lb1AaTUhQhflDhE3o o/CZ/GgKAjEFalTySq9D39ziKIIc/jye1seQm2EM514tNtSDLETIPAUxJun3iXbyOSWI J3k3kjEl1c9wbw2whC2KNHtgkL5dz3ORxvvDLqgUWZaH0lM6U39x1KMJqwILqvBSZn8+ EQw8LqGeunhXAoCI55mr4EkwlpoqpaW9zufVClsZa1R4KtdoXE4lZwRqpTX3awPXzAr/ Y9wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ATIOjkr9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qb11-20020a1709077e8b00b007c0a8ff3384si6759018ejc.763.2022.12.12.16.48.08; Mon, 12 Dec 2022 16:48:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ATIOjkr9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234089AbiLMAWy (ORCPT + 74 others); Mon, 12 Dec 2022 19:22:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234193AbiLMAW2 (ORCPT ); Mon, 12 Dec 2022 19:22:28 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B36B91EC4F for ; Mon, 12 Dec 2022 16:20:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670890758; 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=ATIOjkr9MCaTNB0eEFnwbOr/qS9G3kpwPaDL5450i5DGGgtsKhiytihZ2x5El3NeP1szpv G/0/ZhbWbBzvBTuSAuz8Z9uIqAEqxYd8VhYA0S+P7LlU/qz2AmxJh+RUtEgpaz1W0nsIa1 7BBDrrhsgXkvqUi/E/OsgkcQTkJTp2I= 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); >> + }