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 9913DC00140 for ; Thu, 18 Aug 2022 10:09:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0AA356B0073; Thu, 18 Aug 2022 06:09:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0359E6B0074; Thu, 18 Aug 2022 06:09:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DEE448D0001; Thu, 18 Aug 2022 06:09:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id CB8B66B0073 for ; Thu, 18 Aug 2022 06:09:53 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A989580990 for ; Thu, 18 Aug 2022 10:09:53 +0000 (UTC) X-FDA: 79812292266.10.449C219 Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by imf07.hostedemail.com (Postfix) with ESMTP id 6845142472 for ; Thu, 18 Aug 2022 10:01:12 +0000 (UTC) Received: from relay.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id ABBCCA186C for ; Thu, 18 Aug 2022 10:01:04 +0000 (UTC) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8EBF2AC32D for ; Thu, 18 Aug 2022 10:01:04 +0000 (UTC) X-FDA: 79812270048.19.06013A1 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by imf11.hostedemail.com (Postfix) with ESMTP id 7ACB440BE5 for ; Thu, 18 Aug 2022 09:50:02 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=liusong@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0VMZx3Mr_1660811864; Received: from 30.178.80.93(mailfrom:liusong@linux.alibaba.com fp:SMTPD_---0VMZx3Mr_1660811864) by smtp.aliyun-inc.com; Thu, 18 Aug 2022 16:37:46 +0800 Message-ID: Date: Thu, 18 Aug 2022 16:37:44 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.0.3 Subject: Re: [PATCH v2] mm/dmapool.c: avoid duplicate memset within dma_pool_alloc To: Christoph Hellwig , Robin Murphy , akpm@linux-foundation.org Cc: Marek Szyprowski , "linux-arm-kernel@lists.infradead.org" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "iommu@lists.linux.dev" 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> <20220817053628.GA28747@lst.de> From: Liu Song In-Reply-To: <20220817053628.GA28747@lst.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660816206; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1Bmj/qOCjWJh/Ir9RrTFSW8lcd8ZIw8uIToAw5xclCY=; b=u0x6MF5+fb2Kitk4ViWEz599IAGuK4OuKwQOv7NBWch1MEv0K3CGKndX9UKiz+At2OxZ2W GrSDqUx3zqGD/NQSxFIYfmBNzRVi7JtdHW6Oc/FO5QuWP0ZCAn478zsOLef5UFc29X78He 8mLXxRlQN8PrCS3TUBGF4rFAtUccwkU= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of liusong@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=liusong@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660816206; a=rsa-sha256; cv=none; b=M8qmDx7rUqQ/vK8wBump476MZXTTedeL7rVA1hnlJgIOmPJn9Eof4RYo7gyIQpaEp6ip0l b7ZYk3E7QY3XPAbkLqkGOrCKqZ65Avarba8Bv1rQD9ObnUYJc5JWV7COQ2Pz7JJOvm8Pmo xnOutMrK3Az+cXCAPwRlqQfgUHvscqQ= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1660816874; a=rsa-sha256; cv=pass; b=lx6uJ7B22IXhEr0UnZBYkgllT5eFZUjmQKlzICiabTpQo/umsMSJpsBMNVxKr/BuY6e6Bh Nl17QLaf9ucZIHRxg5y7SNO5ptwDcZ27DGw2I7axZJTDE5GaeDpb1VnYbgTM7vTNc0npLn fUYN8JH04c9jeVTNP4TBN0Am9WU2fBc= ARC-Authentication-Results: i=2; imf07.hostedemail.com; dkim=none; spf=fail (imf07.hostedemail.com: domain of liusong@linux.alibaba.com does not designate 216.40.44.13 as permitted sender) smtp.mailfrom=liusong@linux.alibaba.com; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=alibaba.com (policy=none); arc=pass ("hostedemail.com:s=arc-20220608:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660816874; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1Bmj/qOCjWJh/Ir9RrTFSW8lcd8ZIw8uIToAw5xclCY=; b=0CTssaQF7n0CowO4/Ofr/ANGyiejngYHta0V1gSSKBT8L/7v9AZrtsJjJIImME1SgdgtBm mSek/rUDPF7olownSiGrn+EA7mdXKFp8GTKbZCvYr3aDTLXbZLtVXESIokgErqt8UNUPFw eekx9f2H7txhHV/Vflw9bDpeceISQkg= X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 6845142472 X-Stat-Signature: 1brrdrru1pi9m6iqyk7tmpmwfhs88h5y X-HE-Tag-Orig: 1660816202-227970 Authentication-Results: imf07.hostedemail.com; dkim=none; spf=fail (imf07.hostedemail.com: domain of liusong@linux.alibaba.com does not designate 216.40.44.13 as permitted sender) smtp.mailfrom=liusong@linux.alibaba.com; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=alibaba.com (policy=none); arc=pass ("hostedemail.com:s=arc-20220608:i=1") X-HE-Tag: 1660816872-433765 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. After reading everyone's comments, I found that fixing this patch will make the code look strange, so the benefits of the changes will be dispensable, so I also agree to discard this patch. Sorry for this trouble again. Thanks