Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2095315ybv; Fri, 21 Feb 2020 08:48:20 -0800 (PST) X-Google-Smtp-Source: APXvYqzi98yGvtviOnC3Zi0q0hQtCCvbeTuCOqm8YTVAg/qP9FdSkpVp7COC9a/X/1ezhlAhAdUs X-Received: by 2002:a05:6830:1047:: with SMTP id b7mr30565924otp.77.1582303700038; Fri, 21 Feb 2020 08:48:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582303700; cv=none; d=google.com; s=arc-20160816; b=uhyNVJHhfG0Us3Lrh0enP/lfUqdWyNMNbgZD40RH2qWC6RyzK/xjNWw5ufMmQe76ld +VOMU+QOsILs5Vh/G2bLDqChNPsZpYCTrg4Jwozclw8G4rjubigi/zuzssaDhpmTJY/m aJB52tFrL5Zc/knaNPs47s61BKDVZiZY2xN+1aAbr9V8qa4OzfM1rbja2Y+H6O8fjtnk oMKCjggaS5rMqVHtlbmXzw+P/gndEt9eUXrkdb1rkmEdo/516wXU5/FL25DOTcyaNQx2 Bymw1bKo4etsH0+0SOICcF4S2Ykc9EyOEdtWZoHuTadGN4V4g9A8FFnddiP1RhO7X5Yr zanw== 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=5wRkIvqHeewoRgkx2ICE5+hqflMzEh31Zy/vWVb0eBQ=; b=Nbf2SAemzFiYT0isZxrIw/0DHG9kXcM5ScQSnAL9TQr59rNl34MX4xkfptwpk7vDMb TCPf67AZJsc/m8HTv21F4NrvDfsPRqpyc3fuHg9rErUMg1v6HcKNpAJ3ZLyXxO922BBz zLaMG4+ZkiUNxTbTYbFUEVjeZBE3pr2L5AjyzAC0baM0N5gBl0IfTOgLrtAE4Ia5frKP pk5xTJJdpEEyOjRknMHXeZ9Ny0IqVbU0w3GkoijtdtHtkfXxP4mfVC7UvA3y7x6kFUy9 9gPfxlKZppP1wI5EWsyAXD5puUCDJhDmjuOPzmpb32Ncs3GXtzy+8m2+7x7NmgO3avBJ A8sQ== 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 g10si1590384otn.12.2020.02.21.08.48.01; Fri, 21 Feb 2020 08:48:20 -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 S1726762AbgBUQru (ORCPT + 99 others); Fri, 21 Feb 2020 11:47:50 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:62606 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726132AbgBUQru (ORCPT ); Fri, 21 Feb 2020 11:47:50 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 01LGigIr011113; Fri, 21 Feb 2020 11:47:44 -0500 Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 2y8ubym7gq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Feb 2020 11:47:43 -0500 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 01LGj8b7004900; Fri, 21 Feb 2020 16:47:42 GMT Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma04wdc.us.ibm.com with ESMTP id 2y68976dqq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Feb 2020 16:47:42 +0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 01LGlgtk50856246 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Feb 2020 16:47:42 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 423F6124053; Fri, 21 Feb 2020 16:47:42 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1E774124054; Fri, 21 Feb 2020 16:47:42 +0000 (GMT) Received: from localhost (unknown [9.41.179.160]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 21 Feb 2020 16:47:42 +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 v2 3/5] powerpc/pseries: Account for SPURR ticks on idle CPUs In-Reply-To: <1582262314-8319-4-git-send-email-ego@linux.vnet.ibm.com> References: <1582262314-8319-1-git-send-email-ego@linux.vnet.ibm.com> <1582262314-8319-4-git-send-email-ego@linux.vnet.ibm.com> Date: Fri, 21 Feb 2020 10:47:41 -0600 Message-ID: <87ftf3ubte.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.138,18.0.572 definitions=2020-02-21_05:2020-02-21,2020-02-21 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 phishscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 suspectscore=1 malwarescore=0 mlxlogscore=879 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002210126 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "Gautham R. Shenoy" writes: > +static inline void snapshot_spurr_idle_entry(void) > +{ > + *this_cpu_ptr(&idle_entry_spurr_snap) = mfspr(SPRN_SPURR); > +} > + [...] > +static inline void update_idle_spurr_accounting(void) > +{ > + u64 *idle_spurr_cycles_ptr = this_cpu_ptr(&idle_spurr_cycles); > + u64 in_spurr = *this_cpu_ptr(&idle_entry_spurr_snap); > + > + *idle_spurr_cycles_ptr += mfspr(SPRN_SPURR) - in_spurr; > +} [...] > +static inline u64 read_this_idle_spurr(void) > +{ > + /* > + * If we are reading from an idle context, update the > + * idle-spurr cycles corresponding to the last idle period. > + * Since the idle context is not yet over, take a fresh > + * snapshot of the idle-spurr. > + */ > + if (get_lppaca()->idle == 1) { > + update_idle_spurr_accounting(); > + snapshot_spurr_idle_entry(); This samples spurr twice when it could do with just one. I don't know the performance implications, but will the results be coherent?