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]
Date:	Fri,  7 Mar 2008 10:13:23 +0100 (CET)
From:	Andi Kleen <andi@...stfloor.org>
To:	axboe@...nel.dk, linux-kernel@...r.kernel.org
Subject: [PATCH] [3/7] Add mempool support for page allocation through the mask allocator


Right now for struct page *s because that is what the block bounce code
needs.

I chose to add a small scratch area to the mempool structure instead
of allocating separately.

Signed-off-by: Andi Kleen <ak@...e.de>

---
 include/linux/mempool.h |    3 +++
 mm/mempool.c            |   31 +++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

Index: linux/mm/mempool.c
===================================================================
--- linux.orig/mm/mempool.c
+++ linux/mm/mempool.c
@@ -338,3 +338,34 @@ void mempool_free_pages(void *element, v
 	__free_pages(element, order);
 }
 EXPORT_SYMBOL(mempool_free_pages);
+
+struct mempool_apm_data {
+	u64 mask;
+	unsigned size;
+};
+
+static void *mempool_alloc_pages_mask(gfp_t gfp_mask, void *pool_data)
+{
+	struct mempool_apm_data *apm = (struct mempool_apm_data *)pool_data;
+	return alloc_pages_mask(gfp_mask, apm->size, apm->mask);
+}
+
+static void mempool_free_pages_mask(void *element, void *pool_data)
+{
+	struct mempool_apm_data *apm = (struct mempool_apm_data *)pool_data;
+	__free_pages_mask(element, apm->size);
+}
+
+mempool_t *mempool_create_pool_pmask(int min_nr, int size, u64 mask)
+{
+	struct mempool_apm_data apm = { .size = size, .mask = mask };
+	mempool_t *m = mempool_create(min_nr, mempool_alloc_pages_mask,
+				      mempool_free_pages_mask, &apm);
+	if (m) {
+		BUILD_BUG_ON(sizeof(m->private) < sizeof(apm));
+		memcpy(m->private, &apm, sizeof(struct mempool_apm_data));
+		m->pool_data = (struct mempool_apm_data *)&m->private;
+	}
+	return m;
+}
+EXPORT_SYMBOL(mempool_create_pool_pmask);
Index: linux/include/linux/mempool.h
===================================================================
--- linux.orig/include/linux/mempool.h
+++ linux/include/linux/mempool.h
@@ -21,6 +21,7 @@ typedef struct mempool_s {
 	mempool_alloc_t *alloc;
 	mempool_free_t *free;
 	wait_queue_head_t wait;
+	char private[16];
 } mempool_t;
 
 extern mempool_t *mempool_create(int min_nr, mempool_alloc_t *alloc_fn,
@@ -76,4 +77,6 @@ static inline mempool_t *mempool_create_
 			      (void *)(long)order);
 }
 
+mempool_t *mempool_create_pool_pmask(int min_nr, int size, u64 mask);
+
 #endif /* _LINUX_MEMPOOL_H */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ