提交 60d69023 编写于 作者: C Chen Jun 提交者: Wang Wensheng

mm/sharepool: Extract sp_mapping_find

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

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

Extract code logic of obtaining sp_mapping by address into a function
sp_mapping_find.
Signed-off-by: NChen Jun <chenjun102@huawei.com>
上级 91bc1d52
无相关合并请求
......@@ -448,6 +448,15 @@ static int sp_mapping_group_setup(struct mm_struct *mm, struct sp_group *spg)
return 0;
}
static inline struct sp_mapping *sp_mapping_find(struct sp_group *spg,
unsigned long addr)
{
if (addr >= MMAP_SHARE_POOL_NORMAL_START && addr < MMAP_SHARE_POOL_NORMAL_END)
return spg->mapping[SP_MAPPING_NORMAL];
return spg->mapping[SP_MAPPING_DVPP];
}
static struct sp_group *create_spg(int spg_id, unsigned long flag);
static void free_new_spg_id(bool new, int spg_id);
static void free_sp_group_locked(struct sp_group *spg);
......@@ -1881,13 +1890,8 @@ static struct sp_area *sp_alloc_area(unsigned long size, unsigned long flags,
static struct sp_area *__find_sp_area_locked(struct sp_group *spg,
unsigned long addr)
{
struct rb_node *n;
if (addr >= MMAP_SHARE_POOL_NORMAL_START && addr < MMAP_SHARE_POOL_NORMAL_END)
n = spg->mapping[SP_MAPPING_NORMAL]->area_root.rb_node;
else
n = spg->mapping[SP_MAPPING_DVPP]->area_root.rb_node;
struct sp_mapping *spm = sp_mapping_find(spg, addr);
struct rb_node *n = spm->area_root.rb_node;
while (n) {
struct sp_area *spa;
......@@ -1939,11 +1943,7 @@ static void sp_free_area(struct sp_area *spa)
lockdep_assert_held(&sp_area_lock);
if (addr >= MMAP_SHARE_POOL_NORMAL_START && addr < MMAP_SHARE_POOL_NORMAL_END)
spm = spa->spg->mapping[SP_MAPPING_NORMAL];
else
spm = spa->spg->mapping[SP_MAPPING_DVPP];
spm = sp_mapping_find(spa->spg, addr);
if (spm->free_area_cache) {
struct sp_area *cache;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部