Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp787195pxk; Wed, 23 Sep 2020 16:40:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuVFB1SNfHeRtJ3RDwNUbLrYwNWc8Ypg5n2eF0oqKOvn0smcZONKO/H2/GYptwIG9vEqdC X-Received: by 2002:a05:6402:326:: with SMTP id q6mr1839696edw.216.1600904399878; Wed, 23 Sep 2020 16:39:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600904399; cv=none; d=google.com; s=arc-20160816; b=jCivvHyoTUk7Key+5qG3RYQ2UZ1y++wqLqcVriYPq6zMQl4/68RB+4GoN5w6J43874 lCXnaanNmFgZkUWDR0wLhBm3WDkLIVHReQe7RJk+4+cwsYrTs1Hqdw2b3y1PLaxhMDa3 WPcQmI7STfxFPdvgPj1MFDSkEYj5bq6fsUxnKbnauDwJk4WqpPXU83lmmd7UhVeVRshb 4BobgEXZnaydcZhGI4zjqBxoly+j/ReXai+pR69okEOluPMEykKw2cLFpAVPc+2vrKOf a88X52/VEScDjPPnvKbaRYKxbrEmxS7nrIxxPLHDaVeQSoe6ob0XU9Nm7uMQgNq7Mf91 5cSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dmarc-filter:sender:dkim-signature; bh=Bj+5WM36OBYaYaJ70VrcSWSbLrbdIOYy4LnLId1Zr9g=; b=Tpm2W+tvFn+6/JD1bBmoOaSDPt2hUtPSn5g0LuxQIonaM6+NY3wvJqf2C8/CkAL9Zu KBMWYQ+QqqnZSKrv9+FNZsZ0KlN/bES32k5ZcRYB/ApXGAWkMQ4mkNilZr55gnn4pxyR 39RHrpaxE1S1G6RV1pt+7Xng7w3Nwq+q3vfRXIRy2pH+Z6ob1nKLurOG/xaTWgp7npTG cV/46wMV31yK21jy9HVYrrGv3Q65JCx/pYQ/82/VjnhvWh5My53+ekUntCjSvhDwJJ6k i3chdmEpRB2HvMaJsdLuvoHmjVTVpq3ntwtS42uWq3U+e56gT0JmJ2j9+CD0LdSefqqx iz9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=wG2uEi8l; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t18si942137eje.652.2020.09.23.16.39.37; Wed, 23 Sep 2020 16:39:59 -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; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=wG2uEi8l; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726774AbgIWXiE (ORCPT + 99 others); Wed, 23 Sep 2020 19:38:04 -0400 Received: from z5.mailgun.us ([104.130.96.5]:54628 "EHLO z5.mailgun.us" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726419AbgIWXiE (ORCPT ); Wed, 23 Sep 2020 19:38:04 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1600904283; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=Bj+5WM36OBYaYaJ70VrcSWSbLrbdIOYy4LnLId1Zr9g=; b=wG2uEi8lFucX2HyqklbQtGJBdOOU2maLW35X3YcNsdoRNKIz0f5uSfW8hlWbt1Ij/epfh+HS M3JKItXT19y77QPxk0rmDLzz1CYgYmeqamTnz7Pes6YEggMlBAl1OaWBXBPJPk+186jptKqh u2QthTHwniV2t0Rb7cEicZglbnc= X-Mailgun-Sending-Ip: 104.130.96.5 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n05.prod.us-west-2.postgun.com with SMTP id 5f6bdc5ad8a57df5abe3c107 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 23 Sep 2020 23:38:02 GMT Sender: psodagud=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 8A34EC43385; Wed, 23 Sep 2020 23:38:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL autolearn=no autolearn_force=no version=3.4.0 Received: from th-lint-038.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: psodagud) by smtp.codeaurora.org (Postfix) with ESMTPSA id 20CEAC433FE; Wed, 23 Sep 2020 23:38:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 20CEAC433FE Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=psodagud@codeaurora.org From: Prasad Sodagudi To: rostedt@goodmis.org, tglx@linutronix.de, qais.yousef@arm.com, peterz@infradead.org, mingo@kernel.org, cai@lca.pw, tyhicks@canonical.com, arnd@arndb.de Cc: rameezmustafa@codeaurora.org, linux-kernel@vger.kernel.org, Prasad Sodagudi Subject: [PATCH 1/2] cpu/hotplug: Add cpuhp_latency trace event Date: Wed, 23 Sep 2020 16:37:45 -0700 Message-Id: <1600904266-102397-2-git-send-email-psodagud@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1600904266-102397-1-git-send-email-psodagud@codeaurora.org> References: <1600904266-102397-1-git-send-email-psodagud@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add ftrace event trace_cpuhp_latency to track cpu hotplug latency. It helps to track the hotplug latency impact by firmware changes and kernel cpu hotplug callbacks. Signed-off-by: Prasad Sodagudi --- include/trace/events/cpuhp.h | 29 +++++++++++++++++++++++++++++ kernel/cpu.c | 9 +++++++++ 2 files changed, 38 insertions(+) diff --git a/include/trace/events/cpuhp.h b/include/trace/events/cpuhp.h index ad16f77..c871850 100644 --- a/include/trace/events/cpuhp.h +++ b/include/trace/events/cpuhp.h @@ -6,6 +6,7 @@ #define _TRACE_CPUHP_H #include +#include TRACE_EVENT(cpuhp_enter, @@ -89,6 +90,34 @@ TRACE_EVENT(cpuhp_exit, __entry->cpu, __entry->state, __entry->idx, __entry->ret) ); +TRACE_EVENT(cpuhp_latency, + + TP_PROTO(unsigned int cpu, unsigned int state, + u64 start_time, int ret), + + TP_ARGS(cpu, state, start_time, ret), + + TP_STRUCT__entry( + __field(unsigned int, cpu) + __field(unsigned int, state) + __field(u64, time) + __field(int, ret) + ), + + TP_fast_assign( + __entry->cpu = cpu; + __entry->state = state; + __entry->time = div64_u64(sched_clock() - start_time, 1000); + __entry->ret = ret; + ), + + TP_printk(" cpu:%d state:%s latency:%llu USEC ret: %d", + __entry->cpu, __entry->state ? "online" : "offline", + __entry->time, __entry->ret) +); + + + #endif /* This part must be outside protection */ diff --git a/kernel/cpu.c b/kernel/cpu.c index 6ff2578..68b3740 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -36,6 +36,7 @@ #include #define CREATE_TRACE_POINTS #include +#include #include "smpboot.h" @@ -994,6 +995,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen, { struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu); int prev_state, ret = 0; + u64 start_time = 0; if (num_online_cpus() == 1) return -EBUSY; @@ -1002,6 +1004,8 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen, return -EINVAL; cpus_write_lock(); + if (trace_cpuhp_latency_enabled()) + start_time = sched_clock(); cpuhp_tasks_frozen = tasks_frozen; @@ -1040,6 +1044,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen, } out: + trace_cpuhp_latency(cpu, 0, start_time, ret); cpus_write_unlock(); /* * Do post unplug cleanup. This is still protected against @@ -1192,8 +1197,11 @@ static int _cpu_up(unsigned int cpu, int tasks_frozen, enum cpuhp_state target) struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu); struct task_struct *idle; int ret = 0; + u64 start_time = 0; cpus_write_lock(); + if (trace_cpuhp_latency_enabled()) + start_time = sched_clock(); if (!cpu_present(cpu)) { ret = -EINVAL; @@ -1241,6 +1249,7 @@ static int _cpu_up(unsigned int cpu, int tasks_frozen, enum cpuhp_state target) target = min((int)target, CPUHP_BRINGUP_CPU); ret = cpuhp_up_callbacks(cpu, st, target); out: + trace_cpuhp_latency(cpu, 1, start_time, ret); cpus_write_unlock(); arch_smt_update(); return ret; -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project