Commit af2100e2 authored by ZhangPeng's avatar ZhangPeng Committed by Peng Zhang
Browse files

mm/userswap: add enable_userswap boot option

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8KESX


CVE: NA

--------------------------------

Add enable_userswap boot option to enable userswap feature. Add static
key userswap_enabled to indicate whether the feature is enabled.

Signed-off-by: default avatarZhangPeng <zhangpeng362@huawei.com>
parent ec625021
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -456,8 +456,12 @@ static inline int pte_none_mostly(pte_t pte)
}

#ifdef CONFIG_USERSWAP
extern struct static_key_false userswap_enabled;

static inline int is_userswap_entry(swp_entry_t entry)
{
	if (!static_branch_unlikely(&userswap_enabled))
		return 0;
	return unlikely(swp_type(entry) == SWP_USERSWAP_ENTRY);
}
#else
+1 −0
Original line number Diff line number Diff line
@@ -122,6 +122,7 @@ obj-$(CONFIG_CMA_DEBUGFS) += cma_debug.o
obj-$(CONFIG_SECRETMEM) += secretmem.o
obj-$(CONFIG_CMA_SYSFS) += cma_sysfs.o
obj-$(CONFIG_USERFAULTFD) += userfaultfd.o
obj-$(CONFIG_USERSWAP) += userswap.o
obj-$(CONFIG_IDLE_PAGE_TRACKING) += page_idle.o
obj-$(CONFIG_DEBUG_PAGEALLOC) += debug_page_alloc.o
obj-$(CONFIG_DEBUG_PAGE_REF) += debug_page_ref.o

mm/userswap.c

0 → 100644
+17 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) Huawei Technologies Co., Ltd. 2023. All rights reserved.
 *
 * userswap core file
 */

#include "internal.h"

DEFINE_STATIC_KEY_FALSE(userswap_enabled);

static int __init enable_userswap_setup(char *str)
{
	static_branch_enable(&userswap_enabled);
	return 1;
}
__setup("enable_userswap", enable_userswap_setup);