From patchwork Mon May 1 16:54:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13227658 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 3E8B7C77B73 for ; Mon, 1 May 2023 16:56:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF55F90001B; Mon, 1 May 2023 12:56:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CCD35900002; Mon, 1 May 2023 12:56:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B6F3190001B; Mon, 1 May 2023 12:56:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A264C900002 for ; Mon, 1 May 2023 12:56:03 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 737FF407F4 for ; Mon, 1 May 2023 16:56:03 +0000 (UTC) X-FDA: 80742288606.21.0C4CFC9 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf18.hostedemail.com (Postfix) with ESMTP id 8773A1C0019 for ; Mon, 1 May 2023 16:56:01 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b="Nr4QXyj/"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf18.hostedemail.com: domain of 3IO9PZAYKCGcXZWJSGLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3IO9PZAYKCGcXZWJSGLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682960161; 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=3JQAU/dBFDp2j3prOKpx9pu61B2aRzHMn5ijo1mj0wk=; b=xnJfbWRI6fcJVX6NFpBG1o9nLGNBtGVNuaGqHoyfcXutfXBewrWRht9B//w6VFyMNd569Y mlu5Pp1+6TIkjavEoIHwMTToJ9SmXDbf+UMQIknFrpQwPgcwPNT73J8NAtvq7ehNWTT4uH yhS88Vx/AJIckfA2CD7i3mZjdRKLuRo= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b="Nr4QXyj/"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf18.hostedemail.com: domain of 3IO9PZAYKCGcXZWJSGLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3IO9PZAYKCGcXZWJSGLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682960161; a=rsa-sha256; cv=none; b=Y6/HSoXWJa9CKg5bT0u0Rdonsmd14EawxlhUQXta5vVqDUH56M07kCMswJ4k3C3gLD8qSM I+wWd/74gymiBel7144HD/n24nz/8+30JVzFesDkF5g+31XZ8xvknsANy8DONZjbbiqztb 2E5eA1lfHkbQLLGdDdaAkzAVU7Gbqgc= Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-b9a7df507c5so5361612276.1 for ; Mon, 01 May 2023 09:56:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682960160; x=1685552160; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=3JQAU/dBFDp2j3prOKpx9pu61B2aRzHMn5ijo1mj0wk=; b=Nr4QXyj/etzJlAh8i4e3XnDFrHrok+4KAhChzrGdGYpNpzqnTzNz+b7TDzIFPvjVWJ 9m6bX+drGU9A6fH4AYp0HUvbrb0fCoSPBmCg7BeIb7knPz8EfEfG9cPbzcBJ5VX+RXOe xKxhA1OiVlh84AEwzHBh+cMUHvzUPF37NpWH9RACZgYBnn9nhrwQ+ZtD6LOD5aF3vQAg h9QGbAMavYpJls9fxf3kDm4J6+Qn0mT0BuRWWAvY6omxOHY3anv02SbqbukFuexGdvmI uLtak6s/1IGom0RtuY8qFrrhQXG4Ym0F7I61Qiqk5+0EJAXYPW/dDKZJd/GArGchifG6 ytrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682960160; x=1685552160; 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=3JQAU/dBFDp2j3prOKpx9pu61B2aRzHMn5ijo1mj0wk=; b=OEGxXtcp2jwemJTVElZgbV47CLDGo8y6xs53IU/rORB706YqIf4uWK+T53pM7WCUCU UQ6ppiiddmOTa5c6AgEhTu1U+7DrVZuMG3OHUiLwONgNVDWbSsWlriWIiXCLzQxHrm66 qOWdvoSCZIinxaNEBqRvpU2cyD6cFXztPltIaMPz0enb382Pbgu08eGSpj2cQ+nEc4C8 pZrO8AKWwzkRyzBVeaR+4P1H5+uJ4o0UpPqY44dwQQByB/HxFUzTT4UWKHnZC5gfhViK Wq8IrPXU3J5kBQSAUZptXc4CQG8QnpfUBS72gCi6XUmoN1BrheeL040KsudUbsDNcHlE AUNg== X-Gm-Message-State: AC+VfDz1EMYUKN0KaOcWQHEHZaNpCC6xaGepNkgrBZ4NRc5grwqN2FEP do24meB56PEAfqmKrcyI3RPA3k132eg= X-Google-Smtp-Source: ACHHUZ5flxShenE/t9NPL/moLDuNx9TkwM/Lf/8wW54V2Eq3VJ/wRhfgfjc0frmw2aZZoQxo3iYMAN5xHBU= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:6d24:3efd:facc:7ac4]) (user=surenb job=sendgmr) by 2002:a25:2484:0:b0:b95:e649:34b6 with SMTP id k126-20020a252484000000b00b95e64934b6mr8454589ybk.1.1682960160542; Mon, 01 May 2023 09:56:00 -0700 (PDT) Date: Mon, 1 May 2023 09:54:33 -0700 In-Reply-To: <20230501165450.15352-1-surenb@google.com> Mime-Version: 1.0 References: <20230501165450.15352-1-surenb@google.com> X-Mailer: git-send-email 2.40.1.495.gc816e09b53d-goog Message-ID: <20230501165450.15352-24-surenb@google.com> Subject: [PATCH 23/40] lib: add codetag reference into slabobj_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, 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-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 8773A1C0019 X-Stat-Signature: utr9to1zc9onm8o7nccgo1pf53tybst4 X-HE-Tag: 1682960161-625313 X-HE-Meta: U2FsdGVkX18Almyy9NwDE73D9ur4vDg3ZwZkq1csaxT2BSv9j7/rd3Sf+wFNwcFZuFsyIDY8ud+qqYJL4oiOf0rNrdyrMiJ1Jxvstj9Op/3ard66a924GXwqc3a5xRZdzRS719XRnBYyid/qeu2IdNiEjKQ2F+s1KB2gbR4UlANFfOzNuMJFicsPJWwJVqxgpND2eQ+HKzBs5Ixsl1OwEZZ0wSHot/MK5aAKGVD+0MydgoS9XCfeBXxMyzjMlHDqyMoS53d4B3s+YoiokCf8gjegslwRKIym70ziywPM2T0Kwh2E9VvmZOBxuXC96qlxRgAOCxBu3cXiqJY2ZGtts5NVPikRlivTmlpAwOnLUsoBtJ+ql2Mlmn4JEjRYdDqvwMV76HrYh6+CzWyNI1b2e+Extv9DA6BVoNQUkpBZNKM2a06wWVU//uUEYSuELJW+12otDTz6K/Te2GGpYY/zGZonJvox8m6LG/9KQ126eGTpS1O0h7w37pZGfgYB/6BXbCs39uWyo96e65SYr0oSR3qhhSZQBTyOkkmnbgxJztB6luLijCgrdskshOC3BlrqL8Phlb8kF2m1vss6pJkhOcawqXY/Ky7EKAMMiF+6q43aAGpoVrnzP2EuYLIZaqEkNE0zpTFOdZMS1Pk+rV7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icity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: To store code tag for every slab object, a codetag reference is embedded into slabobj_ext when CONFIG_MEM_ALLOC_PROFILING=y. Signed-off-by: Suren Baghdasaryan Co-developed-by: Kent Overstreet Signed-off-by: Kent Overstreet --- include/linux/memcontrol.h | 5 +++++ lib/Kconfig.debug | 1 + mm/slab.h | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 5e2da63c525f..c7f21b15b540 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1626,7 +1626,12 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order, * if MEMCG_DATA_OBJEXTS is set. */ struct slabobj_ext { +#ifdef CONFIG_MEMCG_KMEM struct obj_cgroup *objcg; +#endif +#ifdef CONFIG_MEM_ALLOC_PROFILING + union codetag_ref ref; +#endif } __aligned(8); static inline void __inc_lruvec_kmem_state(void *p, enum node_stat_item idx) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index d3aa5ee0bf0d..4157c2251b07 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -968,6 +968,7 @@ config MEM_ALLOC_PROFILING select CODE_TAGGING select LAZY_PERCPU_COUNTER select PAGE_EXTENSION + select SLAB_OBJ_EXT help Track allocation source code and record total allocation size initiated at that code location. The mechanism can be used to track diff --git a/mm/slab.h b/mm/slab.h index bec202bdcfb8..f953e7c81e98 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -418,6 +418,10 @@ int alloc_slab_obj_exts(struct slab *slab, struct kmem_cache *s, static inline bool need_slab_obj_ext(void) { +#ifdef CONFIG_MEM_ALLOC_PROFILING + if (mem_alloc_profiling_enabled()) + return true; +#endif /* * CONFIG_MEMCG_KMEM creates vector of obj_cgroup objects conditionally * inside memcg_slab_post_alloc_hook. No other users for now.