Source kernel commit:
3050bd0bfe706381c36e4b48bf4de465b0ab94f7
Use kmem_cache_alloc() directly.
All kmem_zone_alloc() users pass 0 as flags, which are translated into:
GFP_KERNEL | __GFP_NOWARN, and kmem_zone_alloc() loops forever until the
allocation succeeds.
We can use __GFP_NOFAIL to tell the allocator to loop forever rather
than doing it ourself, and because the allocation will never fail, we do
not need to use __GFP_NOWARN anymore. Hence, all callers can be
converted to use GFP_KERNEL | __GFP_NOFAIL
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[darrick: add a comment back in about nofail]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
int allocated; /* debug: How many currently allocated */
} kmem_zone_t;
+typedef unsigned int __bitwise gfp_t;
+
+#define GFP_KERNEL ((__force gfp_t)0)
+#define __GFP_NOFAIL ((__force gfp_t)0)
+
extern kmem_zone_t *kmem_zone_init(int, char *);
-extern void *kmem_zone_alloc(kmem_zone_t *, int);
+extern void *kmem_cache_alloc(kmem_zone_t *, gfp_t);
extern void *kmem_zone_zalloc(kmem_zone_t *, int);
extern int kmem_zone_destroy(kmem_zone_t *);
}
void *
-kmem_zone_alloc(kmem_zone_t *zone, int flags)
+kmem_cache_alloc(kmem_zone_t *zone, gfp_t flags)
{
void *ptr = malloc(zone->zone_unitsize);
zone->allocated++;
return ptr;
}
+
void *
kmem_zone_zalloc(kmem_zone_t *zone, int flags)
{
- void *ptr = kmem_zone_alloc(zone, flags);
+ void *ptr = kmem_cache_alloc(zone, flags);
memset(ptr, 0, zone->zone_unitsize);
return ptr;
}
-
void *
kmem_alloc(size_t size, int flags)
{
ASSERT(xfs_bmap_free_item_zone != NULL);
ASSERT(oinfo != NULL);
- new = kmem_zone_alloc(xfs_bmap_free_item_zone, 0);
+ new = kmem_cache_alloc(xfs_bmap_free_item_zone,
+ GFP_KERNEL | __GFP_NOFAIL);
new->xefi_startblock = XFS_AGB_TO_FSB(mp, agno, agbno);
new->xefi_blockcount = 1;
new->xefi_oinfo = *oinfo;
#endif
ASSERT(xfs_bmap_free_item_zone != NULL);
- new = kmem_zone_alloc(xfs_bmap_free_item_zone, 0);
+ new = kmem_cache_alloc(xfs_bmap_free_item_zone,
+ GFP_KERNEL | __GFP_NOFAIL);
new->xefi_startblock = bno;
new->xefi_blockcount = (xfs_extlen_t)len;
if (oinfo)