* [PATCH] printk: Export log_buf_len to userland
@ 2022-08-10 20:25 Marc Aurèle La France
2022-08-15 2:15 ` Sergey Senozhatsky
0 siblings, 1 reply; 4+ messages in thread
From: Marc Aurèle La France @ 2022-08-10 20:25 UTC (permalink / raw)
To: Petr Mladek, Sergey Senozhatsky, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1967 bytes --]
Make the kernel log's buffer size available to userland so it can be used with
`dmesg -s`.
This change is not eligible for stable@.
Please Reply-To-All.
Thanks and have a great day.
Marc.
Signed-off-by: Marc Aurèle La France <tsi@tuyoix.net>
diff -aNpRruz -X /etc/diff.excludes linux-5.17.1/include/linux/printk.h devel-5.17.1/include/linux/printk.h
--- linux-5.17.1/include/linux/printk.h 2022-03-28 02:03:22.000000000 -0600
+++ devel-5.17.1/include/linux/printk.h 2022-03-28 07:14:10.803008293 -0600
@@ -318,6 +337,7 @@ extern void __printk_cpu_unlock(void);
#endif /* CONFIG_SMP */
extern int kptr_restrict;
+extern u32 log_buf_len;
/**
* pr_fmt - used by the pr_*() macros to generate the printk format string
diff -aNpRruz -X /etc/diff.excludes linux-5.17.1/kernel/printk/printk.c devel-5.17.1/kernel/printk/printk.c
--- linux-5.17.1/kernel/printk/printk.c 2022-03-28 02:03:22.000000000 -0600
+++ devel-5.17.1/kernel/printk/printk.c 2022-03-28 07:14:10.803008293 -0600
@@ -404,7 +404,7 @@ static struct latched_seq clear_seq = {
#define LOG_BUF_LEN_MAX (u32)(1 << 31)
static char __log_buf[__LOG_BUF_LEN] __aligned(LOG_ALIGN);
static char *log_buf = __log_buf;
-static u32 log_buf_len = __LOG_BUF_LEN;
+u32 log_buf_len = __LOG_BUF_LEN;
/*
* Define the average message size. This only affects the number of
diff -aNpRruz -X /etc/diff.excludes linux-5.17.1/kernel/printk/sysctl.c devel-5.17.1/kernel/printk/sysctl.c
--- linux-5.17.1/kernel/printk/sysctl.c 2022-03-28 02:03:22.000000000 -0600
+++ devel-5.17.1/kernel/printk/sysctl.c 2022-03-28 07:14:10.803008293 -0600
@@ -22,6 +22,13 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
static struct ctl_table printk_sysctls[] = {
{
+ .procname = "log_buf_len",
+ .data = &log_buf_len,
+ .maxlen = sizeof(u32),
+ .mode = 0444,
+ .proc_handler = proc_dointvec,
+ },
+ {
.procname = "printk",
.data = &console_loglevel,
.maxlen = 4*sizeof(int),
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] printk: Export log_buf_len to userland
2022-08-10 20:25 [PATCH] printk: Export log_buf_len to userland Marc Aurèle La France
@ 2022-08-15 2:15 ` Sergey Senozhatsky
2022-08-15 16:03 ` John Ogness
0 siblings, 1 reply; 4+ messages in thread
From: Sergey Senozhatsky @ 2022-08-15 2:15 UTC (permalink / raw)
To: Marc Aurèle La France
Cc: Petr Mladek, Sergey Senozhatsky, linux-kernel, Steven Rostedt,
John Ogness
Cc-ing John and Steven
On (22/08/10 14:25), Marc Aurèle La France wrote:
>
> Make the kernel log's buffer size available to userland so it can be used with
> `dmesg -s`.
And what doesn't work now?
> This change is not eligible for stable@.
>
> Please Reply-To-All.
>
> Thanks and have a great day.
>
> Marc.
These lines don't belong here. Please see
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.0-rc1
> Signed-off-by: Marc Aurèle La France <tsi@tuyoix.net>
>
> diff -aNpRruz -X /etc/diff.excludes linux-5.17.1/include/linux/printk.h devel-5.17.1/include/linux/printk.h
> --- linux-5.17.1/include/linux/printk.h 2022-03-28 02:03:22.000000000 -0600
> +++ devel-5.17.1/include/linux/printk.h 2022-03-28 07:14:10.803008293 -0600
> @@ -318,6 +337,7 @@ extern void __printk_cpu_unlock(void);
> #endif /* CONFIG_SMP */
>
> extern int kptr_restrict;
> +extern u32 log_buf_len;
>
> /**
> * pr_fmt - used by the pr_*() macros to generate the printk format string
> diff -aNpRruz -X /etc/diff.excludes linux-5.17.1/kernel/printk/printk.c devel-5.17.1/kernel/printk/printk.c
> --- linux-5.17.1/kernel/printk/printk.c 2022-03-28 02:03:22.000000000 -0600
> +++ devel-5.17.1/kernel/printk/printk.c 2022-03-28 07:14:10.803008293 -0600
> @@ -404,7 +404,7 @@ static struct latched_seq clear_seq = {
> #define LOG_BUF_LEN_MAX (u32)(1 << 31)
> static char __log_buf[__LOG_BUF_LEN] __aligned(LOG_ALIGN);
> static char *log_buf = __log_buf;
> -static u32 log_buf_len = __LOG_BUF_LEN;
> +u32 log_buf_len = __LOG_BUF_LEN;
>
> /*
> * Define the average message size. This only affects the number of
> diff -aNpRruz -X /etc/diff.excludes linux-5.17.1/kernel/printk/sysctl.c devel-5.17.1/kernel/printk/sysctl.c
> --- linux-5.17.1/kernel/printk/sysctl.c 2022-03-28 02:03:22.000000000 -0600
> +++ devel-5.17.1/kernel/printk/sysctl.c 2022-03-28 07:14:10.803008293 -0600
> @@ -22,6 +22,13 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
>
> static struct ctl_table printk_sysctls[] = {
> {
> + .procname = "log_buf_len",
> + .data = &log_buf_len,
> + .maxlen = sizeof(u32),
> + .mode = 0444,
> + .proc_handler = proc_dointvec,
> + },
> + {
> .procname = "printk",
> .data = &console_loglevel,
> .maxlen = 4*sizeof(int),
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] printk: Export log_buf_len to userland
2022-08-15 2:15 ` Sergey Senozhatsky
@ 2022-08-15 16:03 ` John Ogness
2022-08-15 20:01 ` Marc Aurèle La France
0 siblings, 1 reply; 4+ messages in thread
From: John Ogness @ 2022-08-15 16:03 UTC (permalink / raw)
To: Sergey Senozhatsky, Marc Aurèle La France
Cc: Petr Mladek, Sergey Senozhatsky, linux-kernel, Steven Rostedt
On 2022-08-15, Sergey Senozhatsky <senozhatsky@chromium.org> wrote:
> On (22/08/10 14:25), Marc Aurèle La France wrote:
>>
>> Make the kernel log's buffer size available to userland so it can be
>> used with `dmesg -s`.
This information is already available via:
klogctl(SYSLOG_ACTION_SIZE_BUFFER, NULL, 0)
And dmesg already uses this with "dmesg -S".
John Ogness
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] printk: Export log_buf_len to userland
2022-08-15 16:03 ` John Ogness
@ 2022-08-15 20:01 ` Marc Aurèle La France
0 siblings, 0 replies; 4+ messages in thread
From: Marc Aurèle La France @ 2022-08-15 20:01 UTC (permalink / raw)
To: John Ogness; +Cc: Sergey Senozhatsky, Petr Mladek, linux-kernel, Steven Rostedt
[-- Attachment #1: Type: text/plain, Size: 474 bytes --]
On Mon, 15 Aug 2022, John Ogness wrote:
> On 2022-08-15, Sergey Senozhatsky <senozhatsky@chromium.org> wrote:
>> On (22/08/10 14:25), Marc Aurèle La France wrote:
>>> Make the kernel log's buffer size available to userland so it can be
>>> used with `dmesg -s`.
> This information is already available via:
> klogctl(SYSLOG_ACTION_SIZE_BUFFER, NULL, 0)
> And dmesg already uses this with "dmesg -S".
Thanks for the much more helpful reply.
Have a great day.
Marc.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-08-15 23:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-10 20:25 [PATCH] printk: Export log_buf_len to userland Marc Aurèle La France
2022-08-15 2:15 ` Sergey Senozhatsky
2022-08-15 16:03 ` John Ogness
2022-08-15 20:01 ` Marc Aurèle La France
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.