Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4546020rwb; Mon, 8 Aug 2022 03:02:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR6npmsdbW2aGOuThj56z4vmx//koQTO1VUPU3UyEhw5ZLlgTJtbr9y6Ha7t/vvvvu3moUil X-Received: by 2002:a05:6402:42ca:b0:43e:3f8d:faf3 with SMTP id i10-20020a05640242ca00b0043e3f8dfaf3mr17486299edc.122.1659952973281; Mon, 08 Aug 2022 03:02:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659952973; cv=none; d=google.com; s=arc-20160816; b=youJ9cJ933yqj33//jKdJTittAU/Kr0W1HdQEN8fw8EHDziRLcVJj81EI3pYtMgEl+ SO0lTpqL/NTHysvEjCfyZYbexM8OBYM7D9h+ngegJNp+m5rPe0xrOTJRI7HyI+uhy36t A6VpVMl9UFLaB1O3g2BuGdOmDpGRn9fx/ZMnrNTOJTXYNPR+xjSF6L3jSR2mAocRsyeL VpDnXCF08uMaBgxdZ0U/7PbahCVmxvhHmPcOS8KzAiAsWFq9ERGzvTJgMhrFDaAJMMUm a77VMCU9QbijGPTmDkavzRkEKW/Jvshv51t4Ojp6tkGKGBIW3bU49bS9SEjHlRe5byCw /W5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=HT23advkXo54Tqy77hUt7Q6ZuPWTwdQqniPFu2Wc1NI=; b=UdWr+/tlcBVIBuaglrEBquyrTWWIm5u2Fgu5O3/fQXTaa2wAUpofpGP+K6x3IUCQbn wnlwWdBIwauIqSxTJS3adG9o3sPnkuqnUM3gB2agZWUPIjMiP9w7TnqnQ09/hWcx1OYv 2KJnZZH2J8KtWL37muYwrEO2GtUOljPQ4pkFeM/dxjdD3/AW9eFJo8yY0boq1eJIANng eeZG3K1f45upWc2khLqZhlWflKHSbgfVnTni7LAmZS+5EC1DnzWRZ3PKProZP98d/DCB Ii4Nkw/pMMM9jQaPo70QyXbBk6QwiAmhupqZrQIzcpwLIoap0IW1RC+0owd3Hisp3jon QFvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=kR8xq+y1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb6-20020a170907960600b00730a5a60aa6si12063110ejc.492.2022.08.08.03.02.26; Mon, 08 Aug 2022 03:02:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=kR8xq+y1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236621AbiHHJs6 (ORCPT + 99 others); Mon, 8 Aug 2022 05:48:58 -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> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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