msm_sysstats: Stub out non-exported functions

Remove dependencies on two non-exported functions (si_swapinfo() and
vmalloc_nr_pages()) along with one non-existant one. User space
clients of the sysstats driver will need to obtain swap_total from
/proc/meminfo's SwapTotal, swap_used from SwapTotal - SwapFree, and
vmalloc_total from VmallocUsed.

For now, the unreclaimable field will now return 0 as a value or just
the KGSL allocated memory, depending on the call path.

Change-Id: If3e204a5ff405bd9cbcb080c5d151c3a77c4b944
Signed-off-by: Chris Goldsworthy <quic_cgoldswo@quicinc.com>
This commit is contained in:
Chris Goldsworthy 2023-02-02 10:15:39 -08:00
parent 9aa48da0b8
commit 725bec3fc6
2 changed files with 23 additions and 8 deletions

View File

@ -605,6 +605,16 @@ config MSM_SYSSTATS
socket.
If unsure, say N
config MSM_SYSSTATS_STUB_NONEXPORTED_SYMBOLS
bool "Stub out non-exported core-kernel symbols"
depends on MSM_SYSSTATS
help
Stub out is_system_dmabufheap(), vmalloc_nr_pages() and si_swapinfo().
Enabling this option will make the swap_used, swap_total and
vmalloc_total fields of struct sysstats_mem 0, and will make the
unreclaimable field either 0, or make it only include the KGSL memory.
If unsure, say N.
config TASK_DELAY_ACCT
bool "Enable per-task delay accounting"
depends on TASKSTATS

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/kernel.h>
@ -168,13 +168,14 @@ static int get_dma_info(const void *data, struct file *file, unsigned int n)
struct dma_buf *dmabuf;
unsigned long *size = (unsigned long *)data;
#ifndef CONFIG_MSM_SYSSTATS_STUB_NONEXPORTED_SYMBOLS
if (!is_dma_buf_file(file))
#endif
return 0;
dmabuf = (struct dma_buf *)file->private_data;
if (is_system_dmabufheap(dmabuf))
*size += dmabuf->size;
return 0;
}
@ -483,8 +484,7 @@ static int sysstats_task_foreach(struct sk_buff *skb, struct netlink_callback *c
K(get_mm_counter(p->mm, MM_SHMEMPAGES));
stats->swap_rss =
K(get_mm_counter(p->mm, MM_SWAPENTS));
stats->unreclaimable =
K(get_task_unreclaimable_info(p));
stats->unreclaimable = K(get_task_unreclaimable_info(p));
task_unlock(p);
#undef K
}
@ -572,16 +572,21 @@ static void sysstats_build(struct sysstats_mem *stats)
struct sysinfo i;
si_meminfo(&i);
#ifndef CONFIG_MSM_SYSSTATS_STUB_NONEXPORTED_SYMBOLS
si_swapinfo(&i);
stats->swap_used = K(i.totalswap - i.freeswap);
stats->swap_total = K(i.totalswap);
stats->vmalloc_total = K(vmalloc_nr_pages());
#else
stats->swap_used = 0;
stats->swap_total = 0;
stats->vmalloc_total = 0;
#endif
stats->memtotal = K(i.totalram);
stats->misc_reclaimable =
K(global_node_page_state(NR_KERNEL_MISC_RECLAIMABLE));
stats->unreclaimable = K(get_system_unreclaimble_info());
stats->buffer = K(i.bufferram);
stats->swap_used = K(i.totalswap - i.freeswap);
stats->swap_total = K(i.totalswap);
stats->vmalloc_total = K(vmalloc_nr_pages());
stats->swapcache = K(total_swapcache_pages());
stats->slab_reclaimable =
K(global_node_page_state_pages(NR_SLAB_RECLAIMABLE_B));