diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-03 15:22:22 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-09 16:26:14 -0400 |
commit | 477670f48167cac1b871b061713cc1b594a2a941 (patch) | |
tree | 699c9d61214fc762a5a971f73feb59798909d620 /include/linux | |
parent | 5531accc97da082b7a102240e34fdf15c68a8991 (diff) |
Update bcachefs sources to 07f9a27f1969 bcachefs: add no_invalid_checks flag
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/blkdev.h | 2 | ||||
-rw-r--r-- | include/linux/closure.h | 12 | ||||
-rw-r--r-- | include/linux/sched.h | 2 | ||||
-rw-r--r-- | include/linux/sched/mm.h | 111 | ||||
-rw-r--r-- | include/linux/slab.h | 4 | ||||
-rw-r--r-- | include/linux/srcu.h | 5 | ||||
-rw-r--r-- | include/linux/string.h | 1 |
7 files changed, 126 insertions, 11 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 1d825a70..b295bd9a 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -73,7 +73,7 @@ static inline struct block_device *file_bdev(struct file *file) return container_of(file->f_inode, struct block_device, __bd_inode); } -void fput(struct file *); +void bdev_fput(struct file *); struct file *bdev_file_open_by_path(const char *, blk_mode_t, void *, const struct blk_holder_ops *); int lookup_bdev(const char *path, dev_t *); diff --git a/include/linux/closure.h b/include/linux/closure.h index c554c6a0..99155df1 100644 --- a/include/linux/closure.h +++ b/include/linux/closure.h @@ -194,6 +194,18 @@ static inline void closure_sync(struct closure *cl) __closure_sync(cl); } +int __closure_sync_timeout(struct closure *cl, unsigned long timeout); + +static inline int closure_sync_timeout(struct closure *cl, unsigned long timeout) +{ +#ifdef CONFIG_DEBUG_CLOSURES + BUG_ON(closure_nr_remaining(cl) != 1 && !cl->closure_get_happened); +#endif + return cl->closure_get_happened + ? __closure_sync_timeout(cl, timeout) + : 0; +} + #ifdef CONFIG_DEBUG_CLOSURES void closure_debug_create(struct closure *cl); diff --git a/include/linux/sched.h b/include/linux/sched.h index 7afb6d54..fedb1c3c 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -176,6 +176,8 @@ static inline void ktime_get_coarse_real_ts64(struct timespec64 *ts) #define current_kernel_time64() current_kernel_time() #define CURRENT_TIME (current_kernel_time()) +#define sched_annotate_sleep() do {} while (0) + static inline unsigned int stack_trace_save_tsk(struct task_struct *task, unsigned long *store, unsigned int size, unsigned int skipnr) diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index 03feda7a..34045ce0 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -4,28 +4,123 @@ #define PF_MEMALLOC 0x00000800 /* Allocating memory */ #define PF_MEMALLOC_NOFS 0x00040000 /* All allocation requests will inherit GFP_NOFS */ +/** + * memalloc_flags_save - Add a PF_* flag to current->flags, save old value + * + * This allows PF_* flags to be conveniently added, irrespective of current + * value, and then the old version restored with memalloc_flags_restore(). + */ +static inline unsigned memalloc_flags_save(unsigned flags) +{ + unsigned oldflags = ~current->flags & flags; + current->flags |= flags; + return oldflags; +} + +static inline void memalloc_flags_restore(unsigned flags) +{ + current->flags &= ~flags; +} + +/** + * memalloc_noio_save - Marks implicit GFP_NOIO allocation scope. + * + * This functions marks the beginning of the GFP_NOIO allocation scope. + * All further allocations will implicitly drop __GFP_IO flag and so + * they are safe for the IO critical section from the allocation recursion + * point of view. Use memalloc_noio_restore to end the scope with flags + * returned by this function. + * + * Context: This function is safe to be used from any context. + * Return: The saved flags to be passed to memalloc_noio_restore. + */ +static inline unsigned int memalloc_noio_save(void) +{ + return memalloc_flags_save(PF_MEMALLOC_NOIO); +} + +/** + * memalloc_noio_restore - Ends the implicit GFP_NOIO scope. + * @flags: Flags to restore. + * + * Ends the implicit GFP_NOIO scope started by memalloc_noio_save function. + * Always make sure that the given flags is the return value from the + * pairing memalloc_noio_save call. + */ +static inline void memalloc_noio_restore(unsigned int flags) +{ + memalloc_flags_restore(flags); +} + +/** + * memalloc_nofs_save - Marks implicit GFP_NOFS allocation scope. + * + * This functions marks the beginning of the GFP_NOFS allocation scope. + * All further allocations will implicitly drop __GFP_FS flag and so + * they are safe for the FS critical section from the allocation recursion + * point of view. Use memalloc_nofs_restore to end the scope with flags + * returned by this function. + * + * Context: This function is safe to be used from any context. + * Return: The saved flags to be passed to memalloc_nofs_restore. + */ static inline unsigned int memalloc_nofs_save(void) { - unsigned int flags = current->flags & PF_MEMALLOC_NOFS; - current->flags |= PF_MEMALLOC_NOFS; - return flags; + return memalloc_flags_save(PF_MEMALLOC_NOFS); } +/** + * memalloc_nofs_restore - Ends the implicit GFP_NOFS scope. + * @flags: Flags to restore. + * + * Ends the implicit GFP_NOFS scope started by memalloc_nofs_save function. + * Always make sure that the given flags is the return value from the + * pairing memalloc_nofs_save call. + */ static inline void memalloc_nofs_restore(unsigned int flags) { - current->flags = (current->flags & ~PF_MEMALLOC_NOFS) | flags; + memalloc_flags_restore(flags); } +/** + * memalloc_noreclaim_save - Marks implicit __GFP_MEMALLOC scope. + * + * This function marks the beginning of the __GFP_MEMALLOC allocation scope. + * All further allocations will implicitly add the __GFP_MEMALLOC flag, which + * prevents entering reclaim and allows access to all memory reserves. This + * should only be used when the caller guarantees the allocation will allow more + * memory to be freed very shortly, i.e. it needs to allocate some memory in + * the process of freeing memory, and cannot reclaim due to potential recursion. + * + * Users of this scope have to be extremely careful to not deplete the reserves + * completely and implement a throttling mechanism which controls the + * consumption of the reserve based on the amount of freed memory. Usage of a + * pre-allocated pool (e.g. mempool) should be always considered before using + * this scope. + * + * Individual allocations under the scope can opt out using __GFP_NOMEMALLOC + * + * Context: This function should not be used in an interrupt context as that one + * does not give PF_MEMALLOC access to reserves. + * See __gfp_pfmemalloc_flags(). + * Return: The saved flags to be passed to memalloc_noreclaim_restore. + */ static inline unsigned int memalloc_noreclaim_save(void) { - unsigned int flags = current->flags & PF_MEMALLOC; - current->flags |= PF_MEMALLOC; - return flags; + return memalloc_flags_save(PF_MEMALLOC); } +/** + * memalloc_noreclaim_restore - Ends the implicit __GFP_MEMALLOC scope. + * @flags: Flags to restore. + * + * Ends the implicit __GFP_MEMALLOC scope started by memalloc_noreclaim_save + * function. Always make sure that the given flags is the return value from the + * pairing memalloc_noreclaim_save call. + */ static inline void memalloc_noreclaim_restore(unsigned int flags) { - current->flags = (current->flags & ~PF_MEMALLOC) | flags; + memalloc_flags_restore(flags); } #endif /* _LINUX_SCHED_MM_H */ diff --git a/include/linux/slab.h b/include/linux/slab.h index 35f7b1ba..6dad5653 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -102,8 +102,8 @@ static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags) #define kcalloc(n, size, flags) kmalloc_array(n, size, flags|__GFP_ZERO) -#define kfree(p) free(p) -#define kzfree(p) free(p) +#define kfree(p) free((void *) p) +#define kzfree(p) free((void *) p) #define kvmalloc(size, flags) kmalloc(size, flags) #define kvzalloc(size, flags) kzalloc(size, flags) diff --git a/include/linux/srcu.h b/include/linux/srcu.h index 75823cf2..e667df22 100644 --- a/include/linux/srcu.h +++ b/include/linux/srcu.h @@ -21,6 +21,11 @@ static inline unsigned long start_poll_synchronize_srcu(struct srcu_struct *ssp) return 0; } +static inline unsigned long get_state_synchronize_srcu(struct srcu_struct *ssp) +{ + return 0; +} + static inline void cleanup_srcu_struct(struct srcu_struct *ssp) {} static inline int init_srcu_struct(struct srcu_struct *ssp) diff --git a/include/linux/string.h b/include/linux/string.h index 3ceda3a3..f6ce8dde 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -10,6 +10,7 @@ extern ssize_t strscpy(char *dest, const char *src, size_t count); extern char *strim(char *); extern void memzero_explicit(void *, size_t); int match_string(const char * const *, size_t, const char *); +extern void * memscan(void *,int, size_t); #define kstrndup(s, n, gfp) strndup(s, n) #define kstrdup(s, gfp) strdup(s) |