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 9FB2AC32771 for ; Wed, 17 Aug 2022 05:36:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE4FB6B0073; Wed, 17 Aug 2022 01:36:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B6D678D0001; Wed, 17 Aug 2022 01:36:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A0D6F6B0075; Wed, 17 Aug 2022 01:36:33 -0400 (EDT) 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 8CAF46B0073 for ; Wed, 17 Aug 2022 01:36:33 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 596E8AB8C6 for ; Wed, 17 Aug 2022 05:36:33 +0000 (UTC) X-FDA: 79807974666.21.3FA96B3 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by imf26.hostedemail.com (Postfix) with ESMTP id A9CF71401D9 for ; Wed, 17 Aug 2022 05:36:32 +0000 (UTC) Received: by verein.lst.de (Postfix, from userid 2407) id 8176D68AA6; Wed, 17 Aug 2022 07:36:28 +0200 (CEST) Date: Wed, 17 Aug 2022 07:36:28 +0200 From: Christoph Hellwig To: Robin Murphy Cc: Marek Szyprowski , Liu Song , akpm@linux-foundation.org, "linux-arm-kernel@lists.infradead.org" , Christoph Hellwig , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "iommu@lists.linux.dev" Subject: Re: [PATCH v2] mm/dmapool.c: avoid duplicate memset within dma_pool_alloc Message-ID: <20220817053628.GA28747@lst.de> References: <1658125690-76930-1-git-send-email-liusong@linux.alibaba.com> <1dbe63ff-5575-745b-653a-a992ae53e1aa@samsung.com> <413d8666-7a82-efd7-6716-13658016ca10@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <413d8666-7a82-efd7-6716-13658016ca10@arm.com> User-Agent: Mutt/1.5.17 (2007-11-01) ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=none (imf26.hostedemail.com: domain of hch@lst.de has no SPF policy when checking 213.95.11.211) smtp.mailfrom=hch@lst.de; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660714593; a=rsa-sha256; cv=none; b=HjzHWKatdeMk5BMO6Cil9aaNRsSZyiRH7/9G2YGZOcPZ7r+sEU5Mp8pkvJRISiCqGMNgP3 XWbmBOY00qH0p+PigPfdUIrn3Bro4Qz1rx2WFbniKRyJN8ROI+F6lNCBCo9XK614RE0uJW 4MVZCLFPwlXVLXv2mmVGlxIvX7p4dQM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660714593; 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: in-reply-to:in-reply-to:references:references; bh=5nN1QgeV7mDwoWM0UkFxSiI4FDYB9x74123ki1nQwHk=; b=1h2l+H2V/VWqvIpMBmOOOqRAdZeXXBRo2WYjlWhYstsoZ9JPZ0S99aVqm5irx3R0EMA0dk 1kS91N3hOAjiu2i/v05UkcTZlDWuF6jFyGVLyR8IPH9VYjnH9tcu004DZ7HldGF38li0x6 xv+u76Rh1djNgRhNretlYbA1cmThwLA= Authentication-Results: imf26.hostedemail.com; dkim=none; spf=none (imf26.hostedemail.com: domain of hch@lst.de has no SPF policy when checking 213.95.11.211) smtp.mailfrom=hch@lst.de; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: tc9pwuonxkqkneuhqhfa4jazghyw1nkw X-Rspamd-Queue-Id: A9CF71401D9 X-HE-Tag: 1660714592-71369 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: >>> A helper function "use_dev_coherent_memory" is introduced here to >>> determine whether the memory is allocated by "dma_alloc_from_dev_coherent". >>> >>> And use "get_dma_ops" to determine whether the memory is allocated by >>> "dma_direct_alloc". WTF? get_dma_ops is privat to the DMA API layer, and dmapool has no business even using that. Even independent of this particular case, consumers of an API never have any business looking at the implementation of the API, that is the whole point of the abstraction. > It's not even that, the change here is just obviously broken, since it ends > up entirely ignoring want_init_on_alloc() for devices using dma-direct. > Sure, the memory backing a dma_page is zeroed *once* by its initial > dma-coherent allocation, but who says we're not not reallocating pool > entries from an existing dma_page? And yes, in addition to that it also is completely broken.