Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2908201rdb; Tue, 13 Feb 2024 00:19:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IFSqezDgZvDRpC651Nf9Hoskv7uC4B2rb7+h8oT2NIzLl39E9yZLpgcNQvFhaezj6KPET0P X-Received: by 2002:aa7:d80f:0:b0:561:ec1a:95d1 with SMTP id v15-20020aa7d80f000000b00561ec1a95d1mr1069338edq.37.1707812356319; Tue, 13 Feb 2024 00:19:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707812356; cv=pass; d=google.com; s=arc-20160816; b=dWLq29tRbnNT5w92llwmzoARVI/s+l687yLoiKB4C4P7pwdpZ96QN7Igw6/Fc9aoLT Wf5YiFXd5zzNlGQEsaO30BIVGnuHRNtvTzyFCeIpGOFCB/xiunzhMaoFnPcIYBNS9FJz yUNUfmxdOjRA+xinK2EQQ8BXU4lO7ZATkIayK2Lq1gcAmb5MGsyVR0haUnKdiYZUnOfh aVwv1LQGZFSlyLGsgPY+gUrX+vcGf3moWotIxyUkdDqECElHja3EHBf2XCLZr82qyLEb BqS3Njcm7kUUt+b2Ulczin51jOeCuMDAfvOnEcRHXYOG46T0fPKLtza7ycfwXxUg6TlC hn5w== 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=hC5Sp72DpOGszEFoskDK+zxBIS3uARFrNh6dT/DOYpw=; fh=1tf4Ng/tEtbNAtVi39NpZk2zWiC1lMeImL3VPoDY+EU=; b=Ms4QFgKMHTeR9su1Czy+5yf4dWtmIB5CJy9Vd4BJcjchOw/2K/iDY19XuutWrO4+uo 9XCzaKBcfx8doqxEBfsc6W+x+gwIRZStd+EkSUSGAcqgOw2eY3GrbFmuT6NC+hgNLIHI jopGCSMCHsEoksbkvwBb/lYaLJzevrAq+txad9kgCrXU45NYNF0jQpD5SZ3PanTrUZvL ch0WLTo+0oyXnCoXzthiKgt1I9xZAjdpXlPct2y6KIRjkoJ5UWbshLOJ95pLYN3HLv2a fYFy2S2qxNBE48sFNJTo+omOu9kfpRoK6LvTcOMOo4KVRYuWht1JMv9MxLqzgTroDYq7 gmzA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=aQC6uG1A; 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-63088-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63088-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCW8t2KlpoAoj7pyRjcVDqEKrOiN/1nugjs44mPzG9krRJD6/1FkapplPBy0GEHT5aihMpKqUYvaVOgGmpy3LXQsEQbvXPQZIY/DHlOOAw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h6-20020a05640250c600b0056179ae96a9si3135403edb.241.2024.02.13.00.19.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 00:19:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63088-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=aQC6uG1A; 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-63088-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63088-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 120D31F22627 for ; Tue, 13 Feb 2024 08:19:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 032BB210FE; Tue, 13 Feb 2024 08:17:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="aQC6uG1A" Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com [209.85.219.180]) (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 415F7249F9 for ; Tue, 13 Feb 2024 08:17:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707812242; cv=none; b=QYqybEowA2U8jCjWSoUo7cBZX+seWeOfszrkJ6dL2XGLLssjHMnWM0EhwYgN5rKgApbVBQjrE5R4zDJ3gJZaxnShY45uyahFoVzzc1Jyn0UH5j5F57b0DDIG7iLy83tcC+K+qLiPbmLFgTWywYHbWe8S8JxAEpAKz8A4HJ6Aeik= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707812242; c=relaxed/simple; bh=k0dlcOpqCeQ859XsaJEpqmX/eHez3ZKf32wZRP8twEM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=rH+jg23hS933+QpuXnrdcfWsjbDJPhEEvgCmIpvSxTdV1uEiAMV6HzNsFzhuf2ch2DpoHCQvQXbdn6BwHCA5gfGZSYOZpXwnRM4lDYPWCBAZu20Tp5XI63YaeOa/Tiv/dWHK2w7d+m1wbUTLWn2Js3WhF92JiZWx6o4iOcTp1mg= 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=aQC6uG1A; arc=none smtp.client-ip=209.85.219.180 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-f180.google.com with SMTP id 3f1490d57ef6-dcbef31a9dbso717788276.1 for ; Tue, 13 Feb 2024 00:17:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707812239; x=1708417039; 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=hC5Sp72DpOGszEFoskDK+zxBIS3uARFrNh6dT/DOYpw=; b=aQC6uG1AXej3oTFT3m2fKoYa7LYFxfuAxPkLfo/+dHttTZeAGK1ACiZfvHg7uw0Mk1 NyffctXcL4SO7EBLTKauvlsluF9l45qqYYS/KQONb+jIPCiLK+c+WbNi/zBkjJmV5iQn WsnqaAKYBSrfSkW7fXdosoOrkNwAzcUp43y8upwgTF2pjdBLkjHiuPGOfOCToa6iDsSZ CavdtF6mFt5fTzar38xQes3PQzi0/e6CRsAp0GocFdrTQFzMDfarix1y1+EUFBjx1Fx0 EFHr6x3Um7GcCahg2w7MywWIgN9lVJvVg/DnGOrIZQvRXVxFAH/k3iDSS1SZW7/xRNNz zarQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707812239; x=1708417039; 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=hC5Sp72DpOGszEFoskDK+zxBIS3uARFrNh6dT/DOYpw=; b=h+l2xJf8IrTe+K5hTrauzOA6fqiag/V5TNpfo5KDHCL7RFF6gZrEhwNRKfyu9SpEIm aWPDJ8tg1J4Qn2zeI4tnfJTHnKL1pAznYB3GRpqug49SgVpkhLmQdbiT0/+uZ8vXf44w 1khnDAbhQppNLflW9+HhVFcMB9r2+hRwabyFyt2GnfHjN4u9jNhWVb+/rjBjD14adXcC 2KR/FOuPs0UFb+t8Ld9/vUeiNByn7CZcXzxdrNd64PdSyCyZO1+9S5FLZKDnYX+6+TZq 4CdsoVnYBbHp2gVG8C1WIc1ZPVSa2qTGaLIS3SRCCfk+9hbiK8nw5JfJFMZf7BhvxP2Q 1cRg== X-Gm-Message-State: AOJu0YwjWWrlXmwouizGNsdsw0GYdpZADH4epPR6UB9YbkGJyq8arDKR rQqrOhPyooANqOyf0j0OL5cBCPkWkxUR+4EM+nzZn7AHnaNE8Hn2CcQ4lln5zb2p0VG27VNfO0B KA3wfLaaA3BMGf6jQOKkSCTu7uAHvRhGMgAzO X-Received: by 2002:a25:6841:0:b0:dcd:24b6:1aee with SMTP id d62-20020a256841000000b00dcd24b61aeemr45209ybc.47.1707812238953; Tue, 13 Feb 2024 00:17:18 -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> <202402121606.687E798B@keescook> <20240212192242.44493392@gandalf.local.home> In-Reply-To: From: Suren Baghdasaryan Date: Tue, 13 Feb 2024 00:17:04 -0800 Message-ID: Subject: Re: [PATCH v3 31/35] lib: add memory allocations report in show_mem() To: Kent Overstreet Cc: Steven Rostedt , Kees Cook , akpm@linux-foundation.org, mhocko@suse.com, 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, ndesaulniers@google.com, vvvvvv@google.com, gregkh@linuxfoundation.org, ebiggers@google.com, ytcoode@gmail.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, 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 Mon, Feb 12, 2024 at 8:33=E2=80=AFPM Kent Overstreet wrote: > > On Mon, Feb 12, 2024 at 07:22:42PM -0500, Steven Rostedt wrote: > > On Mon, 12 Feb 2024 16:10:02 -0800 > > Kees Cook wrote: > > > > > > #endif > > > > +#ifdef CONFIG_MEM_ALLOC_PROFILING > > > > + { > > > > + struct seq_buf s; > > > > + char *buf =3D kmalloc(4096, GFP_ATOMIC); > > > > > > Why 4096? Maybe use PAGE_SIZE instead? > > > > Will it make a difference for architectures that don't have 4096 PAGE_S= IZE? > > Like PowerPC which has PAGE_SIZE of anywhere between 4K to 256K! > > it's just a string buffer We should document that __show_mem() prints only the top 10 largest allocations, therefore as long as this buffer is large enough to hold 10 records we should be good. Technically we could simply print one record at a time and then the buffer can be smaller.