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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8032DC4332F for ; Mon, 12 Dec 2022 08:48:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231415AbiLLIsA (ORCPT ); Mon, 12 Dec 2022 03:48:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231213AbiLLIr7 (ORCPT ); Mon, 12 Dec 2022 03:47:59 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3253B85; Mon, 12 Dec 2022 00:47:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=pUS0fRVuVl28efMmBL1cfrJsUvoRpvkefUc506NhvMs=; b=C3JZ2MLMHV9lxb2dpe3XDzlN9m UtvdwvY9w6C7R1gTQTR87vhICvE8PlmEhX889b/IHQN4NVCbIFZgdov+9GfE2XOslvUcpBrusCrpQ M3mQdPNaiKDPoYeUD2Ye4ClUOPiNsemr6TmMNZeLq92zFE2zNulIjC49Wdnb25YQtKEjVraqfVnzz 5mErGIlhBGmw6zoPts2sPGEAUGp4ynvM7h5MorgNEOILbbvcjuxVBd3/biQY6CnhkAPxewO6ohptw p0nnRdi6aegVspDWUwK67iBdYVm+D4SbSimbEDZ/wPoz6vEXiPFI/8hyMMDkCLOe6IasufH4uDb6j s6RWk0oQ==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4eTd-00AXPQ-Dx; Mon, 12 Dec 2022 08:47:57 +0000 Date: Mon, 12 Dec 2022 00:47:57 -0800 From: Christoph Hellwig To: Tejun Heo Cc: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, darklight2357@icloud.com, Josef Bacik , Linus Torvalds , cgroups@vger.kernel.org Subject: Re: [PATCH 1/2 block/for-6.2] blk-iolatency: Fix memory leak on add_disk() failures Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On Sat, Dec 10, 2022 at 08:33:10AM -1000, Tejun Heo wrote: > When a gendisk is successfully initialized but add_disk() fails such as when > a loop device has invalid number of minor device numbers specified, > blkcg_init_disk() is called during init and then blkcg_exit_disk() during > error handling. Unfortunately, iolatency gets initialized in the former but > doesn't get cleaned up in the latter. > > This is because, in non-error cases, the cleanup is performed by > del_gendisk() calling rq_qos_exit(), the assumption being that rq_qos > policies, iolatency being one of them, can only be activated once the disk > is fully registered and visible. That assumption is true for wbt and iocost, > but not so for iolatency as it gets initialized before add_disk() is called. > > It is desirable to lazy-init rq_qos policies because they are optional > features and add to hot path overhead once initialized - each IO has to walk > all the registered rq_qos policies. So, we want to switch iolatency to lazy > init too. However, that's a bigger change. As a fix for the immediate > problem, let's just add an extra call to rq_qos_exit() in blkcg_exit_disk(). > This is safe because duplicate calls to rq_qos_exit() become noop's. > > Signed-off-by: Tejun Heo > Reported-by: darklight2357@icloud.com Looks good: Reviewed-by: Christoph Hellwig