zhong jiang <zhongjiang-ali(a)linux.alibaba.com> writes:
On 2022/1/13 4:13 H, Huang, Ying wrote:
zhong jiang
<zhongjiang-ali(a)linux.alibaba.com> writes:
On 2022/1/13 9:02 H, Huang, Ying wrote:
zhong jiang
<zhongjiang-ali(a)linux.alibaba.com> writes:
> Read tthe patch again, see the following issue.
>
> On 2022/1/12 11:02
H, Huang, Ying wrote:
>> Hi, Jiang,
>>
>> I failed to reproduce the bug on my side. Could you help me to test
>> whether the below patch can fix the bug?
>>
>> Best Regards,
>> Huang, Ying
>>
>> ------------------------------8<----------------------------------------
>> From 919db496945d45e2c593470ce84f5d6c50ae95a8 Mon Sep 17 00:00:00 2001
>> From: Huang Ying <ying.huang(a)intel.com>
>> Date: Mon, 10 Jan 2022 15:29:38 +0800
>> Subject: [PATCH] Fix panic when disabling memory tiering mode dynamically
>>
>> ---
>> include/linux/mm.h | 5 +++++
>> kernel/sched/fair.c | 20 +++++++++++++++++---
>> 2 files changed, 22 insertions(+), 3 deletions(-)
>>
>> diff --git a/include/linux/mm.h b/include/linux/mm.h
>> index a9ea778eafe0..b22e18676d29 100644
>> --- a/include/linux/mm.h
>> +++ b/include/linux/mm.h
>> @@ -1440,6 +1440,11 @@ static inline bool __cpupid_match_pid(pid_t task_pid, int
cpupid)
>> return (task_pid & LAST__PID_MASK) == cpupid_to_pid(cpupid);
>> }
>> +static inline bool check_cpupid(int cpupid)
>> +{
>> + return cpupid_to_cpu(cpupid) >= nr_cpumask_bits;
>> +}
>> +
> Oops. s/>=/</
Oops! Thanks for pointing this out. Have you tested your revised version?
I
think nr_cpumask_bits should be replaced with
num_possible_cpus(), We should can not parse the cpu beyond
max_possible_cpus , is it right ?
If my understanding to the following code were
correct, they are same in
most situations,
but It will make nr_cpumask_bits equal to NR_CPUS when
CONFIG_CPUMASK_OFFSTACK=n.
The cpu excess nr_cpu_ids should has the some issue.
It seems that nr_cpu_ids is the right choice. Yes?
Best Regards,
Huang, Ying
> void __init setup_nr_cpu_ids(void)
> {
> nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),NR_CPUS) + 1;
> }
>
> And in theory, it's possible that there are "holes" in
cpu_possible_mask.
>
> Best Regards,
> Huang, Ying
>
>> Thanks,
>>
>> zhong jiang
>>
>>> Best Regards,
>>> Huang, Ying
>>>
>>>>> #define cpupid_match_pid(task, cpupid)
__cpupid_match_pid(task->pid, cpupid)
>>>>> #ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS
>>>>> static inline int page_cpupid_xchg_last(struct page *page, int
cpupid)
>>>>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>>>>> index 7ca4ab033180..85a01906d796 100644
>>>>> --- a/kernel/sched/fair.c
>>>>> +++ b/kernel/sched/fair.c
>>>>> @@ -1597,6 +1597,14 @@ bool should_numa_migrate_memory(struct
task_struct *p, struct page * page,
>>>>> this_cpupid = cpu_pid_to_cpupid(dst_cpu, current->pid);
>>>>> last_cpupid = page_cpupid_xchg_last(page, this_cpupid);
>>>>> + /*
>>>>> + * The cpupid may be invalid when NUMA_BALANCING_MEMORY_TIERING
>>>>> + * is disabled dynamically.
>>>>> + */
>>>>> + if (!(sysctl_numa_balancing_mode &
NUMA_BALANCING_MEMORY_TIERING) &&
>>>>> + !node_is_toptier(src_nid) &&
!check_cpupid(last_cpupid))
>>>>> + return false;
>>>>> +
>>>>> /*
>>>>> * Allow first faults or private faults to migrate immediately
early in
>>>>> * the lifetime of a task. The magic number 4 is based on
waiting for
>>>>> @@ -2812,9 +2820,15 @@ void task_numa_fault(int last_cpupid, int
mem_node, int pages, int flags)
>>>>> if (!p->mm)
>>>>> return;
>>>>> - /* Numa faults statistics are unnecessary for the slow memory
>>>>> node */
>>>>> - if (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING
&&
>>>>> - !node_is_toptier(mem_node))
>>>>> + /*
>>>>> + * NUMA faults statistics are unnecessary for the slow memory
node.
>>>>> + *
>>>>> + * And, the cpupid may be invalid when
NUMA_BALANCING_MEMORY_TIERING
>>>>> + * is disabled dynamically.
>>>>> + */
>>>>> + if (!node_is_toptier(mem_node) &&
>>>>> + (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING
||
>>>>> + !check_cpupid(last_cpupid)))
>>>>> return;
>>>>> /* Allocate buffer to track faults on a per-node basis */
>>>> _______________________________________________
>>>> Pmem mailing list -- pmem(a)lists.openanolis.cn
>>>> To unsubscribe send an email to pmem-leave(a)lists.openanolis.cn