Message ID | 20240306182440.2003814-29-surenb@google.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 6AD70C5475B for <linux-mm@archiver.kernel.org>; Wed, 6 Mar 2024 18:26:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77D156B00B9; Wed, 6 Mar 2024 13:25:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 704A86B00BA; Wed, 6 Mar 2024 13:25:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52FF86B00BB; Wed, 6 Mar 2024 13:25:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3A2456B00B9 for <linux-mm@kvack.org>; Wed, 6 Mar 2024 13:25:48 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id EDE23803CA for <linux-mm@kvack.org>; Wed, 6 Mar 2024 18:25:47 +0000 (UTC) X-FDA: 81867442734.28.3644644 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf12.hostedemail.com (Postfix) with ESMTP id 4869940018 for <linux-mm@kvack.org>; Wed, 6 Mar 2024 18:25:46 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="suJlHS/f"; spf=pass (imf12.hostedemail.com: domain of 3KbXoZQYKCGwcebOXLQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3KbXoZQYKCGwcebOXLQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--surenb.bounces.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=1709749546; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=uTM4daMpjhNnHNsVheTGd2gBho3MSeHG2jrz4iVybwI=; b=BypyUVgBlKtdWVVYolzXiKNbwflnUxXfwqA9HAnp00/fBjD1nONG7nzsssShedTeOysHqg bKoqu2ZazHfr5TsfcGIKSF2ZPk137EcIlnAyNWZhOXPRsuuLUdEAPLOQ5fLluLBN/LOwiz fI6qCIGUDeUgyTHWU98pvwDFWuYF7eY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709749546; a=rsa-sha256; cv=none; b=awypSPRe/84BKKXzhlNUXyiM6I1mxDBLluIzvAkK39H5Kfyi1VfvoQ7OBB7K2mauX+ob1E YoZjHHMXmIo993F+IjOG1eHax4pzqEwevbaflWR8RbxSX07z5VNvQYBXGDfucFSkGiuDfh y6YbZOtBD9Qx/dgby2JM4kmQtzCqJ/E= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="suJlHS/f"; spf=pass (imf12.hostedemail.com: domain of 3KbXoZQYKCGwcebOXLQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3KbXoZQYKCGwcebOXLQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-608dc99b401so725807b3.0 for <linux-mm@kvack.org>; Wed, 06 Mar 2024 10:25:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709749545; x=1710354345; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=uTM4daMpjhNnHNsVheTGd2gBho3MSeHG2jrz4iVybwI=; b=suJlHS/f1ptV98PsbzkAbICfV7Q3x6YkTNboSLx30BFU5tmgKcg3Z35fNrI1b5tZHg T2igux5z/MZrKCW4R56VipuIjhIrrL+9MRnTiDZfh/p5bM0eqnMiFZEwdkwifBVDLkiN 4CunZAHx+XMDY8+Q49j9ajsOEOn5AhR7NUDcOJE+MgBNYj2YDFblONCDghMqxeSx9f57 2m4jOyjl4/xUXlCjtsOOABgYayOO/AJujfQrjp+srzsn0THbPyF80F6b1YRUuR9xch1l gbO2HVdNoTw3rXdQBJj0XJk+51cJBo/qjHSGb8+y7fJV4qsvZ1kkhNQ0F2oZSHsCwccv A7yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709749545; x=1710354345; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uTM4daMpjhNnHNsVheTGd2gBho3MSeHG2jrz4iVybwI=; b=AVh8QTNt09TIeFpyNGGUrhDcVmOMD9r5y1/aFIQt+Z1RdRA2j2PRCBWe66B+76lWvh f3eRwatcLGEQjfqx6odgnjgOXnDpRedZVTNLEIJwceinzKCyNP6uM0ltN2BcQuvQmvd2 wLxr/8tfpo7+Ed4Vge8BQuEOF1PT1eIuds8TmYiTxyUzFZjiXe29s1k6/1pK5XONUHUU Yp9wMre0v1f+8m2/YTCUco24utApeJIfo0s4gMEDg0RPo58AhTen4HCOMrFKy5Ae3Vdd EcyBDfsWiA9gxtEBs4+7VVzssVFhKXcEzwJC+6yniV7ToOD6nltcCpOL1Z+IP9cNhxFC 355A== X-Forwarded-Encrypted: i=1; AJvYcCW1l6ApzCRXbKU4HIT9upZAgA8fceb+HHyPrbtr+p9IkvpE7J2pzKCzUdUEq0sXlV6EK1XK1sx5cbBDG7Do64EoVyc= X-Gm-Message-State: AOJu0Yx+u3OpL8LB2pHyKr1xBEQ6+VztVlUNtRaIhd3ep7VzALa8/ac6 I6y37EK+iw7l/pfO5Am/Bcbro5tMCc+l+MhRyoUFTiv/sUCzUs8AN6OmQJJGCr11wYK6MwnN6H8 WWg== X-Google-Smtp-Source: AGHT+IEnKzMil/vcPtNXvwckm3OECYjnTJYXETMu8tDMF6y1iGrklNs9lczJgJmwr4/pSL8XxNI2NQuejS8= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:85f0:e3db:db05:85e2]) (user=surenb job=sendgmr) by 2002:a05:690c:e18:b0:609:247a:bdc5 with SMTP id cp24-20020a05690c0e1800b00609247abdc5mr4410842ywb.4.1709749545152; Wed, 06 Mar 2024 10:25:45 -0800 (PST) Date: Wed, 6 Mar 2024 10:24:26 -0800 In-Reply-To: <20240306182440.2003814-1-surenb@google.com> Mime-Version: 1.0 References: <20240306182440.2003814-1-surenb@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Message-ID: <20240306182440.2003814-29-surenb@google.com> Subject: [PATCH v5 28/37] mm: percpu: Add codetag reference into pcpuobj_ext From: Suren Baghdasaryan <surenb@google.com> To: akpm@linux-foundation.org Cc: kent.overstreet@linux.dev, 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, penguin-kernel@i-love.sakura.ne.jp, 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, jhubbard@nvidia.com, 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, aliceryhl@google.com, rientjes@google.com, minchan@google.com, kaleshsingh@google.com, surenb@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" X-Stat-Signature: p14w67sdrfk447mp4q59mstkcptnnqsu X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 4869940018 X-Rspam-User: X-HE-Tag: 1709749546-877340 X-HE-Meta: U2FsdGVkX19CQP3Iy4KqglKYlXht6DRi6ys4dl4w6eZ2gYnBM89q+/nIL6jQczLlEqWszpv2PRumxMJ7B9zCFGfjOaM9W3CMkse6aUDr+WNtlBRbBkuADd7vnYCdWxiJrNvvQ35kyJJnh+8AUes9W3udWVUUPe6b2U1mo7hTCyoCrTAOte7FQF/PQMzA56NReHuK4v4B2Up7XSDYWGIifaLoMi2pkqGnT8FAmYESj9WIsiwrP0M5dVXoLLcTOhzwWfJ2P34JrLYOCJ3nYBaMGZoebWn0pRjO49n1xEkiothoXUi5UFzdNoGzTPEHp57Z1nTaA3bTLCuLKZe5tJtxWGiSNgoLsiTzBris8zndFv0nuxAJpjS9S50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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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
Memory allocation profiling
|
expand
|
diff --git a/mm/percpu-internal.h b/mm/percpu-internal.h index e62d582f4bf3..7e42f0ca3b7b 100644 --- a/mm/percpu-internal.h +++ b/mm/percpu-internal.h @@ -36,9 +36,12 @@ struct pcpuobj_ext { #ifdef CONFIG_MEMCG_KMEM struct obj_cgroup *cgroup; #endif +#ifdef CONFIG_MEM_ALLOC_PROFILING + union codetag_ref tag; +#endif }; -#ifdef CONFIG_MEMCG_KMEM +#if defined(CONFIG_MEMCG_KMEM) || defined(CONFIG_MEM_ALLOC_PROFILING) #define NEED_PCPUOBJ_EXT #endif @@ -86,7 +89,11 @@ struct pcpu_chunk { static inline bool need_pcpuobj_ext(void) { - return !mem_cgroup_kmem_disabled(); + if (IS_ENABLED(CONFIG_MEM_ALLOC_PROFILING)) + return true; + if (!mem_cgroup_kmem_disabled()) + return true; + return false; } extern spinlock_t pcpu_lock; diff --git a/mm/percpu.c b/mm/percpu.c index 2e5edaad9cc3..90e9e4004ac9 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -1699,6 +1699,32 @@ static void pcpu_memcg_free_hook(struct pcpu_chunk *chunk, int off, size_t size) } #endif /* CONFIG_MEMCG_KMEM */ +#ifdef CONFIG_MEM_ALLOC_PROFILING +static void pcpu_alloc_tag_alloc_hook(struct pcpu_chunk *chunk, int off, + size_t size) +{ + if (mem_alloc_profiling_enabled() && likely(chunk->obj_exts)) { + alloc_tag_add(&chunk->obj_exts[off >> PCPU_MIN_ALLOC_SHIFT].tag, + current->alloc_tag, size); + } +} + +static void pcpu_alloc_tag_free_hook(struct pcpu_chunk *chunk, int off, size_t size) +{ + if (mem_alloc_profiling_enabled() && likely(chunk->obj_exts)) + alloc_tag_sub(&chunk->obj_exts[off >> PCPU_MIN_ALLOC_SHIFT].tag, size); +} +#else +static void pcpu_alloc_tag_alloc_hook(struct pcpu_chunk *chunk, int off, + size_t size) +{ +} + +static void pcpu_alloc_tag_free_hook(struct pcpu_chunk *chunk, int off, size_t size) +{ +} +#endif + /** * pcpu_alloc - the percpu allocator * @size: size of area to allocate in bytes