Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4706300rwb; Mon, 8 Aug 2022 05:55:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR5auNB7w06qZB2wpzGElEYoDT2x0vVlmexWdYnBBhicvo+GdjuuR1j9WRd0eMiKrRyrFCCW X-Received: by 2002:a17:907:7601:b0:730:3da4:217c with SMTP id jx1-20020a170907760100b007303da4217cmr13096564ejc.563.1659963350853; Mon, 08 Aug 2022 05:55:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659963350; cv=none; d=google.com; s=arc-20160816; b=ALQWA4hB/EA/u6ShhXT2Jve0wEnKWKkQs2FLauK+GUuWK/KcGFJpg1ZoeXNfEeljXS yKHweySVHrJagOmpjqn5xx36dAKwWXlDWzlva3PhKUAVkwRY3QY6VEg5oPgEQQZIPgOU 8NviQ1arz8hyg5WI7bfNKDNm7jCs9MY5A6GzPTTe4um7tObP6QdqdJ0Lsvi0SdoKbnpd +QuLfWSFtDjrd/6cgQvoDQ7HbdZqMWnLJMgvKb/T3xYCPfZc/dHSbp3x5QlISb+xlB3R GmSiA+1w8E6c6Onw4uyoLLBquMcu/CY82YBW7hqn3zQd+XzNlNxwiYvIVf7cimEkUrpw QaYg== 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=W1sGZxl3xXz477fHR3FYxaBFtzx2Vm8TywnLraTFFDk=; b=iwemXgy/x13O+iQ10jHHfa3051OGemBcUOcfriCH1K0spBVegvehY2DT17bVKMAeCo +XBVev6e0eMedminVXfQ6s3M8SPNrGflQ2Zcyy29FDAUinJpaoHnKK2YfC1qplu3MlCo SZAHn13Q7kupucTKBvjKtpYASL3uOU8LzZTZEgRMpJxleHKGXg09F461fWmbQEJMnCAZ ANHNgPClZ9aeksgO/xNqrk+8N2PSG2Da7WMXttnyiUHy7nBbzB3JeW8M/R+wGIDo8arp D1m63eXFopFRf7rLJjlcMz2sp8rY5fJ98MhgI4wX2q1E9icnzNlkF7Druc5S4pABLXVc b+Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=S0bPOeu0; 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 z15-20020a05640240cf00b0043e14ec047bsi7604954edb.6.2022.08.08.05.55.24; Mon, 08 Aug 2022 05:55:50 -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=S0bPOeu0; 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 S242080AbiHHMsI (ORCPT + 99 others); Mon, 8 Aug 2022 08:48:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233836AbiHHMsG (ORCPT ); Mon, 8 Aug 2022 08:48:06 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 523A7C8 for ; Mon, 8 Aug 2022 05:48:05 -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-out1.suse.de (Postfix) with ESMTPS id E6DA537AB6; Mon, 8 Aug 2022 12:48:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1659962883; 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=W1sGZxl3xXz477fHR3FYxaBFtzx2Vm8TywnLraTFFDk=; b=S0bPOeu0jS1g1dwW41BJKGxrsmfb9XkpqQD3GW5l5RNYPfuqNbVdjSarlTb/ze3ttYy+1B owAj1pKC1te4bt7lV05SN1mo/iJjqr4SouyiS2b38ExKCBQI65voqCQ22YF7dRKedfFEqW CdomP6sYVzOZCaevt4ejYX3yhHGrOyg= 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 C5FA913A7C; Mon, 8 Aug 2022 12:48:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id bBWjLQMG8WJ/TwAAMHmgww (envelope-from ); Mon, 08 Aug 2022 12:48:03 +0000 Date: Mon, 8 Aug 2022 14:48:03 +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: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 11:48:53, Michal Hocko wrote: > 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! And answering to myself. THere is an internal pos field which gets initialized by PRINTBUF_EXTERN even when not mentioned explicitly because it gets a default 0 initialization Acked-by: Michal Hocko -- Michal Hocko SUSE Labs