diff options
author | Fuad Tabba <tabba@google.com> | 2023-07-17 13:12:30 +0100 |
---|---|---|
committer | Will Deacon <will@kernel.org> | 2023-07-20 15:58:06 +0100 |
commit | b6bae725decc42a4b5bc76058afb4c9d6abe4645 (patch) | |
tree | 18e4ced915b12fe0cd5496326301c4d3373b1c27 | |
parent | bd4ba57156dad39349edfb2338bdc2f4ed3c0bae (diff) | |
download | kvmtool-b6bae725decc42a4b5bc76058afb4c9d6abe4645.tar.gz |
Factor out getting the host page size
Factor out getting the page size of 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-2-tabba@google.com
Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r-- | builtin-run.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/builtin-run.c b/builtin-run.c index b1a27fda..2801735c 100644 --- a/builtin-run.c +++ b/builtin-run.c @@ -360,9 +360,21 @@ static void kernel_usage_with_options(void) KVM_BINARY_NAME); } +static long host_page_size(void) +{ + long page_size = sysconf(_SC_PAGE_SIZE); + + if (page_size < 0) { + pr_warning("sysconf(_SC_PAGE_SIZE) failed"); + return 0; + } + + return page_size; +} + static u64 host_ram_size(void) { - long page_size; + long page_size = host_page_size(); long nr_pages; nr_pages = sysconf(_SC_PHYS_PAGES); @@ -371,12 +383,6 @@ static u64 host_ram_size(void) return 0; } - page_size = sysconf(_SC_PAGE_SIZE); - if (page_size < 0) { - pr_warning("sysconf(_SC_PAGE_SIZE) failed"); - return 0; - } - return (u64)nr_pages * page_size; } |