提交 5b7a6003 编写于 作者: L Lijun Fang 提交者: Zheng Zengkai

mm: Change tmpfs size base on ddr size.

ascend inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4JMLR
CVE: NA
-------------------

If it enable COHERENT_DEVICE and config HBM for device,
the tmpfs will statistics all memory including HBM, which
couldn't be used by system. When the system runs out of memory,
statistical residual memory but also left a lot,
so this will cause many problems.
Signed-off-by: NLijun Fang <fanglijun3@huawei.com>
Reviewed-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 baff4b7b
......@@ -124,9 +124,37 @@ struct shmem_options {
};
#ifdef CONFIG_TMPFS
#ifdef CONFIG_COHERENT_DEVICE
static unsigned long ddr_totalram_pages(void)
{
int nid;
int zone_type;
unsigned long managed_pages = 0;
pg_data_t *pgdat;
if (nodes_empty(cdmmask))
return totalram_pages();
for_each_online_node(nid) {
if (is_cdm_node(nid))
continue;
pgdat = NODE_DATA(nid);
for (zone_type = 0; zone_type < MAX_NR_ZONES; zone_type++)
managed_pages += zone_managed_pages(&pgdat->node_zones[zone_type]);
}
return managed_pages;
}
#else
static unsigned long ddr_totalram_pages(void)
{
return totalram_pages();
}
#endif
static unsigned long shmem_default_max_blocks(void)
{
return totalram_pages() / 2;
return ddr_totalram_pages() / 2;
}
static unsigned long shmem_default_max_inodes(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册