Hi Tejun,
On 1/28/25 4:17 AM, Tejun Heo Wrote:
On Sat, Jan 25, 2025 at 01:25:11PM +0800, Abel Wu wrote:
There were efforts like b824766504e4 ("cgroup/rstat: add force idle show helper")
to escape from #ifdef hells, and there could be new stats coming out in
the future, let's clean it up once for all.
Signed-off-by: Abel Wu <wuyun.abel@xxxxxxxxxxxxx>
---
kernel/cgroup/rstat.c | 47 ++++++++++++++++++++++++-------------------
1 file changed, 26 insertions(+), 21 deletions(-)
Is this materially better? The existing code has ifdef in one place which
the new code can't avoid.
Indeed, # of ifdefs will stay unchanged, but they will be folded
into one place inside the bstats[] array quite the same as the
definition of the struct cgroup_base_stat, which IMHO won't hurt
readability.
The new code is more complex and has more lines.
Does the balance get better with additions of new entries?
The line diff is 5, and 4 of them are for readability. If adding
one more field into cpu.stat, 1 or 3 lines will be added w/o or
w/ ifdef respectively, comparing to 8 or 10 lines without this
cleanup. So the balance will be better if cpu.stat extends. And
it would also be better cleanup duplicated code for each field.
Thanks,
Abel