Re: [PATCH 1/3] memory: extern memory_block_size_bytes and set_memory_block_size_order

From: David Hildenbrand
Date: Mon Oct 14 2024 - 07:54:43 EST


On 08.10.24 17:21, Gregory Price wrote:
On Tue, Oct 08, 2024 at 05:02:33PM +0200, David Hildenbrand wrote:
On 08.10.24 16:51, Gregory Price wrote:
+int __weak set_memory_block_size_order(unsigned int order)
+{
+ return -ENODEV;
+}
+EXPORT_SYMBOL_GPL(set_memory_block_size_order);

I can understand what you are trying to achieve, but letting arbitrary
modules mess with this sounds like a bad idea.


I suppose the alternative is trying to scan the CEDT from inside each
machine, rather than the ACPI driver? Seems less maintainable.

I don't entirely disagree with your comment. I hummed and hawwed over
externing this - hence the warning in the x86 machine.

Open to better answers.

Maybe an interface to add more restrictions on the maximum size might be
better (instead of setting the size/order, you would impose another upper
limit).

That is effectively what set_memory_block_size_order is, though. Once
blocks are exposed to the allocators, its no longer safe to change the
size (in part because it was built assuming it wouldn't change, but I
imagine there are other dragons waiting in the shadows to bite me).

Yes, we must run very early.

How is this supposed to interact with code like

set_block_size()

that also calls set_memory_block_size_order() on UV systems (assuming there will be CXL support sooner or later?)?



So this would basically amount to a lock-bit being set in the architecture,
beyond which block size can no longer be changed and a big ol' splat
can be generated that says "NO TOUCH".

Just imagine having various users of such an interface ..

I don't wanna D:

Right, and it also doesn't make sense as explained in my other comment: this should never apply to loaded modules. :)

--
Cheers,

David / dhildenb