Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1133892ybt; Tue, 7 Jul 2020 08:30:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJw3zeCtvDr7+rXhKudOHIOIHZTb4vGhu4zueUX96+lZC5whBvPitfhjVVclXD+NhN96oa X-Received: by 2002:aa7:d6cc:: with SMTP id x12mr55145986edr.354.1594135825023; Tue, 07 Jul 2020 08:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594135825; cv=none; d=google.com; s=arc-20160816; b=v6MPRsEHAHrCMk+gi16DIp3kEt0C0ZIO8G/xsKBigw5qvayhf9c8he5vHjrLPCQGUm wkDTFZ2BE1QRA5Mmh4wjsTFoLrwDmQAHFTmzqmiy/+zQUNz1Hmjz88Qn3TqoON6Y2w2b aC0DJPFkFaLwjX1Sv+MsqsumNziVm3CGxHANkWBMW+o8n/3MCvnF3eTti+PlMAsIFgy1 7XliAFGh57+zNfGUdkENnYt4jcrrZZ61AnePI4j41nrwqMmQvXm8DiUoL0kL0TFKQOx0 y9b1LOXIEeH3g2h6TtFBdRgZXECi+wsbp4JYLkkOVPA1Pksu6bT0DhEUqiifl4qPmgr0 vbMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:to:from; bh=w6C8lUdoea1TVLuGFygcJh2j0NN9MvJte5ruaEEAixM=; b=vZsMQKjamPp3MyfryBmCyvbvrRP7chxBvVPu47gU3vo4kwh1bD00BMpS+o1sza1imS Q8lKmpxksoPyy76mVtRFPBy7rSihGN+gMZS4aTeQykT0gMziM1tB+SRT4rERpKO1ZFNR y+gBoUU0a791+2VAxsejtfWB3ooKT7gkJ3nPLBc3lHVXjWL93+zESMI19exoIFMLBtku pF0EicpwyjVFaEhwmLpFYpEpPZGRD2ROn6nZgH0xBV0mQovvly8rcCLWmvaMcQQ/4uCM yBgrVMdwmu0BWsNIeTWiS6dx1rAPa7hVmoXHS9L2InpRILu9C67DPWyjRdf74F5y/bxs 5Nuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id ox14si15521889ejb.688.2020.07.07.08.30.01; Tue, 07 Jul 2020 08:30:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1729702AbgGGP3y (ORCPT + 99 others); Tue, 7 Jul 2020 11:29:54 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:7858 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728955AbgGGP3w (ORCPT ); Tue, 7 Jul 2020 11:29:52 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 067F3Ghu051693; Tue, 7 Jul 2020 11:29:25 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 324pxshwr5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Jul 2020 11:29:24 -0400 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 067F6qAD013963; Tue, 7 Jul 2020 15:29:22 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma06ams.nl.ibm.com with ESMTP id 322h1h3gw4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Jul 2020 15:29:22 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 067FTKUU53673996 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 7 Jul 2020 15:29:20 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F113AE057; Tue, 7 Jul 2020 15:29:20 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3EB1EAE045; Tue, 7 Jul 2020 15:29:18 +0000 (GMT) Received: from pratiks-thinkpad.ibmuc.com (unknown [9.85.70.197]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 7 Jul 2020 15:29:18 +0000 (GMT) From: Pratik Rajesh Sampat To: rjw@rjwysocki.net, daniel.lezcano@linaro.org, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, srivatsa@csail.mit.edu, shuah@kernel.org, ego@linux.vnet.ibm.com, svaidy@linux.ibm.com, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH 0/2] Selftest for cpuidle latency measurement Date: Tue, 7 Jul 2020 20:59:15 +0530 Message-Id: <20200707152917.10652-1-psampat@linux.ibm.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-07_08:2020-07-07,2020-07-07 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 clxscore=1011 impostorscore=0 cotscore=-2147483648 suspectscore=0 adultscore=0 mlxlogscore=623 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2007070109 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch series introduces a mechanism to measure wakeup latency for IPI and timer based interrupts The motivation behind this series is to find significant deviations behind advertised latency and resisdency values To achieve this, we introduce a kernel module and expose its control knobs through the debugfs interface that the selftests can engage with. The kernel module provides the following interfaces within /sys/kernel/debug/latency_test/ for, 1. IPI test: ipi_cpu_dest # Destination CPU for the IPI ipi_cpu_src # Origin of the IPI ipi_latency_ns # Measured latency time in ns 2. Timeout test: timeout_cpu_src # CPU on which the timer to be queued timeout_expected_ns # Timer duration timeout_diff_ns # Difference of actual duration vs expected timer To include the module, check option and include as module kernel hacking -> Cpuidle latency selftests The selftest inserts the module, disables all the idle states and enables them one by one testing: 1. Keeping source CPU constant, iterates through all the CPUS measuring IPI latency for baseline (CPU is busy with "yes" workload) and the when the CPU is at rest 2. Iterating through all the CPUs, sending expected timer durations to be equivalent to the residency of the the deepest idle state enabled and extracting the difference in time between the time of wakeup and the expected timer duration Usage ----- Can be used in conjuction to the rest of the selftests. Default Output location in: tools/testing/cpuidle/cpuidle.log To run this test specifically: $ make -C tools/testing/selftests TARGETS="cpuidle" run_tests There are a few optinal arguments too that the script can take [-h ] [-m ] [-o ] Sample output snippet --------------------- --IPI Latency Test--- ---Enabling state: 0--- SRC_CPU DEST_CPU Base_IPI_Latency(ns) IPI_Latency(ns) 0 0 328 291 0 1 1500 1071 0 2 1070 1062 0 3 1557 1668 . . . . Expected IPI latency(ns): 1000 Baseline Average IPI latency(ns): 1113 Observed Average IPI latency(ns): 1023 --Timeout Latency Test-- ---Enabling state: 0--- Wakeup_src Baseline_delay(ns) Delay(ns) 0 3134 2128 1 2275 2107 2 2222 2198 3 2421 2325 . . . . Expected timeout(ns): 200 Baseline Average timeout diff(ns): 2513 Observed Average timeout diff(ns): 2189 Pratik Rajesh Sampat (2): cpuidle: Trace IPI based and timer based wakeup latency from idle states selftest/cpuidle: Add support for cpuidle latency measurement drivers/cpuidle/Makefile | 1 + drivers/cpuidle/test-cpuidle_latency.c | 150 +++++++++++++ lib/Kconfig.debug | 10 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/cpuidle/Makefile | 6 + tools/testing/selftests/cpuidle/cpuidle.sh | 240 +++++++++++++++++++++ tools/testing/selftests/cpuidle/settings | 1 + 7 files changed, 409 insertions(+) create mode 100644 drivers/cpuidle/test-cpuidle_latency.c create mode 100644 tools/testing/selftests/cpuidle/Makefile create mode 100755 tools/testing/selftests/cpuidle/cpuidle.sh create mode 100644 tools/testing/selftests/cpuidle/settings -- 2.25.4