Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp726126lqc; Fri, 8 Mar 2024 09:51:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUzP3lRElj1zmhfqGAxUC3aVU3TkUb885IBKg6cVwdkSvePnfN/qq2DpyawUedySRQzyb7tnQE/vvXx9VbmTW6vg4Wls4e3Dq5IvAtD3w== X-Google-Smtp-Source: AGHT+IEcGzIybAOPlPi0U1NyUSEeU8lMnY19k4//QYeBRULpApersuFdkgyMjWQF4Qb/icG13fWR X-Received: by 2002:a05:620a:222f:b0:787:db46:87ee with SMTP id n15-20020a05620a222f00b00787db4687eemr11156106qkh.10.1709920282564; Fri, 08 Mar 2024 09:51:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709920282; cv=pass; d=google.com; s=arc-20160816; b=pKdpxnoKTPFKtM79eLzry4edWYTYtygqGpTnJPmM+E8LVK0UsoBY5US/0Za7JEf8ma bRnyL3OsIraApCqcVJDJT7T1rXRI1ehZuTtWTMercKTnS/fPVyLcRhnUDq2QkUUwdZk6 raXyoQle+NlNeRlkE72IaIKgE6rr344kKXT7L84HX/jQcDn86wjF8IVg6pqwIxGeJEBx M5rU83dXqR12/JH/I/kL+b7c76YHnCBIyCiPJkPQ3D7+G+Kts0sTCrEjXy1Ca9+7N6GI uQGfR1dhEXw/Cw+cULBiC4qgU/8yJf3EWLv/AKwP2eyKaqtObWE0iujOISkWjCqcO6DX T8Ug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=S5R2lygD/edD8KrwnMmUxMbKupEMSvtT3ZQaRunxMRo=; fh=CMtRrK48xhsgZIBOhYR+WhjKRvfK7+ozDVwv4ITuT8Q=; b=NWSD+H842bL3mPC4+FNX4zOoXBTQI8z8svdRqEz7CWb7dzo+qzUrvsuJNTKgMKnL6H K/uX416ZSvLeGshHqsW6hJ5v1cuGv95HYQ4gzTGbYa75anS7Lx1pQ5Bul4U8+hFpLXBa cohEefvQ78ubeT50GQe/PHLEuym4XiloUpJkUwNb704vf3qF8L0zhA6oCuAhT4UTSIDR TZUyzOgPk2sGsbU+3J7+myHrQHEpBDUWrw/W7VI88TTgQW+pvwVedL7LHVBcP7ZJ7iZ3 p6QOc+xjrJBt5jChmAY1Xo9wda9D7tpv4VGZSkByC6VygSGVVSxItd73JFn0BdIxnfS2 s9+A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZhNN5zWY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-97418-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97418-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id pi32-20020a05620a37a000b00787a71e63d5si19135307qkn.151.2024.03.08.09.51.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 09:51:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97418-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZhNN5zWY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-97418-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97418-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 44A851C20B29 for ; Fri, 8 Mar 2024 17:51:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 895F255E40; Fri, 8 Mar 2024 17:51:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZhNN5zWY" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2A7D54BDD; Fri, 8 Mar 2024 17:51:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709920261; cv=none; b=hK6LGzm3+RzwXOMdmHIfSaIAIihFhtAz+l31wCnRz73H8I9icct4vDgTTfB7Qqajw4Hf8mb/ZivKSnZjbsOcc7Y7LKLa4PgvdfVeD/fI9lPwA0gasFGTKB0opdM+F/adQ0Ny2G9Kh8KvKNvP01E4DfMCcGupdHUgOt35UZZe9js= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709920261; c=relaxed/simple; bh=8xpc/axsp72plSKaCPH3+hOrfvbTeluipeAKh/UkzdI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Jk/dbtRkonduJ7AafBwfhWsD7ghSeQX+x1QL+ZE0j6IDr4V7BMBKpKnUOCr3tjFs9WFksE0Z3TyukGjIpWeGGY5UmSVtFF3RL6S94kL9gcrGxAVKSI0+BSfF6qIGcjYz+Rtb5YGSIC7kzmt6hCEz/3U3wN3GCWQE7sS/a71u0Fk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZhNN5zWY; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3776C433A6; Fri, 8 Mar 2024 17:50:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709920261; bh=8xpc/axsp72plSKaCPH3+hOrfvbTeluipeAKh/UkzdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZhNN5zWYs38TBT7S7W7Dw6E+W7sFfwwY5CXk9o+kZwRfR6vNHEh37mElNvMmEzXri 3E4kEKjokQRPYP2CqHd6eZNHfGIQrk2bm7Rs3+gBx0XR6RD13lZ9m4nDguE111fKZb FLRD92Kc91wu9d6iV4STN+S2g4Qq4GyDT5kl5Bd6so8BNe6keekNsjh7Yd09KOFb/F TjvM0N60Mkb8ixpweKqEI4JGu8RhBYA/lF83LfxdfHfLFHaJ5FwrETg37AbtKRC4kk oEya8C7C5eiDNRr6738guWI9RJQ+s5y/ZeTDvsM0u2S5ip1A7qCWHCkuODOegbm5th 8kRSuS5ySSetg== From: Daniel Bristot de Oliveira To: Linus Torvalds , Steven Rostedt , Arnaldo Carvalho de Melo Cc: Daniel Bristot de Oliveira , Josh Poimboeuf , John Kacur , Namhyung Kim , Jiri Olsa , linux-perf-users@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] tools/tracing: Use tools/build makefiles on latency-collector Date: Fri, 8 Mar 2024 18:50:43 +0100 Message-ID: <6f2b86be6286d91ed5fd8e36ec54e07a908cc468.1709914259.git.bristot@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Use tools/build/ makefiles to build latency-collector, inheriting the benefits of it. For example, having a proper way to handle dependencies. Inspired on perf and objtool. Suggested-by: Linus Torvalds Signed-off-by: Daniel Bristot de Oliveira --- tools/tracing/latency/.gitignore | 1 + tools/tracing/latency/Build | 1 + tools/tracing/latency/Makefile | 48 +++++++++++++++++---------- tools/tracing/latency/Makefile.config | 28 ++++++++++++++++ 4 files changed, 61 insertions(+), 17 deletions(-) create mode 100644 tools/tracing/latency/Build create mode 100644 tools/tracing/latency/Makefile.config diff --git a/tools/tracing/latency/.gitignore b/tools/tracing/latency/.gitignore index 0863960761e7..11490d9da0b3 100644 --- a/tools/tracing/latency/.gitignore +++ b/tools/tracing/latency/.gitignore @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 latency-collector +FEATURE-DUMP diff --git a/tools/tracing/latency/Build b/tools/tracing/latency/Build new file mode 100644 index 000000000000..0ce65ea72bf9 --- /dev/null +++ b/tools/tracing/latency/Build @@ -0,0 +1 @@ +latency-collector-y += latency-collector.o diff --git a/tools/tracing/latency/Makefile b/tools/tracing/latency/Makefile index 40c4ddaf8be1..3a2b5e8f5997 100644 --- a/tools/tracing/latency/Makefile +++ b/tools/tracing/latency/Makefile @@ -1,24 +1,38 @@ # 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) +export srctree := $(abspath ../../..) +export CC := gcc +export LD := ld +export AR := ar +export PKG_CONFIG := pkg-config -TARGETS = latency-collector -CFLAGS = -Wall -Wextra -g -O2 $(VAR_CFLAGS) -LDFLAGS = -lpthread $(VAR_LDLIBS) +FEATURE_TESTS := libtraceevent +FEATURE_TESTS += libtracefs +FEATURE_DISPLAY := libtraceevent +FEATURE_DISPLAY += libtracefs -all: $(TARGETS) +latency-collector: -%: %.c - $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) +include $(srctree)/tools/build/Makefile.include +include $(srctree)/tools/build/Makefile.feature +include $(srctree)/tools/scripts/Makefile.include +include Makefile.config -clean: - $(RM) latency-collector +CFLAGS += $(INCLUDES) $(LIB_INCLUDES) + +export CFLAGS := $(CFLAGS) + +latency-collector: latency-collector-in.o + $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $^ $(EXTLIBS) -prefix ?= /usr/local -sbindir ?= ${prefix}/sbin +latency-collector.%: fixdep FORCE + make -f $(srctree)/tools/build/Makefile.build dir=. $@ + +latency-collector-in.o: fixdep FORCE + make $(build)=latency-collector + +clean: + $(call QUIET_CLEAN, latency-collector) + @find . -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete + @rm -f latency-collector FEATURE-DUMP -install: all - install -d $(DESTDIR)$(sbindir) - install -m 755 -p $(TARGETS) $(DESTDIR)$(sbindir) +.PHONY: FORCE clean diff --git a/tools/tracing/latency/Makefile.config b/tools/tracing/latency/Makefile.config new file mode 100644 index 000000000000..5100d89346ab --- /dev/null +++ b/tools/tracing/latency/Makefile.config @@ -0,0 +1,28 @@ +STOP_ERROR := + +define lib_setup + $(eval EXTLIBS += -l$(1)) + $(eval LIB_INCLUDES += $(shell sh -c "$(PKG_CONFIG) --cflags lib$(1)")) +endef + +$(call feature_check,libtraceevent) +ifeq ($(feature-libtraceevent), 1) + $(call detected,CONFIG_LIBTRACEEVENT) + $(call lib_setup,traceevent) +else + STOP_ERROR := 1 + $(info libtraceevent is missing. Please install libtraceevent-dev/libtraceevent-devel) +endif + +$(call feature_check,libtracefs) +ifeq ($(feature-libtracefs), 1) + $(call detected,CONFIG_LIBTRACEFS) + $(call lib_setup,tracefs) +else + STOP_ERROR := 1 + $(info libtracefs is missing. Please install libtracefs-dev/libtracefs-devel) +endif + +ifeq ($(STOP_ERROR),1) + $(error Please, check the errors above.) +endif -- 2.44.0