mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
percpu: implement [__]alloc_percpu_gfp()
Now that pcpu_alloc_area() can allocate only from populated areas, it's easy to add atomic allocation support to [__]alloc_percpu(). Update pcpu_alloc() so that it accepts @gfp and skips all the blocking operations and allocates only from the populated areas if @gfp doesn't contain GFP_KERNEL. New interface functions [__]alloc_percpu_gfp() are added. While this means that atomic allocations are possible, this isn't complete yet as there's no mechanism to ensure that certain amount of populated areas is kept available and atomic allocations may keep failing under certain conditions. Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
@@ -122,11 +122,16 @@ extern void __init setup_per_cpu_areas(void);
|
||||
#endif
|
||||
extern void __init percpu_init_late(void);
|
||||
|
||||
extern void __percpu *__alloc_percpu_gfp(size_t size, size_t align, gfp_t gfp);
|
||||
extern void __percpu *__alloc_percpu(size_t size, size_t align);
|
||||
extern void free_percpu(void __percpu *__pdata);
|
||||
extern phys_addr_t per_cpu_ptr_to_phys(void *addr);
|
||||
|
||||
#define alloc_percpu(type) \
|
||||
(typeof(type) __percpu *)__alloc_percpu(sizeof(type), __alignof__(type))
|
||||
#define alloc_percpu_gfp(type, gfp) \
|
||||
(typeof(type) __percpu *)__alloc_percpu_gfp(sizeof(type), \
|
||||
__alignof__(type), gfp)
|
||||
#define alloc_percpu(type) \
|
||||
(typeof(type) __percpu *)__alloc_percpu(sizeof(type), \
|
||||
__alignof__(type))
|
||||
|
||||
#endif /* __LINUX_PERCPU_H */
|
||||
|
Reference in New Issue
Block a user