Re: [PATCH v2 4/7] s390/physmem_info: query diag500(STORAGE LIMIT) to support QEMU/KVM memory devices

David Hildenbrand
2024-10-17T12:07:18Z

On 17.10.24 12:00, David Hildenbrand wrote:
> On 17.10.24 11:53, Alexander Gordeev wrote:
>>>> Why search_mem_end() is not tried in case sclp_early_get_memsize() failed?
>>>
>>> Patch #3 documents that:
>>>
>>> + The storage limit does not indicate currently usable storage, it may
>>> + include holes, standby storage and areas reserved for other means, such
>>> + as memory hotplug or virtio-mem devices. Other interfaces for detecting
>>> + actually usable storage, such as SCLP, must be used in conjunction with
>>> + this subfunction.
>>
>> Yes, I read this and that exactly what causes my confusion. In this wording it
>> sounds like SCLP *or* other methods are fine to use. But then you use SCLP or
>> DIAGNOSE 260, but not memory scanning. So I am still confused ;)
>
> Well, DIAGNOSE 260 is z/VM only and DIAG 500 is KVM only. So there are
> currently not really any other reasonable ways besides SCLP.

Correction: Staring at the code again, in detect_physmem_online_ranges()
we will indeed try:

a) sclp_early_read_storage_info()
b) diag260()

But if neither works, we cannot blindly add all that memory, something is
messed up. So we'll fallback to

c) sclp_early_get_memsize()

But if none of that works, something is seriously wrong.

I will squash the following:

diff --git a/arch/s390/boot/physmem_info.c b/arch/s390/boot/physmem_info.c
index 975fc478e0e3..6ad3ac2050eb 100644
--- a/arch/s390/boot/physmem_info.c
+++ b/arch/s390/boot/physmem_info.c
@@ -214,6 +214,12 @@ void detect_physmem_online_ranges(unsigned long max_physmem_end)
return;
} else if (physmem_info.info_source == MEM_DETECT_DIAG500_STOR_LIMIT) {
max_physmem_end = 0;
+ /*
+ * If we know the storage limit but do not find any other
+ * indication of usable initial memory, something is messed
+ * up. In that case, we'll not add any physical memory so
+ * we'll run into die_oom() later.
+ */
if (!sclp_early_get_memsize(&max_physmem_end))
physmem_info.info_source = MEM_DETECT_SCLP_READ_INFO;
}

--
Cheers,

David / dhildenb