mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-30 13:52:50 +01:00
Concurrent reads and writes of sysctl_max_map_count are possible, so we should READ_ONCE() and WRITE_ONCE(). The sysctl procfs logic already enforces WRITE_ONCE(), so abstract the read side with get_sysctl_max_map_count(). While we're here, also move the field to mm/internal.h and add the getter there since only mm interacts with it, there's no need for anybody else to have access. Finally, update the VMA userland tests to reflect the change. Link: https://lkml.kernel.org/r/0715259eb37cbdfde4f9e5db92a20ec7110a1ce5.1773249037.git.ljs@kernel.org Signed-off-by: Lorenzo Stoakes (Oracle) <[email protected]> Reviewed-by: Pedro Falcato <[email protected]> Cc: Jann Horn <[email protected]> Cc: Jianzhou Zhao <[email protected]> Cc: Liam Howlett <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Oscar Salvador <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: Vlastimil Babka <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
58 lines
1.3 KiB
C
58 lines
1.3 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include "shared.h"
|
|
/*
|
|
* Directly import the VMA implementation here. Our vma_internal.h wrapper
|
|
* provides userland-equivalent functionality for everything vma.c uses.
|
|
*/
|
|
#include "../../../mm/vma_init.c"
|
|
#include "../../../mm/vma_exec.c"
|
|
#include "../../../mm/vma.c"
|
|
|
|
/* Tests are included directly so they can test static functions in mm/vma.c. */
|
|
#include "tests/merge.c"
|
|
#include "tests/mmap.c"
|
|
#include "tests/vma.c"
|
|
|
|
int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
|
|
|
|
/* Helper functions which utilise static kernel functions. */
|
|
|
|
struct vm_area_struct *merge_existing(struct vma_merge_struct *vmg)
|
|
{
|
|
struct vm_area_struct *vma;
|
|
|
|
vma = vma_merge_existing_range(vmg);
|
|
if (vma)
|
|
vma_assert_attached(vma);
|
|
return vma;
|
|
}
|
|
|
|
int attach_vma(struct mm_struct *mm, struct vm_area_struct *vma)
|
|
{
|
|
int res;
|
|
|
|
res = vma_link(mm, vma);
|
|
if (!res)
|
|
vma_assert_attached(vma);
|
|
return res;
|
|
}
|
|
|
|
/* Main test running which invokes tests/ *.c runners. */
|
|
int main(void)
|
|
{
|
|
int num_tests = 0, num_fail = 0;
|
|
|
|
maple_tree_init();
|
|
vma_state_init();
|
|
|
|
run_merge_tests(&num_tests, &num_fail);
|
|
run_mmap_tests(&num_tests, &num_fail);
|
|
run_vma_tests(&num_tests, &num_fail);
|
|
|
|
printf("%d tests run, %d passed, %d failed.\n",
|
|
num_tests, num_tests - num_fail, num_fail);
|
|
|
|
return num_fail == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
}
|