LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: axboe@kernel.dk, linux-kernel@vger.kernel.org
Subject: [PATCH] [3/7] Add mempool support for page allocation through the mask allocator
Date: Fri, 7 Mar 2008 10:13:23 +0100 (CET) [thread overview]
Message-ID: <20080307091324.0031D1B419C@basil.firstfloor.org> (raw)
In-Reply-To: <200803071013.837692778@firstfloor.org>
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@suse.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 */
next prev parent reply other threads:[~2008-03-07 9:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-07 9:13 [PATCH] [0/7] Block layer rework for " Andi Kleen
2008-03-07 9:13 ` [PATCH] [1/7] Convert a few direct bounce_gfp users over to the blk_* wrappers Andi Kleen
2008-03-07 9:13 ` [PATCH] [2/7] Convert open coded reference in libata to q->bounce_gfp to blk_kmalloc Andi Kleen
2008-03-07 21:06 ` Jeff Garzik
2008-03-07 9:13 ` Andi Kleen [this message]
2008-03-07 9:13 ` [PATCH] [4/7] Add blk_q_mask Andi Kleen
2008-03-07 9:13 ` [PATCH] [5/7] Convert the blk allocator functions over to the mask allocator Andi Kleen
2008-03-07 9:13 ` [PATCH] [6/7] Remove bounce_gfp Andi Kleen
2008-03-07 9:13 ` [PATCH] [7/7] Allow swiotlb to move block data bouncing to the block layer Andi Kleen
2008-03-08 12:08 ` Andi Kleen
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=20080307091324.0031D1B419C@basil.firstfloor.org \
--to=andi@firstfloor.org \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
--subject='Re: [PATCH] [3/7] Add mempool support for page allocation through the mask allocator' \
/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
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).