Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp533218rdb; Thu, 15 Feb 2024 07:35:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXKidNM1vYjs9RoVOOWSRjS7AyO10YK4ID3gvSriukxFMVFfkbI/ZHmNRdw+X7/N5YYJTs+2x/SXv/ZBNxnwzlQixCgkbz2+sHkF4SEpw== X-Google-Smtp-Source: AGHT+IFEOR+cNWOX6ApDSFzc0moW5P+dU3X4nbPqVXh+K4vIo/PoW4dzZxi0yWL/TQ5aG/tFrktz X-Received: by 2002:a05:6a21:8cc4:b0:199:7d51:a942 with SMTP id ta4-20020a056a218cc400b001997d51a942mr3277252pzb.50.1708011300711; Thu, 15 Feb 2024 07:35:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708011300; cv=pass; d=google.com; s=arc-20160816; b=T+ddaI1n4QhupRBfjrQyi9dI2W5BazF/QMGUkee8Z2qV31KuJghBd2Hn32A+AS7H25 yJH2veAIbJsC0s4dixuW1qi3kemjOIHESQSvS4R3pLIWOKVxWNVscxDP2v5AnsjWsATV xZ8x28lyWvgkww+ACMhpbTNrgeDiArUNYfQAHj+5RPK+/G3jRA+IdGq4ZCHf2I9mlefO VWydCE0J9S2OvTH91G8wOVe/iSvdXWmgf+vpgkdxhmzGC09oG94P8MBKjs6fGuEa+Aa7 xiCQG7USgfN464pPizAbbSiA0CB1TVhpIlIa/v4RhVKLTOZN9k0JlhHneh0Xyqo6Q/3g h9lA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Tw/wN6EwhF1l4GL2nZ/ht1qejqJOWh5ecVMENBzDBDY=; fh=ZUpVfRgznGzcp5a/udrhqCB2GpZlxYKNd79qdQWWyKQ=; b=OCoR4Mm3TZAysu/XyLRG85HitXarm4fi7lDaOVSWgmO2xKtc4Zh2PhUCp/K57pdg2f E8Gw9qSrc49rXw09ywN4DnqFnIKg+LrzEq3l8/COykTX9qatDm2QVPLD/kUKnuRQoVai zBavZQJvvjAR/qkL3RtRNEbnJiMT1yTFzj17MByOJQjolb1LKatVzKghPpOfFCR+uha3 C6o+KbmkTOh+/bMtEIu154mTEpIkDsTgLQ3sC41yq9YFocnkQr8+y7YYKkaGGc0aHRnL lmCAYyTnJ7BLoTZj1+pHQHNDZzPwCFbJ/v68mYGON5kCM1TzX+kfXQH//DdMAlxT4A+Q o8Vg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QCSBC1fn; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-67129-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67129-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id ay2-20020a056a00300200b006e04a017037si1321452pfb.209.2024.02.15.07.35.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 07:35:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67129-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QCSBC1fn; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-67129-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67129-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 795FCB2A016 for ; Thu, 15 Feb 2024 15:01:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 40D32132C00; Thu, 15 Feb 2024 14:58:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QCSBC1fn" Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94A2A132C05 for ; Thu, 15 Feb 2024 14:58:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708009138; cv=none; b=Sr8fpHYMesJHxKIcAT+vuw2faHusJme6eiPfMuEeCHBYWG2RqiSrFN3W2HUeozUYKRg3/9Mj4y/VjDLF/El3G4N4i4vhVEwXuFD7ZdDAhxsbVlttWEDE7cWX5XRsdUW68cxbiRhgm9yUHpIOyGqq+om/hs+qRPFYqHdYTScypf0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708009138; c=relaxed/simple; bh=6IMij2aMCDzlI1InstPj/0SjhHnSgb7se0txHOjqYec=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=P1v/H9CnwgbcIlreQPtPOt7i+oj8a4D2OWeChEXKNnKGMu9UP+lUjuWNJnM7hsjn0DHz8sMd5v2YqibNVyN458u20SrXD6c1CfdT1bhv7X/zbrEaICCZ2PvHtVTnOirHQWUThOQfCgjsPYWWHraPkPg9TxpAUF7zcF1QRKuXkLQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=QCSBC1fn; arc=none smtp.client-ip=209.85.219.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-yb1-f175.google.com with SMTP id 3f1490d57ef6-dcbef31a9dbso664656276.1 for ; Thu, 15 Feb 2024 06:58:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708009135; x=1708613935; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Tw/wN6EwhF1l4GL2nZ/ht1qejqJOWh5ecVMENBzDBDY=; b=QCSBC1fn1Ka2h7g6fyuo/iR+OmsxJN+44ewMiK7TnEvXLUwE54/Fla7TeargSAD7FL K4XY0N++HOd/XQR20ySjDvDEt4AT0wRqIA6SonOzfFP5z8DdEIZqaTEQUNCb8KPaAgTi KuGZZAXkpnbLQ8uo8Gzowy4mMy4fIf8FjABi8dPX6Dpz9E5EvFoaI1UKe7ERn4Wuu7vW 9RpviaBpJWGkU607Q3RTsx1Q9BMnNxYkHWLkp9p4vl9Ttstb/nKLi8MMIMkJ5YhE7prP AqX5xmoXXbk2RV4MOgo4U2hdSmx6j9jUjLVFg+6dNyF4KktkZz5uVsTEJBtCoOEQfFva 7uKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708009135; x=1708613935; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Tw/wN6EwhF1l4GL2nZ/ht1qejqJOWh5ecVMENBzDBDY=; b=YJrV9qXHMeNvabOJRmLmdytTYCmKYY954ihmXhPdwTiMPKwfDxMG4f9W4qH4jQ/+wY XalQcYgAwcY6rSCW3Df+XLoFDD4jC7juYOoXwkVgNBcrs/sM6UsIDzFdhZQTXGhUFery oA+fGilL3ZedlIdpZwMLi17NjGacW1iy78pLdCK1mQ56hllPfEDKjoa+69VyIi3Zt5M9 Zjt9Jy+Ai1wawQecz71fFp2XX5XMYjDmo8S129Ad/9DeDW2sgiVhgHIVgA9QgU5TKqtU PFaG6rHHwrim9Y2dSbdCrsnbP7wq+tkP9+HfqEL++xiXQStg6H2CQkwJXnRkIDKG0Ndf g2vQ== X-Forwarded-Encrypted: i=1; AJvYcCVdUVZ7RI8ZR+7sAinMLJhR4BHvLlcS6A3rqdjHLbAdTEZEpszE1EL1/VkHRjNcjcC6tE9cpp0cP+K6aYMRx59A52jxiY8lKO6Y77RV X-Gm-Message-State: AOJu0Yx3HFFoD6y/M4jumANBUnTMYn9QQIgx60s7RMCRDEhnU+anYhkN RuB3UPeaZ5mIqNtp1UjxK8zEKU63PsMvWa/EVQrXQ0mFgcNzI/fiYtlixTXkdlZyas2TRuxB3lT nF6hggyI33yoLbsKn6OWqG2mOAV/Duq9Ij20H X-Received: by 2002:a25:8750:0:b0:dbe:9509:141c with SMTP id e16-20020a258750000000b00dbe9509141cmr1821330ybn.30.1708009135319; Thu, 15 Feb 2024 06:58:55 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240212213922.783301-1-surenb@google.com> <20240212213922.783301-32-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 15 Feb 2024 06:58:42 -0800 Message-ID: Subject: Re: [PATCH v3 31/35] lib: add memory allocations report in show_mem() To: Michal Hocko Cc: akpm@linux-foundation.org, kent.overstreet@linux.dev, vbabka@suse.cz, hannes@cmpxchg.org, roman.gushchin@linux.dev, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, corbet@lwn.net, void@manifault.com, peterz@infradead.org, juri.lelli@redhat.com, catalin.marinas@arm.com, will@kernel.org, arnd@arndb.de, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, peterx@redhat.com, david@redhat.com, axboe@kernel.dk, mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, dennis@kernel.org, tj@kernel.org, muchun.song@linux.dev, rppt@kernel.org, paulmck@kernel.org, pasha.tatashin@soleen.com, yosryahmed@google.com, yuzhao@google.com, dhowells@redhat.com, hughd@google.com, andreyknvl@gmail.com, keescook@chromium.org, ndesaulniers@google.com, vvvvvv@google.com, gregkh@linuxfoundation.org, ebiggers@google.com, ytcoode@gmail.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, bristot@redhat.com, vschneid@redhat.com, cl@linux.com, penberg@kernel.org, iamjoonsoo.kim@lge.com, 42.hyeyoo@gmail.com, glider@google.com, elver@google.com, dvyukov@google.com, shakeelb@google.com, songmuchun@bytedance.com, jbaron@akamai.com, rientjes@google.com, minchan@google.com, kaleshsingh@google.com, kernel-team@android.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, kasan-dev@googlegroups.com, cgroups@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Feb 15, 2024 at 1:22=E2=80=AFAM Michal Hocko wrot= e: > > On Mon 12-02-24 13:39:17, Suren Baghdasaryan wrote: > [...] > > @@ -423,4 +424,18 @@ void __show_mem(unsigned int filter, nodemask_t *n= odemask, int max_zone_idx) > > #ifdef CONFIG_MEMORY_FAILURE > > printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_p= ages)); > > #endif > > +#ifdef CONFIG_MEM_ALLOC_PROFILING > > + { > > + struct seq_buf s; > > + char *buf =3D kmalloc(4096, GFP_ATOMIC); > > + > > + if (buf) { > > + printk("Memory allocations:\n"); > > + seq_buf_init(&s, buf, 4096); > > + alloc_tags_show_mem_report(&s); > > + printk("%s", buf); > > + kfree(buf); > > + } > > + } > > +#endif > > I am pretty sure I have already objected to this. Memory allocations in > the oom path are simply no go unless there is absolutely no other way > around that. In this case the buffer could be preallocated. Good point. We will change this to a smaller buffer allocated on the stack and will print records one-by-one. Thanks! > > -- > Michal Hocko > SUSE Labs