All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Robin Murphy <robin.murphy@arm.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
	Liu Song <liusong@linux.alibaba.com>,
	akpm@linux-foundation.org,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	Christoph Hellwig <hch@lst.de>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>
Subject: Re: [PATCH v2] mm/dmapool.c: avoid duplicate memset within dma_pool_alloc
Date: Wed, 17 Aug 2022 07:36:28 +0200	[thread overview]
Message-ID: <20220817053628.GA28747@lst.de> (raw)
In-Reply-To: <413d8666-7a82-efd7-6716-13658016ca10@arm.com>

>>> 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.

WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Robin Murphy <robin.murphy@arm.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
	Liu Song <liusong@linux.alibaba.com>,
	akpm@linux-foundation.org,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	Christoph Hellwig <hch@lst.de>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>
Subject: Re: [PATCH v2] mm/dmapool.c: avoid duplicate memset within dma_pool_alloc
Date: Wed, 17 Aug 2022 07:36:28 +0200	[thread overview]
Message-ID: <20220817053628.GA28747@lst.de> (raw)
In-Reply-To: <413d8666-7a82-efd7-6716-13658016ca10@arm.com>

>>> 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.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2022-08-17  5:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-18  6:28 [PATCH v2] mm/dmapool.c: avoid duplicate memset within dma_pool_alloc Liu Song
     [not found] ` <CGME20220816123958eucas1p1b03a5efa1f5804245a5c1a9b27529015@eucas1p1.samsung.com>
2022-08-16 12:39   ` Marek Szyprowski
2022-08-16 12:39     ` Marek Szyprowski
2022-08-16 15:00     ` Robin Murphy
2022-08-16 15:00       ` Robin Murphy
2022-08-17  2:03       ` Liu Song
2022-08-17  2:03         ` Liu Song
2022-08-17  5:36       ` Christoph Hellwig [this message]
2022-08-17  5:36         ` Christoph Hellwig
2022-08-18  8:37         ` Liu Song
2022-08-18  8:37           ` Liu Song

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220817053628.GA28747@lst.de \
    --to=hch@lst.de \
    --cc=akpm@linux-foundation.org \
    --cc=iommu@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liusong@linux.alibaba.com \
    --cc=m.szyprowski@samsung.com \
    --cc=robin.murphy@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.