Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp924533rwj; Fri, 23 Dec 2022 09:51:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXuPMKbOa9vOvVqAY/r9zLpJCyk7dExj5vGM2yX1ikKajRfodfrVlr5hjRKXtVqZqI27mPBP X-Received: by 2002:a17:907:c28f:b0:7c1:eb:b2a7 with SMTP id tk15-20020a170907c28f00b007c100ebb2a7mr11950055ejc.13.1671817902486; Fri, 23 Dec 2022 09:51:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671817902; cv=none; d=google.com; s=arc-20160816; b=Cr1XlM60y9zG7lpe5q+Mo2mp1sDVBmwo9tcotpIRA5FSCtfvA4NFhEU7nDScynCxj9 wOOnrFxXXFgdmoISMSzsuS0zQGsvN+2XzzXHRl+12L0Bm3SgfAGHx8KHm3EuR0/gywjL VJjiJ+ouMstE84v+lVyi2z4uoJLb072PIQTc0eFZ/DCNvhX9Qoxs6rhLD0BVpafMpTUh B9HE3jzEnk7jICvzEWMpQAn8euLxkfQ0nQwuI2TNRtck+UnUtY3hF82dI1ei/SLIqcKl x2BIJb6/1aI+lwQihyM6kfB667RYUQJfq6v9m7FOGFJdZikmu/p/+5aOkt9WfZWfTGwF XHCw== 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=EYSG91C6cZ+G8ROzIZso2hzCSRMc6hmS4xPa9jppU4k=; b=voXTJv9Rs1X6A6xTn/izSNG8IwMpFyZaEdWu/nOyMhg66QA2em9BWSavtceFQfxJVi T4VclXRVP6qxcYs8/HlTesqoyrZc+dAw7FbWZFBhrWUxphioTt/WHv3eA1dYYFqGC0K+ W9Rw8wEi5uJ5yK2exSg11l6uTugLb2I5z5mniCwmji6djvDiQh6dG3IViuIgGdqdgASN YlqZbTxcfF+++mhhYrURdD44uQRjRqmW04riuVkaQ02z06nDpx2plRIG3LMkiTZHufGB lBPPj1beORFMo13/ZEh9U11y9X1Wzn15bYaFRlHJJE8RAm/F9bDWS/HgciKCIflaxXr/ 0RAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=PXlBDbqc; 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 dd8-20020a1709069b8800b007ae74740fa4si3260719ejc.275.2022.12.23.09.51.27; Fri, 23 Dec 2022 09:51:42 -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=PXlBDbqc; 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 S231400AbiLWQjB (ORCPT + 65 others); Fri, 23 Dec 2022 11:39:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230155AbiLWQi7 (ORCPT ); Fri, 23 Dec 2022 11:38:59 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F1B92DDA for ; Fri, 23 Dec 2022 08:38: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=EYSG91C6cZ+G8ROzIZso2hzCSRMc6hmS4xPa9jppU4k=; b=PXlBDbqcgNeVERJWHENKzVYTpT 8wvXWzu+aOiB+QmLpVTPDevj/3xxqcqU8OD+1h2YcaKpN6QpPxJ0gxGH3n/YhBqNR4yMw4IzCdET5 pM5NstCxnV53JAcm1JpTkJxBoxnMcjl0hT1RGCRX69JxCOb3oCizk6jEfZBn9ZQgIL9LabNbU66Dc U+3r/gnOwEdOEtgNllzz8yOkNzEGkwaRtr5/qTpT6TL88k/3py2pwf/6pv61rkHcnVZoPxN/iLQPW iPe2UA3nYv8ysDeznb2UCqmdf+AKQ+bw6fkfE2eeZBOdGnRR+WAdil2BI2jy1AsD+8zTAIcjhC0PZ o1mUMoMw==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8l4R-00A2qS-Ob; Fri, 23 Dec 2022 16:38:55 +0000 Date: Fri, 23 Dec 2022 08:38:55 -0800 From: Christoph Hellwig To: Keith Busch Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Matthew Wilcox , Tony Battersby , Kernel Team , Keith Busch Subject: Re: [PATCHv2 09/11] dmapool: simplify freeing Message-ID: References: <20221216201625.2362737-1-kbusch@meta.com> <20221216201625.2362737-10-kbusch@meta.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221216201625.2362737-10-kbusch@meta.com> 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 > @@ -280,14 +268,14 @@ void dma_pool_destroy(struct dma_pool *pool) > mutex_unlock(&pools_reg_lock); > > list_for_each_entry_safe(page, tmp, &pool->page_list, page_list) { > + if (!is_page_busy(page)) > + dma_free_coherent(pool->dev, pool->allocation, > + page->vaddr, page->dma); > + else > dev_err(pool->dev, "%s %s, %p busy\n", __func__, > pool->name, page->vaddr); > + list_del(&page->page_list); > + kfree(page); Hmm. The is_page_busy case is really a should not happen case. What is the benefit of skipping the dma_free_coherent and leaking memory here, vs letting KASAN and friends see the free and possibly help with debugging? In other words, why is this not: WARN_ON_ONCE(is_page_busy(page)); dma_free_coherent(pool->dev, pool->allocation, page->vaddr, page->dma); ... > page->in_use--; > *(int *)vaddr = page->offset; > page->offset = offset; > - /* > - * Resist a temptation to do > - * if (!is_page_busy(page)) pool_free_page(pool, page); > - * Better have a few empty pages hang around. > - */ This doesn't look related to the rest, or am I missing something?