Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp978256ybl; Wed, 4 Dec 2019 14:26:17 -0800 (PST) X-Google-Smtp-Source: APXvYqx6hZoBgd9LS/f3rfh/4KqFcCqs5qrRXAc4oO2vYLQ7ywHPi2mf3vDb8gpFEUwAqKIbIpvz X-Received: by 2002:aca:c256:: with SMTP id s83mr3817466oif.57.1575498377565; Wed, 04 Dec 2019 14:26:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575498377; cv=none; d=google.com; s=arc-20160816; b=idsbqs8hjeHM4hXutFYGuJwuQeeJIX6BtfvDQZ8kSBLRXIkcsxzu9yHWYIghKwSeIl 0O+HHgSsyAVd29/HvaXie16kp6cI5X12pA4C7yzO7sj4x0bPuV2/ExmtvAlCGiMEBZsU 7gz+YURHhtLGN0p3XFsZV16J44hXR2q8DAPp3z6p832E4HQW9XDq0ZJVUGJnV6fVUFzI XGYM3Bth2VJ9qvwYjuQb8pF3f6inTR6kWqeUGFg1eKh+2BJmZYtp07xENnNzLmv0RqW3 9I8j9q9gIXtYNkc+s2HwHrKoc7f+Cyz+3xYYD6P3i4dw9Tk4booPhcteg6VqGjNvO1vR htjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=hCIUfL5kWfyzYUBBW/W8eRI+GRlqjiz4D1oMs3XbSW8=; b=WpmpXTCCoWw7oEyVi4wa8nPynQa3DsD/DN1xeUZp4gSFNiivAD141xKDHuHJkhSABq 3EDDr+eQU5pbWzgPLQhhiYpO3J1DvOet4jGki9VUuIEEDg8MyMSuiYG5aNKPT329pcr9 QAIDRTlf/0P7k5ICWGz8AhEXhvsC9JKNF5DS92O8IjSutl6LvKFED90PXETAXJ6V3QNq ZwzmJjd0eQkqe5Fc/PvL5EZfOhfutCkr+hw0DraU/2g0oG5JHrLPG8z3aQmtVRjV3PNo qGODMFRB7OaWML8812x6gyy0+ibn3t0dSlD8nIxt+8kG+bxU8n59nbKwkvi97WOqvxCm 2biA== 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 k23si4167498otp.181.2019.12.04.14.26.04; Wed, 04 Dec 2019 14:26:17 -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 S1728407AbfLDWZE (ORCPT + 99 others); Wed, 4 Dec 2019 17:25:04 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:18914 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728053AbfLDWZE (ORCPT ); Wed, 4 Dec 2019 17:25:04 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xB4MILax021525; Wed, 4 Dec 2019 17:24:55 -0500 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0b-001b2d01.pphosted.com with ESMTP id 2wnsd5sc28-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Dec 2019 17:24:54 -0500 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id xB4MOoIm001860; Wed, 4 Dec 2019 22:24:54 GMT Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by ppma04dal.us.ibm.com with ESMTP id 2wkg27bfe3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Dec 2019 22:24:54 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xB4MOri634865646 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Dec 2019 22:24:53 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 55ABDBE04F; Wed, 4 Dec 2019 22:24:53 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3BE03BE054; Wed, 4 Dec 2019 22:24:53 +0000 (GMT) Received: from localhost (unknown [9.41.179.251]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 4 Dec 2019 22:24:53 +0000 (GMT) From: Nathan Lynch To: "Gautham R. Shenoy" Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Michael Ellerman , Vaidyanathan Srinivasan , Kamalesh Babulal , "Naveen N. Rao" , Tyrel Datwyler Subject: Re: [PATCH 1/3] powerpc/pseries: Account for SPURR ticks on idle CPUs In-Reply-To: <1574856072-30972-2-git-send-email-ego@linux.vnet.ibm.com> References: <1574856072-30972-1-git-send-email-ego@linux.vnet.ibm.com> <1574856072-30972-2-git-send-email-ego@linux.vnet.ibm.com> Date: Wed, 04 Dec 2019 16:24:52 -0600 Message-ID: <87o8wnu3t7.fsf@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-12-04_03:2019-12-04,2019-12-04 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 spamscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 impostorscore=0 suspectscore=1 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1912040185 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "Gautham R. Shenoy" writes: > diff --git a/arch/powerpc/kernel/idle.c b/arch/powerpc/kernel/idle.c > index a36fd05..708ec68 100644 > --- a/arch/powerpc/kernel/idle.c > +++ b/arch/powerpc/kernel/idle.c > @@ -33,6 +33,8 @@ > unsigned long cpuidle_disable = IDLE_NO_OVERRIDE; > EXPORT_SYMBOL(cpuidle_disable); > > +DEFINE_PER_CPU(u64, idle_spurr_cycles); > + Does idle_spurr_cycles need any special treatment for CPU online/offline? > static int __init powersave_off(char *arg) > { > ppc_md.power_save = NULL; > diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c > index 74c2479..45e2be4 100644 > --- a/drivers/cpuidle/cpuidle-pseries.c > +++ b/drivers/cpuidle/cpuidle-pseries.c > @@ -30,11 +30,14 @@ struct cpuidle_driver pseries_idle_driver = { > static struct cpuidle_state *cpuidle_state_table __read_mostly; > static u64 snooze_timeout __read_mostly; > static bool snooze_timeout_en __read_mostly; > +DECLARE_PER_CPU(u64, idle_spurr_cycles); This belongs in a header... > -static inline void idle_loop_prolog(unsigned long *in_purr) > +static inline void idle_loop_prolog(unsigned long *in_purr, > + unsigned long *in_spurr) > { > ppc64_runlatch_off(); > *in_purr = mfspr(SPRN_PURR); > + *in_spurr = mfspr(SPRN_SPURR); > /* > * Indicate to the HV that we are idle. Now would be > * a good time to find other work to dispatch. > @@ -42,13 +45,16 @@ static inline void idle_loop_prolog(unsigned long *in_purr) > get_lppaca()->idle = 1; > } > > -static inline void idle_loop_epilog(unsigned long in_purr) > +static inline void idle_loop_epilog(unsigned long in_purr, > + unsigned long in_spurr) > { > u64 wait_cycles; > + u64 *idle_spurr_cycles_ptr = this_cpu_ptr(&idle_spurr_cycles); > > wait_cycles = be64_to_cpu(get_lppaca()->wait_state_cycles); > wait_cycles += mfspr(SPRN_PURR) - in_purr; > get_lppaca()->wait_state_cycles = cpu_to_be64(wait_cycles); > + *idle_spurr_cycles_ptr += mfspr(SPRN_SPURR) - in_spurr; ... and the sampling and increment logic probably should be further encapsulated in accessor functions that can be used in both the cpuidle driver and the default/generic idle implementation. Or is there some reason this is specific to the pseries cpuidle driver?