On Wed, 2026-01-07 at 10:48 -0800, Andrew Morton wrote:

> I'm not understanding why negative numbers get this treatment - could
> you please add the reasoning to the code comment?

Hm. I suppose that memvalue() may (and hopefully will) be used to parse
and return an amount of "actually used" (for some particular task) memory,
allowing 0 with possible "use some default value" treatment in the caller.
Negative values just introduces some confusion (and possible weird effects
caused by an erroneous conversion of negative values to huge positive ones). 
If someone needs some special treatment of, say, "memsize=-32M" somewhere,
there should be a kind of an extra handling beyond memvalue(). 

> Presumably it's because memvalue() returns ULL, presumably because
> memparse() returns ULL?  Maybe that's all wrong, and memparse() should
> have returned LL - negative numbers are a bit odd, but why deny that
> option.  With the new memvalue() we get to partially address that?

I would rather try

int __must_check memvalue(const char *ptr, unsigned long long *addr);

as suggested by Kees. 

Dmitry

Reply via email to