video: tegra: nvmap: Add numa checks

Android builds don't have CONFIG_NUMA enabled hence
/sys/devices/system/node/node0/meminfo is not present on android.
While nvscibuf calls the QueryHeapParams to check presence of the
hugetlbfs based carveout, the error prints will be seen due to absence
of the above sysfs file. Hence first check whethere there are multiple
numa nodes are not. If not, then use /proc/meminfo file to retrieve the
hugetlbfs size otherwise use the meminfo sysfs node from the
corresponding numa node.

Bug 5200644

Change-Id: I5495de91726d323210807e86f22757b798226fca
Signed-off-by: Ketan Patil <ketanp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3338255
Reviewed-by: Pritesh Raithatha <praithatha@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Jian-Min Liu <jianminl@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Ketan Patil
2025-04-11 11:23:31 +00:00
committed by Jon Hunter
parent a7b08a9c27
commit 93fde3b573

View File

@@ -178,7 +178,16 @@ static int compute_hugetlbfs_stat(u64 *total, u64 *free, int numa_id)
bool total_found = false, free_found = false;
int nid, rc;
sprintf(meminfo_path, "/sys/devices/system/node/node%d/meminfo", numa_id);
if (num_online_nodes() > 1) {
sprintf(meminfo_path, "/sys/devices/system/node/node%d/meminfo", numa_id);
} else {
if (numa_id != 0) {
pr_err("Incorrect input for numa_id:%d\n", numa_id);
return -EINVAL;
}
sprintf(meminfo_path, "/proc/meminfo");
}
file = filp_open(meminfo_path, O_RDONLY, 0);
if (IS_ERR(file)) {
pr_err("Could not open file:%s\n", meminfo_path);
@@ -200,10 +209,17 @@ static int compute_hugetlbfs_stat(u64 *total, u64 *free, int numa_id)
while ((ptr = strsep(&buffer, "\n")) != NULL) {
if (!ptr[0])
continue;
else if (sscanf(ptr, "Node %d HugePages_Total: %u\n", &nid, &huge_total) == 2)
total_found = true;
else if (sscanf(ptr, "Node %d HugePages_Free: %u\n", &nid, &huge_free) == 2)
free_found = true;
if (num_online_nodes() > 1) {
if (sscanf(ptr, "Node %d HugePages_Total: %u\n", &nid, &huge_total) == 2)
total_found = true;
else if (sscanf(ptr, "Node %d HugePages_Free: %u\n", &nid, &huge_free) == 2)
free_found = true;
} else {
if (sscanf(ptr, "HugePages_Total: %u\n", &huge_total) == 1)
total_found = true;
else if (sscanf(ptr, "HugePages_Free: %u\n", &huge_free) == 1)
free_found = true;
}
}
nvmap_altfree(buf, MEMINFO_SIZE * sizeof(*buf));