Re: [PATCH] sched/numa: Fix NULL pointer access to mm_struct durng task swap
From: Libo Chen
Date: Thu Jul 03 2025 - 08:27:26 EST
On 7/3/25 05:04, Chen, Yu C wrote:
> On 7/3/2025 8:01 PM, Michal Hocko wrote:
>> On Thu 03-07-25 13:50:06, Peter Zijlstra wrote:
>>> On Thu, Jul 03, 2025 at 11:28:46AM +0200, Michal Hocko wrote:
>>>
>>>> But thinking about this some more, this would be racy same as the
>>>> PF_EXITING check. This is not my area but is this performance sensitive
>>>> path that couldn't live with the proper find_lock_task_mm?
>>>
>>> find_lock_task_mm() seems eminently unsuitable for accounting --
>>> iterating the task group is insane.
>>>
>>> Looking at this, the mm_struct lifetimes suck.. task_struct reference
>>> doesn't help, rcu doesn't help :-(
>>>
>>> Also, whatever the solution it needs to be inside this count_memcg_*()
>>> nonsense, because nobody wants this overhead, esp. not for something
>>> daft like accounting.
>>>
>>> My primary desire at this point is to just revert the patch that caused
>>> this. Accounting just isn't worth it. Esp. not since there is already a
>>> tracepoint in this path -- people that want to count crap can very well
>>> get their numbers from that.
>>
>> I would tend to agree with this. Doing the accounting race free on a
>> remote task is nasty and if this is a rare event that could be avoided
>> then it should be just dropped than racy and oops prone.
>>
>
> OK, Michal and Peter,
> how about keeping the per task schedstat and drop the memcg statistics?
> The user can still get the per task information without having to filter
> the ftrace log.
>
I agree. The other parts, schedstat and vmstat, are still quite helpful.
Also tracepoints are more expensive than counters once enabled, I think
that's too much for just counting numbers.
Libo
> thanks,
> Chenyu