[Devel] [PATCH RHEL7 COMMIT] sched: Count loadavg under rq::lock in calc_load_nohz_start()

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jul 10 12:03:15 MSK 2017


Please consider to release this patch as a ReadyKernel patch.

https://readykernel.com/

--
Best regards,

Konstantin Khorenko,
Virtuozzo Linux Kernel Team

On 07/10/2017 11:59 AM, Konstantin Khorenko wrote:
> The commit is pushed to "branch-rh7-3.10.0-514.26.1.vz7.33.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
> after rh7-3.10.0-514.26.1.vz7.33.2
> ------>
> commit 60643fbff6bc70e42ae3e39b1ebaa7230f02b11f
> Author: Kirill Tkhai <ktkhai at virtuozzo.com>
> Date:   Mon Jul 10 12:59:23 2017 +0400
>
>     sched: Count loadavg under rq::lock in calc_load_nohz_start()
>
>     Since calc_load_fold_active() reads two variables (nr_running
>     and nr_uninterruptible) it may race with parallel try_to_wake_up().
>     So it must be executed under rq::lock to prevent that.
>     This seems to be the reason of negative calc_load_tasks, observed
>     on several machines.
>
>     https://jira.sw.ru/browse/PSBM-68052
>
>     Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
> ---
>  kernel/sched/core.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 0c35ee9..4befd7c 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2904,7 +2904,10 @@ void calc_load_enter_idle(void)
>  	 * We're going into NOHZ mode, if there's any pending delta, fold it
>  	 * into the pending idle delta.
>  	 */
> +
> +	raw_spin_lock(&this_rq->lock);
>  	delta = calc_load_fold_active(this_rq);
> +	raw_spin_unlock(&this_rq->lock);
>  	if (delta) {
>  		int idx = calc_load_write_idx();
>  		atomic_long_add(delta, &calc_load_idle[idx]);
> .
>


More information about the Devel mailing list