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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA3D9C4829E for ; Thu, 15 Feb 2024 18:50:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5EBA28D0006; Thu, 15 Feb 2024 13:50:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 599038D0001; Thu, 15 Feb 2024 13:50:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 413668D0006; Thu, 15 Feb 2024 13:50:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 2C6328D0001 for ; Thu, 15 Feb 2024 13:50:16 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id AF49E12126A for ; Thu, 15 Feb 2024 18:50:15 +0000 (UTC) X-FDA: 81794928390.02.0B4116D Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) by imf19.hostedemail.com (Postfix) with ESMTP id DD0291A0003 for ; Thu, 15 Feb 2024 18:50:13 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=R9Kjvh4j; spf=pass (imf19.hostedemail.com: domain of surenb@google.com designates 209.85.219.169 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708023013; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WUlsSeO8LefyO4xLZYNJ9jNHAOJrLbOdsT9pDfMZXA8=; b=WebX9l9G7S1HqrdXB6z+1mAhPragFqa4OSZT/VkmaDPtQSWslpJAwjEtsBl9EaktN/vdSP B+69VIgKYURHyEsw7mFOeIxapqKXoKkVzZgoGGhmOBVIhB2pUxxlmTdo4Q3e8we40xf17W 4qW/H1OYs6cxb+TfTnJHCETysa6MV54= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708023013; a=rsa-sha256; cv=none; b=6TC6yjle+0I28UHvYPt8usidQx3sxkMJ+dW523aMgHgbC4U3lzEEv+ZBTl8K4svQFx4seL ac1TlWcvHT/K+B9Os0yXQ2a6rqInLvdpCdtHN9rh3/ePhByv6nRoBmWmGKDj5yBG4oy29h Aq8e6R2aiNW8orCQm5VRGPp/iVr6yxw= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=R9Kjvh4j; spf=pass (imf19.hostedemail.com: domain of surenb@google.com designates 209.85.219.169 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-dcc6fc978ddso1101878276.0 for ; Thu, 15 Feb 2024 10:50:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708023013; x=1708627813; darn=kvack.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=WUlsSeO8LefyO4xLZYNJ9jNHAOJrLbOdsT9pDfMZXA8=; b=R9Kjvh4jEt54rJGVp/xo+bWiaVuh1k42g+nQgRxx0moeCEiJEMrkT36mT5R+8tVS8O jawF5k80wm9N0GVh3OIzu9mKGh26b+gIKZjssBSZB2UTwEdA7LhPAZH/ZUuOtqA8sRtF osApOeX1FxsekHTnEssQRE/VrZvyVDiQpjTyrdXx5bsXuGr9zn6ka6lpUyU7MbfBpGDD C6WmtGoj2dLuEp6uec8aHX4jlvhCqgMkcmfNvFIr8hXX/jq5Mlku6SWuOhltuwe6E55b 3zf9d+Yqap3PnvSTeRcWyBUd6ofYGiXdoN0DddbhCnd+gE6MosPo3a6ZWY1ul5Qtj3CT ylLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708023013; x=1708627813; 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=WUlsSeO8LefyO4xLZYNJ9jNHAOJrLbOdsT9pDfMZXA8=; b=SmqjWFWZM6I1Ojax1oIgJJJwJCCEvjC6bGEPTk6LKfBQKFuD30Z0rexoJTeizllwSw WibMce7f7fooaxMWNfsqxW1pP9lWxTV0kYJKtLqb+dnB+VtUXgIZ7EYVFmS+sH4T+5+Y bCBDOyEG4p5BlZT6IFlULtT0xHtto6/PlVikJaOIR0qGclNLRP/Y+2tOVJr0wLwfIFhj fKdSOLqVdNO4f8asDCdv0oGUqLhXpO/c+227N60rqHuXW4FCFTMHwR8+VKlwKbrVnr6g EXRuM6GXzkDYlPDDsRExZUsNsmiscDRpGS4/00bcv+YmW+1aIkycOP7jEQKCevk0abEv SM5w== X-Forwarded-Encrypted: i=1; AJvYcCVHkkVZ6hFK+RLujEi/moaXOj5ljVIK9xfCghEoyZzDY+l7oaiOFVROeBE9nGoczK6wUgdnSpDUsK2PWLe1Em2AJuI= X-Gm-Message-State: AOJu0YzS2KrOpIZPtG3X3GYnW1ROCay320w7Ue99cS1ratfKIwYbHN3P ID+Wd8M91kQz6537DsLvZ2CdfKoWOcIFtA8BN4uENXRJ8/fUXTOJtJuSkJiAGXTRZKUHe4RdBMl fHygnuAPq6munwD8os17FJ54UHvgQkDs7Dq8E X-Google-Smtp-Source: AGHT+IHQQXGNaksc4ZLhdDELtvsfOEVbOUct07hRFV1UcZvxQkhvZT74vejiVn2ZOSoGey1AwcE3FMB7Y05S+V1u8DE= X-Received: by 2002:a25:ae28:0:b0:dc2:4fff:75ee with SMTP id a40-20020a25ae28000000b00dc24fff75eemr1999749ybj.3.1708023012635; Thu, 15 Feb 2024 10:50:12 -0800 (PST) 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 10:49:59 -0800 Message-ID: Subject: Re: [PATCH v3 31/35] lib: add memory allocations report in show_mem() To: Michal Hocko Cc: Kent Overstreet , akpm@linux-foundation.org, 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 X-Rspamd-Queue-Id: DD0291A0003 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ox5xw4b8r7ibqtnwgifx4jsrbkzkhqh5 X-HE-Tag: 1708023013-425618 X-HE-Meta: U2FsdGVkX18A/AsCOip1F+h1rjwb2YMzjN8XXEgcnChsWGkKgaEV9pqAOOWohwb9i+xE04UlD0UKB4c6Bfc7i5lBQ1K+bWAEJRKV3OYneenrVFgpMVRaXtiqhlVmXZJfP/sApWQ3m1yqcUMuy1Kp2S1eVm9QJ/BuOnNSVo+bDwdcP7hT21QxZeA5Ky6THsqHmu5IVRYQlbyEsd3gn5UZBUHuYpsY4xSD12p+GO6IfheEUJMJvX8Xfzv51gC9493XWRE2H4spWGMURhZ60oBDkUvaP/HzMX88p3H+RKVAFgOWZZxz0xFqcR5HNxWcxfIzqE/FvkL+DMhF/BoZX/hUl5KVwRmkJdAoRWrBEj+tVsutaF97IlFY5F2P5c6/Oe3vo6OUyE8WKOnpA2giwB0lhyTnTPdT656cOhdk+jROZnQL30yAymTf9eVjpkRLVa8tthQPAduSVVHzOgXBHoJz/nS+E59OvSxlOpYfhSMkiSOFLDniKWe3p5xio0dUpxkm35mMEiiMvYwnFSUw+BthbuipCH+wNF9KbglyMuiOHT4sAkn5+QT7AkFGRuTylMe/9ttZBoiVwIdLw95lUX9rXS6ihv9fhU7ms+oHs+j4zpnUV4mEHa1t6cZBzSDdAvUZye4VSb5Q4HtpBHs5eY6fjVM1ENoB7anfW9ESwaqFPvqJJyERmY/CaNrDUDWGqArj/MB6ZU7DieRZgnnMuZOKS0FIywvjN/dIeWtT+VQbO+7q1EsMHdZ52joi4lvoO11YgAoUyM3gzOWK4AemnEVR4f4ne0HHgMpo1OiPuH/4oOd9FTaEvBC5vK9ijFGZnfdxb4Y5IqMupSgp6/gFUpzcU8pG226Y6F+xQ9hKJz7SuZkbXLCivXLHI+0u1I6Qwv6IVDSsf4lchLL0+YD4WyYSkiGIRb+ZL/DuAZ1gyCBDEC0ZAmDdzYM1D4HBQY88y3SvaBDawV90fbGtKLx40jv tbDBN8j4 gYTmQehuUeaJ9T++lqoi5DCzlYo2EdJ53wJp2NzDk4GTdlWFOiiXXSijlaO6xpMZUhqwyRN531L/XMXCuuZh3HSkuFUjS7Z6GfykM3RU6d2/MAXs0zgyjHdz/09Mt1aiLHQxdbURcfKWJl3aJVw9Lr7hyZI6LRt6dhzPFvw7qmi+vYrqz/+ZbtORAAtcs8WsTwrUpifk+O++97+94cfHdFEusg17OXsVrNeT98GKyIfh5+YpjKQukpEZRfJkmAcZniBj/Z/uROt2HYhvYEi/JCaUpOvlfT2JWRKpjz6S3aBjRwH5+GemSxhtoCgWAueBu8Z4o X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Feb 15, 2024 at 10:41=E2=80=AFAM Michal Hocko wro= te: > > On Thu 15-02-24 13:29:40, Kent Overstreet wrote: > > On Thu, Feb 15, 2024 at 08:47:59AM -0800, Suren Baghdasaryan wrote: > > > On Thu, Feb 15, 2024 at 8:45=E2=80=AFAM Michal Hocko wrote: > > > > > > > > On Thu 15-02-24 06:58:42, Suren Baghdasaryan wrote: > > > > > On Thu, Feb 15, 2024 at 1:22=E2=80=AFAM Michal Hocko wrote: > > > > > > > > > > > > On Mon 12-02-24 13:39:17, Suren Baghdasaryan wrote: > > > > > > [...] > > > > > > > @@ -423,4 +424,18 @@ void __show_mem(unsigned int filter, nod= emask_t *nodemask, int max_zone_idx) > > > > > > > #ifdef CONFIG_MEMORY_FAILURE > > > > > > > printk("%lu pages hwpoisoned\n", atomic_long_read(&num_= poisoned_pages)); > > > > > > > #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 alloca= tions in > > > > > > the oom path are simply no go unless there is absolutely no oth= er 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! > > > > > > > > __show_mem could be called with a very deep call chains. A single > > > > pre-allocated buffer should just do ok. > > > > > > Ack. Will do. > > > > No, we're not going to permanently burn 4k here. > > > > It's completely fine if the allocation fails, there's nothing "unsafe" > > about doing a GFP_ATOMIC allocation here. > > Nobody is talking about safety. This is just a wrong thing to do when > you are likely under OOM situation. This is a situation when you > GFP_ATOMIC allocation is _likely_ to fail. Yes, yes you will get some > additional memory reservers head room, but you shouldn't rely on that > because that will make the output unreliable. Not something you want in > situation when you really want to know that information. > > More over you do not need to preallocate a full page. Folks, please stop arguing about it. We have more important things to do. I'll fix it to use a small preallocated buffer. > > -- > Michal Hocko > SUSE Labs