Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5734234rwr; Mon, 1 May 2023 09:59:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6P5kpB737oapkyYktFcRmUtjoh6WZM9eYyAXXJrvnWh0gtSI69h10/WeVM2DRDhLjdtqvF X-Received: by 2002:a17:90b:4a90:b0:24d:fb8c:5ab3 with SMTP id lp16-20020a17090b4a9000b0024dfb8c5ab3mr4485726pjb.24.1682960371838; Mon, 01 May 2023 09:59:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682960371; cv=none; d=google.com; s=arc-20160816; b=GBxSWsX60nwkb/7SWix4lST+fQfLC3EQioX4/cqWzLsQUh5b9NvmTv0vRJsf0c7ISr 5gFpPEOrBfX+rYTBaLhhqiVmWJ+ksHNR+gFvxzza1+2LRgzO0DSbFPJccQg7arZ23yG7 JAxMSAoO6Dja0Ncqui/k5vTdxcdRR6Fm/0qQcxir7jjSejjQSxA6qeWdWRanub/D4aHt ppLcE52Z4RPYBm1XfE3UCZ809ssNUXJA+02yTMe6VUwXZP81jlipI//Zp/cKLU+HLAv6 s7Z+RRJZMvw4BTVU3beOORVYmw4RkDnB0s2Nl0hxNGBIZsqWEGw5HhxYXXJiLfY4EaMI MG+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=3JQAU/dBFDp2j3prOKpx9pu61B2aRzHMn5ijo1mj0wk=; b=cjJ17eUSvVHSJIIONH8LfHS6vt8G5UGnwjxU7t8NkyGGxJiEDvkWo1V48wtK6jhfGM yMrSy0n3joam5bJRfpwxp2fONTIbryyk91VYL+b2OhJjl128/6LKN3u9eTWBxSoc7roE 4JduZaE+G+mcDF3cGcri3AvlKn3amwwdIc0/b6/Q1bsiYDN3GjWAyzdJHq6+7BHT0TVD aNK/K2FRs1Y1XLyaT77eKc5iD9Oh26/lF0ORPZDCnF8JHInX3/mccajKVa3xVus6Flp4 Y9BMsNDu9SFmWtsfc97vAJe10OQ8WEfiOhgZds1caxgJuD/PMEp7PUD0DVpfoK6cxwyu xKdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="Nr4QXyj/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ng6-20020a17090b1a8600b00244b2aad680si10108856pjb.63.2023.05.01.09.59.18; Mon, 01 May 2023 09:59:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="Nr4QXyj/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232946AbjEAQ7A (ORCPT + 99 others); Mon, 1 May 2023 12:59:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232356AbjEAQ5q (ORCPT ); Mon, 1 May 2023 12:57:46 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E73A2D46 for ; Mon, 1 May 2023 09:56:01 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-b9a7df507c5so5361614276.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=Sc1mQ2ck5OfdtWZfgXIirNbAn2BKmbCnL2LoM92sIaHi34kkNt5TRJNlkk3lpLgkoV ytO3lanyFH4YC+ZdM7SA5Q4yTjvSxliSGJGu2+TBtZuSfv9fjtqaUrwgxCLKYxEZPVKX eG9hQTQ25hrMa4MdX3T7OVlHYoa7pHVZBCMjNIokPTYn3gEfYYQ0XuzNIVt5Y4eLpWVC eGGucfLeOXmVetl6H7/YGTjLRY1L8DidkZz6vzD6Dt/7OcGWvb/bYE1WH6vqUeDNEEaq rCWFellHN+6da9xREqueffsvDI23MTdWyEzdLmPOEuDjTJvXN96x3GIRL/CL8OZ/T/QL YbMw== X-Gm-Message-State: AC+VfDyqT4mCfxV4BBzSfKIZeFcgvW+W3YDeWuGpqk7aQ/8ZYPLWNczZ Ll8ofhcqN9WFM7CEPFZKhY/8ttuK8hs= 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. -- 2.40.1.495.gc816e09b53d-goog