Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6414035rwb; Mon, 12 Dec 2022 01:17:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf6g5l06mKf90zJvpz46IcE2Y8cmT3+ezQUzR8WleiNfx17Vh1vGDfEhGGo4g/0BFESEOzsw X-Received: by 2002:a17:902:efc7:b0:189:812f:48a8 with SMTP id ja7-20020a170902efc700b00189812f48a8mr14860102plb.63.1670836653266; Mon, 12 Dec 2022 01:17:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670836653; cv=none; d=google.com; s=arc-20160816; b=cbIqfYyKHtFwZJ3ZdGHf5fkVgUtoZmmEGFEdM1AHnCRFaj5Z0zWbPeadLgtm4SVIkj 9a5bp1YcivuhlYSdHUZx+CIdjroLzNwVxq60mhR+v6ZIuFi6bij0y633ixClp6fk1PkG ZcuQf24ugQ930M4CVlLZaJWD8H7FETraZq4gCBjn7IwX9aedIetUk+auVtmQLSuyCIDZ taI8AEw0cN2+z4I+YTntQ4Dfn2Dg4t1vPZJV2HWQbepLG2aTJHXwYckbyfRLK5jgx+UH szYMh5Zpx14Ba8yGE0PKY/frxl1rgm4Gf2BGckpS+DMBtfhDSMIctrqVmylItKMXDnCE B0Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pUS0fRVuVl28efMmBL1cfrJsUvoRpvkefUc506NhvMs=; b=TADVGxzVURanoNXIMGRV9DBoLF2ekpewPCFfXwVU6cvM5GqRRxRBqF9OQrVNRfTUZI 6FhvGBB4orGiboI8uANl1D/9lT7PtHHRtU6NjO4wB/Av+PY9J3oN/UOdEwOnYyYWXnvV G1XlA1xOOLhVvmHSnknLkGrF1H4QW+HpCXUcs3KKMsDoEh+znNbOnRdmeDSe9b53PZsd Gc9WzH2diQvitbkj7gxgX3e6SSTj7cCnqoezTcTWOtEaKocBUgpsyRKZlavQgrT/nAZx Hgsi/Bw/XzJsKMBBTrFPM8M0SwqvJMHecnsRsRUd1Y0qmjHw5MldmgR5sXunOuCYN17i Cw6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=C3JZ2MLM; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a170902f70b00b00188f663e2d7si9050280plo.421.2022.12.12.01.17.22; Mon, 12 Dec 2022 01:17:33 -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=@infradead.org header.s=bombadil.20210309 header.b=C3JZ2MLM; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231445AbiLLIsB (ORCPT + 75 others); Mon, 12 Dec 2022 03:48:01 -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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham 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 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