From patchwork Mon Feb 12 21:39:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13554056 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 8D6AAC4829F for ; Mon, 12 Feb 2024 21:40:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4927D6B009E; Mon, 12 Feb 2024 16:40:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 441646B009F; Mon, 12 Feb 2024 16:40:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BBB36B00A0; Mon, 12 Feb 2024 16:40:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 176746B009E for ; Mon, 12 Feb 2024 16:40:15 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id DD7F514049B for ; Mon, 12 Feb 2024 21:40:14 +0000 (UTC) X-FDA: 81784470348.10.95AAC20 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf22.hostedemail.com (Postfix) with ESMTP id 0E533C0002 for ; Mon, 12 Feb 2024 21:40:12 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ZLqfeUN+; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of 3PJDKZQYKCLstvsfochpphmf.dpnmjovy-nnlwbdl.psh@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3PJDKZQYKCLstvsfochpphmf.dpnmjovy-nnlwbdl.psh@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707774013; 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=ZrBz9DyywfwO606ZQMwpTbc2aylPEGoXqCQTswmuPUY=; b=nyr3ig6JHQgPNQNAt4s+iEI1Ug5/SXmFbufUHoe+hHjVyDGSkhHQEkLUmgUqfEKeQkqVDu DuVhh44c5dCQiCOsZ4lUEbJmEOZfR506k2FdQfYo92JmEpAcxDSs77VHnzkA/AS2JZhP8b 6O67RYLGYKtzlENhHcrGYs4WDmDdBRU= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ZLqfeUN+; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of 3PJDKZQYKCLstvsfochpphmf.dpnmjovy-nnlwbdl.psh@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3PJDKZQYKCLstvsfochpphmf.dpnmjovy-nnlwbdl.psh@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707774013; a=rsa-sha256; cv=none; b=W3LLdf+T3g+vFPeQwb35lN0nark+VAaRBS41NMsdS4b8rBgV8UluFkBugagEH8M7QoEMAw G8uRG48+0lPRsFDwTD6chLGjGw9uhCpOEfwkonml4tDsqXi3LHexB25vqr0jwcyNAJ26to 8G+w9o66Jp7XoH6F42xbf+PVSpZ0X6I= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-607838c0800so506607b3.1 for ; Mon, 12 Feb 2024 13:40:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707774012; x=1708378812; 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=ZrBz9DyywfwO606ZQMwpTbc2aylPEGoXqCQTswmuPUY=; b=ZLqfeUN+61Tkgsnk2Qp6vAWWz3+kANGaLkdOPkMMXgVWWADqWaCbtTx8X51NEe3Sje bhxL4sU3ycF/OWWDRE0eeKvmR0KFMKOwjyGT/YTDjuzkxe8Ssg5Eirt7SQHoqv01FKDH GKoFOruA2GnOSd1yPLo4DRboyQYXpLT98rSbOBQ5GZQZfUjkilS4e3Mi0UAjLtb0h468 at+lWYdzcADRjbzjEwqrAULDUb3NFCIl8CXh4YpLbmdzj7RICB2tFGu2LBqa1uqyu1bl nay7s2JZFz/A1Y/vYwbvMhlhQCbPAMTcPc9XDTN+B9pKbgNOR01XpqfTGw9czB+/jAvf 8QwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707774012; x=1708378812; 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=ZrBz9DyywfwO606ZQMwpTbc2aylPEGoXqCQTswmuPUY=; b=mTWdziUrZCXKNiOjE/ZTBEjggI5Vzpq/ULMYzweW/yV25DqgVJsTDGKDNg4rn/VrgZ Hk4twxNDkrsDfFxTQc0g0RzEEZ9FS7LzmSjLk1pCVLCZlV8w5bYgS6Zq7vHyZQCitDTf vhbasdeYXIzvy1qX0cpC0iSWrtoHXcEC792Z1BZQq5zeCpRNBcpACOY8UfgFMIijzzXm jLJxsvoI3UCKuLgkyNWYEfLnSocxMBhejOCFocG3CBsSdn3zdQE0JfKCRiFpPuMlYWZC uv4AviwSldUCxomu9IIIPlsbsyLBD7Ropl9S35MMdo15pMopkHDba6N/Ew3rOInyLHHu 92Lg== X-Forwarded-Encrypted: i=1; AJvYcCV8gnCmdVxq0Rfhf9ITLwC8AzLZRPbkfyWOmU6xdMMHcfAXkgUOA90Pi9Vlz40bKXSN+yqj/Sxq8dPZfsvPmxN4m3E= X-Gm-Message-State: AOJu0Yw0Ct9Rl1NwG9mmdtty+Ze2+SUIoLsjzpMWBG1V/UnhGtBKQ12j o2UqNi8A48wV2PL0U/XsQPqED+q8xR32stf7E4pkrw1/6cJ1j9CyIsQA6pVAdAflab8R8/Ocfqx UwA== X-Google-Smtp-Source: AGHT+IGdELNRz/U7g++PhfoEsyUKyEa0DYZtdFbwbl9fcNHM0h9+fVLMKP8bhlCRwXrMrONYMoTWo6orz2A= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:b848:2b3f:be49:9cbc]) (user=surenb job=sendgmr) by 2002:a25:ad02:0:b0:dcc:2267:796e with SMTP id y2-20020a25ad02000000b00dcc2267796emr133364ybi.2.1707774012029; Mon, 12 Feb 2024 13:40:12 -0800 (PST) Date: Mon, 12 Feb 2024 13:39:04 -0800 In-Reply-To: <20240212213922.783301-1-surenb@google.com> 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-19-surenb@google.com> Subject: [PATCH v3 18/35] mm: create new codetag references during page splitting 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, 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-Server: rspam09 X-Rspamd-Queue-Id: 0E533C0002 X-Stat-Signature: aodsj931emju1ket3ckjogeur7f8raaq X-Rspam-User: X-HE-Tag: 1707774012-679066 X-HE-Meta: U2FsdGVkX18xpHRMC3NQ6HD/owebveaM/ffhkxPz6vtYOVHX0nJimHDWaEg7miWvDfHbwGMb0h4uOzmXCScU3l8071i3HhmJtC2btkXW8FewfK95W28Sso1abeoIEWtvcXLByS2HSUEYpGXGsyb6HSYX1IhpWvw3GCa7cTDc+pD1yolY1vi9TMnay0Q5qPUsFRwW/jtrp75CJ/oXUQPkOxjmQawq3hTUy1GUx571ROjk5gZEyD6SjGocSLxHf2fYVPhajSMBrWqSl7Dby6OC/wA/ZwKzoLBlidwgsWtq4NVrCj3z1B34OP2nCfTdZpxqI/zg95KkCwHAXLv9v2AuaIqL6Q/pYMlWAN/oAxz8Z/Y7fgHT9ywQTAOKcISnl0BujNKBrA+mhEkMnu2ml0Wy4LXBVBMBe2Cpv0U+VT20u2EihBs7BkumGRhH726Sykyt7e8F53V/Ollgc5Aqno/c3hJahDh1clS00+imic6lR8IyRDs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vhf2UubjO077E7aWyyzGVJIWbnebIezoC0Kk/XmqdkdPCbWGP3IqTS6sReZ7dqd8pdU1Ns1gIGdKObDVnUKFpTvZocP6pgx6/YTPaCcS40Zdg= 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: When a high-order page is split into smaller ones, each newly split page should get its codetag. The original codetag is reused for these pages but it's recorded as 0-byte allocation because original codetag already accounts for the original high-order allocated page. Signed-off-by: Suren Baghdasaryan --- include/linux/pgalloc_tag.h | 30 ++++++++++++++++++++++++++++++ mm/huge_memory.c | 2 ++ mm/page_alloc.c | 2 ++ 3 files changed, 34 insertions(+) diff --git a/include/linux/pgalloc_tag.h b/include/linux/pgalloc_tag.h index a060c26eb449..0174aff5e871 100644 --- a/include/linux/pgalloc_tag.h +++ b/include/linux/pgalloc_tag.h @@ -62,11 +62,41 @@ static inline void pgalloc_tag_sub(struct page *page, unsigned int order) } } +static inline void pgalloc_tag_split(struct page *page, unsigned int nr) +{ + int i; + struct page_ext *page_ext; + union codetag_ref *ref; + struct alloc_tag *tag; + + if (!mem_alloc_profiling_enabled()) + return; + + page_ext = page_ext_get(page); + if (unlikely(!page_ext)) + return; + + ref = codetag_ref_from_page_ext(page_ext); + if (!ref->ct) + goto out; + + tag = ct_to_alloc_tag(ref->ct); + page_ext = page_ext_next(page_ext); + for (i = 1; i < nr; i++) { + /* New reference with 0 bytes accounted */ + alloc_tag_add(codetag_ref_from_page_ext(page_ext), tag, 0); + page_ext = page_ext_next(page_ext); + } +out: + page_ext_put(page_ext); +} + #else /* CONFIG_MEM_ALLOC_PROFILING */ static inline void pgalloc_tag_add(struct page *page, struct task_struct *task, unsigned int order) {} static inline void pgalloc_tag_sub(struct page *page, unsigned int order) {} +static inline void pgalloc_tag_split(struct page *page, unsigned int nr) {} #endif /* CONFIG_MEM_ALLOC_PROFILING */ diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 94c958f7ebb5..86daae671319 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -2899,6 +2900,7 @@ static void __split_huge_page(struct page *page, struct list_head *list, /* Caller disabled irqs, so they are still disabled here */ split_page_owner(head, nr); + pgalloc_tag_split(head, nr); /* See comment in __split_huge_page_tail() */ if (PageAnon(head)) { diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 58c0e8b948a4..4bc5b4720fee 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2621,6 +2621,7 @@ void split_page(struct page *page, unsigned int order) for (i = 1; i < (1 << order); i++) set_page_refcounted(page + i); split_page_owner(page, 1 << order); + pgalloc_tag_split(page, 1 << order); split_page_memcg(page, 1 << order); } EXPORT_SYMBOL_GPL(split_page); @@ -4806,6 +4807,7 @@ static void *make_alloc_exact(unsigned long addr, unsigned int order, struct page *last = page + nr; split_page_owner(page, 1 << order); + pgalloc_tag_split(page, 1 << order); split_page_memcg(page, 1 << order); while (page < --last) set_page_refcounted(last);