Blame view
net/xfrm/xfrm_hash.c
806 Bytes
44e36b42a
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
/* xfrm_hash.c: Common hash table code. * * Copyright (C) 2006 David S. Miller (davem@davemloft.net) */ #include <linux/kernel.h> #include <linux/mm.h> #include <linux/bootmem.h> #include <linux/vmalloc.h> #include <linux/slab.h> #include <linux/xfrm.h> #include "xfrm_hash.h" struct hlist_head *xfrm_hash_alloc(unsigned int sz) { struct hlist_head *n; if (sz <= PAGE_SIZE) |
dcaee95a1
|
20 |
n = kzalloc(sz, GFP_KERNEL); |
44e36b42a
|
21 |
else if (hashdist) |
dcaee95a1
|
22 |
n = __vmalloc(sz, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL); |
44e36b42a
|
23 24 |
else n = (struct hlist_head *) |
dcaee95a1
|
25 |
__get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, |
6253db055
|
26 |
get_order(sz)); |
44e36b42a
|
27 |
|
44e36b42a
|
28 29 30 31 32 33 34 35 36 37 38 39 |
return n; } void xfrm_hash_free(struct hlist_head *n, unsigned int sz) { if (sz <= PAGE_SIZE) kfree(n); else if (hashdist) vfree(n); else free_pages((unsigned long)n, get_order(sz)); } |