summaryrefslogtreecommitdiff
path: root/linux/shrinker.c
diff options
context:
space:
mode:
authorChris Webb <chris@arachsys.com>2023-12-09 12:49:12 +0000
committerKent Overstreet <kent.overstreet@linux.dev>2023-12-09 23:26:29 -0500
commitddc71615311b9f134f6e1c3caaf6ff7bf1bddaeb (patch)
tree9aa3a60c96aead6ba61591f55c97db3458f0f656 /linux/shrinker.c
parent2d5118e01fddf09a9f9b9713d857b70515cc9b4b (diff)
bcachefs-tools: Use sysinfo(2) directly to implement si_meminfo()
Use a single sysinfo(2) call to fill out struct sysinfo instead of multiple libc sysconf(3) requests, which will only make sysinfo(2) calls internally anyway. This also enables us to access other struct sysinfo fields, not just the three filled-out previously. As we provide our own definition of struct sysinfo in include/linux/mm.h to match the kernel, which is not guaranteed to align with the definition libc provides in <sys/sysinfo.h>, use syscall(SYS_sysinfo, ...) directly instead of the libc wrapper. Signed-off-by: Chris Webb <chris@arachsys.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'linux/shrinker.c')
-rw-r--r--linux/shrinker.c15
1 files changed, 0 insertions, 15 deletions
diff --git a/linux/shrinker.c b/linux/shrinker.c
index 91f633b5..7658fb7e 100644
--- a/linux/shrinker.c
+++ b/linux/shrinker.c
@@ -33,21 +33,6 @@ void unregister_shrinker(struct shrinker *shrinker)
mutex_unlock(&shrinker_lock);
}
-struct meminfo {
- u64 total;
- u64 available;
-};
-
-void si_meminfo(struct sysinfo *val)
-{
- long page_size = sysconf(_SC_PAGESIZE);
- memset(val, 0, sizeof(*val));
- val->mem_unit = 1;
-
- val->totalram = sysconf(_SC_PHYS_PAGES) * page_size;
- val->freeram = sysconf(_SC_AVPHYS_PAGES) * page_size;
-}
-
static void run_shrinkers_allocation_failed(gfp_t gfp_mask)
{
struct shrinker *shrinker;