[Devel] [PATCH vz8 v2] kernel/sched/fair.c: Add more missing update_rq_clock() calls

2020-09-29 Thread Andrey Ryabinin
Add update_rq_clock() for 'target_rq' to avoid WARN() coming
from attach_task(). Also add rq_repin_lock(busiest, &rf); in
load_balance() for detach_task(). The update_rq_clock() isn't
necessary since it was updated before, but we need the repin
since rq lock was released after update.

https://jira.sw.ru/browse/PSBM-108013
Reported-by: Kirill Tkhai 
Signed-off-by: Andrey Ryabinin 
---
 kernel/sched/fair.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index e6dc21d5fa03..fc87dee4fd0e 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7817,6 +7817,7 @@ static int cpulimit_balance_cpu_stop(void *data)
schedstat_inc(sd->clb_count);
 
update_rq_clock(rq);
+   update_rq_clock(target_rq);
if (do_cpulimit_balance(&env))
schedstat_inc(sd->clb_pushed);
else
@@ -9177,6 +9178,7 @@ static int load_balance(int this_cpu, struct rq *this_rq,
env.loop = 0;
local_irq_save(rf.flags);
double_rq_lock(env.dst_rq, busiest);
+   rq_repin_lock(env.src_rq, &rf);
update_rq_clock(env.dst_rq);
cur_ld_moved = ld_moved = move_task_groups(&env);
double_rq_unlock(env.dst_rq, busiest);
-- 
2.26.2

___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


Re: [Devel] [PATCH vz8 v2] kernel/sched/fair.c: Add more missing update_rq_clock() calls

2020-09-29 Thread Kirill Tkhai
On 29.09.2020 18:32, Andrey Ryabinin wrote:
> Add update_rq_clock() for 'target_rq' to avoid WARN() coming
> from attach_task(). Also add rq_repin_lock(busiest, &rf); in
> load_balance() for detach_task(). The update_rq_clock() isn't
> necessary since it was updated before, but we need the repin
> since rq lock was released after update.
> 
> https://jira.sw.ru/browse/PSBM-108013
> Reported-by: Kirill Tkhai 
> Signed-off-by: Andrey Ryabinin 

Acked-by: Kirill Tkhai 

> ---
>  kernel/sched/fair.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index e6dc21d5fa03..fc87dee4fd0e 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -7817,6 +7817,7 @@ static int cpulimit_balance_cpu_stop(void *data)
>   schedstat_inc(sd->clb_count);
>  
>   update_rq_clock(rq);
> + update_rq_clock(target_rq);
>   if (do_cpulimit_balance(&env))
>   schedstat_inc(sd->clb_pushed);
>   else
> @@ -9177,6 +9178,7 @@ static int load_balance(int this_cpu, struct rq 
> *this_rq,
>   env.loop = 0;
>   local_irq_save(rf.flags);
>   double_rq_lock(env.dst_rq, busiest);
> + rq_repin_lock(env.src_rq, &rf);
>   update_rq_clock(env.dst_rq);
>   cur_ld_moved = ld_moved = move_task_groups(&env);
>   double_rq_unlock(env.dst_rq, busiest);
> 

___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


Re: [Devel] [PATCH vz8] kernel/sched/fair.c: Add more missing update_rq_clock() calls

2020-09-29 Thread Kirill Tkhai
On 29.09.2020 16:55, Andrey Ryabinin wrote:
> Add update_rq_clock() for 'target_rq' to avoid WARN() coming
> from attach_task(). Also add update_rq_clock(env.src_rq); in
> load_balance() for detach_task().
> 
> https://jira.sw.ru/browse/PSBM-108013
> Reported-by: Kirill Tkhai 
> Signed-off-by: Andrey Ryabinin 
> ---
>  kernel/sched/fair.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index e6dc21d5fa03..99dcb9e77efd 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -7817,6 +7817,7 @@ static int cpulimit_balance_cpu_stop(void *data)
>   schedstat_inc(sd->clb_count);
>  
>   update_rq_clock(rq);
> + update_rq_clock(target_rq);
>   if (do_cpulimit_balance(&env))
>   schedstat_inc(sd->clb_pushed);
>   else
> @@ -9177,6 +9178,7 @@ static int load_balance(int this_cpu, struct rq 
> *this_rq,
>   env.loop = 0;
>   local_irq_save(rf.flags);
>   double_rq_lock(env.dst_rq, busiest);
> + update_rq_clock(env.src_rq);

Fortunately, we may avoid update_rq_clock here, since srq_rq clock are already 
updated.
Also, I'm afraid this will bring to SCHED_WARN_ON(rq->clock_update_flags & 
RQCF_UPDATED)
in this function. It looks we should use rq_repin_lock() here instead:

@@ -9177,6 +9177,7 @@ static int load_balance(int this_cpu, struct rq *this_rq,
env.loop = 0;
local_irq_save(rf.flags);
double_rq_lock(env.dst_rq, busiest);
+   rq_repin_lock(rq, &rf);
update_rq_clock(env.dst_rq);
cur_ld_moved = ld_moved = move_task_groups(&env);
double_rq_unlock(env.dst_rq, busiest);

>   update_rq_clock(env.dst_rq);
>   cur_ld_moved = ld_moved = move_task_groups(&env);
>   double_rq_unlock(env.dst_rq, busiest);
> 

___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH vz8] kernel/sched/fair.c: Add more missing update_rq_clock() calls

2020-09-29 Thread Andrey Ryabinin
Add update_rq_clock() for 'target_rq' to avoid WARN() coming
from attach_task(). Also add update_rq_clock(env.src_rq); in
load_balance() for detach_task().

https://jira.sw.ru/browse/PSBM-108013
Reported-by: Kirill Tkhai 
Signed-off-by: Andrey Ryabinin 
---
 kernel/sched/fair.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index e6dc21d5fa03..99dcb9e77efd 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7817,6 +7817,7 @@ static int cpulimit_balance_cpu_stop(void *data)
schedstat_inc(sd->clb_count);
 
update_rq_clock(rq);
+   update_rq_clock(target_rq);
if (do_cpulimit_balance(&env))
schedstat_inc(sd->clb_pushed);
else
@@ -9177,6 +9178,7 @@ static int load_balance(int this_cpu, struct rq *this_rq,
env.loop = 0;
local_irq_save(rf.flags);
double_rq_lock(env.dst_rq, busiest);
+   update_rq_clock(env.src_rq);
update_rq_clock(env.dst_rq);
cur_ld_moved = ld_moved = move_task_groups(&env);
double_rq_unlock(env.dst_rq, busiest);
-- 
2.26.2

___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


Re: [Devel] [PATCH v2 vz8] kernel/sched/fair.c: Add missing update_rq_clock() calls

2020-09-29 Thread Kirill Tkhai
On 29.09.2020 15:07, Andrey Ryabinin wrote:
> 
> 
> On 9/29/20 11:24 AM, Kirill Tkhai wrote:
>> On 28.09.2020 15:03, Andrey Ryabinin wrote:
>>> We've got a hard lockup which seems to be caused by mgag200
>>> console printk code calling to schedule_work from scheduler
>>> with rq->lock held:
>>>   #5 [b79e034239a8] native_queued_spin_lock_slowpath at 8b50c6c6
>>>   #6 [b79e034239a8] _raw_spin_lock at 8bc96e5c
>>>   #7 [b79e034239b0] try_to_wake_up at 8b4e26ff
>>>   #8 [b79e03423a10] __queue_work at 8b4ce3f3
>>>   #9 [b79e03423a58] queue_work_on at 8b4ce714
>>>  #10 [b79e03423a68] mga_imageblit at c026d666 [mgag200]
>>>  #11 [b79e03423a80] soft_cursor at 8b8a9d84
>>>  #12 [b79e03423ad8] bit_cursor at 8b8a99b2
>>>  #13 [b79e03423ba0] hide_cursor at 8b93bc7a
>>>  #14 [b79e03423bb0] vt_console_print at 8b93e07d
>>>  #15 [b79e03423c18] console_unlock at 8b518f0e
>>>  #16 [b79e03423c68] vprintk_emit_log at 8b51acf7
>>>  #17 [b79e03423cc0] vprintk_default at 8b51adcd
>>>  #18 [b79e03423cd0] printk at 8b51b3d6
>>>  #19 [b79e03423d30] __warn_printk at 8b4b13a0
>>>  #20 [b79e03423d98] assert_clock_updated at 8b4dd293
>>>  #21 [b79e03423da0] deactivate_task at 8b4e12d1
>>>  #22 [b79e03423dc8] move_task_group at 8b4eaa5b
>>>  #23 [b79e03423e00] cpulimit_balance_cpu_stop at 8b4f02f3
>>>  #24 [b79e03423eb0] cpu_stopper_thread at 8b576b67
>>>  #25 [b79e03423ee8] smpboot_thread_fn at 8b4d9125
>>>  #26 [b79e03423f10] kthread at 8b4d4fc2
>>>  #27 [b79e03423f50] ret_from_fork at 8be00255
>>>
>>> The printk called because assert_clock_updated() triggered
>>> SCHED_WARN_ON(rq->clock_update_flags < RQCF_ACT_SKIP);
>>>
>>> This means that we missing necessary update_rq_clock() call.
>>> Add one to cpulimit_balance_cpu_stop() to fix the warning.
>>> Also add one in load_balance() before move_task_groups() call.
>>> It seems to be another place missing this call.
>>>
>>> https://jira.sw.ru/browse/PSBM-108013
>>> Signed-off-by: Andrey Ryabinin 
>>> ---
>>>  kernel/sched/fair.c | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>>> index 5d3556b15e70..e6dc21d5fa03 100644
>>> --- a/kernel/sched/fair.c
>>> +++ b/kernel/sched/fair.c
>>> @@ -7816,6 +7816,7 @@ static int cpulimit_balance_cpu_stop(void *data)
>>>  
>>> schedstat_inc(sd->clb_count);
>>>  
>>> +   update_rq_clock(rq);
>>
>> Shouldn't we also add the same for target_rq to avoid WARN() coming from 
>> attach_task()?
>>
> 
> It seems like we should.

Are you going to send v3 or patch on top of this?

___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


Re: [Devel] [PATCH v2 vz8] kernel/sched/fair.c: Add missing update_rq_clock() calls

2020-09-29 Thread Andrey Ryabinin



On 9/29/20 11:24 AM, Kirill Tkhai wrote:
> On 28.09.2020 15:03, Andrey Ryabinin wrote:
>> We've got a hard lockup which seems to be caused by mgag200
>> console printk code calling to schedule_work from scheduler
>> with rq->lock held:
>>   #5 [b79e034239a8] native_queued_spin_lock_slowpath at 8b50c6c6
>>   #6 [b79e034239a8] _raw_spin_lock at 8bc96e5c
>>   #7 [b79e034239b0] try_to_wake_up at 8b4e26ff
>>   #8 [b79e03423a10] __queue_work at 8b4ce3f3
>>   #9 [b79e03423a58] queue_work_on at 8b4ce714
>>  #10 [b79e03423a68] mga_imageblit at c026d666 [mgag200]
>>  #11 [b79e03423a80] soft_cursor at 8b8a9d84
>>  #12 [b79e03423ad8] bit_cursor at 8b8a99b2
>>  #13 [b79e03423ba0] hide_cursor at 8b93bc7a
>>  #14 [b79e03423bb0] vt_console_print at 8b93e07d
>>  #15 [b79e03423c18] console_unlock at 8b518f0e
>>  #16 [b79e03423c68] vprintk_emit_log at 8b51acf7
>>  #17 [b79e03423cc0] vprintk_default at 8b51adcd
>>  #18 [b79e03423cd0] printk at 8b51b3d6
>>  #19 [b79e03423d30] __warn_printk at 8b4b13a0
>>  #20 [b79e03423d98] assert_clock_updated at 8b4dd293
>>  #21 [b79e03423da0] deactivate_task at 8b4e12d1
>>  #22 [b79e03423dc8] move_task_group at 8b4eaa5b
>>  #23 [b79e03423e00] cpulimit_balance_cpu_stop at 8b4f02f3
>>  #24 [b79e03423eb0] cpu_stopper_thread at 8b576b67
>>  #25 [b79e03423ee8] smpboot_thread_fn at 8b4d9125
>>  #26 [b79e03423f10] kthread at 8b4d4fc2
>>  #27 [b79e03423f50] ret_from_fork at 8be00255
>>
>> The printk called because assert_clock_updated() triggered
>>  SCHED_WARN_ON(rq->clock_update_flags < RQCF_ACT_SKIP);
>>
>> This means that we missing necessary update_rq_clock() call.
>> Add one to cpulimit_balance_cpu_stop() to fix the warning.
>> Also add one in load_balance() before move_task_groups() call.
>> It seems to be another place missing this call.
>>
>> https://jira.sw.ru/browse/PSBM-108013
>> Signed-off-by: Andrey Ryabinin 
>> ---
>>  kernel/sched/fair.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index 5d3556b15e70..e6dc21d5fa03 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -7816,6 +7816,7 @@ static int cpulimit_balance_cpu_stop(void *data)
>>  
>>  schedstat_inc(sd->clb_count);
>>  
>> +update_rq_clock(rq);
> 
> Shouldn't we also add the same for target_rq to avoid WARN() coming from 
> attach_task()?
> 

It seems like we should.
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


Re: [Devel] [PATCH v2 vz8] kernel/sched/fair.c: Add missing update_rq_clock() calls

2020-09-29 Thread Kirill Tkhai
On 28.09.2020 15:03, Andrey Ryabinin wrote:
> We've got a hard lockup which seems to be caused by mgag200
> console printk code calling to schedule_work from scheduler
> with rq->lock held:
>   #5 [b79e034239a8] native_queued_spin_lock_slowpath at 8b50c6c6
>   #6 [b79e034239a8] _raw_spin_lock at 8bc96e5c
>   #7 [b79e034239b0] try_to_wake_up at 8b4e26ff
>   #8 [b79e03423a10] __queue_work at 8b4ce3f3
>   #9 [b79e03423a58] queue_work_on at 8b4ce714
>  #10 [b79e03423a68] mga_imageblit at c026d666 [mgag200]
>  #11 [b79e03423a80] soft_cursor at 8b8a9d84
>  #12 [b79e03423ad8] bit_cursor at 8b8a99b2
>  #13 [b79e03423ba0] hide_cursor at 8b93bc7a
>  #14 [b79e03423bb0] vt_console_print at 8b93e07d
>  #15 [b79e03423c18] console_unlock at 8b518f0e
>  #16 [b79e03423c68] vprintk_emit_log at 8b51acf7
>  #17 [b79e03423cc0] vprintk_default at 8b51adcd
>  #18 [b79e03423cd0] printk at 8b51b3d6
>  #19 [b79e03423d30] __warn_printk at 8b4b13a0
>  #20 [b79e03423d98] assert_clock_updated at 8b4dd293
>  #21 [b79e03423da0] deactivate_task at 8b4e12d1
>  #22 [b79e03423dc8] move_task_group at 8b4eaa5b
>  #23 [b79e03423e00] cpulimit_balance_cpu_stop at 8b4f02f3
>  #24 [b79e03423eb0] cpu_stopper_thread at 8b576b67
>  #25 [b79e03423ee8] smpboot_thread_fn at 8b4d9125
>  #26 [b79e03423f10] kthread at 8b4d4fc2
>  #27 [b79e03423f50] ret_from_fork at 8be00255
> 
> The printk called because assert_clock_updated() triggered
>   SCHED_WARN_ON(rq->clock_update_flags < RQCF_ACT_SKIP);
> 
> This means that we missing necessary update_rq_clock() call.
> Add one to cpulimit_balance_cpu_stop() to fix the warning.
> Also add one in load_balance() before move_task_groups() call.
> It seems to be another place missing this call.
> 
> https://jira.sw.ru/browse/PSBM-108013
> Signed-off-by: Andrey Ryabinin 
> ---
>  kernel/sched/fair.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 5d3556b15e70..e6dc21d5fa03 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -7816,6 +7816,7 @@ static int cpulimit_balance_cpu_stop(void *data)
>  
>   schedstat_inc(sd->clb_count);
>  
> + update_rq_clock(rq);

Shouldn't we also add the same for target_rq to avoid WARN() coming from 
attach_task()?

>   if (do_cpulimit_balance(&env))
>   schedstat_inc(sd->clb_pushed);
>   else
> @@ -9176,6 +9177,7 @@ static int load_balance(int this_cpu, struct rq 
> *this_rq,
>   env.loop = 0;
>   local_irq_save(rf.flags);
>   double_rq_lock(env.dst_rq, busiest);
> + update_rq_clock(env.dst_rq);
>   cur_ld_moved = ld_moved = move_task_groups(&env);
>   double_rq_unlock(env.dst_rq, busiest);
>   local_irq_restore(rf.flags);
> 

___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH RH8] memcg: enable memory accounting for flctx_cache

2020-09-29 Thread Vasily Averin
New kernels allocates flctx_cache entries for each locked inode.
If we account memory used for filelock_cache entries it makes sense
to account flctx_cache entries too.

https://jira.sw.ru/browse/PSBM-120694
Signed-off-by: Vasily Averin 
---
 fs/locks.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/locks.c b/fs/locks.c
index 7fd8fc5afc47..0049244a2732 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -2801,7 +2801,8 @@ static int __init filelock_init(void)
int i;
 
flctx_cache = kmem_cache_create("file_lock_ctx",
-   sizeof(struct file_lock_context), 0, SLAB_PANIC, NULL);
+sizeof(struct file_lock_context), 0,
+SLAB_PANIC | SLAB_ACCOUNT, NULL);
 
filelock_cache = kmem_cache_create("file_lock_cache",
sizeof(struct file_lock), 0, SLAB_PANIC | SLAB_ACCOUNT, 
NULL);
-- 
2.17.1

___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel