On 6/25/26 15:51, Gregory Price wrote:
> On Thu, Jun 25, 2026 at 09:22:01AM +0200, David Hildenbrand (Arm) wrote:
>> On 6/24/26 16:57, Gregory Price wrote:
>>>  extern int offline_and_remove_memory(u64 start, u64 size);
>>> +int offline_and_remove_memory_ranges(const struct range *ranges, int 
>>> nr_ranges);
>>>  
>>>  #else
>>>  static inline void try_offline_node(int nid) {}
>>> @@ -283,6 +284,12 @@ static inline int remove_memory(u64 start, u64 size)
>>>  }
>>>  
>>>  static inline void __remove_memory(u64 start, u64 size) {}
>>> +
>>> +static inline int offline_and_remove_memory_ranges(const struct range 
>>> *ranges,
>>> +                                              int nr_ranges)
>>
>> Best to use "unsigned int" right from the start and use two tabs to indent.
>>
> 
> ack, ack.  need to reprogram my brain to two-indent style, i keep doing
> this reflexively.
> 
>>> +int offline_and_remove_memory_ranges(const struct range *ranges, int 
>>> nr_ranges)
>>> +{
>>> +   unsigned long mb_total = 0;
>>>     uint8_t *online_types, *tmp;
>>> -   int rc;
>>> +   int i, rc = 0;
>>>  
>>> -   if (!IS_ALIGNED(start, memory_block_size_bytes()) ||
>>> -       !IS_ALIGNED(size, memory_block_size_bytes()) || !size)
>>> +   if (!ranges || nr_ranges <= 0)
>>
>> With "unsigned int" this will be !nr_ranges.
>>
>> Wondering whether we would WARN_ON_ONCE() here.
>>
> 
> Seems reasonable.  Do we normally WARN when callers send dumb arguments?
> Seems like sending -EINVAL is sufficient?

We do it when we really expect no sane user to do that and doing it would
indicate an actual problem.

Like passing a nid to add_memory_resource() that doesn't even exist.

But yeah, no strong opinion here, we can just keep it as is.

-- 
Cheers,

David

Reply via email to