On 1/22/26 17:35, Stanislav Kinsburskii wrote:
Replace direct comparisons of hv_result(status) against
HV_STATUS_INSUFFICIENT_MEMORY with a new hv_result_oom() helper function.
This improves code readability and provides a consistent and extendable
interface for checking out-of-memory conditions in hypercall results.
No functional changes intended.
Signed-off-by: Stanislav Kinsburskii <[email protected]>
---
drivers/hv/hv_proc.c | 14 ++++++++++++--
drivers/hv/mshv_root_hv_call.c | 20 ++++++++++----------
drivers/hv/mshv_root_main.c | 2 +-
include/asm-generic/mshyperv.h | 3 +++
4 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/drivers/hv/hv_proc.c b/drivers/hv/hv_proc.c
index fbb4eb3901bb..80c66d1c74d5 100644
--- a/drivers/hv/hv_proc.c
+++ b/drivers/hv/hv_proc.c
@@ -110,6 +110,16 @@ int hv_call_deposit_pages(int node, u64 partition_id, u32
num_pages)
}
EXPORT_SYMBOL_GPL(hv_call_deposit_pages);
+bool hv_result_oom(u64 status)
+{
+ switch (hv_result(status)) {
+ case HV_STATUS_INSUFFICIENT_MEMORY:
+ return true;
+ }
+ return false;
+}
+EXPORT_SYMBOL_GPL(hv_result_oom);
I had mentioned this during internal review previously, so forgive me
for repeating. I don't think using _oom suffix is a good idea. Firstly,
system is not out of memory, hypervisor will continue to work perfectly,
just the particalur hypercall needs a bit more ram to succeed. Secondly
and more importantly, "oom" has come to mean a very specific event
in linux, and as such reusing it for something totally different is
unnecessary. For example, if another maintainer working on oom happens
to see this, and not being familiar with HyperV may get totally confused
and waste time unnecessarily.
It can easily be renamed: hv_result_insuff_mem, or hv_result_enomem,
or hv_result_deposit_ram etc... there are many options.
Thanks,
-Mukesh
.... deleted ...