summaryrefslogtreecommitdiff
path: root/fs/xfs/linux-2.6/kmem.c
diff options
context:
space:
mode:
authorNathan Scott <nathans@sgi.com>2006-09-28 11:03:27 +1000
committerTim Shimmin <tes@sgi.com>2006-09-28 11:03:27 +1000
commit77e4635ae191774526ed695482a151ac986f3806 (patch)
tree42cfa03f913883cd7f3d53be19b7e8c25258ee2c /fs/xfs/linux-2.6/kmem.c
parent572d95f49f3652fffe8242c4498b85f4083e52ab (diff)
[XFS] Add a greedy allocation interface, allocating within a min/max size
range. SGI-PV: 955302 SGI-Modid: xfs-linux-melb:xfs-kern:26803a Signed-off-by: Nathan Scott <nathans@sgi.com> Signed-off-by: Tim Shimmin <tes@sgi.com>
Diffstat (limited to 'fs/xfs/linux-2.6/kmem.c')
-rw-r--r--fs/xfs/linux-2.6/kmem.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/fs/xfs/linux-2.6/kmem.c b/fs/xfs/linux-2.6/kmem.c
index f77fe5c8fcc1..80b9340488e5 100644
--- a/fs/xfs/linux-2.6/kmem.c
+++ b/fs/xfs/linux-2.6/kmem.c
@@ -68,6 +68,22 @@ kmem_zalloc(size_t size, unsigned int __nocast flags)
return ptr;
}
+void *
+kmem_zalloc_greedy(size_t *size, size_t minsize, size_t maxsize,
+ unsigned int __nocast flags)
+{
+ void *ptr;
+
+ while (!(ptr = kmem_zalloc(maxsize, flags))) {
+ if ((maxsize >>= 1) <= minsize) {
+ maxsize = minsize;
+ flags = KM_SLEEP;
+ }
+ }
+ *size = maxsize;
+ return ptr;
+}
+
void
kmem_free(void *ptr, size_t size)
{