Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp76403yba; Fri, 5 Apr 2019 02:18:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqysSeslo4s+Lq7qO1MFlVIj3kihf967+IqZeFsNSf6bLnc1med3gZQSK8XISP/nsg7U9kEx X-Received: by 2002:a62:ac08:: with SMTP id v8mr11200707pfe.42.1554455884958; Fri, 05 Apr 2019 02:18:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554455884; cv=none; d=google.com; s=arc-20160816; b=erj+nDVPWDUroCu/fi0ehC8bbdUkDmMU6tA9eX5HH7GRyBKOul5d/n/MAgr6gxxmdw 9rjhLYWHrv0SwrARha/q68of0/NXTIfq0KgulFvtuwl+8C3loWVdxp2ZQTrom869zXLL +E4/74GVhzULh1Gip406kxoHHOwKSKsYyiLRxK5l1HJ3U6yA7omZD4hpjfKCzHXr7rEN KO/BTA6KFD76X5g2HRRvs0h8UCvfTE/51s7bcOgrYiVPFNGJmnKn1fO2N+H43VFrJ6Qp JPfhhAnkcXzAtWypIO6p6Ve2Q35IXZ1Ps06/+qo7t16IYG80vNvSnvrV2zo3xrneZOBQ VpEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=zoO9pPIf9RouBp9jXjJJWItLV9zsh+2FmHflf1gpVxY=; b=cwl3/wnop5ruhSkqpEMU2NA8rjDr4Gsb4lUB0Mri75PmcaNPNesp2X+sS5benJdZLX uKBQ53bhpIKMBynQipiG4Tq7kwZGbZ8vDfbdn2PLu8opkP7BepbJB+jbynMKpmyxQo4G CioLn8ZE95aHhvGfSjAemOAD+DF1lpbUZk8a6+PsvcQBH3x+gI6GmxwT2n+JuxY8m4yw tj2Xba6sqWTj6Om6LIWISyG7TvzJ1siIBFn+hUh6+M0Ds3e++YnR3AvgKQXNwLq6xdzl 2uBhZfRHBP6q2pxtAn6yhqBG3nsxSAvO2XGCT+kZC5OSb24RgDtpZHWL1JdLShiMXdBf gJDg== 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 s17si4853279pfm.170.2019.04.05.02.17.49; Fri, 05 Apr 2019 02:18:04 -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 S1730466AbfDEJRL (ORCPT + 99 others); Fri, 5 Apr 2019 05:17:11 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:57316 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729728AbfDEJRK (ORCPT ); Fri, 5 Apr 2019 05:17:10 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x359BSAk052490 for ; Fri, 5 Apr 2019 05:17:09 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2rp4308k15-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 05 Apr 2019 05:17:09 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 5 Apr 2019 10:17:07 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 5 Apr 2019 10:17:04 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x359H3vO56295500 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Apr 2019 09:17:03 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9728652054; Fri, 5 Apr 2019 09:17:03 +0000 (GMT) Received: from boston16h.aus.stglabs.ibm.com (unknown [9.3.23.78]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 56E2E52067; Fri, 5 Apr 2019 09:17:02 +0000 (GMT) From: Abhishek Goel To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-pm@vger.kernel.org Cc: rjw@rjwysocki.net, daniel.lezcano@linaro.org, mpe@ellerman.id.au, ego@linux.vnet.ibm.com, Abhishek Goel Subject: [PATCH v2 0/2] Auto-promotion logic for cpuidle states Date: Fri, 5 Apr 2019 04:16:45 -0500 X-Mailer: git-send-email 2.17.1 X-TM-AS-GCONF: 00 x-cbid: 19040509-0012-0000-0000-0000030B9169 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19040509-0013-0000-0000-00002143A4DA Message-Id: <20190405091647.4169-1-huntbag@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-04-05_06:,, 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=811 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904050068 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, the cpuidle governors (menu/ladder) determine what idle state a idling CPU should enter into based on heuristics that depend on the idle history on that CPU. Given that no predictive heuristic is perfect, there are cases where the governor predicts a shallow idle state, hoping that the CPU will be busy soon. However, if no new workload is scheduled on that CPU in the near future, the CPU will end up in the shallow state. Motivation ---------- In case of POWER, this is problematic, when the predicted state in the aforementioned scenario is a lite stop state, as such lite states will inhibit SMT folding, thereby depriving the other threads in the core from using the core resources. To address this, such lite states need to be autopromoted. The cpuidle-core can queue timer to correspond with the residency value of the next available state. Thus leading to auto-promotion to a deeper idle state as soon as possible. Experiment ---------- I performed experiments for three scenarios to collect some data. case 1 : Without this patch and without tick retained, i.e. in a upstream kernel, It would spend more than even a second to get out of stop0_lite. case 2 : With tick retained(as suggested) - Generally, we have a sched tick at 4ms(CONF_HZ = 250). Ideally I expected it to take 8 sched tick to get out of stop0_lite. Experimentally, observation was ========================================================= sample min max 99percentile 20 4ms 12ms 4ms ========================================================= *ms = milliseconds It would take atleast one sched tick to get out of stop0_lite. case 2 : With this patch (not stopping tick, but explicitly queuing a timer) ============================================================ sample min max 99percentile ============================================================ 20 144us 192us 144us ============================================================ *us = microseconds In this patch, we queue a timer just before entering into a stop0_lite state. The timer fires at (residency of next available state + exit latency of next available state * 2). Let's say if next state(stop0) is available which has residency of 20us, it should get out in as low as (20+2*2)*8 [Based on the forumla (residency + 2xlatency)*history length] microseconds = 192us. Ideally we would expect 8 iterations, it was observed to get out in 6-7 iterations. Even if let's say stop2 is next available state(stop0 and stop1 both are unavailable), it would take (100+2*10)*8 = 960us to get into stop2. So, We are able to get out of stop0_lite generally in 150us(with this patch) as compared to 4ms(with tick retained). As stated earlier, we do not want to get stuck into stop0_lite as it inhibits SMT folding for other sibling threads, depriving them of core resources. Current patch is using auto-promotion only for stop0_lite, as it gives performance benefit(primary reason) along with lowering down power consumption. We may extend this model for other states in future. Abhishek Goel (2): cpuidle : auto-promotion for cpuidle states cpuidle : Add auto-promotion flag to cpuidle flags arch/powerpc/include/asm/opal-api.h | 1 + drivers/cpuidle/Kconfig | 4 ++ drivers/cpuidle/cpuidle-powernv.c | 13 +++++- drivers/cpuidle/cpuidle.c | 68 ++++++++++++++++++++++++++++- drivers/cpuidle/governors/ladder.c | 3 +- drivers/cpuidle/governors/menu.c | 22 +++++++++- include/linux/cpuidle.h | 10 ++++- 7 files changed, 115 insertions(+), 6 deletions(-) -- 2.17.1