Re: [External] Re: [PATCH v4] mm: memcontrol: Add the missing numa_stat interface for cgroup v2

From: Randy Dunlap
Date: Tue Sep 15 2020 - 13:05:40 EST


On 9/15/20 9:01 AM, Muchun Song wrote:
> On Tue, Sep 15, 2020 at 11:45 PM Randy Dunlap <rdunlap@xxxxxxxxxxxxx> wrote:
>>

>>> +static int __init numa_stats_init(void)
>>> +{
>>> + int i;
>>> +
>>> + for (i = 0; i < ARRAY_SIZE(numa_stats); i++) {
>>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>>> + if (numa_stats[i].idx == NR_ANON_THPS)
>>> + numa_stats[i].ratio = HPAGE_PMD_SIZE;
>>> +#endif
>>> + }
>>
>> Although the loop may be needed sometime in the future due to
>> other changes.. why couldn't it be like this for now?
>
> The compiler is so smart, so there is nothing difference between
> them. I disassemble the numa_stats_init when
> !CONFIG_TRANSPARENT_HUGEPAGE.
>
> Dump of assembler code for function numa_stats_init:
> 0xffffffff8273b061 <+0>: callq 0xffffffff81057490 <__fentry__>
> 0xffffffff8273b066 <+5>: xor %eax,%eax
> 0xffffffff8273b068 <+7>: retq
>

Of course! Thanks.

>>
>>
>>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>>> + for (i = 0; i < ARRAY_SIZE(numa_stats); i++) {
>>> + if (numa_stats[i].idx == NR_ANON_THPS)
>>> + numa_stats[i].ratio = HPAGE_PMD_SIZE;
>>> + }
>>> +#endif
>>
>>
>>> +
>>> + return 0;
>>> +}
>>> +pure_initcall(numa_stats_init);


--
~Randy