From patchwork Tue Oct 24 13:46:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13434599 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 92C0BC00A8F for ; Tue, 24 Oct 2023 13:48:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B94636B028D; Tue, 24 Oct 2023 09:47:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B1C4C6B028E; Tue, 24 Oct 2023 09:47:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F9166B028F; Tue, 24 Oct 2023 09:47:51 -0400 (EDT) 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 76E016B028D for ; Tue, 24 Oct 2023 09:47:51 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 4A5671A09F7 for ; Tue, 24 Oct 2023 13:47:51 +0000 (UTC) X-FDA: 81380483142.02.F2339C1 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf06.hostedemail.com (Postfix) with ESMTP id 6EA14180028 for ; Tue, 24 Oct 2023 13:47:49 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=v1icPGNx; spf=pass (imf06.hostedemail.com: domain of 3BMs3ZQYKCKkbdaNWKPXXPUN.LXVURWdg-VVTeJLT.XaP@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3BMs3ZQYKCKkbdaNWKPXXPUN.LXVURWdg-VVTeJLT.XaP@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=1698155269; 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=HuI3Xrhprruhc52//OZX/xia3QtNu4igKL3qfHIbn+g=; b=vY2JAMA9lTW2eyd7Bw0M5bSzEnHxjhhNa5UL+daLRRIIMPr7O1wlZXz4taEG49fYGBX0qF PmvbDDOr72ERmLaxIjoCva05W9xM70cDn7pVgtmOF/QMkwWdQIJPJLnDrE8reqYo8lWvCZ Vaq4D4h5rcEcksGkNdvOaRiEHpeH2Oc= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=v1icPGNx; spf=pass (imf06.hostedemail.com: domain of 3BMs3ZQYKCKkbdaNWKPXXPUN.LXVURWdg-VVTeJLT.XaP@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3BMs3ZQYKCKkbdaNWKPXXPUN.LXVURWdg-VVTeJLT.XaP@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698155269; a=rsa-sha256; cv=none; b=au0IR89pRTxYK6ncoEe6PXKKKihMBiw255xFX5P+2jHGbnSsyctn2mg3ESV0gqLd9RV6N0 GlEfyirj0FOMg2Bm8RUOsrw/bG3+rAolWYEa+tFPw8ew7apObiZsq15RVaz6/d6n7hER8Y HYFdlS+nJg/7uR5VRH2KmwAaGFNu6XE= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-d9c4ae201e0so4420772276.1 for ; Tue, 24 Oct 2023 06:47:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698155268; x=1698760068; 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=HuI3Xrhprruhc52//OZX/xia3QtNu4igKL3qfHIbn+g=; b=v1icPGNxHbMXo9cu+X/4Tn8gVdflX2Vv8lkPSoi7zingS7MKNcCu4kkUVJXk3J/PN4 MU776ujMYzcJelm6clFiRw1BBIHQg204op27apwqKhKKzjr68twvFZUbr1vtS6YqWvhi Vuor9L5Y3AgQ4Zzztz/o2foviT5+QSUG9K00MpZFne8+T4YdsBTOQCPgA4/HEUeqWwks kv5gxG+u8xyGwOuP+hIsxKgut1B8/GKh4osnrIdWG6oPGSFuMXiQge2AYkzH/e9Am0as VKl6UDCtmj5JbEVp3S9iq4aDZMQNvmPSpcc3tnqrafXGOYadT7U6aocJu9yegH4wqbYv +wyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698155268; x=1698760068; 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=HuI3Xrhprruhc52//OZX/xia3QtNu4igKL3qfHIbn+g=; b=pM+PUpcUcIMXTfX8CqG00WsSTrv3417WPrfduOUGD67buHgwAQk0gKpsnaf/pZaE0v HQJdCfaXsSrrfdJa+Yh/bnJ9F0miXCn933vG4CIHNNggqxYhAr1c2QHsiDCyuSgAJv5e gC1kLtM3Y8YjBnCTL0JdBeglmUnKiT4rqkw4K150X4KTFB9koSVcrXeQBNwWlZh4oIdY 4OFUsss3ZG6ceEGaepZlztzPBYiiTSFGRDlzIz8+5UEodHMu/WAHopfE3IhCY4UDUUnr Es96uONfyZ1miWvEwAiDZBzlhPew5sj3Iq/SnIWHE7knIFH+6w2xcAl4jH1FMYFG2ZdC +Gow== X-Gm-Message-State: AOJu0YyF4l2Izuv6HJyhbhFnwtHCpE4SReQ5KG/p5T3MvztcRc+B30tD cBrM/R7DxWfk21tLdjApMfJej6qX6Pc= X-Google-Smtp-Source: AGHT+IFJAKlMWbiV50/LrVqB8mrnoydVscOxG9uaLGUhxnV+JO976d9OMlZUiNtdsluAhIYZmngChgUkEcg= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:45ba:3318:d7a5:336a]) (user=surenb job=sendgmr) by 2002:a25:ad41:0:b0:da0:6216:7990 with SMTP id l1-20020a25ad41000000b00da062167990mr3869ybe.3.1698155268465; Tue, 24 Oct 2023 06:47:48 -0700 (PDT) Date: Tue, 24 Oct 2023 06:46:27 -0700 In-Reply-To: <20231024134637.3120277-1-surenb@google.com> Mime-Version: 1.0 References: <20231024134637.3120277-1-surenb@google.com> X-Mailer: git-send-email 2.42.0.758.gaed0368e0e-goog Message-ID: <20231024134637.3120277-31-surenb@google.com> Subject: [PATCH v2 30/39] mm: percpu: Add codetag reference into pcpuobj_ext From: Suren Baghdasaryan 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, ldufour@linux.ibm.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 X-Rspamd-Queue-Id: 6EA14180028 X-Rspam-User: X-Stat-Signature: 45rgob565jwarnw67kt6gqumedtewu3q X-Rspamd-Server: rspam01 X-HE-Tag: 1698155269-471574 X-HE-Meta: U2FsdGVkX1/oXJl53zE9+T/Wi6Ypp8uUeicqmCVaHrFV+fZ5ysMuoyM2Zx2lSfkSmY3xB3kyNBxZW75PObBIkIMaVC9cuNvR4DgL9sIJyZDH3Idbv9sCis4wjW+92P5ksrTzjs22Yd2yOWkeBGCTkrHtx1irmECGHJoQU/I54aIE/VSL6NNOTKYFWKGocm0YeumNYb24eGx6VS7mHZqPqLEqsDW7JW6uc4h8ho0tKiF85Ua7IdSQjA5VB4osyodQipg8v8xTROnVLjQH7DNQQOveEQAOsuLJeG+YPIIaQTamg3+7x073+BNAftrJ3hQo9DvVRmXA7w5l6tAuS60YaEwwcc3TZvY02v4TRIIUX3GVoR9z0Fdr6xHrqk3Flt4sojBMRY96aruOMajmKjqsOUl5spZoREyPd7nqFt270wCfC33cl7w1kOm1/us3aTce+KMfP6zoYVVsQqX+oaxNx5zYDVzBa+029NLTtG2H+HBsrlUL9tfvenooZ9H9XocJf7Fm48MQ7mF8WlQZVrpHkctYYi9RN7fdTDLJg6qgqFzO0tId328L4rcWjbQh79rVNrBNYha9Iaik3T2MpB1hpW4L7GvqkctV8XDmkJAGUpoVh3zh9biZfj1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Or4Iv9KWFPYzQ== 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: From: Kent Overstreet 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 Signed-off-by: Suren Baghdasaryan --- 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 5a6202acffa3..002ee5d38fd5 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -1701,6 +1701,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