From nobody Mon Dec 1 22:04:01 2025 Received: from mail-yx1-f41.google.com (mail-yx1-f41.google.com [74.125.224.41]) (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 578FF25785E for ; Sat, 29 Nov 2025 19:53:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764445988; cv=none; b=FDqeaLo5vcOj/PmKLO+fBG6haUY/Q+39QEPS83zQKZs+QLmACmAFbfa00r2r3opm0/3JgsV6yzC8fUNxDny8R4NiRuBYxFo2rgFwQHX0LqZBmMbT44xNS2+pAxpHo23sFJRVHNa0LrbXKmyTSXJgyh+Scl00iF4C619K2BxIE2I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764445988; c=relaxed/simple; bh=U6wVjDQqWIkEPY9m3/jjaLkHW2qb9EnJS9XX+Cslv54=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HeSbJHl80x8W8MDpdsxGQDRNBSNqp4nbmblWd7AuPeVRveWuAso+A0WF8psH9q5x0xlJ/EhN35esUudNf8d0eAlL3T/ZwqukL72v4A9Kd4/cHhins9h5vLnqg4cs7P7IuH3zMizmvkY2eV4ekQMR3Rt66pWK66xNY/NESdJxgWc= 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=Hoxjn+d5; arc=none smtp.client-ip=74.125.224.41 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="Hoxjn+d5" Received: by mail-yx1-f41.google.com with SMTP id 956f58d0204a3-6420c08f886so3413643d50.3 for ; Sat, 29 Nov 2025 11:53:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764445986; x=1765050786; 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=gMtAFmfUFSqT7Mio9YvaV3lvjHpX+ONaRINwsv8b7ko=; b=Hoxjn+d5lQ+osEJtdy81Bdv7RMu4hA2RK5i5Y+W3oyzginhMEjFS6/pCG7jd3KNj6i NgPB2Y2agsqDx6g0jkRMSm3jdxWYLUM0UIsOmOGoHCZLoF6aKQ3PnRsKdLokW50Nfy3n gk51VQKg7Ybo/izPTilrxXieWKJGb5pixFcz+1SwqrkynepDpkqqqj68UJuK1nYonZvr PHqtXNUr1mkPYvPQQHgG+FdfYkuR4zSfnKhk33uBTXSJb6YIqJvU9Fg5R9dhJSRzDYuc HNILPUUBmI9Fhg/AjvwUlsFs+O2SHuQ9IHQ9vxPPHqNe4zFlwX96+Kco8FWP8QImFxkM M0UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764445986; x=1765050786; 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=gMtAFmfUFSqT7Mio9YvaV3lvjHpX+ONaRINwsv8b7ko=; b=NaBmGLagFQiZljVgv+FL20vWM+am04GIRw4L4bZvcH5qthmpt8sSdCJnbXDGHwKWdp FrUVIV6VfDU4GxRUwTUalSezf9IAeXZeLTxEHEYmP4LRfuQqbYvV0r9m428OZdcOD5kf cQ2fGWpjSkdPSAPhWzTVQxVZw/dHrluCB3Yl8yc7qXULhURjdLQumxh8sySzrIYDjXWL C4BNDrhSbGWmDXWpNMVcQlkea3FDKRGva5Ks44T14yoEuP+9D1cnyrxnccfSCppNwcQk WELBcibSzByUt03BSYZoaB2/5/0Lncqjs0NsfSSSsVPEGwtW/RkbGnyV6zGjUpDU4PUG lCLQ== X-Forwarded-Encrypted: i=1; AJvYcCU80oWvf8Q1fqiu6ALWxRsDLVJ2DYX3JMsfHF9O7HqLRdAmdTfM+dmxWDwpUfDvBnA2HY01GhnSs9h/kIk=@vger.kernel.org X-Gm-Message-State: AOJu0YycbSr8PippzIbp/hJhFh6ra9c3CGoA+cCCK3lnYu0k+OsUkEJt CqrgrSQXz9GgDs2wI2Q3TfiIKJjqUpJCpGCToRQprgiOThAZzs28Z6TY X-Gm-Gg: ASbGncs0MWgp3UvefJAQwVzVII8tnFB9KoYzS0KMVVxWuvscSj4HW+V/PGDRrVPALea Pk5hDsGypt1378ebDmqefOp4qW0W0rAj1onpR6a3dnV77ZIAC4kYRRbXdF21cIIL/QlqPvzglkL j+H4pNugBPeZFHH4w+INwNtFId77jg2WrUYvGm6KmfDgoDWKsNNidmSNMMl6p58T0PKSCwtrNIt dUjBs/ld90QC0lLRf5w+i6sInGWfL2ULITh9TQUmu+TPblP/GmxLc/LcIkEOoeOsk1qLrIkMnmX J1wQox0NVmxoVcKWMX2fyvPW/rjP1R7gBVHoVIUaWvVfAyMOwuUR3CsE335Ur6ora1rIxgi+c8T xmWVUz2Lv/j4G0ghaoH0U27mIF5e7JQkHvztNVmOtWkEIg42InQiz5q+vFJ2sSko5koiDSBwaQl uRHUFiZLc= X-Google-Smtp-Source: AGHT+IFe8Y0GMh+6LMlCZSdBuNKhw5C68QDt9RitlP5LR9LIFpydTgLo1EIGXwaP+uPjQ4SltW6e2g== X-Received: by 2002:a53:c052:0:20b0:63f:b922:ed79 with SMTP id 956f58d0204a3-64302a3a8d1mr19964013d50.14.1764445986251; Sat, 29 Nov 2025 11:53:06 -0800 (PST) Received: from localhost ([2601:346:0:79bd:353a:b6ab:d4ee:67b9]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-6433c073e07sm2844621d50.6.2025.11.29.11.53.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Nov 2025 11:53:05 -0800 (PST) From: "Yury Norov (NVIDIA)" To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Andy Shevchenko , Randy Dunlap , Ingo Molnar , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Petr Pavlu , 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 1/3] kernel.h: drop STACK_MAGIC macro Date: Sat, 29 Nov 2025 14:53:00 -0500 Message-ID: <20251129195304.204082-2-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251129195304.204082-1-yury.norov@gmail.com> References: <20251129195304.204082-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 only used by i915. Move it to a local header and drop from the kernel.h. Signed-off-by: Yury Norov (NVIDIA) Acked-by: Randy Dunlap Reviewed-by: Andy Shevchenko --- drivers/gpu/drm/i915/i915_utils.h | 2 ++ include/linux/kernel.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_utils.h b/drivers/gpu/drm/i915/i915_= utils.h index a0c892e4c40d..6c197e968305 100644 --- a/drivers/gpu/drm/i915/i915_utils.h +++ b/drivers/gpu/drm/i915/i915_utils.h @@ -32,6 +32,8 @@ #include #include =20 +#define STACK_MAGIC 0xdeadbeef + #ifdef CONFIG_X86 #include #endif 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 Mon Dec 1 22:04:01 2025 Received: from mail-yx1-f45.google.com (mail-yx1-f45.google.com [74.125.224.45]) (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 5668B30E843 for ; Sat, 29 Nov 2025 19:53:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764445990; cv=none; b=QkM5f+sygjnNaFp9IVdepTkN3qHTufo9a4KYSsEZcOP9LUaf5bbuglKiSBLQeX9IwBCILKVL10ii9ugJDDBSWRZjhOioDJWbe0nSQlqQUUD0oVfeMuTV7yCTB2z7MNY1jAWAFEHIb6aTZHGLktVOV4Qwq6jKhHcTsCf3pMokhio= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764445990; c=relaxed/simple; bh=FdiOAxi8x3qeEv/Dh//XevJQnEeuuiAcs/Vi/TNMfo0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O1ZIlZViouoeCOsg0L9lDPnvVC7JC6rdnGZY1lPMqe1bglJ7GcIiosUpNiBPPyjVqui7Nwrw+4gU80ySmUvaOgAevKS4mrbaGWYdgEn9ikiQHlDR1f27YrgF0aQkEm/Mk/MrEyrGtOUNXww/JC6ukI7PvBKoqJLFKvkjUNbpC9k= 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=gsQkxn5C; arc=none smtp.client-ip=74.125.224.45 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="gsQkxn5C" Received: by mail-yx1-f45.google.com with SMTP id 956f58d0204a3-642f3bab0c8so2300548d50.0 for ; Sat, 29 Nov 2025 11:53:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764445987; x=1765050787; 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=T1J39AX21q7vFvdSQspB28V0qpAzX2/AVdKjbIUMHgo=; b=gsQkxn5CeSWsLIx5Q07eFrabGC3wNQn896BtPFZ1HHdO8o1dXUjUAVs1sPGhnvkr5h dbo++8cvEbMH/V4GE5J7VLHjQxleD58kd3QtDuTr1/b8OVZrTlbs38aypYifTQu4rr27 93wwDQfI1RKh0FFva4xDub6om71OacNVSf+sxZWHPBp/TXk26MvUfqlUZpah18QQ21Ca QQV3+DUAnqlySb3upmvYoLaIcQJ+/BV8EYK3hC9x3K1934z8DgxbOr6jBG4Ox5Cz5Aww AAryjRhhy7F3t35tgETfzPTw2tuv8TNIkrrzxrHg/4aC/gaXGiNPpKrDrux3+IyGNyLn GCqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764445987; x=1765050787; 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=T1J39AX21q7vFvdSQspB28V0qpAzX2/AVdKjbIUMHgo=; b=XGalu9KqFj651AeExFS+vD5C7ROONUtpjeTMdfCuevRweSeVLPq91VV6xnnuUcl54H OfeVozhgv3tb2KSI7bm8OWo05aoYBfumwIbOK9m2oba0KIQAOI5G2ggjKyqGV7f61RGh Frel2I+chuZ8DqaqPsXKpnXcz7Aspq5rAcQ5NzwwL5p3o/FEUflcGvJ5LLidwevDoX5q ib7E4MQUTwvltUarqRe10N6P0K9Fl8P4HjT1frXrjXOqN6IN8iDWPJiYSK2qo42lbLDp YxhiBXcAdQCtVIPbvJhUsLO/UqsD1qurgHJvKfzGt0bhcdZje2keooGXKC3rx7ARptl5 UKsQ== X-Forwarded-Encrypted: i=1; AJvYcCULlfkKaeDjVHypHzsp3fISHKmdLjZl15l5teOvsOVYmGiF8TkbRFOTlNI/uotnUQQmmHuGS30Wj/eY4S0=@vger.kernel.org X-Gm-Message-State: AOJu0YwvvSaJOZL+KKGWUEEZdzYy2j7H1NVyk2cDzBkRv31YvVu1gHIy nuCVz79LJnB5xZErzKml1MJTqqA/T4yFvLToFpL7iNKxd4Lw8WzJAi8x X-Gm-Gg: ASbGncs0ZIke9xti30Wha18HORg9fmgZMH5PmDRaec81wsTf30SzlU03KEOGghcFloB epfEm52NopDmQDpz3H5YEDpoKDohu9xhp9P9Gc+aWfPKnztJ/PQfmFicjTBq/LaJ7LNw3+00U9N aTAbT8Tv3eVCtfPBnGyyDeqk3V9tdr1GaK34wJCttdvbMFJinzQZkc52VVqyZ09ocb7t8Fu8APA ABhIjk6Qc0hR0E+JNsodx2ZK8FK6437fUufVSVegNYeGK98dxTFzbSX8Qh4Iit68JfWDyiTsF+l Qr/9bQmuKvTxT2HH5QvHVrwODFLjyNpNUBRqwDK+k3WpMj7IHZJr5Za+t/1FJkubg95PaqpvZLX Gsw5ft4BHSpi1R3hCyTNeSf6iDiHrWPCOZEGV4KguMJsgKgOM5IMStWjrIXH1lJNk8tMfy8TFEO M/Fgc8pug= X-Google-Smtp-Source: AGHT+IGoe6k+HGoU1YAfc/PgjNGtkUsJD9d1pFuoEvQqZEuvaXl0b1nF4MNPaTfl/35pvJr8rQDxmg== X-Received: by 2002:a53:cd8c:0:b0:63e:1943:ce49 with SMTP id 956f58d0204a3-64302abb486mr16805469d50.39.1764445987167; Sat, 29 Nov 2025 11:53:07 -0800 (PST) Received: from localhost ([2601:346:0:79bd:353a:b6ab:d4ee:67b9]) by smtp.gmail.com with ESMTPSA id 00721157ae682-78ad1044f9esm28752057b3.56.2025.11.29.11.53.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Nov 2025 11:53:06 -0800 (PST) From: "Yury Norov (NVIDIA)" To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Andy Shevchenko , Randy Dunlap , Ingo Molnar , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Petr Pavlu , 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 2/3] kernel.h: move VERIFY_OCTAL_PERMISSIONS() to sysfs.h Date: Sat, 29 Nov 2025 14:53:01 -0500 Message-ID: <20251129195304.204082-3-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251129195304.204082-1-yury.norov@gmail.com> References: <20251129195304.204082-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. Signed-off-by: Yury Norov (NVIDIA) Acked-by: Randy Dunlap Reviewed-by: Andy Shevchenko Suggested-by: Andy Shevchenko Tested-by: Randy Dunlap --- include/linux/kernel.h | 12 ------------ include/linux/moduleparam.h | 2 +- include/linux/sysfs.h | 13 +++++++++++++ 3 files changed, 14 insertions(+), 13 deletions(-) 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 6907aedc4f74..4e390a84a8bc 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -4,7 +4,7 @@ /* (C) Copyright 2001, 2002 Rusty Russell IBM Corporation */ #include #include -#include +#include =20 /* * The maximum module name length, including the NUL byte. 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 Mon Dec 1 22:04:01 2025 Received: from mail-yx1-f48.google.com (mail-yx1-f48.google.com [74.125.224.48]) (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 32AEB30FC03 for ; Sat, 29 Nov 2025 19:53:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764445992; cv=none; b=h217JBfSUsMiYSEe3ZNbN4rRzp92yupIKVIl/vrjBt5IfuO8wlXpXz1Ntd2MIk/c39yhwuIm8hceSp03FqtVRcV/eG/W8hIHMDdzTM6g8N9FoyoH8gtOX+nt8AVfIQ0l8E0umWdcd2p7ayKXenCoCKMMuDx5LmUGYjYtHOsKC44= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764445992; c=relaxed/simple; bh=aXRfTaRGpbjnvq4qNF4ICgoIeZ9X37XGGJ9DOHdRdJM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p0uimRNt4BdNzhUEHOoxf6c28zvo57Ejw7AWADhuKDE6AREp98kZM3x0hje2AWvP4eDVJHg05KSEx7SuhVCnwB1yyz5Aup60HcitSKC9oHvvBuoavfbQWhtASQuBor0oLEBnBWfh8oGy2iJxqmwXr7Th5bL9cG2b4DOkpjCNG98= 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=E6DPDfQs; arc=none smtp.client-ip=74.125.224.48 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="E6DPDfQs" Received: by mail-yx1-f48.google.com with SMTP id 956f58d0204a3-6420c0cf4abso2707246d50.1 for ; Sat, 29 Nov 2025 11:53:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764445988; x=1765050788; 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=KPhKot9RrW+4OVEYlhiH2dUrdgdiYCdMeVF+/QnKJpk=; b=E6DPDfQsPNWAb6D2lI9b0X6TBBj2eFaYhEsBoAJ40/UINhdMcPLUq4g4N0f086rtN5 9GlrXiFbdvLCtL7O/xaiquIZMHXm2gpJJL2t06lgzxXsWnoenc89EiIs1Mq1Rhju7WPX UEm91Fh1otLKkVV7FzxQMKF7dO2gZ8hoQioBoQsf46X2pNU5Vi4YYrAggQHVqvm1X8h3 Dlq4PD/yM6DZ4giHiBfVrxRfwoBCKTs4BXw9Pc/3G6G5yxHeZsCrW/13l954ptXOkX6W OdT+3pW/v9a5GTvV7dh18kWP6PMDBFXFP1tgRfWY016k8blbuOrnFegkAImp00kq4w7p EunQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764445988; x=1765050788; 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=KPhKot9RrW+4OVEYlhiH2dUrdgdiYCdMeVF+/QnKJpk=; b=ti9vEJ7vcLL4+nwfoRDaVl/FfsE6cyncJnzmN7WSiH2gSrCMcR2XW62prJtZLmLM97 mC9QIIVA7smZtE3pVAgJLiu0cceZqqJ1pHTn3Ro3FsDkyzUksjV7OiPU0nPU36v7e7oz Fr2sWIQxLWCdv9EgVgE2jBLwze8jgCQ2I294ZJQz+fX8NKLcDRRHvlcqfK8+OvWjEEMU XJ0NP08UYIWXao4oXe8CDjSpX0CdgEQipyjJRn0oa9CG/BjjdHvARY9yORmTUQATX0Ju q+cdvSOFAVcBR4ykUxy0nfStLg2Xd/9KSHQamV/Ssa2KyWZubntVygXyhaiECuoKLEgG jwVg== X-Forwarded-Encrypted: i=1; AJvYcCWJWkWcN+UZtouBm9PwUXR76s6qISlaR6ycQ7n86O/nC+ck4HosVcdOSyl/H8Ce82kZ3SjtUMeI7QG6ob4=@vger.kernel.org X-Gm-Message-State: AOJu0YxqIFUCD81l5RdARiAZeYzKpWJHhciCGvIt5nTFQ0+kXUFJSHcn F6ubmRS5tlqOaZN7YLi/JDre/Kw2QKqcSH0hajKjUpYEmiZ7pSIFECz8 X-Gm-Gg: ASbGncvy2Lcl1RUfj3Zr2LkvGvkv3acYRcOnEULQWZDClwyD8JPP5zC0VpmMEn5wA90 HnGgN2b6lp1KdBrlDVc7udyZ2hEP38BdWW3RLhLQGiO0z6vLyMMRe00qLm9BNYpvp1NYo+6cOPE BXnZu+2zRU+eK4ZIXCiekVlVL/dI+JQ8DLgVMjDT5UKlL2fEtyQBrvMjkoUOLA4B6m1hLNSiyYK COUJWllXSHceY1kr3beP+8lJDPBPeIwgYJSkN3eEj88XdcWAzhAFak8K+kPrGbncaAk6aHHW9TL R6RSUqvbXk8UsKMhPXW38Jfpzcs0ofYGN+d+4KQxhZ2LFRWwiGy23Q3bnDS0P0ZwftBOAOxlLlD jZDwBOGO6NV16MU49yf6Vevja1WbANpptGuTfr5Rr9U8rXrUOc+sn1mzLbWNBhmtmXW9b8/Izn8 /ZceVhpAA= X-Google-Smtp-Source: AGHT+IFRuLzNF/pr0yH2EAr8HpHXwB/WeGCGG0/WvzHFo3LTXr61qS6+iXCYXDnEXYF/tuCt9oopew== X-Received: by 2002:a05:690e:144a:b0:63e:233a:3ee6 with SMTP id 956f58d0204a3-64302b0fc69mr23750126d50.38.1764445988022; Sat, 29 Nov 2025 11:53:08 -0800 (PST) Received: from localhost ([2601:346:0:79bd:353a:b6ab:d4ee:67b9]) by smtp.gmail.com with ESMTPSA id 00721157ae682-78ad101115asm28750137b3.29.2025.11.29.11.53.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Nov 2025 11:53:07 -0800 (PST) From: "Yury Norov (NVIDIA)" To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Andy Shevchenko , Randy Dunlap , Ingo Molnar , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Petr Pavlu , 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 3/3] tracing: move tracing declarations from kernel.h to a dedicated header Date: Sat, 29 Nov 2025 14:53:02 -0500 Message-ID: <20251129195304.204082-4-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251129195304.204082-1-yury.norov@gmail.com> References: <20251129195304.204082-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. Move it to a separate header. This is a pure move, except for removing a few 'extern's. Signed-off-by: Yury Norov (NVIDIA) Acked-by: Steven Rostedt --- 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 be6a4217caa5..706bbb5da263 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26071,6 +26071,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..265c0d31f369 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -27,6 +27,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