From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5C47C00140 for ; Mon, 8 Aug 2022 09:49:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237320AbiHHJs7 (ORCPT ); Mon, 8 Aug 2022 05:48:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232190AbiHHJs4 (ORCPT ); Mon, 8 Aug 2022 05:48:56 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3627711A17 for ; Mon, 8 Aug 2022 02:48:55 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C2696206D3; Mon, 8 Aug 2022 09:48:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1659952133; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HT23advkXo54Tqy77hUt7Q6ZuPWTwdQqniPFu2Wc1NI=; b=kR8xq+y1mXmd3ja9TrjwhcNhmjMopGVURnuWPtq8wHUcGSD3Cv6vIY0P3N6ed6N/RrScDG zO/EVO3oCbwZz0ffTHYxTA/dGpNcwV8kBdAEmU75GJMd99nTjojxjq2+O5Tpvsg87mm/HQ GUSs8gLUOB6U19dVmAL+aY/zfPUOa/s= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A3A7613A7C; Mon, 8 Aug 2022 09:48:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WEYYJgXc8GIudwAAMHmgww (envelope-from ); Mon, 08 Aug 2022 09:48:53 +0000 Date: Mon, 8 Aug 2022 11:48:52 +0200 From: Michal Hocko To: "Matthew Wilcox (Oracle)" Cc: linux-kernel@vger.kernel.org, pmladek@suse.com, Kent Overstreet , Johannes Weiner , Roman Gushchin Subject: Re: [PATCH v5 22/32] mm/memcontrol.c: Convert to printbuf Message-ID: References: <20220808024128.3219082-1-willy@infradead.org> <20220808024128.3219082-23-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220808024128.3219082-23-willy@infradead.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 08-08-22 03:41:18, Matthew Wilcox wrote: > From: Kent Overstreet > > 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 > Cc: Johannes Weiner > Cc: Michal Hocko > Cc: Roman Gushchin > -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