From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C2F4C329E6C for ; Mon, 16 Mar 2026 16:09:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773677363; cv=none; b=Cij8iC3O6yP9ikS8BpdL8799wSsitC71+VAoQKE00DKajPRiwfzPRfB4N3mtbWRN9DPqPDDqHy6FhGI+K1GzMqHc/x8D856lEAZxiZwHncjS+/mhvfeSpJOgFmnxkCBwDAhlJHq7t8aIuVtaB/zKPjo2lsOGaWBtBCawEx5ZLy4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773677363; c=relaxed/simple; bh=MS5DnQIMjjClNAWCekKLtXXIS0LYDXozb4lauPDyQ4I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Vm5f/YINRl+WaTPvW1/ZTh2+hF6RrdNTX+RP1qOWbUjEBSt0MjH+AyfY27k1h7SCTSooAv4S98KO6j7ZItJnUhOxQrJZU18Ei4C3YpziBM7t+fELk33AegKZOxB/s9HAdkSpoChgyR3bPrfkmwwGNBRaSzjv4pfFbklr4cf8FgU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=YMlaIPac; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="YMlaIPac" Received: from LAPTOP-U3CCR7C6.lan (unknown [20.236.10.206]) by linux.microsoft.com (Postfix) with ESMTPSA id 213CF20B6F08; Mon, 16 Mar 2026 09:09:22 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 213CF20B6F08 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1773677362; bh=4Ypitji6HvLgh1Bouw6IlwmBShM4FKdmCgCPJw+u+OU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YMlaIPacVDH8XinFWvGfD+ZOrL+OK2JD0Bwcg+887X7/enfYsmn6E29cmvqijN1dw 4ZED13DS33lrW2YY92iRqpvOTB8wM1fiSQhFYod9561NR247VvAtYPbzdI5cVuFeSV WmTHhqFTiWmXwwzHutNI9wipiqFqL8cj+HDIFCs0= From: Thomas Ballasi To: tballasi@linux.microsoft.com Cc: akpm@linux-foundation.org, axelrasmussen@google.com, david@kernel.org, hannes@cmpxchg.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, lorenzo.stoakes@oracle.com, mhiramat@kernel.org, mhocko@kernel.org, rostedt@goodmis.org, shakeel.butt@linux.dev, weixugc@google.com, yuanchu@google.com, zhengqi.arch@bytedance.com Subject: [PATCH v8 1/3] tracing: Add __event_in_*irq() helpers Date: Mon, 16 Mar 2026 09:09:06 -0700 Message-Id: <20260316160908.42727-2-tballasi@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260316160908.42727-1-tballasi@linux.microsoft.com> References: <20260223171544.4750-1-tballasi@linux.microsoft.com> <20260316160908.42727-1-tballasi@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Steven Rostedt Some trace events want to expose in their output if they were triggered in an interrupt or softirq context. Instead of recording this in the event structure itself, as this information is stored in the flags portion of the event header, add helper macros that can be used in the print format: TP_printk("val=%d %s", __entry->val, __event_in_irq() ? "(in-irq)" : "") This will output "(in-irq)" for the event in the trace data if the event was triggered in hard or soft interrupt context. Link: https://lore.kernel.org/all/20251229132942.31a2b583@gandalf.local.home/ Signed-off-by: Steven Rostedt (Google) Signed-off-by: Thomas Ballasi --- include/trace/stages/stage3_trace_output.h | 8 ++++++++ include/trace/stages/stage7_class_define.h | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/trace/stages/stage3_trace_output.h b/include/trace/stages/stage3_trace_output.h index 1e7b0bef95f52..53a23988a3b8a 100644 --- a/include/trace/stages/stage3_trace_output.h +++ b/include/trace/stages/stage3_trace_output.h @@ -150,3 +150,11 @@ #undef __get_buf #define __get_buf(len) trace_seq_acquire(p, (len)) + +#undef __event_in_hardirq +#undef __event_in_softirq +#undef __event_in_irq + +#define __event_in_hardirq() (__entry->ent.flags & TRACE_FLAG_HARDIRQ) +#define __event_in_softirq() (__entry->ent.flags & TRACE_FLAG_SOFTIRQ) +#define __event_in_irq() (__entry->ent.flags & (TRACE_FLAG_HARDIRQ | TRACE_FLAG_SOFTIRQ)) diff --git a/include/trace/stages/stage7_class_define.h b/include/trace/stages/stage7_class_define.h index fcd564a590f43..47008897a7956 100644 --- a/include/trace/stages/stage7_class_define.h +++ b/include/trace/stages/stage7_class_define.h @@ -26,6 +26,25 @@ #undef __print_hex_dump #undef __get_buf +#undef __event_in_hardirq +#undef __event_in_softirq +#undef __event_in_irq + +/* + * The TRACE_FLAG_* are enums. Instead of using TRACE_DEFINE_ENUM(), + * use their hardcoded values. These values are parsed by user space + * tooling elsewhere so they will never change. + * + * See "enum trace_flag_type" in linux/trace_events.h: + * TRACE_FLAG_HARDIRQ + * TRACE_FLAG_SOFTIRQ + */ + +/* This is what is displayed in the format files */ +#define __event_in_hardirq() (REC->common_flags & 0x8) +#define __event_in_softirq() (REC->common_flags & 0x10) +#define __event_in_irq() (REC->common_flags & 0x18) + /* * The below is not executed in the kernel. It is only what is * displayed in the print format for userspace to parse. -- 2.45.3