Message ID | 20240212213922.783301-28-surenb@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-62433-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp185761dyb; Mon, 12 Feb 2024 13:51:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVToecLJqhIw0V12Y86yzdPb9Rj08YZC35e497sg52vCtDPnCDmEdIrNDbtwA7X+Wz5tbz2Pe7X7c2ZcMklbcTWlL4vGQ== X-Google-Smtp-Source: AGHT+IFoCMrguK6Zk+B0oh2xn6gJYTzVvLAbl5ce5DBtOX7I4PmA6aSIOzMvtTvHM+Wf98ZbjL6O X-Received: by 2002:a17:906:254e:b0:a3c:a5d7:3689 with SMTP id j14-20020a170906254e00b00a3ca5d73689mr2588806ejb.1.1707774691005; Mon, 12 Feb 2024 13:51:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707774690; cv=pass; d=google.com; s=arc-20160816; b=trtn0FT5efHxfC3afJZwN6PUUxHNXJi799pgMPbdpOSfRw+ckTTjRT3LeYv/YNgT3D 3K0JThG7KcMy3mKkwWjR/OJFzPOF1sEsqGXyLMspLLRe+AhjxnjHVcEaAVVp50HyzkNc 3nraJykdpGxw5N2+dUmgW4m6h80HbjDDYRU47HUdgY8KQMOesjaQa4RHr7NZ011otczQ PF1hDaEuK9Oqdr68Lzwy9eC34QzeF1YB8njHho3iZyusxyZhbFK4z7PkIskGkNk/QY8W uHTAYWOvxwjOcdAlb9+SlvI/7F+WuRFfN7+WrQ6nxjoixphBD9dsvIIe9eNpfCfvBEmZ iHvA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=X07z1RjJe29sLMh5N/vKSXU8uipRKYcH64glAbq+0r0=; fh=ljBhjFWCxefUOUdHK8JafvO2n9ErvsJBGgkwTnPvyF4=; b=HJCqe3/GQu4htP0EJhyhcIuo9f0IncNyAEny8T1R6sqqSpTYVi0xfIMLGcEdaTU731 Lbujpl8Gec7L/WzJUBh6eAVJE6ATzdIQ73pcS/hKTP2LP09lKMjeurvprSdSeSU3XYd9 Nl/9/I+t1ksZJHhrP1ixrXQjFjhE+Q2FgHFMZlDSzD58PpHbwftf4ThhW8LD892fGzN4 wNMJHPKSiOIW1Kg8wMMkD/0O52z8wWmpwqni2IxzJmkyZsI/ITQLx7/ROa1IXPICutki /ja8w4VdT4XX/i8w7MBwzDARCDpXAj6ApYd0TiQPuBIitGvDDYYuzK2PBl1Ic2tAaGH3 elhw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=lPzM8CUh; arc=pass (i=1 spf=pass spfdomain=flex--surenb.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-62433-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62433-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCWlRhdwK9z9QMJYbDDztYoVtHRIaE+9PkY/GkBaTSsVcU4Ox5KO/R9GL6bnkIWWwuj59eXCyUdwVq9LizbmtcV1d3KcTQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id z8-20020a1709060ac800b00a3ca40ab03dsi590226ejf.642.2024.02.12.13.51.30 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 13:51:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62433-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=lPzM8CUh; arc=pass (i=1 spf=pass spfdomain=flex--surenb.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-62433-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62433-ouuuleilei=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 A10A01F2366A for <ouuuleilei@gmail.com>; Mon, 12 Feb 2024 21:51:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 202F15D8F8; Mon, 12 Feb 2024 21:40:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lPzM8CUh" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 C1E4D5A7A9 for <linux-kernel@vger.kernel.org>; Mon, 12 Feb 2024 21:40:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707774033; cv=none; b=bSsJXkZkW5ooSMOiAQFgm6Zr9Y9eAoM57/YWRaE1YnVaEgWdUgnSNSjn9Twih+IkZj/7FijdLqnBMEdkgG67DiIbnaOAlxSkOXadkmJmwlP6JlJt5hk9mIwG6icg6sEuqkcRxUb6QrBmLlJAhV5gqrSiccwY+zq4EaoPaFBwz7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707774033; c=relaxed/simple; bh=agT5b25ACG41VKpR8q87SrJ3Bcb+qFiIEtA30AzV538=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=JM4yjYLOzgTGERugZ9JoIUUrSC/DwV7clpsNrvr+9fcs6pXKLT2KFH0RdE0GQLjp3iijJgDL+NzPkXjOyuIpmCvLCPYmCr0sMjRUZ2AVGGoCG/3fpLpFztdYkGUNNBRyOzZZ2FemdtX0mwVL/47V8odiwq88bzokeyRNBXcojWg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=lPzM8CUh; arc=none smtp.client-ip=209.85.219.201 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=flex--surenb.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc6b26eef6cso335872276.3 for <linux-kernel@vger.kernel.org>; Mon, 12 Feb 2024 13:40:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707774031; x=1708378831; darn=vger.kernel.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=X07z1RjJe29sLMh5N/vKSXU8uipRKYcH64glAbq+0r0=; b=lPzM8CUhyrv/sPst6GWvy6n9rv20CXuQ/4zauYIxESdrS2e2oB2YyltlxNYRqZELJb 3Y/9ffwm1BbBJlPShZ1vB3Y6vjjuiwYOzEBK/lVXxRuoRd2w3mdiIe6SgufsOP0ggnEv //jwQp8FI7R7NqRIX5QBKXIkWU/tzVLtP9ERHhZowRn0AohY1d/3H+p7sZiKXG5Wky5Z g30I5jKc0TzaAvbZxQTIV+1zKgTbqfLF9NJi9+2H9YR/paoKEJwC0Y/Ww7VlTp+ieXpB l4frLkDMMBdyyhwpEmkde49wedJgoqTs4fuWb66SoZAEY/ZddeT0lsRPtBebBHaMKZSi yh7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707774031; x=1708378831; 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=X07z1RjJe29sLMh5N/vKSXU8uipRKYcH64glAbq+0r0=; b=YuahM3whCLRqNQt6r2cpZlvmD5dLO9TFCmAXqqwPk1s3aNSHFkvya/liFn3IS0vzTB PRFHKfjElWHERMDRF93H88qLd6aWad1z7/pvkAJVpjhMcOf8JzjH3qd47Qh6edBgo65V S6CT03TRAYgzYg0x8jfxw+i0BeIcd8nKGaYoQiMrReauzt0vBfba03KyY5wU4CZV54CU MRXn3uFkMJM5BIf7oNoKzEORXvjmbLyoHQmvnjecX0UCfIuMsqx5ZRoBHIKEyq/H4WAt tjjcPSeuwu9gOMk2zl3Iky2XbLUisi6S7AHfxEB7vJY9kZizeHLlDmV4B3q0QigYugFl CSOg== X-Forwarded-Encrypted: i=1; AJvYcCV6Kq6T5yF9Hnfe/PXFvKdrokl9memnUvNVVGwSAhigOQdJcS9SzTRNrd1LsGsvWjtBpJ5ctBZU5D0dPrPfEwrk9PKq8MMyCbOFIGDc X-Gm-Message-State: AOJu0Yy5H2jJsXVYDjDWxwHX5WrKqt1lrgRf/p3BniBr0qOiZxqCesa0 RD77fn1Pi5tMdGVJ/kjf3l7VbVr3QHWCzQYcXwZ/6YznFxQXo6Grv4nEbHuYa3rlkyzX9qad0nI PAg== X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:b848:2b3f:be49:9cbc]) (user=surenb job=sendgmr) by 2002:a05:6902:709:b0:dc7:59d9:7b46 with SMTP id k9-20020a056902070900b00dc759d97b46mr291099ybt.3.1707774030642; Mon, 12 Feb 2024 13:40:30 -0800 (PST) Date: Mon, 12 Feb 2024 13:39:13 -0800 In-Reply-To: <20240212213922.783301-1-surenb@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> Mime-Version: 1.0 References: <20240212213922.783301-1-surenb@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240212213922.783301-28-surenb@google.com> Subject: [PATCH v3 27/35] 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, 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, 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790731554644159770 X-GMAIL-MSGID: 1790731554644159770 |
Series |
Memory allocation profiling
|
|
Commit Message
Suren Baghdasaryan
Feb. 12, 2024, 9:39 p.m. UTC
From: Kent Overstreet <kent.overstreet@linux.dev> To store codetag for every per-cpu allocation, a codetag reference is embedded into pcpuobj_ext when CONFIG_MEM_ALLOC_PROFILING=y. Hooks to use the newly introduced codetag are added. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev> Signed-off-by: Suren Baghdasaryan <surenb@google.com> --- mm/percpu-internal.h | 11 +++++++++-- mm/percpu.c | 26 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-)
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..578531ea1f43 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_noalloc(&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