[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 8 Aug 2022 11:48:52 +0200
From: Michal Hocko <mhocko@...e.com>
To: "Matthew Wilcox (Oracle)" <willy@...radead.org>
Cc: linux-kernel@...r.kernel.org, pmladek@...e.com,
Kent Overstreet <kent.overstreet@...il.com>,
Johannes Weiner <hannes@...xchg.org>,
Roman Gushchin <roman.gushchin@...ux.dev>
Subject: Re: [PATCH v5 22/32] mm/memcontrol.c: Convert to printbuf
On Mon 08-08-22 03:41:18, Matthew Wilcox wrote:
> From: Kent Overstreet <kent.overstreet@...il.com>
>
> This converts memory_stat_format() from seq_buf to printbuf. Printbuf is
> simalar to seq_buf except that it heap allocates the string buffer:
> here, we were already heap allocating the buffer with kmalloc() so the
> conversion is trivial.
The changelog probably needs an update because the oom path doesn't
allocated and for somebody just reading this patch in isolation the
PRINTBUF_EXTERN doesn't really seem very obvious.
> Signed-off-by: Kent Overstreet <kent.overstreet@...il.com>
> Cc: Johannes Weiner <hannes@...xchg.org>
> Cc: Michal Hocko <mhocko@...nel.org>
> Cc: Roman Gushchin <roman.gushchin@...ux.dev>
> -static void memory_stat_format(struct mem_cgroup *memcg, char *buf, int bufsize)
> +static void memory_stat_format(struct printbuf *out, struct mem_cgroup *memcg)
> {
> - struct seq_buf s;
> int i;
>
> - seq_buf_init(&s, buf, bufsize);
> -
When is the buffer cleared?
> /*
> * Provide statistics on the state of the memory subsystem as
> * well as cumulative event counters that show past behavior.
[...]
> #define K(x) ((x) << (PAGE_SHIFT-10))
> @@ -1573,7 +1570,8 @@ void mem_cgroup_print_oom_context(struct mem_cgroup *memcg, struct task_struct *
> void mem_cgroup_print_oom_meminfo(struct mem_cgroup *memcg)
> {
> /* Use static buffer, for the caller is holding oom_lock. */
> - static char buf[PAGE_SIZE];
> + static char _buf[PAGE_SIZE];
> + struct printbuf buf = PRINTBUF_EXTERN(_buf, sizeof(_buf));
>
> lockdep_assert_held(&oom_lock);
the buffer is static here!
>
--
Michal Hocko
SUSE Labs
Powered by blists - more mailing lists