Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2029922ybv; Sun, 23 Feb 2020 21:06:51 -0800 (PST) X-Google-Smtp-Source: APXvYqyG4OIGpFNLrZmMyayGsMlID4EaXrObGCyFKzV+UHGXAhUQtsReTfQQwnTrMGNMJq9hQkAY X-Received: by 2002:a9d:6f8f:: with SMTP id h15mr36426145otq.1.1582520811261; Sun, 23 Feb 2020 21:06:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582520811; cv=none; d=google.com; s=arc-20160816; b=UTWx9SaNoST3+wcxMmIkmLxa08iTAhBxVOk1tGaz2tUUOJDV/bqYbIA6LjH/63MFSM 5ZwDlRM/VA2Byxta7xQu9LUBtcdRi8SlVoUldTNHY1utVz0mXMR04R5NywOQL2XSkrYA 6mXRe2CVCH23FFIPTc2sJZJtcHei+4JFECfnMt65da2KXUjI8G61cKp9qv5rJ9pgF5Yy ioCY1layq/og2ZylmJvl9V9af0XXgj/UMM28yy4kiBrvqSPzBJ5c1b2Jb35L+0jxVxJM bEh6Pdnh2i0XcepGkobcobGfXDeAtN2+m0ZffHkXVx6xGnyyM6LV9ibCAHxcM4zPchPJ cbzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date; bh=N6VRrieugqU4AqjZX6fzh3jT5XfmlQSpMGdO6WshwNE=; b=iUKOM3AkzfB6rgaxzXLFwyVITnWgoKGRZ5haCHmgNrT8ou08wuYLFKJzGHTiui0tzz WfcUJK+pgrhpLsDjOIoQ1mRbjdHz7aSSdeVCxe2tLlN7zQBFhFLdFe/Cu5r3vvo6tzqz LhT7+hnLK060L8HWTOEmiVAaBnMqSf0bIggoG9pBYzup0CjbdrlmPAQJLWfXXg5+L34k hAwa9hrETMaHdYSkiOOtcekk7sCxq0As1vWQg7tJpO7ST7ICUqiN8H4YIMMzbN0alSpm 4oZ2P2sX/XMJgfNvM2DtPYZVe3AmXDerH+/j8VmH+Xi1ZL0sNTFAjkaQveiHKjz8K15s f+hg== 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 t28si5473119otr.16.2020.02.23.21.06.38; Sun, 23 Feb 2020 21:06:51 -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 S1726536AbgBXFFU (ORCPT + 99 others); Mon, 24 Feb 2020 00:05:20 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:26998 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725895AbgBXFFU (ORCPT ); Mon, 24 Feb 2020 00:05: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 01O54T6E064675; Mon, 24 Feb 2020 00:05:09 -0500 Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 2yb0g2txeg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Feb 2020 00:05:09 -0500 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 01O4ursG002528; Mon, 24 Feb 2020 05:05:08 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma01dal.us.ibm.com with ESMTP id 2yaux6cv8s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Feb 2020 05:05:08 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 01O557t649021264 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Feb 2020 05:05:07 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E9338136053; Mon, 24 Feb 2020 05:05:06 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AD678136055; Mon, 24 Feb 2020 05:05:06 +0000 (GMT) Received: from sofia.ibm.com (unknown [9.124.35.26]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 24 Feb 2020 05:05:06 +0000 (GMT) Received: by sofia.ibm.com (Postfix, from userid 1000) id B5CEE2E3231; Mon, 24 Feb 2020 10:35:04 +0530 (IST) Date: Mon, 24 Feb 2020 10:35:04 +0530 From: Gautham R Shenoy To: Nathan Lynch Cc: "Gautham R. Shenoy" , 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 Message-ID: <20200224050504.GB12846@in.ibm.com> Reply-To: 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> <87ftf3ubte.fsf@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87ftf3ubte.fsf@linux.ibm.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-02-23_07:2020-02-21,2020-02-23 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 bulkscore=0 adultscore=0 phishscore=0 priorityscore=1501 spamscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002240043 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Nathan, On Fri, Feb 21, 2020 at 10:47:41AM -0600, Nathan Lynch wrote: > "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? We would have taken the snapshot in idle_loop_prolog() just before entering idle. That fact that the "if" condition is true above in read_this_idle_spurr() implies that we are reading the idle_spurr value from an interrupt context and since get_lppaca()->idle == 1, we haven't yet called idle_loop_epilog(), where we would have updated the idle_spurr ticks for the last idle period. Hence, in this function, we first update the idle_spurr accounting from the time of the last snapshot to now. We update the snapshot to the current SPURR value so that when we eventually call idle_loop_epilog(), we will account for the remaining idle duration, i.e from the read_this_idle_spurr() call to idle_loop_epilog() The results are therefore coherant, in that we do not perform double accounting the second time we invoke update_idle_spurr_accounting() from idle_loop_epilog(), but only add the spurr ticks from read_this_idle_spurr() to idle_loop_epilog(). -- Thanks and Regards gautham.