Re: [RFC] mm: get_mm_counter() get the total memory usage of the process

From: David Hildenbrand
Date: Thu Apr 04 2024 - 15:30:57 EST


On 22.03.24 16:11, Chen Taotao wrote:
Currently, the get_mm_counter() function returns only the value of
the process memory counter percpu_counter ->count record, ignoring
the memory usage count maintained by each CPU in the
percpu_counter->counters array, which leads to an error in obtaining
the memory usage count of a process, especially when there are many
CPU cores. counts, especially when there are many CPU cores.

It is now possible to have get_mm_counter() get the memory count of a
process by adding the memory counts maintained by each cpu, thus getting
an accurate memory count of the process.

This patch is an unofficial version that simply fixes the above problem,
as I'm not sure if it makes sense to do so.

What is the effective change? Do you have any real examples where we can observe a real difference, so it's worth the churn?

On the other hand, doing the sum gets more expensive, do we care? How expensive is it?

Such a discussion should ideally be part of this change log.

"I'm not sure if it makes sense" -- you tell us, how did you come up with the idea? :)

--
Cheers,

David / dhildenb