diff options
author | Fuad Tabba <tabba@google.com> | 2023-07-17 13:12:31 +0100 |
---|---|---|
committer | Will Deacon <will@kernel.org> | 2023-07-20 15:58:06 +0100 |
commit | 834e5ed62fb8e4905b31e54d456d4011365b9533 (patch) | |
tree | b8d4fce778998235fec670f6b4da64f6fa335127 | |
parent | b6bae725decc42a4b5bc76058afb4c9d6abe4645 (diff) | |
download | kvmtool-834e5ed62fb8e4905b31e54d456d4011365b9533.tar.gz |
Factor out getting the number of physical memory host pages
Factor out getting the number of physical pages available for the
host into a separate function. This will be used in a subsequent
patch.
No functional change intended.
Signed-off-by: Fuad Tabba <tabba@google.com>
Link: https://lore.kernel.org/r/20230717121232.3559948-3-tabba@google.com
Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r-- | builtin-run.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/builtin-run.c b/builtin-run.c index 2801735c..44ea6908 100644 --- a/builtin-run.c +++ b/builtin-run.c @@ -372,17 +372,23 @@ static long host_page_size(void) return page_size; } -static u64 host_ram_size(void) +static long host_ram_nrpages(void) { - long page_size = host_page_size(); - long nr_pages; + long nr_pages = sysconf(_SC_PHYS_PAGES); - nr_pages = sysconf(_SC_PHYS_PAGES); if (nr_pages < 0) { pr_warning("sysconf(_SC_PHYS_PAGES) failed"); return 0; } + return nr_pages; +} + +static u64 host_ram_size(void) +{ + long page_size = host_page_size(); + long nr_pages = host_ram_nrpages(); + return (u64)nr_pages * page_size; } |