Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6216654pxv; Thu, 29 Jul 2021 09:05:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzd5pphMnl/HyM2q/sE3EkRKnd3G09Ddz4ZvlrDs2Ok/Bj6IgqnlINfBBxzF/cNmRXteIcT X-Received: by 2002:a17:906:8a66:: with SMTP id hy6mr5123220ejc.309.1627574701984; Thu, 29 Jul 2021 09:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627574701; cv=none; d=google.com; s=arc-20160816; b=ApAyUr9neeI9GpKhdnLQhA660Mi8/SnWBVooq2phT5Me+a8WGntOQozDXuHhnbtO5G rkfB/GPBSOomOWUPPJ2WtxokknKgHTNZ4nhUPb+3rcAQWg6MH+YcDK/IVBfGEOJo01VF IwnFqViaRDpr6tfkgFM6VTd3tJ96T15HEdV0wM8mCnSXt9SeUh05oVawpI59plu+MxSH D3FeZcv47tu3Uk4Z09NVz+UbcUBloyGnB5oHbRFSxERicyE5KAMjgRuS2Jq5Edi3Dg+J RZ+gt5JC4jwFBLuty6SWBTP4ifqJoem+LsxQQ/GdYn7BN4d2RiaX3ThA9GEHCSt7DjXC lvMg== 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:date:subject:cc:to:from; bh=u5sjc0GREF8cjNa5YnV99kWh4+nrmK/JDdGKkrrqyG0=; b=fjXYCnRNGsibFPcXTzB1Gs4+RLaEUDjRopnpcC3fQOTX8ZNT+6osf0KYv15lq0XU1Q DGRQTlOESx7Qvi+z/KgGypKxCcRchjC8x7MrI9jjFWyeTtYvtby0QrAEThWt16um5v6z pEFoRnDg0if/jlSJ/j+j29pEs6dJENLOX5iPZ/j3otNyA4Ph0cXI3PFkZRkhEJQVkPpL UsMpCZyKkGEe6V6+F/5mQZSxuJGBj4sRpgRkWUxNZVrYw3jlG5G1bQXfFk+Wq88YOC+E 5zl2RCHm1+dYIZehTyOgpWKDip8BTtP/TC4fH4kyzH6VYOEacSAOGC20fx8NaH6v+pIn odiA== 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=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hy6si3087611ejc.7.2021.07.29.09.04.38; Thu, 29 Jul 2021 09:05:01 -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=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238198AbhG2QAS (ORCPT + 99 others); Thu, 29 Jul 2021 12:00:18 -0400 Received: from foss.arm.com ([217.140.110.172]:51328 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238271AbhG2P6z (ORCPT ); Thu, 29 Jul 2021 11:58:55 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B305CD6E; Thu, 29 Jul 2021 08:58:47 -0700 (PDT) Received: from e121896.arm.com (unknown [10.57.40.10]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 11F6D3F73D; Thu, 29 Jul 2021 08:58:44 -0700 (PDT) From: James Clark To: acme@kernel.org, mathieu.poirier@linaro.org, coresight@lists.linaro.org, linux-perf-users@vger.kernel.org Cc: leo.yan@linaro.org, suzuki.poulose@arm.com, mike.leach@linaro.org, James Clark , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , John Garry , Will Deacon , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 1/6] perf tools: Add WARN_ONCE equivalent for UI warnings Date: Thu, 29 Jul 2021 16:58:00 +0100 Message-Id: <20210729155805.2830-2-james.clark@arm.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210729155805.2830-1-james.clark@arm.com> References: <20210729155805.2830-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently WARN_ONCE prints to stderr and corrupts the TUI. Add equivalent methods for UI warnings. Signed-off-by: James Clark --- tools/perf/util/debug.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index 48f631966067..f99468a7f681 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h @@ -22,6 +22,13 @@ extern int debug_data_convert; eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) #define pr_warning(fmt, ...) \ eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) +#define pr_warning_once(fmt, ...) ({ \ + static int __warned; \ + if (unlikely(!__warned)) { \ + pr_warning(fmt, ##__VA_ARGS__); \ + __warned = 1; \ + } \ +}) #define pr_info(fmt, ...) \ eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) #define pr_debug(fmt, ...) \ @@ -55,6 +62,13 @@ void trace_event(union perf_event *event); int ui__error(const char *format, ...) __printf(1, 2); int ui__warning(const char *format, ...) __printf(1, 2); +#define ui__warning_once(format, ...) ({ \ + static int __warned; \ + if (unlikely(!__warned)) { \ + ui__warning(format, ##__VA_ARGS__); \ + __warned = 1; \ + } \ +}) void pr_stat(const char *fmt, ...); -- 2.28.0