From nobody Fri Dec 19 20:36:17 2025 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A923935BDD0 for ; Wed, 3 Dec 2025 16:23:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764779016; cv=none; b=Gs10CkyXvCZTIIYxj9rEQgkA6ZcwXRii1rdc674TLRVSgVaxs8kBlUsbz99bxXSeflafdrgw1dxRxKoHm9/MrCBdWZ3nkPl6/zSupiY0/jLXdd3zI4vVXVMI/vH2WF8wka234dWRqhhCPJbyKFTKxs/lNyR0PGxZLsV6eWB/QJo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764779016; c=relaxed/simple; bh=XIwl+QOA198wftZNvu9IO4FLzrxnhpjs1uVff2B+sOY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=o8lGqUC6nPZnMdGWD5lPm7SxuvCgJv0z/6mcJ4qdgg+opyZksYkwQe6nSCUIFHFQHQvmjQdNKwW6cG73HVuePSa9H77FD8VDdjbvSzWqG/R44/TvnqdyG95k4SThlNOMl6ZlRzhgSGbH3dVSf1vz7ymVUwPUZRPRm9kobasnBCQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HfOAE2NJ; arc=none smtp.client-ip=209.85.128.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HfOAE2NJ" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-78aa49cde3dso70745597b3.1 for ; Wed, 03 Dec 2025 08:23:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764779012; x=1765383812; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UuNgNlcfjsZ+Qe/j+fC/RN/pSpI7MUBa9s9mWM6ZH0E=; b=HfOAE2NJepvcF3KQas+gk2xFSOkwKNFBrwETBnYtUiGrCsYEJsETi35VT2KAP1OFHk xxgEOn8Vk2oLwtI3LjvxaywokyuxnzLC7WwHqcxJoU6niSdQQ2gunR1kw4mR5k5QQ959 O+Wt3vvSKs9eDHBUwZt0lW3wBAS56rM5XZsK6k1aQSvKLBjMsLAC9a4xCVDl8bc+Bpa0 xYcKwcQqSEXto+j7V2H1oiyM+SZjlO4TU/YFYSzOjPjS7EnudARg1rnzYArjRI3AVMTF f7zErhCqiyALiyVe7RHdZq59JTqCDLpLLHBjG69J+pu/qsMBbt/IDWaUXiVE7rLnBlx5 F1zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764779012; x=1765383812; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=UuNgNlcfjsZ+Qe/j+fC/RN/pSpI7MUBa9s9mWM6ZH0E=; b=PhGCQG8KwWcO+jj2aHO8SpLZBB5I9SuHNCsQbPyq/7a6Ow2h2NOeoBMaKGDxGENhZb AkHKnAR6lyxpwrpnTmQy+OvXSyTTHmq6/at5nu0E954BcMy6RqodrRl88tQc87i14PQZ YcRuCEfhV62lvK3p6L1J7KWNj8g1oN+xfds34bqXyFVH9hMSDnwH0+M28F2NCKnEPfQC HSegmLsKqGZdbKeOhOTbBfphNMbA/IUY2tCvrSyOOohm3PGYbjXz0nDo+XJX+Lt1QIF1 ELMKLkjb3kdpl+B4L28dZi+E8ZTo315wUpKFwrbmfAeiH4Wet1JPN4DsoEVWx4HzVh8U AyqA== X-Forwarded-Encrypted: i=1; AJvYcCXNfdspFyftNJd1h75aTToJ/EZkDTFBczf5VCNcZC2MGe+2rKDrbOPfUMXGCOnO4LROj16qSvBdZdXU/S0=@vger.kernel.org X-Gm-Message-State: AOJu0YzzNm5Ov4IMzA8meOwmFK95n8XwZhI4n1xKkoII5IqHaWSxkRQ3 53wRZQfi3zLyE9z8CZgsTS/dzoEvQlQV8dpUUiQoGCoXO47D4vrovQit X-Gm-Gg: ASbGncsyFquS6r1r4CurpKqNZi86/poj6QOx6DraVdOJ7LBoKYGtgmvvJpxR6Cja1+2 kVp7DVOFFspouSyk64dc24eu24iOmuyHjkXjdNsnnKTXN6CWNDwuJHikR35oTy8pDeayzPO7pdn 5cl3av3N17IULZ3P7Bk+LFF/4f5yGsLo1kGLmX0EBoz3Ps4jK1P1zy7l19ODgJtkvRgkSmOTR0W rJJhsM/WmwVoLZ2Rb2lmDKfKkeRO/fjayC0AHlN3F+k99uPS/svwE1f+P/LRjHf1zNk9iPRWnDF vnF7da8OZ/DyLN89NDGmL0ImJavdNwbcsw5CHiE7CfsD6FlSzYHR8dreXE7sCaGF/SqmrgiHy/Z NLrVpvp0p0gR73oolKV6KRbw6unX+M9PWPLg/vnWFfCg1pFoVEMyChTEv/50A7PmoZo0QLvMAXv 7NPn8EXRc= X-Google-Smtp-Source: AGHT+IGgPWDFUFvsoh4Eu3h95/Sh/XNQIQM+FfTSI/plOCqZ3lQCrUg2djPKk5L/jEKtossHKw/vRg== X-Received: by 2002:a05:690c:23c4:b0:77f:9dae:34f0 with SMTP id 00721157ae682-78c0c2627a5mr21697617b3.46.1764779011881; Wed, 03 Dec 2025 08:23:31 -0800 (PST) Received: from localhost ([2601:346:0:79bd:3422:8bf9:97bc:b085]) by smtp.gmail.com with ESMTPSA id 00721157ae682-78ad0d5fe1bsm74921787b3.15.2025.12.03.08.23.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Dec 2025 08:23:31 -0800 (PST) From: "Yury Norov (NVIDIA)" To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Andy Shevchenko , Christophe Leroy , Randy Dunlap , Ingo Molnar , Jani Nikula , Joonas Lahtinen , David Laight , Petr Pavlu , Andi Shyti , Rodrigo Vivi , Tvrtko Ursulin , Daniel Gomez , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Andrew Morton , linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: "Yury Norov (NVIDIA)" , Jani Nikula Subject: [PATCH v2 1/4] kernel.h: drop STACK_MAGIC macro Date: Wed, 3 Dec 2025 11:23:22 -0500 Message-ID: <20251203162329.280182-2-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251203162329.280182-1-yury.norov@gmail.com> References: <20251203162329.280182-1-yury.norov@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The macro was introduced in 1994, v1.0.4, for stacks protection. Since that, people found better ways to protect stacks, and now the macro is only used by i915 selftests. Move it to a local header and drop from the kernel.h. Reviewed-by: Andy Shevchenko Acked-by: Randy Dunlap Acked-by: Jani Nikula Signed-off-by: Yury Norov (NVIDIA) Reviewed-by: Christophe Leroy (CS GROUP) --- drivers/gpu/drm/i915/gt/selftest_ring_submission.c | 1 + drivers/gpu/drm/i915/i915_selftest.h | 2 ++ include/linux/kernel.h | 2 -- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/selftest_ring_submission.c b/drivers/g= pu/drm/i915/gt/selftest_ring_submission.c index 87ceb0f374b6..600333ae6c8c 100644 --- a/drivers/gpu/drm/i915/gt/selftest_ring_submission.c +++ b/drivers/gpu/drm/i915/gt/selftest_ring_submission.c @@ -3,6 +3,7 @@ * Copyright =C2=A9 2020 Intel Corporation */ =20 +#include "i915_selftest.h" #include "intel_engine_pm.h" #include "selftests/igt_flush_test.h" =20 diff --git a/drivers/gpu/drm/i915/i915_selftest.h b/drivers/gpu/drm/i915/i9= 15_selftest.h index bdf3e22c0a34..72922028f4ba 100644 --- a/drivers/gpu/drm/i915/i915_selftest.h +++ b/drivers/gpu/drm/i915/i915_selftest.h @@ -26,6 +26,8 @@ =20 #include =20 +#define STACK_MAGIC 0xdeadbeef + struct pci_dev; struct drm_i915_private; =20 diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 5b46924fdff5..61d63c57bc2d 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -40,8 +40,6 @@ =20 #include =20 -#define STACK_MAGIC 0xdeadbeef - struct completion; struct user; =20 --=20 2.43.0 From nobody Fri Dec 19 20:36:17 2025 Received: from mail-yx1-f43.google.com (mail-yx1-f43.google.com [74.125.224.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31F1E35B121 for ; Wed, 3 Dec 2025 16:23:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764779017; cv=none; b=aQ7nS/PbGq85pjGCv3iF5GU9xkO17KxsZX3uMha4J3JDBpXIsklE801ryUzrVgaF39VfcQOIVoBLSAczH2HUi9Ce+GZ1/u3ZKylESCJO7+UaVpFDfwWDn8VyrCWlpR6YS+AjEBStGfcB7ga3PSH0YoFhLmUIz6U+ps3Rk/dqrbU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764779017; c=relaxed/simple; bh=dgbvFR+wx/KjNNenMZxNoDBs++lYjE6vJP+Uu1pxyP0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A4s8GVDSRAZCcY9ZOS9A7Gpy3VK5R0ZmceuKDlKsGOjVrCXP81Nw6+1N79DJQikTVFJyDPCmN2d/ffZERYVWm3qzSGnPmabZqO+N/hVdODKgjVQXktNpuDvWBs7joEnTKMtBasbyzZOYeX/pr56TNHSzG5HNwMmPuCiiNnF3oSo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AxtqqDcc; arc=none smtp.client-ip=74.125.224.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AxtqqDcc" Received: by mail-yx1-f43.google.com with SMTP id 956f58d0204a3-640c857ce02so6431037d50.0 for ; Wed, 03 Dec 2025 08:23:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764779013; x=1765383813; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XTRUgw7WGLaikLRGDiMOA9ZeBlhI6lBDtpiU6az4ZI4=; b=AxtqqDccChC3gI+725Z7hgLZ/dTfwtKfWInrVu+NdzWjrA2AcPXsdC9YqSQUYj81vS iaHyegwPG6hpYXfG2ZCh6KvlFRH1HGFGT7sHlWySLEaH6m3DxsY3/n7fyIsdYIbKkQ22 lGNs3uUiWcMLKOrzTwiurOwnHavrNtoUnEKAhyn61NFPZOkrw+DGbrLX2UzfavKJU83I PIjOIAFqL62x8zJhYmpPNVkYhvAjsKese1nWLRkNtE54IKBVcx5w3UER/0XD3rB8A+Dr XEwZt33/5hTe3CKGzDXwffrJKnNNU0hK+tYy6TxrpxMj77DCH/G9IP9EEG37Du8gzQQ3 tzQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764779013; x=1765383813; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=XTRUgw7WGLaikLRGDiMOA9ZeBlhI6lBDtpiU6az4ZI4=; b=jA3DmYJpdSTEeyV/GCHKTlzr1h5tPd22MAcl+DPxgGIb2lbOfXDJ8Jz4xyaRIJ4Biy uLQVTu7eZxEs2mDgBORUVP8MlK5srZugmC6QN3oq/MZdXLk5cj6Sn+YJinW9FXgmxo/x alIwsAAuCjVoIBIECK4H0BzXiEYQvbgMbYtMatS71US4vQSqLFxnBUMGL5msz73jRd+I 4c1HrRyoi6kM6JPV+7+FmIdDbY5UTrO5LuUCoJZOr5++f+qCTluGXx1GwtF1KQIYuUzi LLjCrbuRhAZ8TRfklyOXWK7F8bZuVcP3CilrOmWSDJ+soX6eBQPZa75+sVoPWkbTmmCH GQfw== X-Forwarded-Encrypted: i=1; AJvYcCWh69d6dwnAdZ3UO5aOSNJECTBj3a6TYjWxvaDrYcmLoN0Hq3MmSVgbt3Y4QAzMhq6qcjOxEqknXevfytU=@vger.kernel.org X-Gm-Message-State: AOJu0YzdiyUdcqhVcgwkV9YncAKCKTkS79nn2t8KSwO6NfPrUDVLWCtV /ISc0ufnXRea6JaN4fpfazphKSVFuMJ/EngK2ycAbXVVlQhzLnhf4Ejf X-Gm-Gg: ASbGncs4Hj9lMG2dRmfDv55mM39tURHUvHHNPFlX49b0E94NRU36Qd3Nl83klt7ilMS 7ttrYFmj90Tj0YZ1PdgfACO+lpQgcjv0hfRdz0rKyrs+PXTDLZtm3R1gdDQl/nKTOU6bPY210XY wjJ0BQWMF+NynMrcxfHVy3LqxCEXyS4aRmEmZIbaNR+mSiypgqvXP2C0RnWUY+epXF+rKI/ijn+ OmyHcW92WuQ+yAfO11H7uySqsxmmOJkfkdIPsDCgVdqMoZLITr0I8/y5SiDRhs1JsITGqgxkzgG z71N/Y8YQBa+Eq8Ygmb5xKso+nHBDEAgOknEQI01NutvLaJG8BBVKIzQcYFhlzdCJkNF8aKL7YL fzugLz2I+oPJvQcM1DkWRDkGu6LWXyCmcHFZmXNDd6SEYmShCtzyPokEZ3+JOB6aVOrUYXFt9md aJViBBwYI= X-Google-Smtp-Source: AGHT+IGET334KxCtmx0dp1CAMPdeakUWlqKi8VbPsg55HeK6Rek4Uh9+JNYOdEve9S4FB5Tx8L5MGw== X-Received: by 2002:a05:690e:1442:b0:63e:3994:4ae3 with SMTP id 956f58d0204a3-6443703f028mr1928863d50.41.1764779012882; Wed, 03 Dec 2025 08:23:32 -0800 (PST) Received: from localhost ([2601:346:0:79bd:3422:8bf9:97bc:b085]) by smtp.gmail.com with ESMTPSA id 00721157ae682-78ad0c25ae5sm76024637b3.0.2025.12.03.08.23.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Dec 2025 08:23:32 -0800 (PST) From: "Yury Norov (NVIDIA)" To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Andy Shevchenko , Christophe Leroy , Randy Dunlap , Ingo Molnar , Jani Nikula , Joonas Lahtinen , David Laight , Petr Pavlu , Andi Shyti , Rodrigo Vivi , Tvrtko Ursulin , Daniel Gomez , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Andrew Morton , linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: "Yury Norov (NVIDIA)" Subject: [PATCH v2 2/4] moduleparam: include required headers explicitly Date: Wed, 3 Dec 2025 11:23:23 -0500 Message-ID: <20251203162329.280182-3-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251203162329.280182-1-yury.norov@gmail.com> References: <20251203162329.280182-1-yury.norov@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The following patch drops moduleparam.h dependency on kernel.h. In preparation to it, list all the required headers explicitly. Suggested-by: Petr Pavlu CC: Andy Shevchenko Signed-off-by: Yury Norov (NVIDIA) Reviewed-by: Andy Shevchenko Reviewed-by: Petr Pavlu --- include/linux/moduleparam.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 6907aedc4f74..ca7c8107c7c8 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -2,9 +2,14 @@ #ifndef _LINUX_MODULE_PARAMS_H #define _LINUX_MODULE_PARAMS_H /* (C) Copyright 2001, 2002 Rusty Russell IBM Corporation */ + +#include +#include +#include #include #include #include +#include =20 /* * The maximum module name length, including the NUL byte. --=20 2.43.0 From nobody Fri Dec 19 20:36:17 2025 Received: from mail-yx1-f52.google.com (mail-yx1-f52.google.com [74.125.224.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A97F035BDC7 for ; Wed, 3 Dec 2025 16:23:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764779017; cv=none; b=GyuHPsWjMRPakKD1/arr5/HlwEx0rgN2Rao41rgNzWx39hEupav7FFqT/Po2FCCIS/HYqlq+ugFruHLaGdAJlCPPUO59pMF4mP43GerHr/W77f2xNeq5X+ixBDbMWovuV9SnoZPOt1iPISi2a0SmtC2JvAVroWElEqwoGw6GSyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764779017; c=relaxed/simple; bh=IZvatrejqQTMAZAs55HnDtJ6l1UGli2aSM/VGzyF64M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LTSnzF5/1om+ErHUuimnqljUsR5Y6fPSZP0leKHR8zNOfsmDuZyDOHwLJVOIjZnxKS6G7fti6zRlZyDBnjF+v1QvaKSbfcbAkybC/DrNdJfGgrNfHO/K9LpyRXWHb4O4cfgpkmhFXPWYuxlQ24X8hAFy8EorACxCpSVVpuaB5a0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Vzxiy5Z3; arc=none smtp.client-ip=74.125.224.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Vzxiy5Z3" Received: by mail-yx1-f52.google.com with SMTP id 956f58d0204a3-642fcb38f35so5423690d50.1 for ; Wed, 03 Dec 2025 08:23:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764779014; x=1765383814; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BD9kPlC9NqK4/C2x8UYFTQBB7a0NtQWd16jS1I2SUnE=; b=Vzxiy5Z3syVFxXbv2YJu/n6ByE5xezc3Bc414Iqm2g3lBMqUeG5yqgwSwatHEWIyYh MbH7O6MmQfR4U+vhUX/r36k/nG0D7tZzf1n45wppm2RhGQbyCCEdzdcrWMnhx7aPN12k QI6a4ti0p+2RDuRfU9ZFTWXpE3O3wr/Gy0sG0bmgKa7MffWUe3EhDFamDprIHF3QrSWX vuM/WJ32wZxHhpuS5RZQjzUqdI3b1SIuFzQqEHvcejbLQU1ScN9tgQ3RWx47XVcq++xp g38fIDqDwkHoa/8y8AJnRCY/gO4sk8dDUdmUQkdtrHgbQTtLCA3CP0eVJQci8WcXP8Ol zQyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764779014; x=1765383814; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=BD9kPlC9NqK4/C2x8UYFTQBB7a0NtQWd16jS1I2SUnE=; b=L4aUELTMosEhgoHPAlE7fZtiGiR9a+uYPHhaecEh2TmwZz6GvXRNw6/x3jwntdvKCT fzZyzpSM245zqyoCWbW8XhnfOAUPCgUNpXF8FocaCcpp9XWqCTMkLyK0+m7itHRb3ZeP SGvfHtjg+tNFT/M284c1CiB6NVUUEXmcyz9ywSc2w63BZ4XXCWnJFiFlUH2NkC2fNiFv S6aTeAcIWuYuHNehalUxPkY2SpzlCEq5I64fSjMYwyYBPHZ278CMQ7XNTXjOydYrsAUD OyN8kHVOD1aS/m6zeaiUgywIL00VBjIxuBt71DJuppRvWnGcHLZ+Wf6v6On3zMIbpF4F EQZQ== X-Forwarded-Encrypted: i=1; AJvYcCWBiy1uo8BIryB8ds1zP7nHYn7TXzVzTL/UndhF8R7OfglCJEyFK3SOMMuz9aW0+xWRJiheDM+ELkN2Bj8=@vger.kernel.org X-Gm-Message-State: AOJu0YzBeLk9xZYpdEj7aL0VkKahdqhErbCKirxdVOhGVIdjoYNRZD4Z R3hGY2voveg/6ORC/dPKTjwdEESD+9y8FaIy174k0+LYKRV6H/PgAWbMF/ZoBA== X-Gm-Gg: ASbGnct9nzZYDbkGmeET32KQjiItf67KYrUIozFsEw8uFSq3rDVTF2j8Bcnp4ALJldD GV0dtuDr45fXXPCCI8FPF4IUWeb6Nu7sY/l7XvTWuDqUw00njPvtWmAtuQp/YOXmyfKV3Hsfbo+ MZW2cIti17uF6g2WYSbDmeCbc6lAyne87Ag4VrcbrEjZMrEUcsTZr1x1BUeONAhfgpYnwoMbCWk lxgiw2OCJtmqYiOI6TjYszbEJz5MS+vrQqrxUFiOPUN6H+H9wVN1SreYL+Eyb+4VpuW5+rZ1qbY 4W3TeCdNwO379MV389k92EAMvyCOWJ6KFgS4wz/DLi0X2OQUGrm7tNR3NWdSqnAYUGcJqVXn1NT Y/k9FmNU5SvyR2s5xLqFFN8c4YJu+S6WO4LNvfeeuQ8XvA5Wpv9a55YyUP97HKDvrzHIfIirfon L/6m+Ai+TIFVnTlEtGug== X-Google-Smtp-Source: AGHT+IED9MOFMxvYSeb8SzBPTCp8AtkRM45d5US6WkMtf3ZGLjHaRGAjGtBn2tkqfezw7s+564T5/Q== X-Received: by 2002:a05:690e:134a:b0:640:caa5:57bf with SMTP id 956f58d0204a3-64436fab865mr2201474d50.24.1764779014070; Wed, 03 Dec 2025 08:23:34 -0800 (PST) Received: from localhost ([2601:346:0:79bd:3422:8bf9:97bc:b085]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-6433c089431sm7456743d50.10.2025.12.03.08.23.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Dec 2025 08:23:33 -0800 (PST) From: "Yury Norov (NVIDIA)" To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Andy Shevchenko , Christophe Leroy , Randy Dunlap , Ingo Molnar , Jani Nikula , Joonas Lahtinen , David Laight , Petr Pavlu , Andi Shyti , Rodrigo Vivi , Tvrtko Ursulin , Daniel Gomez , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Andrew Morton , linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: "Yury Norov (NVIDIA)" Subject: [PATCH v2 3/4] kernel.h: move VERIFY_OCTAL_PERMISSIONS() to sysfs.h Date: Wed, 3 Dec 2025 11:23:24 -0500 Message-ID: <20251203162329.280182-4-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251203162329.280182-1-yury.norov@gmail.com> References: <20251203162329.280182-1-yury.norov@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The macro is related to sysfs, but is defined in kernel.h. Move it to the proper header, and unload the generic kernel.h. Now that the macro is removed from kernel.h, linux/moduleparam.h is decoupled, and kernel.h inclusion can be removed. Acked-by: Randy Dunlap Tested-by: Randy Dunlap Reviewed-by: Andy Shevchenko Signed-off-by: Yury Norov (NVIDIA) Reviewed-by: Petr Pavlu --- Documentation/filesystems/sysfs.rst | 2 +- include/linux/kernel.h | 12 ------------ include/linux/moduleparam.h | 2 +- include/linux/sysfs.h | 13 +++++++++++++ 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Documentation/filesystems/sysfs.rst b/Documentation/filesystem= s/sysfs.rst index 2703c04af7d0..ffcef4d6bc8d 100644 --- a/Documentation/filesystems/sysfs.rst +++ b/Documentation/filesystems/sysfs.rst @@ -120,7 +120,7 @@ is equivalent to doing:: .store =3D store_foo, }; =20 -Note as stated in include/linux/kernel.h "OTHER_WRITABLE? Generally +Note as stated in include/linux/sysfs.h "OTHER_WRITABLE? Generally considered a bad idea." so trying to set a sysfs file writable for everyone will fail reverting to RO mode for "Others". =20 diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 61d63c57bc2d..5b879bfea948 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -389,16 +389,4 @@ static inline void ftrace_dump(enum ftrace_dump_mode o= ops_dump_mode) { } # define REBUILD_DUE_TO_DYNAMIC_FTRACE #endif =20 -/* Permissions on a sysfs file: you didn't miss the 0 prefix did you? */ -#define VERIFY_OCTAL_PERMISSIONS(perms) \ - (BUILD_BUG_ON_ZERO((perms) < 0) + \ - BUILD_BUG_ON_ZERO((perms) > 0777) + \ - /* USER_READABLE >=3D GROUP_READABLE >=3D OTHER_READABLE */ \ - BUILD_BUG_ON_ZERO((((perms) >> 6) & 4) < (((perms) >> 3) & 4)) + \ - BUILD_BUG_ON_ZERO((((perms) >> 3) & 4) < ((perms) & 4)) + \ - /* USER_WRITABLE >=3D GROUP_WRITABLE */ \ - BUILD_BUG_ON_ZERO((((perms) >> 6) & 2) < (((perms) >> 3) & 2)) + \ - /* OTHER_WRITABLE? Generally considered a bad idea. */ \ - BUILD_BUG_ON_ZERO((perms) & 2) + \ - (perms)) #endif diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index ca7c8107c7c8..dd2d990b2611 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include =20 /* diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index 9a25a2911652..15ee3ef33991 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -798,4 +798,17 @@ static inline void sysfs_put(struct kernfs_node *kn) kernfs_put(kn); } =20 +/* Permissions on a sysfs file: you didn't miss the 0 prefix did you? */ +#define VERIFY_OCTAL_PERMISSIONS(perms) \ + (BUILD_BUG_ON_ZERO((perms) < 0) + \ + BUILD_BUG_ON_ZERO((perms) > 0777) + \ + /* USER_READABLE >=3D GROUP_READABLE >=3D OTHER_READABLE */ \ + BUILD_BUG_ON_ZERO((((perms) >> 6) & 4) < (((perms) >> 3) & 4)) + \ + BUILD_BUG_ON_ZERO((((perms) >> 3) & 4) < ((perms) & 4)) + \ + /* USER_WRITABLE >=3D GROUP_WRITABLE */ \ + BUILD_BUG_ON_ZERO((((perms) >> 6) & 2) < (((perms) >> 3) & 2)) + \ + /* OTHER_WRITABLE? Generally considered a bad idea. */ \ + BUILD_BUG_ON_ZERO((perms) & 2) + \ + (perms)) + #endif /* _SYSFS_H_ */ --=20 2.43.0 From nobody Fri Dec 19 20:36:17 2025 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6E0735BDB9 for ; Wed, 3 Dec 2025 16:23:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764779019; cv=none; b=gQGD15hTFMclQ8SADgelz8llqAUsnhduKJT5kvzcZQoEnvn6Fa+SbfMRVWKbh7BbcVcOocGzZj2k7Av2jdrqsIr3M7UzoXkuYhyEynTXNyfPU3f+V7+E8U+7hr69xIuiv4Ku5mEIhPGL/wF3AdMr3u/igDgyrH3B0+G9vnu4ooo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764779019; c=relaxed/simple; bh=/xGRmTZUvawxEclmA+XPVYhBIHs2uRp6oua5Ra+o038=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H+Bly39CdT/LWGEaGti7Sn3FiBEKsyTv6gSyNECtLJtHGBDHm9xTt4dKFyodNAajKbPtC0rmrVAHs3IngCk+pxDowkXzD5ZvRtk3lu1kWZAIIk59OdSrIz2L4pHUIU4pHMEfHIRURUbVFJ5DMbrAwiLnvyFgPVKjRdLSYLrgijM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JwVqGuob; arc=none smtp.client-ip=209.85.128.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JwVqGuob" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-78a8bed470bso55591497b3.0 for ; Wed, 03 Dec 2025 08:23:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764779015; x=1765383815; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u+YkI7yxgZbxvWG5CSZuoiKBiRKPO6bzZHfGPllRKlE=; b=JwVqGuob+TtzuGpO1mCJ3HwLFhlC5R0t5gflYrzDg9O7XoUqKVZiwfMUXLwaujI5HX yKXcTRZqi9WiGxHc0ueJ91ybQZwqO4RkNxSyi49wTDkUexkShTZyZ/uLP07TRjiZ0HQk /OZ1a4bRPJFwcMpkr4RM3ItexHZLgbGj4b6LqJhEf9WkQJSH/pZO/xQD6FTjYK6gkfz4 Uyd9V5nLdSJMUm4dK2CtMIfc5LiR/CAFe5NOtiZvjZWtnOZEdDS/U5dNSGOLSVKSGs8a gUAH9nie0CmdJtKkIRjXtMizdX1XEBe6WVUmZTkuuBVIYdTWF8ncAvVIogpF2F6Y7kop b8Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764779015; x=1765383815; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=u+YkI7yxgZbxvWG5CSZuoiKBiRKPO6bzZHfGPllRKlE=; b=CLP3JyMTYho1ghwAUuSBaqqgdY1dt1mCyDWEHUV/tLc4aH1v3qiJ3iKrPlgERLx58n n0MmvI4wnn0a+RnZpYKnqtOjeqWEwfl2iR1fuYQ7ehdWAA6JYP2W/BEm8VZja7yv3Ttz tkdOrnWncmqALzjf87OjWfatI9zVy6FtmVqbDtOfbxcco8OPELV8IHFXQTySeeWoOiAV HsRj3eZ2uFyABJ162vp0VkX+YYzPG74Fhffu5tzGZBMCFqpf/0lkwPKwmQr8KKGYQqnv rdNoDBMG9fP2ED9+HJ8cFfPQDwIl9w7wqvpAh0dhYMz5iT22rOKaC3ucx4sP7A3LSMzf QQzA== X-Forwarded-Encrypted: i=1; AJvYcCUiodsawgtvD6xR1IEg09XT094kasgXpytF/0JajebEo4Cx2qBYGdDDPMFFgJt9pLRh/9/FHldYZOcDj0A=@vger.kernel.org X-Gm-Message-State: AOJu0YxA9M2O3Dfoo9pNDTeIoA+90yLtw1KHP/uBn3C2jBpd+Dh6pl+Q QBGFegvWs9tutwX8IcbaHfVUqBGTnA05eirRuA9I4JzOyWwQZXnfl1T0 X-Gm-Gg: ASbGncsAylRzXZjB/7yB4dvZkKEjgMp9ug4u8wpSIYb7+ee5oFSTy5GSiVLJenG78ul eP54SEsSxUmBqU3qO8Fcesglv5S3calpcs9FBGUasMNTUjs38pALuhkBJXcbhZEONbbP3aJvuBf si7spqzKRvYorf7Ke+aw+S6J/NB+8GISaec+L1avAUWT+4ER4/uqJ2KbwS8BTy2mn4UizPJ6iSy K4g6pi88eOv8f3DikyXGfj2V8KPUDX0YyMYRWkKu/mfq25r6NATODj9+er0VD/AOAhmUoUp4PyA 750ZyEkBiC4xzJyi2xuMSjyCUvu5gyFF7eBK8FwA+dvb11W93VVsaYglcKdaDMpu3L78oENQ+hj jFhKoSYx5En3WrU9ZY2KrqZzcw0uiOxoR6EGnqtDx984Imct1rUtOmRdMIx+DO0+Df6pJ2pbCCD 2AwJ/v3/A= X-Google-Smtp-Source: AGHT+IEPVhBVhHqmXlFlujsvZ2Z7YgyVduNJK+ouLa37SCa3WPL1QjTtN4FQT3/5zFNK8Ka8ZcDd2A== X-Received: by 2002:a05:690c:25c4:b0:786:5471:f44c with SMTP id 00721157ae682-78c0c25b617mr46763917b3.63.1764779014985; Wed, 03 Dec 2025 08:23:34 -0800 (PST) Received: from localhost ([2601:346:0:79bd:3422:8bf9:97bc:b085]) by smtp.gmail.com with ESMTPSA id 00721157ae682-78ad102d1aasm75414447b3.43.2025.12.03.08.23.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Dec 2025 08:23:34 -0800 (PST) From: "Yury Norov (NVIDIA)" To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Andy Shevchenko , Christophe Leroy , Randy Dunlap , Ingo Molnar , Jani Nikula , Joonas Lahtinen , David Laight , Petr Pavlu , Andi Shyti , Rodrigo Vivi , Tvrtko Ursulin , Daniel Gomez , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Andrew Morton , linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: "Yury Norov (NVIDIA)" Subject: [PATCH v2 4/4] tracing: move tracing declarations from kernel.h to a dedicated header Date: Wed, 3 Dec 2025 11:23:25 -0500 Message-ID: <20251203162329.280182-5-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251203162329.280182-1-yury.norov@gmail.com> References: <20251203162329.280182-1-yury.norov@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Tracing is a half of the kernel.h in terms of LOCs, although it's a self-consistent part. It is intended for quick debugging purposes and isn't used by the normal tracing utilities. Move it to a separate header. If someone needs to just throw a trace_printk() in their driver, they will not have to pull all the heavy tracing machinery. This is a pure move, except for removing a few 'extern's. Acked-by: Steven Rostedt Signed-off-by: Yury Norov (NVIDIA) --- MAINTAINERS | 1 + include/linux/kernel.h | 195 +------------------------------------- include/linux/tracing.h | 203 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 205 insertions(+), 194 deletions(-) create mode 100644 include/linux/tracing.h diff --git a/MAINTAINERS b/MAINTAINERS index 3468f6827b13..107cadb613da 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26080,6 +26080,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/gi= t/trace/linux-trace.git F: Documentation/trace/* F: fs/tracefs/ F: include/linux/trace*.h +F: include/linux/tracing.h F: include/trace/ F: kernel/trace/ F: kernel/tracepoint.c diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 5b879bfea948..2e9d65177f45 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -190,200 +191,6 @@ enum system_states { }; extern enum system_states system_state; =20 -/* - * General tracing related utility functions - trace_printk(), - * tracing_on/tracing_off and tracing_start()/tracing_stop - * - * Use tracing_on/tracing_off when you want to quickly turn on or off - * tracing. It simply enables or disables the recording of the trace event= s. - * This also corresponds to the user space /sys/kernel/tracing/tracing_on - * file, which gives a means for the kernel and userspace to interact. - * Place a tracing_off() in the kernel where you want tracing to end. - * From user space, examine the trace, and then echo 1 > tracing_on - * to continue tracing. - * - * tracing_stop/tracing_start has slightly more overhead. It is used - * by things like suspend to ram where disabling the recording of the - * trace is not enough, but tracing must actually stop because things - * like calling smp_processor_id() may crash the system. - * - * Most likely, you want to use tracing_on/tracing_off. - */ - -enum ftrace_dump_mode { - DUMP_NONE, - DUMP_ALL, - DUMP_ORIG, - DUMP_PARAM, -}; - -#ifdef CONFIG_TRACING -void tracing_on(void); -void tracing_off(void); -int tracing_is_on(void); -void tracing_snapshot(void); -void tracing_snapshot_alloc(void); - -extern void tracing_start(void); -extern void tracing_stop(void); - -static inline __printf(1, 2) -void ____trace_printk_check_format(const char *fmt, ...) -{ -} -#define __trace_printk_check_format(fmt, args...) \ -do { \ - if (0) \ - ____trace_printk_check_format(fmt, ##args); \ -} while (0) - -/** - * trace_printk - printf formatting in the ftrace buffer - * @fmt: the printf format for printing - * - * Note: __trace_printk is an internal function for trace_printk() and - * the @ip is passed in via the trace_printk() macro. - * - * This function allows a kernel developer to debug fast path sections - * that printk is not appropriate for. By scattering in various - * printk like tracing in the code, a developer can quickly see - * where problems are occurring. - * - * This is intended as a debugging tool for the developer only. - * Please refrain from leaving trace_printks scattered around in - * your code. (Extra memory is used for special buffers that are - * allocated when trace_printk() is used.) - * - * A little optimization trick is done here. If there's only one - * argument, there's no need to scan the string for printf formats. - * The trace_puts() will suffice. But how can we take advantage of - * using trace_puts() when trace_printk() has only one argument? - * By stringifying the args and checking the size we can tell - * whether or not there are args. __stringify((__VA_ARGS__)) will - * turn into "()\0" with a size of 3 when there are no args, anything - * else will be bigger. All we need to do is define a string to this, - * and then take its size and compare to 3. If it's bigger, use - * do_trace_printk() otherwise, optimize it to trace_puts(). Then just - * let gcc optimize the rest. - */ - -#define trace_printk(fmt, ...) \ -do { \ - char _______STR[] =3D __stringify((__VA_ARGS__)); \ - if (sizeof(_______STR) > 3) \ - do_trace_printk(fmt, ##__VA_ARGS__); \ - else \ - trace_puts(fmt); \ -} while (0) - -#define do_trace_printk(fmt, args...) \ -do { \ - static const char *trace_printk_fmt __used \ - __section("__trace_printk_fmt") =3D \ - __builtin_constant_p(fmt) ? fmt : NULL; \ - \ - __trace_printk_check_format(fmt, ##args); \ - \ - if (__builtin_constant_p(fmt)) \ - __trace_bprintk(_THIS_IP_, trace_printk_fmt, ##args); \ - else \ - __trace_printk(_THIS_IP_, fmt, ##args); \ -} while (0) - -extern __printf(2, 3) -int __trace_bprintk(unsigned long ip, const char *fmt, ...); - -extern __printf(2, 3) -int __trace_printk(unsigned long ip, const char *fmt, ...); - -/** - * trace_puts - write a string into the ftrace buffer - * @str: the string to record - * - * Note: __trace_bputs is an internal function for trace_puts and - * the @ip is passed in via the trace_puts macro. - * - * This is similar to trace_printk() but is made for those really fast - * paths that a developer wants the least amount of "Heisenbug" effects, - * where the processing of the print format is still too much. - * - * This function allows a kernel developer to debug fast path sections - * that printk is not appropriate for. By scattering in various - * printk like tracing in the code, a developer can quickly see - * where problems are occurring. - * - * This is intended as a debugging tool for the developer only. - * Please refrain from leaving trace_puts scattered around in - * your code. (Extra memory is used for special buffers that are - * allocated when trace_puts() is used.) - * - * Returns: 0 if nothing was written, positive # if string was. - * (1 when __trace_bputs is used, strlen(str) when __trace_puts is used) - */ - -#define trace_puts(str) ({ \ - static const char *trace_printk_fmt __used \ - __section("__trace_printk_fmt") =3D \ - __builtin_constant_p(str) ? str : NULL; \ - \ - if (__builtin_constant_p(str)) \ - __trace_bputs(_THIS_IP_, trace_printk_fmt); \ - else \ - __trace_puts(_THIS_IP_, str, strlen(str)); \ -}) -extern int __trace_bputs(unsigned long ip, const char *str); -extern int __trace_puts(unsigned long ip, const char *str, int size); - -extern void trace_dump_stack(int skip); - -/* - * The double __builtin_constant_p is because gcc will give us an error - * if we try to allocate the static variable to fmt if it is not a - * constant. Even with the outer if statement. - */ -#define ftrace_vprintk(fmt, vargs) \ -do { \ - if (__builtin_constant_p(fmt)) { \ - static const char *trace_printk_fmt __used \ - __section("__trace_printk_fmt") =3D \ - __builtin_constant_p(fmt) ? fmt : NULL; \ - \ - __ftrace_vbprintk(_THIS_IP_, trace_printk_fmt, vargs); \ - } else \ - __ftrace_vprintk(_THIS_IP_, fmt, vargs); \ -} while (0) - -extern __printf(2, 0) int -__ftrace_vbprintk(unsigned long ip, const char *fmt, va_list ap); - -extern __printf(2, 0) int -__ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap); - -extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode); -#else -static inline void tracing_start(void) { } -static inline void tracing_stop(void) { } -static inline void trace_dump_stack(int skip) { } - -static inline void tracing_on(void) { } -static inline void tracing_off(void) { } -static inline int tracing_is_on(void) { return 0; } -static inline void tracing_snapshot(void) { } -static inline void tracing_snapshot_alloc(void) { } - -static inline __printf(1, 2) -int trace_printk(const char *fmt, ...) -{ - return 0; -} -static __printf(1, 0) inline int -ftrace_vprintk(const char *fmt, va_list ap) -{ - return 0; -} -static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } -#endif /* CONFIG_TRACING */ - /* Rebuild everything on CONFIG_DYNAMIC_FTRACE */ #ifdef CONFIG_DYNAMIC_FTRACE # define REBUILD_DUE_TO_DYNAMIC_FTRACE diff --git a/include/linux/tracing.h b/include/linux/tracing.h new file mode 100644 index 000000000000..1989e6328c59 --- /dev/null +++ b/include/linux/tracing.h @@ -0,0 +1,203 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_TRACING_H +#define _LINUX_TRACING_H + +#include +#include +#include + +/* + * General tracing related utility functions - trace_printk(), + * tracing_on/tracing_off and tracing_start()/tracing_stop + * + * Use tracing_on/tracing_off when you want to quickly turn on or off + * tracing. It simply enables or disables the recording of the trace event= s. + * This also corresponds to the user space /sys/kernel/tracing/tracing_on + * file, which gives a means for the kernel and userspace to interact. + * Place a tracing_off() in the kernel where you want tracing to end. + * From user space, examine the trace, and then echo 1 > tracing_on + * to continue tracing. + * + * tracing_stop/tracing_start has slightly more overhead. It is used + * by things like suspend to ram where disabling the recording of the + * trace is not enough, but tracing must actually stop because things + * like calling smp_processor_id() may crash the system. + * + * Most likely, you want to use tracing_on/tracing_off. + */ + +enum ftrace_dump_mode { + DUMP_NONE, + DUMP_ALL, + DUMP_ORIG, + DUMP_PARAM, +}; + +#ifdef CONFIG_TRACING +void tracing_on(void); +void tracing_off(void); +int tracing_is_on(void); +void tracing_snapshot(void); +void tracing_snapshot_alloc(void); + +void tracing_start(void); +void tracing_stop(void); + +static inline __printf(1, 2) +void ____trace_printk_check_format(const char *fmt, ...) +{ +} +#define __trace_printk_check_format(fmt, args...) \ +do { \ + if (0) \ + ____trace_printk_check_format(fmt, ##args); \ +} while (0) + +/** + * trace_printk - printf formatting in the ftrace buffer + * @fmt: the printf format for printing + * + * Note: __trace_printk is an internal function for trace_printk() and + * the @ip is passed in via the trace_printk() macro. + * + * This function allows a kernel developer to debug fast path sections + * that printk is not appropriate for. By scattering in various + * printk like tracing in the code, a developer can quickly see + * where problems are occurring. + * + * This is intended as a debugging tool for the developer only. + * Please refrain from leaving trace_printks scattered around in + * your code. (Extra memory is used for special buffers that are + * allocated when trace_printk() is used.) + * + * A little optimization trick is done here. If there's only one + * argument, there's no need to scan the string for printf formats. + * The trace_puts() will suffice. But how can we take advantage of + * using trace_puts() when trace_printk() has only one argument? + * By stringifying the args and checking the size we can tell + * whether or not there are args. __stringify((__VA_ARGS__)) will + * turn into "()\0" with a size of 3 when there are no args, anything + * else will be bigger. All we need to do is define a string to this, + * and then take its size and compare to 3. If it's bigger, use + * do_trace_printk() otherwise, optimize it to trace_puts(). Then just + * let gcc optimize the rest. + */ + +#define trace_printk(fmt, ...) \ +do { \ + char _______STR[] =3D __stringify((__VA_ARGS__)); \ + if (sizeof(_______STR) > 3) \ + do_trace_printk(fmt, ##__VA_ARGS__); \ + else \ + trace_puts(fmt); \ +} while (0) + +#define do_trace_printk(fmt, args...) \ +do { \ + static const char *trace_printk_fmt __used \ + __section("__trace_printk_fmt") =3D \ + __builtin_constant_p(fmt) ? fmt : NULL; \ + \ + __trace_printk_check_format(fmt, ##args); \ + \ + if (__builtin_constant_p(fmt)) \ + __trace_bprintk(_THIS_IP_, trace_printk_fmt, ##args); \ + else \ + __trace_printk(_THIS_IP_, fmt, ##args); \ +} while (0) + +__printf(2, 3) +int __trace_bprintk(unsigned long ip, const char *fmt, ...); + +__printf(2, 3) +int __trace_printk(unsigned long ip, const char *fmt, ...); + +/** + * trace_puts - write a string into the ftrace buffer + * @str: the string to record + * + * Note: __trace_bputs is an internal function for trace_puts and + * the @ip is passed in via the trace_puts macro. + * + * This is similar to trace_printk() but is made for those really fast + * paths that a developer wants the least amount of "Heisenbug" effects, + * where the processing of the print format is still too much. + * + * This function allows a kernel developer to debug fast path sections + * that printk is not appropriate for. By scattering in various + * printk like tracing in the code, a developer can quickly see + * where problems are occurring. + * + * This is intended as a debugging tool for the developer only. + * Please refrain from leaving trace_puts scattered around in + * your code. (Extra memory is used for special buffers that are + * allocated when trace_puts() is used.) + * + * Returns: 0 if nothing was written, positive # if string was. + * (1 when __trace_bputs is used, strlen(str) when __trace_puts is used) + */ + +#define trace_puts(str) ({ \ + static const char *trace_printk_fmt __used \ + __section("__trace_printk_fmt") =3D \ + __builtin_constant_p(str) ? str : NULL; \ + \ + if (__builtin_constant_p(str)) \ + __trace_bputs(_THIS_IP_, trace_printk_fmt); \ + else \ + __trace_puts(_THIS_IP_, str, strlen(str)); \ +}) +int __trace_bputs(unsigned long ip, const char *str); +int __trace_puts(unsigned long ip, const char *str, int size); + +void trace_dump_stack(int skip); + +/* + * The double __builtin_constant_p is because gcc will give us an error + * if we try to allocate the static variable to fmt if it is not a + * constant. Even with the outer if statement. + */ +#define ftrace_vprintk(fmt, vargs) \ +do { \ + if (__builtin_constant_p(fmt)) { \ + static const char *trace_printk_fmt __used \ + __section("__trace_printk_fmt") =3D \ + __builtin_constant_p(fmt) ? fmt : NULL; \ + \ + __ftrace_vbprintk(_THIS_IP_, trace_printk_fmt, vargs); \ + } else \ + __ftrace_vprintk(_THIS_IP_, fmt, vargs); \ +} while (0) + +__printf(2, 0) int +__ftrace_vbprintk(unsigned long ip, const char *fmt, va_list ap); + +__printf(2, 0) int +__ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap); + +void ftrace_dump(enum ftrace_dump_mode oops_dump_mode); +#else +static inline void tracing_start(void) { } +static inline void tracing_stop(void) { } +static inline void trace_dump_stack(int skip) { } + +static inline void tracing_on(void) { } +static inline void tracing_off(void) { } +static inline int tracing_is_on(void) { return 0; } +static inline void tracing_snapshot(void) { } +static inline void tracing_snapshot_alloc(void) { } + +static inline __printf(1, 2) +int trace_printk(const char *fmt, ...) +{ + return 0; +} +static __printf(1, 0) inline int +ftrace_vprintk(const char *fmt, va_list ap) +{ + return 0; +} +static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } +#endif /* CONFIG_TRACING */ + +#endif --=20 2.43.0