forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
maple_tree: add GFP_KERNEL to allocations in mas_expected_entries()
Users complained about OOM errors during fork without triggering compaction. This can be fixed by modifying the flags used in mas_expected_entries() so that the compaction will be triggered in low memory situations. Since mas_expected_entries() is only used during fork, the extra argument does not need to be passed through. Additionally, the two test_maple_tree test cases and one benchmark test were altered to use the correct locking type so that allocations would not trigger sleeping and thus fail. Testing was completed with lockdep atomic sleep detection. The additional locking change requires rwsem support additions to the tools/ directory through the use of pthreads pthread_rwlock_t. With this change test_maple_tree works in userspace, as a module, and in-kernel. Users may notice that the system gave up early on attempting to start new processes instead of attempting to reclaim memory. Link: https://lkml.kernel.org/r/20230915093243epcms1p46fa00bbac1ab7b7dca94acb66c44c456@epcms1p4 Link: https://lkml.kernel.org/r/[email protected] Fixes: 54a611b ("Maple Tree: add new data structure") Signed-off-by: Liam R. Howlett <[email protected]> Reviewed-by: Peng Zhang <[email protected]> Cc: <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
- Loading branch information
Showing
3 changed files
with
65 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* SPDX-License-Identifier: GPL-2.0+ */ | ||
#ifndef _TOOLS__RWSEM_H | ||
#define _TOOLS__RWSEM_H | ||
|
||
#include <pthread.h> | ||
|
||
struct rw_semaphore { | ||
pthread_rwlock_t lock; | ||
}; | ||
|
||
static inline int init_rwsem(struct rw_semaphore *sem) | ||
{ | ||
return pthread_rwlock_init(&sem->lock, NULL); | ||
} | ||
|
||
static inline int exit_rwsem(struct rw_semaphore *sem) | ||
{ | ||
return pthread_rwlock_destroy(&sem->lock); | ||
} | ||
|
||
static inline int down_read(struct rw_semaphore *sem) | ||
{ | ||
return pthread_rwlock_rdlock(&sem->lock); | ||
} | ||
|
||
static inline int up_read(struct rw_semaphore *sem) | ||
{ | ||
return pthread_rwlock_unlock(&sem->lock); | ||
} | ||
|
||
static inline int down_write(struct rw_semaphore *sem) | ||
{ | ||
return pthread_rwlock_wrlock(&sem->lock); | ||
} | ||
|
||
static inline int up_write(struct rw_semaphore *sem) | ||
{ | ||
return pthread_rwlock_unlock(&sem->lock); | ||
} | ||
#endif /* _TOOLS_RWSEM_H */ |