return memcg_page_state(memcg, item) * memcg_page_state_unit(item);
 }
 
-static void memory_stat_format(struct mem_cgroup *memcg, char *buf, int bufsize)
+static void memory_stat_format(struct mem_cgroup *memcg, struct seq_buf *s)
 {
-       struct seq_buf s;
        int i;
 
-       seq_buf_init(&s, buf, bufsize);
-
        /*
         * Provide statistics on the state of the memory subsystem as
         * well as cumulative event counters that show past behavior.
                u64 size;
 
                size = memcg_page_state_output(memcg, memory_stats[i].idx);
-               seq_buf_printf(&s, "%s %llu\n", memory_stats[i].name, size);
+               seq_buf_printf(s, "%s %llu\n", memory_stats[i].name, size);
 
                if (unlikely(memory_stats[i].idx == NR_SLAB_UNRECLAIMABLE_B)) {
                        size += memcg_page_state_output(memcg,
                                                        NR_SLAB_RECLAIMABLE_B);
-                       seq_buf_printf(&s, "slab %llu\n", size);
+                       seq_buf_printf(s, "slab %llu\n", size);
                }
        }
 
        /* Accumulated memory events */
-       seq_buf_printf(&s, "pgscan %lu\n",
+       seq_buf_printf(s, "pgscan %lu\n",
                       memcg_events(memcg, PGSCAN_KSWAPD) +
                       memcg_events(memcg, PGSCAN_DIRECT) +
                       memcg_events(memcg, PGSCAN_KHUGEPAGED));
-       seq_buf_printf(&s, "pgsteal %lu\n",
+       seq_buf_printf(s, "pgsteal %lu\n",
                       memcg_events(memcg, PGSTEAL_KSWAPD) +
                       memcg_events(memcg, PGSTEAL_DIRECT) +
                       memcg_events(memcg, PGSTEAL_KHUGEPAGED));
                    memcg_vm_event_stat[i] == PGPGOUT)
                        continue;
 
-               seq_buf_printf(&s, "%s %lu\n",
+               seq_buf_printf(s, "%s %lu\n",
                               vm_event_name(memcg_vm_event_stat[i]),
                               memcg_events(memcg, memcg_vm_event_stat[i]));
        }
 
        /* The above should easily fit into one page */
-       WARN_ON_ONCE(seq_buf_has_overflowed(&s));
+       WARN_ON_ONCE(seq_buf_has_overflowed(s));
 }
 
 #define K(x) ((x) << (PAGE_SHIFT-10))
 {
        /* Use static buffer, for the caller is holding oom_lock. */
        static char buf[PAGE_SIZE];
+       struct seq_buf s;
 
        lockdep_assert_held(&oom_lock);
 
        pr_info("Memory cgroup stats for ");
        pr_cont_cgroup_path(memcg->css.cgroup);
        pr_cont(":");
-       memory_stat_format(memcg, buf, sizeof(buf));
-       pr_info("%s", buf);
+       seq_buf_init(&s, buf, sizeof(buf));
+       memory_stat_format(memcg, &s);
+       seq_buf_do_printk(&s, KERN_INFO);
 }
 
 /*
 {
        struct mem_cgroup *memcg = mem_cgroup_from_seq(m);
        char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+       struct seq_buf s;
 
        if (!buf)
                return -ENOMEM;
-       memory_stat_format(memcg, buf, PAGE_SIZE);
+       seq_buf_init(&s, buf, PAGE_SIZE);
+       memory_stat_format(memcg, &s);
        seq_puts(m, buf);
        kfree(buf);
        return 0;