提交 68589c78 编写于 作者: Z Zhou Guanghui 提交者: Yongqiang Liu

mm/sharepool: Delete single-group mode

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5EORS
CVE: NA

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

The single-group mode has no application scenario. Therefore, the
related branch is deleted.

The boot option "enable_sp_multi_group_mode" does not take effect.
Signed-off-by: NZhou Guanghui <zhouguanghui1@huawei.com>
Reviewed-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 25c4db2a
......@@ -65,9 +65,6 @@
#define byte2mb(size) ((size) >> 20)
#define page2kb(page_num) ((page_num) << (PAGE_SHIFT - 10))
#define SINGLE_GROUP_MODE 1
#define MULTI_GROUP_MODE 2
#define MAX_GROUP_FOR_SYSTEM 50000
#define MAX_GROUP_FOR_TASK 3000
#define MAX_PROC_PER_GROUP 1024
......@@ -98,8 +95,6 @@ int sysctl_sp_perf_alloc;
int sysctl_sp_perf_k2u;
static int share_pool_group_mode = SINGLE_GROUP_MODE;
static int system_group_count;
static unsigned int sp_device_number;
......@@ -1088,12 +1083,6 @@ static int mm_add_group_init(struct mm_struct *mm, struct sp_group *spg)
struct sp_group_master *master = mm->sp_group_master;
bool exist = false;
if (share_pool_group_mode == SINGLE_GROUP_MODE && master &&
master->count == 1) {
pr_err_ratelimited("at most one sp group for a task is allowed in single mode\n");
return -EEXIST;
}
master = sp_init_group_master_locked(mm, &exist);
if (IS_ERR(master))
return PTR_ERR(master);
......@@ -2235,72 +2224,30 @@ static int sp_alloc_prepare(unsigned long size, unsigned long sp_flags,
if (sp_flags & SP_HUGEPAGE_ONLY)
sp_flags |= SP_HUGEPAGE;
if (share_pool_group_mode == SINGLE_GROUP_MODE) {
spg = __sp_find_spg(current->pid, SPG_ID_DEFAULT);
if (spg) {
if (spg_id != SPG_ID_DEFAULT && spg->id != spg_id) {
sp_group_drop(spg);
return -ENODEV;
}
/* up_read will be at the end of sp_alloc */
down_read(&spg->rw_lock);
if (!spg_valid(spg)) {
up_read(&spg->rw_lock);
sp_group_drop(spg);
pr_err_ratelimited("allocation failed, spg is dead\n");
return -ENODEV;
}
} else { /* alocation pass through scene */
if (enable_mdc_default_group) {
int ret = 0;
ret = sp_group_add_task(current->tgid, spg_id);
if (ret < 0) {
pr_err_ratelimited("add group failed in pass through\n");
return ret;
}
spg = __sp_find_spg(current->pid, SPG_ID_DEFAULT);
/* up_read will be at the end of sp_alloc */
down_read(&spg->rw_lock);
if (!spg_valid(spg)) {
up_read(&spg->rw_lock);
sp_group_drop(spg);
pr_err_ratelimited("pass through allocation failed, spg is dead\n");
return -ENODEV;
}
} else {
spg = spg_none;
}
if (spg_id != SPG_ID_DEFAULT) {
spg = __sp_find_spg(current->pid, spg_id);
if (!spg) {
pr_err_ratelimited("allocation failed, can't find group\n");
return -ENODEV;
}
} else {
if (spg_id != SPG_ID_DEFAULT) {
spg = __sp_find_spg(current->pid, spg_id);
if (!spg) {
pr_err_ratelimited("allocation failed, can't find group\n");
return -ENODEV;
}
/* up_read will be at the end of sp_alloc */
down_read(&spg->rw_lock);
if (!spg_valid(spg)) {
up_read(&spg->rw_lock);
sp_group_drop(spg);
pr_err_ratelimited("allocation failed, spg is dead\n");
return -ENODEV;
}
/* up_read will be at the end of sp_alloc */
down_read(&spg->rw_lock);
if (!spg_valid(spg)) {
up_read(&spg->rw_lock);
sp_group_drop(spg);
pr_err_ratelimited("allocation failed, spg is dead\n");
return -ENODEV;
}
if (!is_process_in_group(spg, current->mm)) {
up_read(&spg->rw_lock);
sp_group_drop(spg);
pr_err_ratelimited("allocation failed, task not in group\n");
return -ENODEV;
}
} else { /* alocation pass through scene */
spg = spg_none;
if (!is_process_in_group(spg, current->mm)) {
up_read(&spg->rw_lock);
sp_group_drop(spg);
pr_err_ratelimited("allocation failed, task not in group\n");
return -ENODEV;
}
} else { /* alocation pass through scene */
spg = spg_none;
}
if (sp_flags & SP_HUGEPAGE) {
......@@ -2914,33 +2861,12 @@ static int sp_k2u_prepare(unsigned long kva, unsigned long size,
kc->size_aligned = size_aligned;
kc->sp_flags = sp_flags;
kc->spg_id = spg_id;
kc->to_task = false;
return 0;
}
static int sp_check_k2task(struct sp_k2u_context *kc)
{
int ret = 0;
int spg_id = kc->spg_id;
if (share_pool_group_mode == SINGLE_GROUP_MODE) {
struct sp_group *spg = get_first_group(current->mm);
if (spg_id == SPG_ID_DEFAULT || spg_id == SPG_ID_NONE)
kc->to_task = true;
else
kc->to_task = false;
if (!spg) {
if (spg_id != SPG_ID_NONE && spg_id != SPG_ID_DEFAULT)
ret = -EINVAL;
else
kc->to_task = true;
} else {
if (spg_id != SPG_ID_DEFAULT && spg_id != spg->id)
ret = -EINVAL;
sp_group_drop(spg);
}
} else {
if (spg_id == SPG_ID_DEFAULT || spg_id == SPG_ID_NONE)
kc->to_task = true;
}
return ret;
return 0;
}
static void *sp_k2u_finish(void *uva, struct sp_k2u_context *kc)
......@@ -2985,12 +2911,6 @@ void *sp_make_share_k2u(unsigned long kva, unsigned long size,
if (ret)
return ERR_PTR(ret);
ret = sp_check_k2task(&kc);
if (ret) {
uva = ERR_PTR(ret);
goto out;
}
if (kc.to_task)
uva = sp_make_share_kva_to_task(kc.kva_aligned, kc.size_aligned, kc.sp_flags);
else {
......@@ -3738,13 +3658,6 @@ static int __init enable_share_k2u_to_group(char *s)
}
__setup("enable_sp_share_k2u_spg", enable_share_k2u_to_group);
static int __init enable_sp_multi_group_mode(char *s)
{
share_pool_group_mode = MULTI_GROUP_MODE;
return 1;
}
__setup("enable_sp_multi_group_mode", enable_sp_multi_group_mode);
/*** Statistical and maintenance functions ***/
static void free_process_spg_proc_stat(struct sp_proc_stat *proc_stat)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册