Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1822050imm; Mon, 3 Sep 2018 10:19:03 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZNM8NrgR5kf1tBi3jvdSWJTbdmFFMbNIVAAYRKlVahRCsV5PWwGtYmXmidmtHL7Z7Tcvca X-Received: by 2002:a17:902:585:: with SMTP id f5-v6mr14231675plf.7.1535995143495; Mon, 03 Sep 2018 10:19:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535995143; cv=none; d=google.com; s=arc-20160816; b=zHEsetxLbhn46lazkEqKxwryx5XEdgqfWLqrhjcsnSgWTThgo8JiEyb1yyDBEdxztT hA6+iOFiCUq3273aC/qeECx7JYVmYFm9xbIugjYkLTQ+PmFlxYlyHSg+dP4oZhvW2Lrq As86iGykZTD6t/Eq9cxl1yMMYafzKYEvjmyp5gKfEPwnq84xPKYWR5AdhCZCOJs4koz3 alcpjJOQH7voiPU6emKQ+tn1QzIMPY55i/2TvMsVhLzm6XWzTdzY7twtr3pFWYYHdjwb Pzg9Sj8jIzHP689COV7AOCoi2Tix00KPQfeL73dxhJ4mS1mO/p4Sg1XF3cTOOGRpGy/J UOvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=e9lQWqO6br0Rj1Opibd2nF3tL4ZGin7PFEMozICiIRQ=; b=DTlDAJVEeEzSoCzu+em1cZrBq/H+IxeQEkIhYh0+YiQxg+pLYmnn63h9YjpZXvGIFK d+ZsarTTnLw0rFYWPBycbN9hZqTt8D3gJ4PtEwbUGdhsiXroAC0V+2ZlundPxnyVXHzp ijH6L5TnCa6DZiRLDGCLe0klv9q6wYZZrWHEPCwjwadFGKrmeEqV0YZ1B1J4z39EwXyv QKNb4sBREUjXpmF4C8UV1aiJ/c5tYdq66XAEuunET/+ymlPctq1IPGUh7grDA+nHUZh3 IB1/tqoio8DxdF5hmhp38bQOOvHKuf0bykzAKw8kTgJFLhY+U6mqfkl/+B/lCg/o+bMB ve0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i33-v6si6613455pld.306.2018.09.03.10.18.48; Mon, 03 Sep 2018 10:19:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730216AbeICViu (ORCPT + 99 others); Mon, 3 Sep 2018 17:38:50 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42892 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728239AbeICViu (ORCPT ); Mon, 3 Sep 2018 17:38:50 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9BF7FD13; Mon, 3 Sep 2018 17:17:44 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hailong Liu , Jiang Biao , "Peter Zijlstra (Intel)" , Linus Torvalds , Thomas Gleixner , zhong.weidong@zte.com.cn, Ingo Molnar , Sasha Levin Subject: [PATCH 4.14 049/165] sched/rt: Restore rt_runtime after disabling RT_RUNTIME_SHARE Date: Mon, 3 Sep 2018 18:55:35 +0200 Message-Id: <20180903165657.584723037@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165655.003605184@linuxfoundation.org> References: <20180903165655.003605184@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hailong Liu [ Upstream commit f3d133ee0a17d5694c6f21873eec9863e11fa423 ] NO_RT_RUNTIME_SHARE feature is used to prevent a CPU borrow enough runtime with a spin-rt-task. However, if RT_RUNTIME_SHARE feature is enabled and rt_rq has borrowd enough rt_runtime at the beginning, rt_runtime can't be restored to its initial bandwidth rt_runtime after we disable RT_RUNTIME_SHARE. E.g. on my PC with 4 cores, procedure to reproduce: 1) Make sure RT_RUNTIME_SHARE is enabled cat /sys/kernel/debug/sched_features GENTLE_FAIR_SLEEPERS START_DEBIT NO_NEXT_BUDDY LAST_BUDDY CACHE_HOT_BUDDY WAKEUP_PREEMPTION NO_HRTICK NO_DOUBLE_TICK LB_BIAS NONTASK_CAPACITY TTWU_QUEUE NO_SIS_AVG_CPU SIS_PROP NO_WARN_DOUBLE_CLOCK RT_PUSH_IPI RT_RUNTIME_SHARE NO_LB_MIN ATTACH_AGE_LOAD WA_IDLE WA_WEIGHT WA_BIAS 2) Start a spin-rt-task ./loop_rr & 3) set affinity to the last cpu taskset -p 8 $pid_of_loop_rr 4) Observe that last cpu have borrowed enough runtime. cat /proc/sched_debug | grep rt_runtime .rt_runtime : 950.000000 .rt_runtime : 900.000000 .rt_runtime : 950.000000 .rt_runtime : 1000.000000 5) Disable RT_RUNTIME_SHARE echo NO_RT_RUNTIME_SHARE > /sys/kernel/debug/sched_features 6) Observe that rt_runtime can not been restored cat /proc/sched_debug | grep rt_runtime .rt_runtime : 950.000000 .rt_runtime : 900.000000 .rt_runtime : 950.000000 .rt_runtime : 1000.000000 This patch help to restore rt_runtime after we disable RT_RUNTIME_SHARE. Signed-off-by: Hailong Liu Signed-off-by: Jiang Biao Signed-off-by: Peter Zijlstra (Intel) Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: zhong.weidong@zte.com.cn Link: http://lkml.kernel.org/r/1531874815-39357-1-git-send-email-liu.hailong6@zte.com.cn Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- kernel/sched/rt.c | 2 ++ 1 file changed, 2 insertions(+) --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -837,6 +837,8 @@ static int do_sched_rt_period_timer(stru * can be time-consuming. Try to avoid it when possible. */ raw_spin_lock(&rt_rq->rt_runtime_lock); + if (!sched_feat(RT_RUNTIME_SHARE) && rt_rq->rt_runtime != RUNTIME_INF) + rt_rq->rt_runtime = rt_b->rt_runtime; skip = !rt_rq->rt_time && !rt_rq->rt_nr_running; raw_spin_unlock(&rt_rq->rt_runtime_lock); if (skip)