* [merged] seq_buf-add-seq_buf_do_printk-helper.patch removed from -mm tree
@ 2023-05-05 22:45 Andrew Morton
2023-05-05 23:57 ` SeongJae Park
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2023-05-05 22:45 UTC (permalink / raw)
To: mm-commits, yosryahmed, rostedt, pmladek, senozhatsky, akpm
The quilt patch titled
Subject: seq_buf: add seq_buf_do_printk() helper
has been removed from the -mm tree. Its filename was
seq_buf-add-seq_buf_do_printk-helper.patch
This patch was dropped because it was merged into mainline or a subsystem tree
------------------------------------------------------
From: Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: seq_buf: add seq_buf_do_printk() helper
Date: Sat, 15 Apr 2023 19:01:10 +0900
(akpm: temporary addition for
memcg-use-seq_buf_do_printk-with-mem_cgroup_print_oom_meminfo.patch)
Sometimes we use seq_buf to format a string buffer, which we then pass to
printk(). However, in certain situations the seq_buf string buffer can
get too big, exceeding the PRINTKRB_RECORD_MAX bytes limit, and causing
printk() to truncate the string.
Add a new seq_buf helper. This helper prints the seq_buf string buffer
line by line, using as a delimiter, rather than passing the whole string
buffer to printk() at once.
Link: https://lkml.kernel.org/r/20230415100110.1419872-1-senozhatsky@chromium.org
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
Cc: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
include/linux/seq_buf.h | 2 ++
lib/seq_buf.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
--- a/include/linux/seq_buf.h~seq_buf-add-seq_buf_do_printk-helper
+++ a/include/linux/seq_buf.h
@@ -159,4 +159,6 @@ extern int
seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary);
#endif
+void seq_buf_do_printk(struct seq_buf *s, const char *lvl);
+
#endif /* _LINUX_SEQ_BUF_H */
--- a/lib/seq_buf.c~seq_buf-add-seq_buf_do_printk-helper
+++ a/lib/seq_buf.c
@@ -93,6 +93,38 @@ int seq_buf_printf(struct seq_buf *s, co
}
EXPORT_SYMBOL_GPL(seq_buf_printf);
+/**
+ * seq_buf_do_printk - printk seq_buf line by line
+ * @s: seq_buf descriptor
+ * @lvl: printk level
+ *
+ * printk()-s a multi-line sequential buffer line by line. The function
+ * makes sure that the buffer in @s is nul terminated and safe to read
+ * as a string.
+ */
+void seq_buf_do_printk(struct seq_buf *s, const char *lvl)
+{
+ const char *start, *lf;
+
+ if (s->size == 0 || s->len == 0)
+ return;
+
+ seq_buf_terminate(s);
+
+ start = s->buffer;
+ while ((lf = strchr(start, '\n'))) {
+ int len = lf - start + 1;
+
+ printk("%s%.*s", lvl, len, start);
+ start = ++lf;
+ }
+
+ /* No trailing LF */
+ if (start < s->buffer + s->len)
+ printk("%s%s\n", lvl, start);
+}
+EXPORT_SYMBOL_GPL(seq_buf_do_printk);
+
#ifdef CONFIG_BINARY_PRINTF
/**
* seq_buf_bprintf - Write the printf string from binary arguments
_
Patches currently in -mm which might be from senozhatsky@chromium.org are
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [merged] seq_buf-add-seq_buf_do_printk-helper.patch removed from -mm tree
2023-05-05 22:45 [merged] seq_buf-add-seq_buf_do_printk-helper.patch removed from -mm tree Andrew Morton
@ 2023-05-05 23:57 ` SeongJae Park
2023-05-06 0:00 ` Yosry Ahmed
0 siblings, 1 reply; 5+ messages in thread
From: SeongJae Park @ 2023-05-05 23:57 UTC (permalink / raw)
To: Andrew Morton; +Cc: mm-commits, yosryahmed, rostedt, pmladek, senozhatsky
Hi Andrew,
On Fri, 05 May 2023 15:45:21 -0700 Andrew Morton <akpm@linux-foundation.org> wrote:
>
> The quilt patch titled
> Subject: seq_buf: add seq_buf_do_printk() helper
> has been removed from the -mm tree. Its filename was
> seq_buf-add-seq_buf_do_printk-helper.patch
>
> This patch was dropped because it was merged into mainline or a subsystem tree
Just for headup. I just found the latest mm-unstable indeed dropped the patch
but a patch[1] depends on it. As a result, build fails as below.
CC mm/memcontrol.o
/mm/memcontrol.c: In function ‘mem_cgroup_print_oom_meminfo’:
/mm/memcontrol.c:1693:2: error: implicit declaration of function ‘seq_buf_do_printk’; did you mean ‘seq_buf_bprintf’? [-Werror=implicit-function-declaration]
1693 | seq_buf_do_printk(&s, KERN_INFO);
| ^~~~~~~~~~~~~~~~~
| seq_buf_bprintf
cc1: some warnings being treated as errors
[1] https://lore.kernel.org/mm-commits/20230502201509.B8711C433D2@smtp.kernel.org/
Thanks,
SJ
>
> ------------------------------------------------------
> From: Sergey Senozhatsky <senozhatsky@chromium.org>
> Subject: seq_buf: add seq_buf_do_printk() helper
> Date: Sat, 15 Apr 2023 19:01:10 +0900
>
> (akpm: temporary addition for
> memcg-use-seq_buf_do_printk-with-mem_cgroup_print_oom_meminfo.patch)
>
> Sometimes we use seq_buf to format a string buffer, which we then pass to
> printk(). However, in certain situations the seq_buf string buffer can
> get too big, exceeding the PRINTKRB_RECORD_MAX bytes limit, and causing
> printk() to truncate the string.
>
> Add a new seq_buf helper. This helper prints the seq_buf string buffer
> line by line, using as a delimiter, rather than passing the whole string
> buffer to printk() at once.
>
> Link: https://lkml.kernel.org/r/20230415100110.1419872-1-senozhatsky@chromium.org
> Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
> Reviewed-by: Petr Mladek <pmladek@suse.com>
> Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
> Cc: Yosry Ahmed <yosryahmed@google.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [merged] seq_buf-add-seq_buf_do_printk-helper.patch removed from -mm tree
2023-05-05 23:57 ` SeongJae Park
@ 2023-05-06 0:00 ` Yosry Ahmed
2023-05-06 0:28 ` SeongJae Park
0 siblings, 1 reply; 5+ messages in thread
From: Yosry Ahmed @ 2023-05-06 0:00 UTC (permalink / raw)
To: SeongJae Park; +Cc: Andrew Morton, mm-commits, rostedt, pmladek, senozhatsky
On Fri, May 5, 2023 at 4:57 PM SeongJae Park <sj@kernel.org> wrote:
>
> Hi Andrew,
>
> On Fri, 05 May 2023 15:45:21 -0700 Andrew Morton <akpm@linux-foundation.org> wrote:
>
> >
> > The quilt patch titled
> > Subject: seq_buf: add seq_buf_do_printk() helper
> > has been removed from the -mm tree. Its filename was
> > seq_buf-add-seq_buf_do_printk-helper.patch
> >
> > This patch was dropped because it was merged into mainline or a subsystem tree
>
> Just for headup. I just found the latest mm-unstable indeed dropped the patch
> but a patch[1] depends on it. As a result, build fails as below.
That patch was merged into Linus's tree, so I assumed that's why it
was dropped from mm-unstable. Perhaps I am wrong.
>
> CC mm/memcontrol.o
> /mm/memcontrol.c: In function ‘mem_cgroup_print_oom_meminfo’:
> /mm/memcontrol.c:1693:2: error: implicit declaration of function ‘seq_buf_do_printk’; did you mean ‘seq_buf_bprintf’? [-Werror=implicit-function-declaration]
> 1693 | seq_buf_do_printk(&s, KERN_INFO);
> | ^~~~~~~~~~~~~~~~~
> | seq_buf_bprintf
> cc1: some warnings being treated as errors
>
> [1] https://lore.kernel.org/mm-commits/20230502201509.B8711C433D2@smtp.kernel.org/
>
>
> Thanks,
> SJ
>
> >
> > ------------------------------------------------------
> > From: Sergey Senozhatsky <senozhatsky@chromium.org>
> > Subject: seq_buf: add seq_buf_do_printk() helper
> > Date: Sat, 15 Apr 2023 19:01:10 +0900
> >
> > (akpm: temporary addition for
> > memcg-use-seq_buf_do_printk-with-mem_cgroup_print_oom_meminfo.patch)
> >
> > Sometimes we use seq_buf to format a string buffer, which we then pass to
> > printk(). However, in certain situations the seq_buf string buffer can
> > get too big, exceeding the PRINTKRB_RECORD_MAX bytes limit, and causing
> > printk() to truncate the string.
> >
> > Add a new seq_buf helper. This helper prints the seq_buf string buffer
> > line by line, using as a delimiter, rather than passing the whole string
> > buffer to printk() at once.
> >
> > Link: https://lkml.kernel.org/r/20230415100110.1419872-1-senozhatsky@chromium.org
> > Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
> > Reviewed-by: Petr Mladek <pmladek@suse.com>
> > Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
> > Cc: Yosry Ahmed <yosryahmed@google.com>
> > Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [merged] seq_buf-add-seq_buf_do_printk-helper.patch removed from -mm tree
2023-05-06 0:00 ` Yosry Ahmed
@ 2023-05-06 0:28 ` SeongJae Park
2023-05-06 0:57 ` Andrew Morton
0 siblings, 1 reply; 5+ messages in thread
From: SeongJae Park @ 2023-05-06 0:28 UTC (permalink / raw)
To: Yosry Ahmed
Cc: SeongJae Park, Andrew Morton, mm-commits, rostedt, pmladek,
senozhatsky
On Fri, 5 May 2023 17:00:20 -0700 Yosry Ahmed <yosryahmed@google.com> wrote:
> On Fri, May 5, 2023 at 4:57 PM SeongJae Park <sj@kernel.org> wrote:
> >
> > Hi Andrew,
> >
> > On Fri, 05 May 2023 15:45:21 -0700 Andrew Morton <akpm@linux-foundation.org> wrote:
> >
> > >
> > > The quilt patch titled
> > > Subject: seq_buf: add seq_buf_do_printk() helper
> > > has been removed from the -mm tree. Its filename was
> > > seq_buf-add-seq_buf_do_printk-helper.patch
> > >
> > > This patch was dropped because it was merged into mainline or a subsystem tree
> >
> > Just for headup. I just found the latest mm-unstable indeed dropped the patch
> > but a patch[1] depends on it. As a result, build fails as below.
>
> That patch was merged into Linus's tree, so I assumed that's why it
> was dropped from mm-unstable. Perhaps I am wrong.
Same to my assumption, and fit with the original mail's explanation. I
confirmed the patch has merged in the mainline as commit 96928d9032a7. So this
will be fixed if 1) mm-unstable is rebased on v6.4-rc1, 2) the dropped patch is
added again on mm-unstable, or 3) the patch[1] currently triggering the failure
is dropped. This is never an important issue for me, so I don't have any
preference or opinion about the fix. I just wanted to save time for others who
might got report of this.
[1] https://lore.kernel.org/mm-commits/20230502201509.B8711C433D2@smtp.kernel.org/
Thanks,
SJ
>
> >
> > CC mm/memcontrol.o
> > /mm/memcontrol.c: In function ‘mem_cgroup_print_oom_meminfo’:
> > /mm/memcontrol.c:1693:2: error: implicit declaration of function ‘seq_buf_do_printk’; did you mean ‘seq_buf_bprintf’? [-Werror=implicit-function-declaration]
> > 1693 | seq_buf_do_printk(&s, KERN_INFO);
> > | ^~~~~~~~~~~~~~~~~
> > | seq_buf_bprintf
> > cc1: some warnings being treated as errors
> >
> > [1] https://lore.kernel.org/mm-commits/20230502201509.B8711C433D2@smtp.kernel.org/
> >
> >
> > Thanks,
> > SJ
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [merged] seq_buf-add-seq_buf_do_printk-helper.patch removed from -mm tree
2023-05-06 0:28 ` SeongJae Park
@ 2023-05-06 0:57 ` Andrew Morton
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2023-05-06 0:57 UTC (permalink / raw)
To: SeongJae Park; +Cc: Yosry Ahmed, mm-commits, rostedt, pmladek, senozhatsky
On Sat, 6 May 2023 00:28:05 +0000 SeongJae Park <sj@kernel.org> wrote:
> > That patch was merged into Linus's tree, so I assumed that's why it
> > was dropped from mm-unstable. Perhaps I am wrong.
>
> Same to my assumption, and fit with the original mail's explanation. I
> confirmed the patch has merged in the mainline as commit 96928d9032a7. So this
> will be fixed if 1) mm-unstable is rebased on v6.4-rc1, 2) the dropped patch is
> added again on mm-unstable, or 3) the patch[1] currently triggering the failure
> is dropped. This is never an important issue for me, so I don't have any
> preference or opinion about the fix. I just wanted to save time for others who
> might got report of this.
The mm-everything which I just pushed out has seq_buf_do_printk().
The mm-unstable branch doesn't, oops. I'll fix and repush.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-05-06 0:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-05 22:45 [merged] seq_buf-add-seq_buf_do_printk-helper.patch removed from -mm tree Andrew Morton
2023-05-05 23:57 ` SeongJae Park
2023-05-06 0:00 ` Yosry Ahmed
2023-05-06 0:28 ` SeongJae Park
2023-05-06 0:57 ` Andrew Morton
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.