Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2427727pxb; Thu, 11 Feb 2021 12:03:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJznodcp4h8G0zAvqNS+I2beZXbFivkCHvQaXU0V/bqe8f+oJQxUkD7qS7Mqe+li6m0BYHSd X-Received: by 2002:a05:6402:374:: with SMTP id s20mr9736890edw.56.1613073834611; Thu, 11 Feb 2021 12:03:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613073834; cv=none; d=google.com; s=arc-20160816; b=JA2Yq9riIPfPtZRqCL2yUUraf2R8+KdM92hi3R6ekQfKixwdhdG5G4d/680qKQAobj LzVvdMQuxE+Ja7tXjwIWrMNvT/ygnLhS0lDqs1Zosm2MWsBB1QPeopFK8MD6cOfrqCAD 8PB24qpZCnk3SR55ycfB6kZVgoVNz6QVQ0DyHRRmDaMnWMPxyLXtaJSTWvXYBSXkj+Wd Sy7iM3f0Rt5/IKShfQlLuAtvD2s1mQBT9saaeLGKu0epamFOTWma2pYOp5rcxVOTbo10 dlwsqKxstGr5L/RrAkoWu8VX7SA7lr4Mnxay1x0YlozcHgIGWbrMNXfSEw+A4YN9efwC 1uWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=/eHM4lFVglybOkDCaddeVtDQTZgCbKUeYeDsOGMhIRg=; b=yzVj8EfJIAbdX+wEAXMs7qLAQR4bVMIPqY2kKkRtA/oRjcgwLtpcjjm+Tkxo/aRaPV 7qqE7YNldHxr5+rFiNA5C6ePSgYDF9tGwofmOr+NV4co1F2vEV0OZUN9PSGIdwOqmMAK IUVeddyIMx7bi+zyOyTGm9OITX/YPcRQUcr4ysJrTWcpBimNOtjhsoP2tLvChv1YG+JI ymoSmtaTa9ltLOfbURYMMq2UnFLzXZGtSofQXvW/oE/7Ovv/d6/45Q/V+JBcokh90FIW mQQy7EXYcsbFwEoWpZ9Hnx+BZcEltcfsUYWEaVoiRt9wLi5fe0CWCgpkKDUoeHyPWwO4 9idg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d5si4391167edu.258.2021.02.11.12.03.30; Thu, 11 Feb 2021 12:03:54 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231519AbhBKUCe (ORCPT + 99 others); Thu, 11 Feb 2021 15:02:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:39226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229918AbhBKT5b (ORCPT ); Thu, 11 Feb 2021 14:57:31 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B25B964E57; Thu, 11 Feb 2021 19:56:49 +0000 (UTC) Date: Thu, 11 Feb 2021 14:56:48 -0500 From: Steven Rostedt To: Viktor Rosendahl Cc: Joel Fernandes , Ingo Molnar , Subject: Re: [PATCH] Add the latency-collector to tools Message-ID: <20210211145648.1e1e1325@gandalf.local.home> In-Reply-To: <20210211161742.25386-1-Viktor.Rosendahl@bmw.de> References: <20210126142652.41b961f2@gandalf.local.home> <20210211161742.25386-1-Viktor.Rosendahl@bmw.de> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 11 Feb 2021 17:17:42 +0100 Viktor Rosendahl wrote: > It seems to work but I discovered during testing that it seems like newer > kernels have a tendency to lose some latencies in longer bursts. I guess this > is likely to be another regression in the preemptirqsoff tracer. Not sure what you mean by the above. I'd be interested in fixing it if is really a problem. > diff --git a/tools/tracing/Makefile b/tools/tracing/Makefile > new file mode 100644 > index 000000000000..f53859765154 > --- /dev/null > +++ b/tools/tracing/Makefile > @@ -0,0 +1,23 @@ > +# SPDX-License-Identifier: GPL-2.0 > +# Makefile for vm tools > +# > +VAR_CFLAGS := $(shell pkg-config --cflags libtracefs 2>/dev/null) > +VAR_LDLIBS := $(shell pkg-config --libs libtracefs 2>/dev/null) > + > +TARGETS = latency-collector > +CFLAGS = -Wall -Wextra -g -O2 $(VAR_CFLAGS) > +LDFLAGS = -lpthread $(VAR_LDLIBS) > + > +all: $(TARGETS) > + > +%: %.c > + $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) > + > +clean: > + $(RM) latency-collector > + > +sbindir ?= /usr/sbin I wonder if it should default to /usr/local? prefix ?= /usr/local sbindir ?= ${prefix}/sbin > + > +install: all > + install -d $(DESTDIR)$(sbindir) > + install -m 755 -p $(TARGETS) $(DESTDIR)$(sbindir) > diff --git a/tools/tracing/latency-collector.c b/tools/tracing/latency-collector.c > new file mode 100644 > index 000000000000..e9aa7a47a8a3 > --- /dev/null > +++ b/tools/tracing/latency-collector.c > @@ -0,0 +1,2102 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (C) 2017, 2018, 2019, 2021 BMW Car IT GmbH > + * Author: Viktor Rosendahl (viktor.rosendahl@bmw.de) > + */ > + > +#define _GNU_SOURCE > +#define _POSIX_C_SOURCE 200809L > + > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +static const char *prg_name; > +static const char *prg_unknown = "unknown program name"; > + > +static int fd_stdout; > + > +static int sched_policy; > +static bool sched_policy_set; > + > +static int sched_pri; > +static bool sched_pri_set; > + > +static bool trace_enable = true; > +static bool setup_ftrace = true; > +static bool use_random_sleep; > + > +enum traceopt { > + OPTIDX_FUNC_TR = 0, > + OPTIDX_DISP_GR, > + OPTIDX_NR > +}; > + > +/* Should be in the order of enum traceopt */ > +static const char * const optstr[] = { > + "function-trace", /* OPTIDX_FUNC_TR */ > + "display-graph", /* OPTIDX_DISP_GR */ > + NULL > +}; A trick to force the enum and string order is this: #define TRACE_OPTS \ C(FUNC_TR, "function-trace"), \ C(DISP_GR, "display-graph") #undef C #define C(a, b) OPTIDX_##a enum traceopt { TRACE_OPTS, OPTIDX_NR }; #undef C #define C(a, b) b static const char *cost optstr[] = { TRACE_OPTS, NULL }; > + > +enum errhandling { > + ERR_EXIT = 0, > + ERR_WARN, > + ERR_CLEANUP, > +}; I didn't look too deeply at the rest, just skimmed it basically, and I tried it out. I'm fine with pulling this into my queue, as it's just a tool and wont cause any other issues. I can move some of the files in scripts that deals with tracing into the tools/tracing directory too. Maybe this should be placed in a sub directory? tools/tracing/latency/ ? Feel free to submit a proper patch (proper change log, etc). Thanks, -- Steve