lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221205145937.54367-9-kbusch@meta.com>
Date:   Mon, 5 Dec 2022 06:59:34 -0800
From:   Keith Busch <kbusch@...a.com>
To:     <linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>,
        Matthew Wilcox <willy@...radead.org>
CC:     Tony Battersby <tonyb@...ernetics.com>,
        Keith Busch <kbusch@...nel.org>
Subject: [PATCH 08/11] dmapool: consolidate page initialization

From: Keith Busch <kbusch@...nel.org>

Various fields of the dma pool are set in different places. Move it all
to one function.

Signed-off-by: Keith Busch <kbusch@...nel.org>
---
 mm/dmapool.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/mm/dmapool.c b/mm/dmapool.c
index f77e2af4941de..33d20ceff18c5 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -202,6 +202,8 @@ static void pool_initialise_page(struct dma_pool *pool, struct dma_page *page)
 	unsigned int offset = 0;
 	unsigned int next_boundary = pool->boundary;
 
+	page->in_use = 0;
+	page->offset = 0;
 	do {
 		unsigned int next = offset + pool->size;
 		if (unlikely((next + pool->size) >= next_boundary)) {
@@ -211,6 +213,8 @@ static void pool_initialise_page(struct dma_pool *pool, struct dma_page *page)
 		*(int *)(page->vaddr + offset) = next;
 		offset = next;
 	} while (offset < pool->allocation);
+
+	list_add(&page->page_list, &pool->page_list);
 }
 
 static struct dma_page *pool_alloc_page(struct dma_pool *pool, gfp_t mem_flags)
@@ -229,10 +233,6 @@ static struct dma_page *pool_alloc_page(struct dma_pool *pool, gfp_t mem_flags)
 #ifdef	DMAPOOL_DEBUG
 	memset(page->vaddr, POOL_POISON_FREED, pool->allocation);
 #endif
-	pool_initialise_page(pool, page);
-	page->in_use = 0;
-	page->offset = 0;
-
 	return page;
 }
 
@@ -354,8 +354,7 @@ void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
 		return NULL;
 
 	spin_lock_irqsave(&pool->lock, flags);
-
-	list_add(&page->page_list, &pool->page_list);
+	pool_initialise_page(pool, page);
  ready:
 	page->in_use++;
 	offset = page->offset;
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ