Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4010227ybp; Mon, 7 Oct 2019 01:32:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwj8zsrTwT6S/Rdfg4d5wuTAAJW+7PcEe25I2eZFH8jf0PuL2vxrIhVVAYu2MXtyUe9m4aK X-Received: by 2002:a17:906:fd4:: with SMTP id c20mr22990572ejk.41.1570437126165; Mon, 07 Oct 2019 01:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570437126; cv=none; d=google.com; s=arc-20160816; b=qhlox7zFlXNPGmFbpKUOuAhR0kr/zIUCMwrh8iT6yRk/otJJb9pO1J+mknelkUjgNy 6GawUdkxS1fbeZYPDvwImwN/il6IHimfhaQlmK+B02JgaOk8ziY83jbjL7G1BCNhXwj7 wSGfpYknNIOJ/sEw+PRLDDAZ1Tejx2nCRjvySu/ZIHp9QiMXpIGzNquPkzeEL37HvECM 6D7TYA2Lc0QGkzCQSA1wC1xoiZqtG9eC1Zezc/LdjrFAuvRqj4Qh4d9Xwhs/NaTZrl5b JSlw4Rd/N5lCZNKw66DOSKw9pWPuKSxPJV5aPgHh45Efk2unUCkDQHQZTwfVOLoJOwo0 Wgjw== 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=/2R+yne8utCjrX4mFLtVKUmPgEWNt9yzlUEJ6NU3ato=; b=iA3kgGSnC8udvoaTD9s/3q8GDZ2pSwWMU734s17v0RcIpm6BbnxLYHHk2H64AvoFN0 be/UapAxnhMGKxWCIb22xmAFN8tOoUG0Yv7mQOCxGHE+obrucY4dfZv6gSHFjx4D4JpG OWb4uosR5zYENQg41SbS/JoiNBmPVXxUCTkObxemhUtB1X7Mg1/TPRTm/h+mkqFJvBZ2 nvADlP8EUzEHJEbfKtRg7MV/5fXSrV5xTZODnYxc6O74L7/I09mZMeYXzsVXTbaOtvcf FP4BR349IP2NCXoRJZjpR96HN/YrixSd15y+MF1sm+u3UpiEMG/Uhua3qboeJL8tRfJ5 WzJA== 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 i9si6735458ejy.106.2019.10.07.01.31.42; Mon, 07 Oct 2019 01:32:06 -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 S1727556AbfJGIbP (ORCPT + 99 others); Mon, 7 Oct 2019 04:31:15 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:47876 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727522AbfJGIbP (ORCPT ); Mon, 7 Oct 2019 04:31:15 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x978SLss086385 for ; Mon, 7 Oct 2019 04:31:11 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2vg1up03fd-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 07 Oct 2019 04:31:10 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 7 Oct 2019 09:31:05 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 7 Oct 2019 09:31:00 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x978Uxdt48234526 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 7 Oct 2019 08:30:59 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE1CB11C058; Mon, 7 Oct 2019 08:30:59 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6D78F11C054; Mon, 7 Oct 2019 08:30:57 +0000 (GMT) Received: from localhost.in.ibm.com (unknown [9.124.35.220]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 7 Oct 2019 08:30:57 +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, quentin.perret@arm.com, rafael.j.wysocki@intel.com, tim.c.chen@linux.intel.com, daniel.lezcano@linaro.org Subject: [RFC v5 2/6] sched: Introduce switch to enable TurboSched for task packing Date: Mon, 7 Oct 2019 14:00:47 +0530 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191007083051.4820-1-parth@linux.ibm.com> References: <20191007083051.4820-1-parth@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19100708-0016-0000-0000-000002B4C032 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19100708-0017-0000-0000-00003315D5ED Message-Id: <20191007083051.4820-3-parth@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-10-07_01:,, 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-1908290000 definitions=main-1910070088 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 | 20 ++++++++++++++++++++ kernel/sched/sched.h | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index e7cda4aa8696..ee5980b4e150 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -72,6 +72,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 802b1f3405f2..4a0b90ea8652 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2423,3 +2423,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