Commit 5b7a6003 authored by Lijun Fang's avatar Lijun Fang Committed by Zheng Zengkai
Browse files

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: default avatarLijun Fang <fanglijun3@huawei.com>
Reviewed-by: default avatarWeilong Chen <chenweilong@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent baff4b7b
Loading
Loading
Loading
Loading
+29 −1
Original line number Diff line number Diff line
@@ -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)