lkml.org 
[lkml]   [2024]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: Re: [PATCH v2 1/4] virtio_balloon: separate vm events into a function
From


On 4/22/24 15:47, David Hildenbrand wrote:
> On 22.04.24 09:42, zhenwei pi wrote:
>> All the VM events related statistics have dependence on
>> 'CONFIG_VM_EVENT_COUNTERS', once any stack variable is required by any
>> VM events in future, we would have codes like:
>>   #ifdef CONFIG_VM_EVENT_COUNTERS
>>        unsigned long foo;
>>   #endif
>>        ...
>>   #ifdef CONFIG_VM_EVENT_COUNTERS
>>        foo = events[XXX] + events[YYY];
>>        update_stat(vb, idx++, VIRTIO_BALLOON_S_XXX, foo);
>>   #endif
>>
>> Separate vm events into a single function, also remove
>
> Why not simply use __maybe_unused for that variable?
>

1>
static unsigned int update_balloon_stats()
{
unsigned __maybe_unused long foo;

...
#ifdef CONFIG_VM_EVENT_COUNTERS
foo = events[XXX] + events[YYY];
update_stat(vb, idx++, VIRTIO_BALLOON_S_XXX, foo);
#endif
}

2>
static inline unsigned int update_balloon_vm_stats()
{
#ifdef CONFIG_VM_EVENT_COUNTERS
unsigned long foo;

foo = events[XXX] + events[YYY];
update_stat(vb, idx++, VIRTIO_BALLOON_S_XXX, foo);
#endif
}

From the point of my view, I don't need to compile code in my brain
when reading codes for case 2. :)

--
zhenwei pi

\
 
 \ /
  Last update: 2024-05-27 17:55    [W:0.039 / U:0.508 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site