Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp4424459rwb; Tue, 16 Aug 2022 22:41:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR5LMRLm22nq8/DR6PunWZpImZv/fKFp+OeYHjHxHvTYolx5n1abpRNR/JPlipyhBFoK9oPy X-Received: by 2002:a05:6402:1777:b0:43d:85da:2fac with SMTP id da23-20020a056402177700b0043d85da2facmr21823270edb.32.1660714886527; Tue, 16 Aug 2022 22:41:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660714886; cv=none; d=google.com; s=arc-20160816; b=KNvHItSX+TSArkXxEGXyqudNJblks4VGfFI5Pfesx0Z2qkW0/UktQCBmRT4EQ49Uwe 83US6gAhDp5GiylrShFHsK8PrFggr6yOyMct2mjRMsx7BEfukM6hMmVhGTQ9pwqBP+ki SlNAjY/Z0oESsE3NBqMWnDsvtamdTdw3Og6MF7A8paXxfGjyVaJup2CceFAZ12yNigN1 tGg+pzvPIq3BxbnUywJpRcVZJHJpIcXrSM+cTVJwBr6I/szazT2d/5cCLf8xKw0id9rP q2TCSBNMK3TCsLAyPlwqIUGlZ1ihsbs7I6goMeFIobAC3CginE1IRkjSV08dCh8AnQjs dm5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=5nN1QgeV7mDwoWM0UkFxSiI4FDYB9x74123ki1nQwHk=; b=tgCS8ShkhTZ9kiH7GIcG0MyfBkfRq+ogb5/5HVkyYzuUkugrg3oLBRe5P0NS485YiJ aVBOngCqWhbpsMtr2e7OyxYmoASV8zl43ojhYiFzqsQEbZGJnPyoxD1jCtCfzR3MJboc UUn+P7Bf71C6JHkBqFqwGrytFEa+Klw0nFkIvmZ2gFTnkrzN12bKafpaYzsctqbbaqMx XVvQeTdmUufkYlnz1pdlhmSBOiSpROqhCW7nriPPbKLks0+C/ArY9FNxBCal0n2r2hFc 1f1keFDrnbD2zOfmBIw0SgbMLWlbewbDtbu4C/Dyut6ggKFzy+PrxtkK9/LUSPTMLpk5 /Jag== ARC-Authentication-Results: i=1; mx.google.com; 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 h4-20020a056402280400b0043d100bcf3bsi14082297ede.538.2022.08.16.22.41.00; Tue, 16 Aug 2022 22:41:26 -0700 (PDT) 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; 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 S238436AbiHQFgt (ORCPT + 99 others); Wed, 17 Aug 2022 01:36:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238334AbiHQFgd (ORCPT ); Wed, 17 Aug 2022 01:36:33 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92C3D65560 for ; Tue, 16 Aug 2022 22:36:32 -0700 (PDT) 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) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 >>> 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.