Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3360165ybl; Mon, 20 Jan 2020 22:34:24 -0800 (PST) X-Google-Smtp-Source: APXvYqwXupJxPSumJArcXYZWhpYTX8zRtLpEKu2Yim/58jx6B5s1ZJFYxFK152dJbpa4G13rVs2R X-Received: by 2002:aca:dc45:: with SMTP id t66mr1950461oig.39.1579588464648; Mon, 20 Jan 2020 22:34:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579588464; cv=none; d=google.com; s=arc-20160816; b=Nt6ZOcIPuEfyK5+DI3NfEez+uFGduij9d8Dwa6FKPtakuqQYveoRSSdsWNugM+3HJ7 Qdvk4U6eHiJ9dYHamk5HoM5Zez/oxrjyFdRsZvxnAki/HLIPkj8ys4ceryr2sa3VRzY3 iIk/Wl/YyVmwZjaECWLMdyElE5C8IXlqad2Y+8i1VNlXls/+DHz8k1BoNO32Fp2/LFv4 IhDrJUo/G2Jyk8lDqlrcTre153YIFUpa6R7hb5zTq6ZyVja4vy/4eoqY4w7jrzeb/Wbg gpCZGNLIQQfmqYncZizdJeFh4lOwicmcqFHVman2hu0BOpQ+mWRtnU3j5eL75z2ZhiQj 1/TQ== 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=rf2LaHVMSLSHUPPevsRRLGghMlaZkJKbuazasUqAB1o=; b=BfGGaWq2H12EnLo6onGtVPfNwIrcgmUet6rsq/GVF5S4wYOlK/fFDjqxJ53Ta16Ei4 bpho4XIcgHffj/Ua1oK4U+sRmkeRI/ePQA78BqSHm+J48FUP0UIoCL3Tk99ot6wi3EVU tuDT6OuhTYgHHUosunZ7vPWt54Q5i6xhySyj2nN8hLOPq1NTa4ol28H0+AYNGqzLPOfe bso8biJby1Ciw+MvvDzWe9EjaC9thgjS6bxQh/t3kMMiI634AI3BO+ZWc8AUw3eee9cv 26fv58fZo54zHKd+R7V/WZrerm47Hke0nikAkwhPXh7xy38GjIbP1RUz+mGAfNS2t/Ha PSBQ== 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 n11si20444854otq.112.2020.01.20.22.34.12; Mon, 20 Jan 2020 22:34:24 -0800 (PST) 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 S1728847AbgAUGdV (ORCPT + 99 others); Tue, 21 Jan 2020 01:33:21 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:20518 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728456AbgAUGdU (ORCPT ); Tue, 21 Jan 2020 01:33:20 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00L6WcqF010636 for ; Tue, 21 Jan 2020 01:33:19 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xmfyynnn4-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 21 Jan 2020 01:33:19 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 21 Jan 2020 06:33:17 -0000 Received: from b06avi18878370.portsmouth.uk.ibm.com (9.149.26.194) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 21 Jan 2020 06:33:13 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00L6XCuW26411448 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Jan 2020 06:33:12 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9C417A4051; Tue, 21 Jan 2020 06:33:12 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9B915A404D; Tue, 21 Jan 2020 06:33:10 +0000 (GMT) Received: from localhost.in.ibm.com (unknown [9.124.35.158]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 21 Jan 2020 06:33:10 +0000 (GMT) From: Parth Shah To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, patrick.bellasi@matbug.net, valentin.schneider@arm.com, pavel@ucw.cz, dsmythies@telus.net, qperret@google.com, tim.c.chen@linux.intel.com Subject: [RFC v6 1/5] sched: Introduce switch to enable TurboSched for task packing Date: Tue, 21 Jan 2020 12:03:03 +0530 X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200121063307.17221-1-parth@linux.ibm.com> References: <20200121063307.17221-1-parth@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 20012106-0008-0000-0000-0000034B47C1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20012106-0009-0000-0000-00004A6BAC62 Message-Id: <20200121063307.17221-2-parth@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-21_01:2020-01-20,2020-01-21 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 clxscore=1015 mlxscore=0 spamscore=0 phishscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001210056 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Create a static key which allows to enable or disable TurboSched feature at runtime. This key is added in order to enable the TurboSched feature only when required. This helps in optimizing the scheduler fast-path when the TurboSched feature is disabled. Also provide get/put methods to keep track of the tasks using the TurboSched feature and also refcount classified background tasks. This allows to enable the feature on setting first task classified as background noise, similarly disable the feature on unsetting of such last task. Signed-off-by: Parth Shah --- kernel/sched/core.c | 25 +++++++++++++++++++++++++ kernel/sched/sched.h | 12 ++++++++++++ 2 files changed, 37 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index a9e5d157b1a5..dfbb52d66b29 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -73,6 +73,31 @@ __read_mostly int scheduler_running; */ int sysctl_sched_rt_runtime = 950000; +#ifdef CONFIG_SCHED_SMT +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); +} +#else +void turbo_sched_get(void) { return ; } +void turbo_sched_get(void) { return ; } +#endif + /* * __task_rq_lock - lock the rq @p resides on. */ diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index edae9277e48d..f841297b7d56 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2497,3 +2497,15 @@ static inline void membarrier_switch_mm(struct rq *rq, { } #endif + +void turbo_sched_get(void); +void turbo_sched_put(void); + +#ifdef CONFIG_SCHED_SMT +DECLARE_STATIC_KEY_FALSE(__turbo_sched_enabled); + +static inline bool is_turbosched_enabled(void) +{ + return static_branch_unlikely(&__turbo_sched_enabled); +} +#endif -- 2.17.2