Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3203465ybd; Mon, 24 Jun 2019 21:40:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxw/I7MiuRW0hCj3q8YfVC3J4+1WvXaPF/RVUdkXHmBMvrvngV5gOo5Qm83Ji4udHxAP8H/ X-Received: by 2002:a65:42cd:: with SMTP id l13mr35927572pgp.72.1561437632924; Mon, 24 Jun 2019 21:40:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561437632; cv=none; d=google.com; s=arc-20160816; b=M6tAAYJP7/3eJKx3ecBpakuZ4TQ025YsC8PtY0gTrhH1pUgaSUucoknYmvT5RKiG9/ PKpdPuuXTskVo7eqJguEC0+A76WJcZhwsmUbXsUzFVuEBsbQWFGngflEaFWp+Wy9PYkW sj5RTCxpnzASS2nSpdDuiGUlHgopy8ILi6gNblI6ngiuvNCen7q+vS38mLyCEP1o5pVI p9kOPyUUdWMuUNXiV5h1qM4ratx3meTeuh2y+Nu6hrre1uLxydwbhvQ6M4wOcif+g8lq 3iJAfWhM0Rvo5UX3ZrRSQMWNke5j8pfE/10lmD6yeovTWGJ/pijI1g8NY02Zzz7bWROS VXcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from; bh=e9HnZBtUfSwt5Nr8iE/+surgLphWWAHVHKYKebNrHuo=; b=Wi2Y41kvvCf4UvvvQM/P/RUs1ZAU5UNIkJqC/NkmXruQGfY6nxSl1LqF1dFAbiip49 +5PT0ShP3bn23+hTVgDoHy2yckwTy/QpuWFkG90vOxFug9KCpF6UjuDcFTgAGc0QKt/r 98so0Q1zItgbhQayUCLjFPdZI5ldsR02exudrgDc2LCayYesTjQTfxmxVjrIdm+Ewa4T PE1QxS5pYbxwgGfEzkrSyZTFoq+8gppavlM8XA1hchfA1lqV1OCXW9RapYlrnWWrUpGh skHy09WpULfY9XFRa89Fka4KVT0V92vEZcFlrDiyb8k0+iapi1e3x/GSBtYGh6DBx2Lk fAQg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v25si12715750pff.274.2019.06.24.21.40.17; Mon, 24 Jun 2019 21:40:32 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727362AbfFYEiJ (ORCPT + 99 others); Tue, 25 Jun 2019 00:38:09 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:23186 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726856AbfFYEhj (ORCPT ); Tue, 25 Jun 2019 00:37:39 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5P4Xulq009021 for ; Tue, 25 Jun 2019 00:37:38 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2tb9r3wshm-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Jun 2019 00:37:37 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 25 Jun 2019 05:37:36 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 25 Jun 2019 05:37:32 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x5P4bV3B56688656 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2019 04:37:31 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C517011C04C; Tue, 25 Jun 2019 04:37:31 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 936B411C04A; Tue, 25 Jun 2019 04:37:30 +0000 (GMT) Received: from localhost.in.ibm.com (unknown [9.124.35.87]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Jun 2019 04:37:30 +0000 (GMT) From: Parth Shah To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: mingo@redhat.com, peterz@infradead.org, dietmar.eggemann@arm.com, patrick.bellasi@arm.com Subject: [RFCv3 2/8] sched: Introduce switch to enable TurboSched mode Date: Tue, 25 Jun 2019 10:07:20 +0530 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190625043726.21490-1-parth@linux.ibm.com> References: <20190625043726.21490-1-parth@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19062504-0028-0000-0000-0000037D46BF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19062504-0029-0000-0000-0000243D6686 Message-Id: <20190625043726.21490-3-parth@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-25_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906250036 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch creates a static key which allows to enable or disable TurboSched feature at runtime. This key is added in order to enable the TurboSched feature. The static key helps in optimizing the scheduler fast-path when the TurboSched feature is disabled. The patch also provides get/put methods to keep track of the tasks using the TurboSched feature. This allows to enable the feature on setting first task classified as jitter, similarly disable the feature on unsetting of such last task. Signed-off-by: Parth Shah --- kernel/sched/core.c | 20 ++++++++++++++++++++ kernel/sched/sched.h | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 19c7204d6351..ef83725bd4b0 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -61,6 +61,26 @@ __read_mostly int scheduler_running; */ int sysctl_sched_rt_runtime = 950000; +DEFINE_STATIC_KEY_FALSE(__turbo_sched_enabled); +static DEFINE_MUTEX(turbo_sched_lock); +static int turbo_sched_count; + +void turbo_sched_get(void) +{ + mutex_lock(&turbo_sched_lock); + if (!turbo_sched_count++) + static_branch_enable(&__turbo_sched_enabled); + mutex_unlock(&turbo_sched_lock); +} + +void turbo_sched_put(void) +{ + mutex_lock(&turbo_sched_lock); + if (!--turbo_sched_count) + static_branch_disable(&__turbo_sched_enabled); + mutex_unlock(&turbo_sched_lock); +} + /* * __task_rq_lock - lock the rq @p resides on. */ diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index e5599b33ffb8..1f239a960a6d 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2426,3 +2426,12 @@ static inline bool sched_energy_enabled(void) static inline bool sched_energy_enabled(void) { return false; } #endif /* CONFIG_ENERGY_MODEL && CONFIG_CPU_FREQ_GOV_SCHEDUTIL */ + +void turbo_sched_get(void); +void turbo_sched_put(void); +DECLARE_STATIC_KEY_FALSE(__turbo_sched_enabled); + +static inline bool is_turbosched_enabled(void) +{ + return static_branch_unlikely(&__turbo_sched_enabled); +} -- 2.17.1