* [PATCH v4 3/9] dmapool: cleanup dma_pool_destroy
@ 2018-11-12 15:42 Tony Battersby
[not found] ` <2ff327bb-59f7-5105-0bba-72329cb73154-vFAe+i1/wJI5UWNf+nJyDw@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Tony Battersby @ 2018-11-12 15:42 UTC (permalink / raw)
To: Matthew Wilcox, Christoph Hellwig, Marek Szyprowski,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-mm-Bw31MaZKKs3YtjvyW6yDsg
Cc: linux-scsi-u79uwXL29TY76Z2rM5mHXA
Remove a small amount of code duplication between dma_pool_destroy() and
pool_free_page() in preparation for adding more code without having to
duplicate it. No functional changes.
Signed-off-by: Tony Battersby <tonyb-vFAe+i1/wJI5UWNf+nJyDw@public.gmane.org>
---
--- linux/mm/dmapool.c.orig 2018-08-02 09:59:15.000000000 -0400
+++ linux/mm/dmapool.c 2018-08-02 10:01:26.000000000 -0400
@@ -249,13 +249,22 @@ static inline bool is_page_busy(struct d
static void pool_free_page(struct dma_pool *pool, struct dma_page *page)
{
+ void *vaddr = page->vaddr;
dma_addr_t dma = page->dma;
+ list_del(&page->page_list);
+
+ if (is_page_busy(page)) {
+ dev_err(pool->dev,
+ "dma_pool_destroy %s, %p busy\n",
+ pool->name, vaddr);
+ /* leak the still-in-use consistent memory */
+ } else {
#ifdef DMAPOOL_DEBUG
- memset(page->vaddr, POOL_POISON_FREED, pool->allocation);
+ memset(vaddr, POOL_POISON_FREED, pool->allocation);
#endif
- dma_free_coherent(pool->dev, pool->allocation, page->vaddr, dma);
- list_del(&page->page_list);
+ dma_free_coherent(pool->dev, pool->allocation, vaddr, dma);
+ }
kfree(page);
}
@@ -269,6 +278,7 @@ static void pool_free_page(struct dma_po
*/
void dma_pool_destroy(struct dma_pool *pool)
{
+ struct dma_page *page;
bool empty = false;
if (unlikely(!pool))
@@ -284,19 +294,10 @@ void dma_pool_destroy(struct dma_pool *p
device_remove_file(pool->dev, &dev_attr_pools);
mutex_unlock(&pools_reg_lock);
- while (!list_empty(&pool->page_list)) {
- struct dma_page *page;
- page = list_entry(pool->page_list.next,
- struct dma_page, page_list);
- if (is_page_busy(page)) {
- dev_err(pool->dev,
- "dma_pool_destroy %s, %p busy\n",
- pool->name, page->vaddr);
- /* leak the still-in-use consistent memory */
- list_del(&page->page_list);
- kfree(page);
- } else
- pool_free_page(pool, page);
+ while ((page = list_first_entry_or_null(&pool->page_list,
+ struct dma_page,
+ page_list))) {
+ pool_free_page(pool, page);
}
kfree(pool);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v4 3/9] dmapool: cleanup dma_pool_destroy
[not found] ` <2ff327bb-59f7-5105-0bba-72329cb73154-vFAe+i1/wJI5UWNf+nJyDw@public.gmane.org>
@ 2018-11-13 6:15 ` Matthew Wilcox
0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2018-11-13 6:15 UTC (permalink / raw)
To: Tony Battersby
Cc: linux-mm-Bw31MaZKKs3YtjvyW6yDsg,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
Christoph Hellwig, linux-scsi-u79uwXL29TY76Z2rM5mHXA
On Mon, Nov 12, 2018 at 10:42:48AM -0500, Tony Battersby wrote:
> Remove a small amount of code duplication between dma_pool_destroy() and
> pool_free_page() in preparation for adding more code without having to
> duplicate it. No functional changes.
>
> Signed-off-by: Tony Battersby <tonyb-vFAe+i1/wJI5UWNf+nJyDw@public.gmane.org>
Acked-by: Matthew Wilcox <willy-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-13 6:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-12 15:42 [PATCH v4 3/9] dmapool: cleanup dma_pool_destroy Tony Battersby
[not found] ` <2ff327bb-59f7-5105-0bba-72329cb73154-vFAe+i1/wJI5UWNf+nJyDw@public.gmane.org>
2018-11-13 6:15 ` Matthew Wilcox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).