From nobody Tue Dec 16 07:33:21 2025 Received: from mail-yx1-f50.google.com (mail-yx1-f50.google.com [74.125.224.50]) (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 3485732ED2D for ; Fri, 5 Dec 2025 17:52:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764957164; cv=none; b=GwTJR2fffbreZhFtHiHGCQmS13M3iLYgvpMv1nvOgD9ctFSvHgJ7/E9VgVE0cyurPGn/42C3D6/8G3HziDpNA2fV93j0RVDng6J2QwwCuj6GOlfaguShnE/6EWINwssbHLCJWE4qu3BVOv2pWzAnYgvfbnmazcpPuyGuSWbDomc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764957164; c=relaxed/simple; bh=/OtVIm0Tic2jaMDmVwxI6p1VsRr2RMHqItaakWV63oc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BNXy4aWSlblKOfaLf/Gw7hfl2eYboOvTCnkXmL3m7bj5xg6JI39/i5gtLUZlM8vD9MXYdCKQTDhjAm/GadwDdv9JiXpnYSxdRf+kR4QjDlu+AgHBpPcIBjmmUcEDqR6JAsqToh1NnGkz1G1eDDAYgqx8xXyFXyJgQttIxKa2NMM= 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=NYm9IiCh; arc=none smtp.client-ip=74.125.224.50 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="NYm9IiCh" Received: by mail-yx1-f50.google.com with SMTP id 956f58d0204a3-641e9422473so2052833d50.2 for ; Fri, 05 Dec 2025 09:52:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764957160; x=1765561960; 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=AIMsjwiJg4RqJtb77Sd/3hjNTplhvG97vleKrEOTwfY=; b=NYm9IiChSv/tk8xyCZC6OCWSX0mOSamUGFmH0vPGGG8++Zpa3B3zL7LNdB5HrLISNP lTTFhr9MRVubJdymuqV1atpRDTQVAb8KmdkQJ+VvrP2x2hbqVcIw6uG3FWY2hX1rHR/L eGqqSGeDn2+aHdhK0zQkfsTX42ZzZ5d/yYLoU2MDku96CVvgu/n1FHIVrvb/a2Ai2aPo zuYzuwFpHwlJRmAyl7AqVrlqyoprUCveJCkS+p79IubOnqOytKONdD/F9LL4onX4O4D4 Ol9rYgKTDQeoSMv9Lgrwfvk0Yd8vw1KhOSgBgiBTVWf7WoaP0EaC+cp/YkXq5cXO5kU1 Bqug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764957160; x=1765561960; 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=AIMsjwiJg4RqJtb77Sd/3hjNTplhvG97vleKrEOTwfY=; b=SqhJT5Co2X41e4KgJTotclGN4WICgpmkxZzcC2Bm8uT3dOm+MSPQMvZsp1WIVjEpwo Sb66IydaYdkAO7O2F1APs+Zj/OGAZOWGbwWm55AqbxRiLuVr2eKhwzcnbNYC5wdjL/lM Xek0zH3FErZ5tGplmoRf3YePjoCogkwHBIsAszqXLH5SkbA1fIs+g2f9xpH7yDMYzeRX AAJoxboxBCIeDYb9AKUjyk4S3ZGlV5Ji1UrvO2BD9BjRalPffCk6X2r2q+ssJzofdz5q /HOthu0dfhy9Af/TxT+7wAaozubRykm598bmx632dJVj1F8LPjCFFVVoOPM+BgDj6qjo YXtA== X-Forwarded-Encrypted: i=1; AJvYcCUY+7qqTkv48mV0CwBbDSPUPOrHOERAlMAA/n+asa0NmykmMovv8SgZWPWH1PtcNNNyY6EaGF41k4sbhDo=@vger.kernel.org X-Gm-Message-State: AOJu0YwtADMbseSmn68sPyZMHOeLR51mPabDN22tkSPjx42X1l/Yk4av wjAwEm8YL2Wg+8PgJGnsgzGZhOcjhN4wMtwLOvlyNp1pzW7yv/XgtS1V X-Gm-Gg: ASbGncsK7BtcVC5LdELfYDZL9JkJUYuJdB9GYKyiPbJPqfOuNZOK1V47GKNH8cuJMsM Bce9A1FruEZn4VKXbusZQ0FktN683O/VlUiGrk4vTvURmyOOanXfFPA0+fqxacK3vkRwjD+sh6R 08YZGC3knaL5wIYn0Eaxmmg8KmM2FqLMslkZgqEsC6YRmsl1McdGc4+PDYDeAAngMYF74sO6mkJ yrh8qQdkcpF2ifv69J0eIYWajMB+XZHNCxzangLpPbNkGZgx6ZWZSNjocSbE2FrVEn7dCabc1YQ 8vCAYpmN+l8EDQxs34s7MhD7p8fY4v8/5dVs/WYgtSZm1pNL4ruQwKLpRQfcd2m974h3ircNDc1 uVMxwlNhS+yuMYXoHRJk13S9s6ORBXvQ4k4jB2RUl2S9euvco3Ywyf06VGyEtGyKsSVGQMWDfvc jXPjCbUQ== X-Google-Smtp-Source: AGHT+IEj0tKsgnYq0A9mSlKiTaWZ9dj9I4yKU0s/KO7Y2wAesrkqKoyujesKH3ZFEOTbGXg0vUaC6A== X-Received: by 2002:a05:690c:6f83:b0:788:e74:b267 with SMTP id 00721157ae682-78c1893c4e9mr110130367b3.65.1764957159703; Fri, 05 Dec 2025 09:52:39 -0800 (PST) Received: from localhost ([2601:346:0:79bd:be2a:7e4d:3bf:3fbc]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-6443f5a3e81sm2042888d50.16.2025.12.05.09.52.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Dec 2025 09:52:39 -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 v3 1/4] kernel.h: drop STACK_MAGIC macro Date: Fri, 5 Dec 2025 12:52:32 -0500 Message-ID: <20251205175237.242022-2-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251205175237.242022-1-yury.norov@gmail.com> References: <20251205175237.242022-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 Reviewed-by: Christophe Leroy (CS GROUP) Signed-off-by: Yury Norov (NVIDIA) Reviewed-by: Aaron Tomlin Reviewed-by: Andi Shyti --- 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 Tue Dec 16 07:33:21 2025 Received: from mail-yx1-f42.google.com (mail-yx1-f42.google.com [74.125.224.42]) (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 08934344022 for ; Fri, 5 Dec 2025 17:52:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764957164; cv=none; b=CYINKAV6DoCFMpH+2rCXObzBPBArzJTmGCcGGiTllP0bXVqqIwGX8m6xsnXrZUs+42x/qEwPXiHKVCJtFPzHiymzoSgVue2nGub8nKt+jVAp2M9aDNwRqeH4cSwLq8se1vNmwZ7+vO3KZpIg9pXQs1UaiKnhHmHdzAUT2XQD0Rc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764957164; c=relaxed/simple; bh=WSOyLaVAbG8nPsi8Fh9vJNEZaG1V5dArA0Vg97NjEvA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b4satW6lB7LkIphMvXCQ0GEwGJunM/zx9W7Rt3ovLOLw1zmcrU1WCLMv/lUHqyBxava8aVdKrVrphYFH7X6hZsqWmFwnXqlLmvY1qmuE7bM+WRwzPUtKbDbD6gGXL1i/Qlj1F/XQAQRlQGuA6JOTHJj2opv4NpM5VEgiNh83rYk= 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=dJnkwzYQ; arc=none smtp.client-ip=74.125.224.42 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="dJnkwzYQ" Received: by mail-yx1-f42.google.com with SMTP id 956f58d0204a3-64306a32ed2so2133389d50.2 for ; Fri, 05 Dec 2025 09:52:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764957161; x=1765561961; 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=wgVl4UPQOdVuiUQDADihFeO6bzjnbrTXUsfv7qld2JA=; b=dJnkwzYQfklN6TTaAJuQ16YzRJmHq+jURTpxoQvIIW1FMEKONaWFcFiYjt0swVjt+A zr0hYyYIWXpWT3MLcL7kPDXDEmw1dzGUlpDgpdNVyPhJsKLh7ickV28HCqTZR5sn+y/9 b2NcGaQEK4/5yDhH+SulYSio94HPbfMhHSjKVdMMVu1Cqk5Z5QQsWMQl+T7v0zVU4k24 wI0jGFaMtRGhFzQw1DFo1Vy1Z5cegY/xUeHb346U+sA4mCpvhjkuRbFqz3hxWCRZXixo PA/HxOc77rlsIoXoQxbmwi1IhcZ4OOEarFU+si7/29hdfWCPTzFBpbmgjYdHMtdJ2Eza /osA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764957161; x=1765561961; 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=wgVl4UPQOdVuiUQDADihFeO6bzjnbrTXUsfv7qld2JA=; b=LH4HYjtulZDGG1+IiYcrCcyEczXsLjFOrTx/urFsqv1yX0dW+RrXU3HgyZc8nL+v9r MNeS/hqga0XFnkcEctpbBRkZ18JkhrAQ2W0Fi/dingHTCfJvY/s/V09ODL5dEozN6KO7 BX79ymhHtxEQ9Uw+KoQ62J1fuBiembCYhBp+EJqQ74m379yDYopXNBvQkS17/RpcOY4d oaw7mHWw70zDeFcCzX8I0IG6x1NLIMbSjDCORpRV9Hmg3cXywmqupEZxfoOr0dzlAYXN 6Cv7e2Qwa7PGvDBU7odopzG8KP6rjnQiFr5hfHdUdMMKaQPK8YwfJG3J8n5zrmERjSC1 IZlg== X-Forwarded-Encrypted: i=1; AJvYcCUUW2NC0mvhGAvsWQ+fOwKqmOaVtTBe2y7fRF55c3EyunFwvk9tcav7MIIy9pW5FnQlK5vdmBLs8HV3Pwk=@vger.kernel.org X-Gm-Message-State: AOJu0YygFhb0a9gRxrRIjqO16RJAIlzIybTdHgr8q4yJofsS2Kdct53a qE05QqhuY/pnqTSDl52YGfNhGkxnX0l2pvQ5YeaZY25jzyRRYmMWeKy2 X-Gm-Gg: ASbGncufo0AcceeUuHKrg37WpE44Gz9Cwnl/5Wiv4nXZj+3SNFAfonMpn0NrB5p6+1w XHl8riXUiaN16if0MQcGTU8/DnTafYGWjHmG70PYwbemtc4K+4Lb/BBSPYRYlYJBtmzQOzN1FyA L1WUfGCjXzI9Zw5DPR7fXJWmPwMw5v5Yl0kl4rk76jtnwB7g6yReuIC0X4VtJ2Mg5b7cm7eEDaE XGZITQTDJRSeon2W5UjGFj6YxQsNuTM3+jvIrwkJgmNUJMm/A8kVzYlgGCS+H2FoDMiy89QXYdN hrpaOIbVwohhbc6d0udckQSQQP+rwdoIgBgTroewq68o8jl4oaXHww4Y95yV0xFwFbmxFB5sEsD 11cHXz/FuvMH85a4uiITEvcWC5nJDJQU+3uSfB1qhz58NDwe5afWWbqAXXylXWcba4cgyqLqZOb GuAkfcs4NegzHloPQM X-Google-Smtp-Source: AGHT+IEmHQrMAc5KhCOB44tPj+C3L7ufMqCejlU3WOz8uzACjmQ1s89nXnFrR9N4AEaBc1g4PgKHgQ== X-Received: by 2002:a05:690c:4f12:b0:78c:2803:c819 with SMTP id 00721157ae682-78c2803ceb0mr17790807b3.22.1764957160598; Fri, 05 Dec 2025 09:52:40 -0800 (PST) Received: from localhost ([2601:346:0:79bd:be2a:7e4d:3bf:3fbc]) by smtp.gmail.com with ESMTPSA id 00721157ae682-78c1b779458sm18946927b3.35.2025.12.05.09.52.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Dec 2025 09:52:40 -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 v3 2/4] moduleparam: include required headers explicitly Date: Fri, 5 Dec 2025 12:52:33 -0500 Message-ID: <20251205175237.242022-3-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251205175237.242022-1-yury.norov@gmail.com> References: <20251205175237.242022-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 Reviewed-by: Petr Pavlu Reviewed-by: Andy Shevchenko Signed-off-by: Yury Norov (NVIDIA) --- 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 Tue Dec 16 07:33:21 2025 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) (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 BD485800 for ; Fri, 5 Dec 2025 17:52:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764957166; cv=none; b=TNbnPogVyaxI6i/ilyl4rlHIvKoi+4RBlDGhjfRIP2niq/vOMQjG1McC/rVvdaSVZDbspOcPd6P6i42TRjNKkyfXf0jokzv/cBRZCbsMPgqgenu+VyND3QrM52/+vf1o786AoO96rwfkRRQFYSa58rfqR09V3upUH2BhrRjBriU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764957166; c=relaxed/simple; bh=6og34fQEZBW+taDejCAi+47vabOoRDY50X8etN5NVU8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Muj64jz4OdCX5ow7IIzh8eJ8J40fuk1DQz5Orrgkt2yGWl7WdUs3rsmKyXEqrzKFjMgB1CXA6xCCUU3TT1hWwWpGxjzdDcl72DcJa9A1b9iyXkszKJ+aDjJRoCtwr3zOg7/V9jdSb+l5+9U/zYpHHqmQwInHRXIayHdMBrfDJ8k= 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=eK7KtmiN; arc=none smtp.client-ip=209.85.128.175 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="eK7KtmiN" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-78c2e5745bdso5454697b3.0 for ; Fri, 05 Dec 2025 09:52:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764957162; x=1765561962; 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=qMcm6nWRLFBVfXJXBUXf6pE+rQOQZFvzs8Y8xJm6ysU=; b=eK7KtmiNIUz+wA4gwYUjx6iD3q9CGZyEdHp/VrKUxOvvX4jDjS6rUrZaTG0u2vMZPf jd+EM1KPrp+vIM+S+7xbgb4ZcVoY/syDiPKoqjJ4wLgSgkTXFSQqNfrMgKzndJKiHvp0 yw+li5ikEj8CMO/l+T0KKrndsm8lS9GikQS+18np0UAyw/rSg41WvL3h7VmfMVwexd7h 1SThsPXsesND6a7LZERi2Pro9BID7ha9Rt67YhZl7DRPyfGqJbPFLbYbh4iizQc06soC sZpAF76JUZYkt6HtGEwOFr+4Gi23uMW4Zc8I5g8WBiSI4JtBsBDd4iRVaLJwaaVO6U8z dUbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764957162; x=1765561962; 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=qMcm6nWRLFBVfXJXBUXf6pE+rQOQZFvzs8Y8xJm6ysU=; b=wlSUqMi+llrXBCXwCzR8gZtwjMtI6Nm/PomUS+7Fs4JspKWn6D92CanHEDuEWf9ztG Ji5HDuGNxqnEWPyYjpilbEHZo641uWCELEvCWWaq+Pa/dcem7KJgCwdCZmMbI1b1fvG0 wi+JJohNm/4pBkKdh711iwx0Uf2o2RktbKRVwgGDXWDJi6hVGZBkycTY3YaLmgtj98Ns E0WhUmPTyWTPUxG7ySQIjwImDAmjPu9eIExcL5e9lekHJZwB7elJ95XOIOMVh4qEqyHv D2Bjoth+OSBI4zVuEZnXnOZk6jbiyg0MBXUtj1OaaPVJo6rx6bgP0mtsQC2uB84S1sdZ 2Z5A== X-Forwarded-Encrypted: i=1; AJvYcCWAhVN6y/Y8ZRxjA6x6/aklzRHcdfMK5+YV0HAqemGUmRbuER1SWa10at+2HDJH5qRIZvgc2ux3WEqQsdA=@vger.kernel.org X-Gm-Message-State: AOJu0YxWnkaflUTE70SO/faD5wHLe6iPgimpUlszkYM2FwahOoAOWBcR o0oNhSwR9F2amdNPr6XGIxFS8DYcRZvLah69tqXHRVudWlfbu2hIduKD X-Gm-Gg: ASbGncsx8hKcShEoDZi64VO9b/QPUSfsMzBoBjYx1J/fzzFkexBMiJr4TFbJfSk+dHI XFW1GCftLFOs75LSVBCpZIk1LJA+qIcXg50uPb4yAqPZD1aqYBf5BW5o2JzOudFL5pDb5ipCbEm j2bLxThCUrch9AAK05ljGXGupcz1qA7OcTfeRBsGmhBXi2mBiE9xC1RJuqOXsm/d17c10u0vOld H7mPOQQRWW8V4KQieU56Nq8TZkKuI+Tu1NU9gZ65giOdmKcnXEU8AXJl5dAXymoy+eusIXr0z0h BoN9wVk0s3uBW8I8qdvE04dyu7vq2UNOU2MhmVgl/KNIhoucvXZMlDL6GtUfBFtJ7GLkdQYKCG+ QNPprhpRc6HuXjz3cB2bYJdITZSctG/fE4Y0MlmcsiAIYyCss5P7alItPzqBOEP9qc3CrjQQPjn ed3z1DLg== X-Google-Smtp-Source: AGHT+IFMa7PLE5Wadu9vbkWwOz5YfxbRiG9Bng/2nx/P0WjNdaVzVzG0hYz8xn0T4porbVJXTUfmtg== X-Received: by 2002:a05:690c:2506:b0:784:9076:a0f5 with SMTP id 00721157ae682-78c188bffcamr128846517b3.44.1764957161553; Fri, 05 Dec 2025 09:52:41 -0800 (PST) Received: from localhost ([2601:346:0:79bd:be2a:7e4d:3bf:3fbc]) by smtp.gmail.com with ESMTPSA id 00721157ae682-78c1b78e63bsm18841887b3.42.2025.12.05.09.52.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Dec 2025 09:52:41 -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 v3 3/4] kernel.h: move VERIFY_OCTAL_PERMISSIONS() to sysfs.h Date: Fri, 5 Dec 2025 12:52:34 -0500 Message-ID: <20251205175237.242022-4-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251205175237.242022-1-yury.norov@gmail.com> References: <20251205175237.242022-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 Reviewed-by: Petr Pavlu Signed-off-by: Yury Norov (NVIDIA) --- 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 Tue Dec 16 07:33:21 2025 Received: from mail-yx1-f47.google.com (mail-yx1-f47.google.com [74.125.224.47]) (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 891A63431EA for ; Fri, 5 Dec 2025 17:52:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764957168; cv=none; b=HGc4jnUN1s80wtKx2LZ4e1oKdGgj8QG2W3EvumQTAUJvlQ+FS1IV6rJTsgIpOqCUIcKSGtesAbQtZzug6wxqOdpDSTob9ihI1p9WXUoFmYyWYBvj35jGi2tnFNMS6g+iOKn0GYabKn6QT+kCT7CWVdyCWrzLKxPgqLOqmlMZe2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764957168; c=relaxed/simple; bh=Fu49DiLLLy2xz3vqP+Og6KdQeKOAhmvWeylSeuOTbTE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tkzlYDkTnh0A6n+bvCXoFp/GPWh3LpFXzvHarvJsEVc/elFed2/k5PmYv3s/E7Yun9IecS7n5cjWuqC5layTRxqVTJsXCFxRBi0nJfQShKdmFj8xYUNAXq4JAQJgpgb/Mtvrxyi3VxaLK3ohpvT4kRA0jZzd0gmzTcitrVgmL9U= 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=BheLUeSO; arc=none smtp.client-ip=74.125.224.47 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="BheLUeSO" Received: by mail-yx1-f47.google.com with SMTP id 956f58d0204a3-6420c0cf4abso2628323d50.1 for ; Fri, 05 Dec 2025 09:52:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764957163; x=1765561963; 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=Af9caxi1mVrpm9W5khQFMmGltlo4MCqM0DPzQkUHKII=; b=BheLUeSO34uzPgump4Z2oe9EYBQTbhDyQr2BtEACHallXUhHfj/hkV9CjLU7OCFc4Z 95iIPZDPZ4YJEIcNF/wCqtUQnSOt1M3cyjsqBv+aUAXbPR5+UJKGJn4d1DQ3gX8DgIHb 0iZ/WssdRN9IfJ0Tcz7hgTfOeFRHFY5H1WpNt1/H+vbzeRNUI3pvyJBKloFnZvb7Tob2 Das1iU19xLIk448dDVIBjVxfD95QW69Il+BNJqBFMYqDNRxL31RwW3TPma3Dcd6YaWHx 7qb8iMZemLGY50XGWsxPa0ZrdtSi69Ssysx/cPjD87ZIPl981UKpr72JlqIjXD7nSI2q vFow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764957163; x=1765561963; 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=Af9caxi1mVrpm9W5khQFMmGltlo4MCqM0DPzQkUHKII=; b=XT1EY8izM7ZUFJ9VwDALlBuy/QHKwUy1QFdstGYHfGo4WONlgJEfTq2sQOuK/rvzkI HM8Uui3PCSHB/6XOlzxEGKpLIXxCoQceIK1CSD8YsWhjWxtYqIKbOG3lnRJLepQnkflR Q04NgcxEx6sn6TvhpbiRlTzhN2LoA8b8yIEPTQ+ylfZTXPipa4VdkR2lHTzQ32Tkk2ll 5NfFI6nigPgrQUynEd0ep3vvFXDQdfv8aaO7bMc/FlUSn54pxSb361lEdLNGyHnLCiE+ 1kf+lqQhkjd5XPC5EsZG5bbxESheypGoOOYu8RF9B2dLkwcBoymkS5EVeeDoudYqV1lv iwNg== X-Forwarded-Encrypted: i=1; AJvYcCVgSlZoFBI/Y/fPR82OIn1TC8sa6iq3s3rlM53co2nmL0tRmToOUPwmHkHmlIb7l8dN1h0jGi7M4Q/kB1s=@vger.kernel.org X-Gm-Message-State: AOJu0Ywb1hAoXGsXrc6BWansFxQ6RWLhEoKxlr8FuGu8QW0ShERtR0Uf wu03ObRcAypZnA3oDDH/NEZ3wngZRpNNj308r2W9oz6DSWYoKuvLOcE5 X-Gm-Gg: ASbGncv4UFgYhbRV55idCusGjCLEm3Gz0W7qOFQ6kTAkJKApZGeo/wi4GwWpfEciPbg 0/O8pnhRK2yW9UOwwhwacIUab9HZDwXP49+dD1FFQpOCGLYJzV11cuI9tkOYV+tyQyp/0iiacXQ /pipZuNJTKzj43gkKmZtYtMAiXBA5JWoF1SNb94C0Ub/K1QwucBakkJ8ICyKSRXb6iJrUU00G09 Z3uqJT4MjxOVJo5nH1+QordlFpQzNaZatO/e6VK1HEBdgfQALNc4lKK68yOL7d2hS0CdR3dbVfk J4BKouMbdrmUfNWPVza1Qi7bpAvCGmoHhdZMlynzXM/HJ7Nlt6okMe3jQAvE5U6cpTm/TvcUcav tKoahjoKkMoUGuR+4xUUy80ZZjiORompcsL7aw/9Do89PGBahpsu03kF9LjcjItNBADJLAk3MEt almXqEEQ== X-Google-Smtp-Source: AGHT+IFPtOSWzCyyKxmEMCdJPnBKygAUiGgzPUF8+F3dSGSxuUQzF5CzJPAwhZsR2TVtIkiXfuLJMA== X-Received: by 2002:a05:690e:14c4:b0:63e:233a:3ee6 with SMTP id 956f58d0204a3-644370398f4mr8521339d50.38.1764957162499; Fri, 05 Dec 2025 09:52:42 -0800 (PST) Received: from localhost ([2601:346:0:79bd:be2a:7e4d:3bf:3fbc]) by smtp.gmail.com with ESMTPSA id 00721157ae682-78c1b79942dsm18837077b3.49.2025.12.05.09.52.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Dec 2025 09:52:42 -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 v3 4/4] tracing: move tracing declarations from kernel.h to a dedicated header Date: Fri, 5 Dec 2025 12:52:35 -0500 Message-ID: <20251205175237.242022-5-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251205175237.242022-1-yury.norov@gmail.com> References: <20251205175237.242022-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) --- include/linux/kernel.h | 196 +-------------------------------- include/linux/trace_printk.h | 205 +++++++++++++++++++++++++++++++++++ 2 files changed, 206 insertions(+), 195 deletions(-) create mode 100644 include/linux/trace_printk.h diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 5b879bfea948..a377335e01da 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include =20 @@ -190,200 +190,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/trace_printk.h b/include/linux/trace_printk.h new file mode 100644 index 000000000000..5c9785c49c8e --- /dev/null +++ b/include/linux/trace_printk.h @@ -0,0 +1,205 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_TRACE_PRINTK_H +#define _LINUX_TRACE_PRINTK_H + +#include +#include +#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