From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8011C433E6 for ; Wed, 2 Sep 2020 08:36:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C04B020773 for ; Wed, 2 Sep 2020 08:36:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="RA9h04Gf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726448AbgIBIg5 (ORCPT ); Wed, 2 Sep 2020 04:36:57 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51336 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726140AbgIBIgZ (ORCPT ); Wed, 2 Sep 2020 04:36:25 -0400 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 0828VZFQ160336; Wed, 2 Sep 2020 04:36:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : reply-to : references : mime-version : content-type : in-reply-to; s=pp1; bh=G92Hnl95YGBFYaXfwRX/u5OBkMFB+BAE9YB8vdXBHZ8=; b=RA9h04GfqI9EWNcAyotn22fDX6A9FMRDHjAfoAocoiXi/b8U5HuxCPmwMgv8yblS3f2e ouADjAfIpySmbm4ZTMX+jb1nJ3/3PSJOJuta07UZjSuQiXIeXsq2m82ctQhEU9JeqPHO 6pi7I798W7JLRSlmJSnyKxqw76gSCnurm8jpWobd4b1zcE5Hq/IYYHTABZVAOkctnJ+g I9kJWVneYIU3V+lBKqSUW1XvR37aZZXULhU+KslWremtubgV6kpA2NrTTOJ+RLPfmxKK o7E1/3u8xoUiR14mv/aueVcMLKXSWGR64G7nENJbMgHdwhNLEKAyfPQHkUSiBsgIa1/d UQ== 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 33a6je2rm1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Sep 2020 04:36:15 -0400 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0828XEp5000387; Wed, 2 Sep 2020 08:36:13 GMT Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by ppma04wdc.us.ibm.com with ESMTP id 337en9eeey-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Sep 2020 08:36:13 +0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0828aDIV52036084 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 2 Sep 2020 08:36:13 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 261D3124058; Wed, 2 Sep 2020 08:36:13 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B62D4124052; Wed, 2 Sep 2020 08:36:11 +0000 (GMT) Received: from sofia.ibm.com (unknown [9.79.220.196]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 2 Sep 2020 08:36:11 +0000 (GMT) Received: by sofia.ibm.com (Postfix, from userid 1000) id 000A72E3027; Wed, 2 Sep 2020 14:05:32 +0530 (IST) Date: Wed, 2 Sep 2020 14:05:32 +0530 From: Gautham R Shenoy To: Joel Stanley Cc: "Gautham R. Shenoy" , Michael Ellerman , "Rafael J. Wysocki" , Vaidyanathan Srinivasan , linuxppc-dev , Linux Kernel Mailing List , linux-pm@vger.kernel.org Subject: Re: [PATCH] cpuidle-pseries: Fix CEDE latency conversion from tb to us Message-ID: <20200902083532.GA14369@in.ibm.com> Reply-To: ego@linux.vnet.ibm.com References: <1598969293-29228-1-git-send-email-ego@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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.235,18.0.687 definitions=2020-09-02_03:2020-09-02,2020-09-02 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 clxscore=1011 impostorscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009020074 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Joel, On Wed, Sep 02, 2020 at 01:08:35AM +0000, Joel Stanley wrote: > On Tue, 1 Sep 2020 at 14:09, Gautham R. Shenoy wrote: > > > > From: "Gautham R. Shenoy" > > > > commit d947fb4c965c ("cpuidle: pseries: Fixup exit latency for > > CEDE(0)") sets the exit latency of CEDE(0) based on the latency values > > of the Extended CEDE states advertised by the platform. The values > > advertised by the platform are in timebase ticks. However the cpuidle > > framework requires the latency values in microseconds. > > > > If the tb-ticks value advertised by the platform correspond to a value > > smaller than 1us, during the conversion from tb-ticks to microseconds, > > in the current code, the result becomes zero. This is incorrect as it > > puts a CEDE state on par with the snooze state. > > > > This patch fixes this by rounding up the result obtained while > > converting the latency value from tb-ticks to microseconds. > > > > Fixes: commit d947fb4c965c ("cpuidle: pseries: Fixup exit latency for > > CEDE(0)") > > > > Signed-off-by: Gautham R. Shenoy > > Reviewed-by: Joel Stanley > Thanks for reviewing the fix. > Should you check for the zero case and print a warning? Yes, that would be better. I will post a v2 with that. > > > --- > > drivers/cpuidle/cpuidle-pseries.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c > > index ff6d99e..9043358 100644 > > --- a/drivers/cpuidle/cpuidle-pseries.c > > +++ b/drivers/cpuidle/cpuidle-pseries.c > > @@ -361,7 +361,7 @@ static void __init fixup_cede0_latency(void) > > for (i = 0; i < nr_xcede_records; i++) { > > struct xcede_latency_record *record = &payload->records[i]; > > u64 latency_tb = be64_to_cpu(record->latency_ticks); > > - u64 latency_us = tb_to_ns(latency_tb) / NSEC_PER_USEC; > > + u64 latency_us = DIV_ROUND_UP_ULL(tb_to_ns(latency_tb), NSEC_PER_USEC); > > > > if (latency_us < min_latency_us) > > min_latency_us = latency_us; > > -- > > 1.9.4 > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD0E3C433E2 for ; Wed, 2 Sep 2020 08:38:04 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6A4C520773 for ; Wed, 2 Sep 2020 08:38:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="RA9h04Gf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A4C520773 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4BhHQ24tYvzDqg4 for ; Wed, 2 Sep 2020 18:38:02 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=ego@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=RA9h04Gf; dkim-atps=neutral Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4BhHN56Y2KzDql5 for ; Wed, 2 Sep 2020 18:36:21 +1000 (AEST) 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 0828VZFQ160336; Wed, 2 Sep 2020 04:36:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : reply-to : references : mime-version : content-type : in-reply-to; s=pp1; bh=G92Hnl95YGBFYaXfwRX/u5OBkMFB+BAE9YB8vdXBHZ8=; b=RA9h04GfqI9EWNcAyotn22fDX6A9FMRDHjAfoAocoiXi/b8U5HuxCPmwMgv8yblS3f2e ouADjAfIpySmbm4ZTMX+jb1nJ3/3PSJOJuta07UZjSuQiXIeXsq2m82ctQhEU9JeqPHO 6pi7I798W7JLRSlmJSnyKxqw76gSCnurm8jpWobd4b1zcE5Hq/IYYHTABZVAOkctnJ+g I9kJWVneYIU3V+lBKqSUW1XvR37aZZXULhU+KslWremtubgV6kpA2NrTTOJ+RLPfmxKK o7E1/3u8xoUiR14mv/aueVcMLKXSWGR64G7nENJbMgHdwhNLEKAyfPQHkUSiBsgIa1/d UQ== 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 33a6je2rm1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Sep 2020 04:36:15 -0400 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0828XEp5000387; Wed, 2 Sep 2020 08:36:13 GMT Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by ppma04wdc.us.ibm.com with ESMTP id 337en9eeey-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Sep 2020 08:36:13 +0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0828aDIV52036084 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 2 Sep 2020 08:36:13 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 261D3124058; Wed, 2 Sep 2020 08:36:13 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B62D4124052; Wed, 2 Sep 2020 08:36:11 +0000 (GMT) Received: from sofia.ibm.com (unknown [9.79.220.196]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 2 Sep 2020 08:36:11 +0000 (GMT) Received: by sofia.ibm.com (Postfix, from userid 1000) id 000A72E3027; Wed, 2 Sep 2020 14:05:32 +0530 (IST) Date: Wed, 2 Sep 2020 14:05:32 +0530 From: Gautham R Shenoy To: Joel Stanley Subject: Re: [PATCH] cpuidle-pseries: Fix CEDE latency conversion from tb to us Message-ID: <20200902083532.GA14369@in.ibm.com> References: <1598969293-29228-1-git-send-email-ego@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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.235, 18.0.687 definitions=2020-09-02_03:2020-09-02, 2020-09-02 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 clxscore=1011 impostorscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009020074 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ego@linux.vnet.ibm.com Cc: "Gautham R. Shenoy" , linux-pm@vger.kernel.org, "Rafael J. Wysocki" , Linux Kernel Mailing List , Vaidyanathan Srinivasan , linuxppc-dev Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Hello Joel, On Wed, Sep 02, 2020 at 01:08:35AM +0000, Joel Stanley wrote: > On Tue, 1 Sep 2020 at 14:09, Gautham R. Shenoy wrote: > > > > From: "Gautham R. Shenoy" > > > > commit d947fb4c965c ("cpuidle: pseries: Fixup exit latency for > > CEDE(0)") sets the exit latency of CEDE(0) based on the latency values > > of the Extended CEDE states advertised by the platform. The values > > advertised by the platform are in timebase ticks. However the cpuidle > > framework requires the latency values in microseconds. > > > > If the tb-ticks value advertised by the platform correspond to a value > > smaller than 1us, during the conversion from tb-ticks to microseconds, > > in the current code, the result becomes zero. This is incorrect as it > > puts a CEDE state on par with the snooze state. > > > > This patch fixes this by rounding up the result obtained while > > converting the latency value from tb-ticks to microseconds. > > > > Fixes: commit d947fb4c965c ("cpuidle: pseries: Fixup exit latency for > > CEDE(0)") > > > > Signed-off-by: Gautham R. Shenoy > > Reviewed-by: Joel Stanley > Thanks for reviewing the fix. > Should you check for the zero case and print a warning? Yes, that would be better. I will post a v2 with that. > > > --- > > drivers/cpuidle/cpuidle-pseries.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c > > index ff6d99e..9043358 100644 > > --- a/drivers/cpuidle/cpuidle-pseries.c > > +++ b/drivers/cpuidle/cpuidle-pseries.c > > @@ -361,7 +361,7 @@ static void __init fixup_cede0_latency(void) > > for (i = 0; i < nr_xcede_records; i++) { > > struct xcede_latency_record *record = &payload->records[i]; > > u64 latency_tb = be64_to_cpu(record->latency_ticks); > > - u64 latency_us = tb_to_ns(latency_tb) / NSEC_PER_USEC; > > + u64 latency_us = DIV_ROUND_UP_ULL(tb_to_ns(latency_tb), NSEC_PER_USEC); > > > > if (latency_us < min_latency_us) > > min_latency_us = latency_us; > > -- > > 1.9.4 > >