From patchwork Wed Feb 21 19:40:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13566199 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 E96FEC5478B for ; Wed, 21 Feb 2024 19:41:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F1786B00AC; Wed, 21 Feb 2024 14:41:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 486156B00AD; Wed, 21 Feb 2024 14:41:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F4B96B00AE; Wed, 21 Feb 2024 14:41:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0ECE56B00AC for ; Wed, 21 Feb 2024 14:41:41 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EAB24A0A75 for ; Wed, 21 Feb 2024 19:41:40 +0000 (UTC) X-FDA: 81816830760.15.A9E60C8 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf08.hostedemail.com (Postfix) with ESMTP id 53C8D16000D for ; Wed, 21 Feb 2024 19:41:39 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=YV0S4Y3C; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf08.hostedemail.com: domain of 38lHWZQYKCCUTVSFOCHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=38lHWZQYKCCUTVSFOCHPPHMF.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=1708544499; 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=1hWNqJFIgMmzuIRMCt7lzLBdngxXaEaZ9g59MUlptRo=; b=l1x3zBBRRIr3sdjN7enzVa2Bu7ehLuYHIRDBuaiY7AtrHRlNbNxy+dBoYAdy1dtVJSZGfy dy5TKBh9FRNmHHLEvOsEyKo/15s5RqFa/Sc3MX2URMxH+yDxJcBr2kjA2iJ6/CPUk833v5 mP5VCtXsgYVHHVE3HEOPjwYtFJY4v9I= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=YV0S4Y3C; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf08.hostedemail.com: domain of 38lHWZQYKCCUTVSFOCHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=38lHWZQYKCCUTVSFOCHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708544499; a=rsa-sha256; cv=none; b=EF8uga2sZwmxCH79J3u/AHvRBaHj7b5Qw4k1lWq5hfFWJsFYeAL6revZHMGWsO6sD3GcKj HWPm0IWNlOEjqEPVas6FFWo5oUo+23s/4LEWmt1964jipHy0WVvdbrl+x39of7+ozpeMeC R6TGZtJdaYBsKeI8E58lH/5ntxQ+A8c= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dcbfe1a42a4so2066395276.2 for ; Wed, 21 Feb 2024 11:41:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708544498; x=1709149298; 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=1hWNqJFIgMmzuIRMCt7lzLBdngxXaEaZ9g59MUlptRo=; b=YV0S4Y3ChLDi6BCj/aUsvVGctFuKt2+jJYqGdSvPtE6xhZwyqvyG5Z8djNdMprnTrm UH8apNV+oiGQl9LlUd73potiTDtuFHGUl3f4UT/mBUjHd9CVChUuo0sNy7oOlPjRX5q8 pe/gJsHVOKV38ApcHCQ3+JWR2fjZBMhLx7OI9GmoMJsuauuX2PfFSipMQvdwkI3Yd4qj Oi38skxo1CwXI3VF5Qsua2CBBDeC0KJVropZJ1xao4gH3awSg8pmpUzrbla38v0eh5it p4P23JpalBdQTTqkJ3y4seOxHpN9eQtKCxvwjE6PeAqk5r3Gp/QLD5+HgmVU/lpWNkrw QkEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708544498; x=1709149298; 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=1hWNqJFIgMmzuIRMCt7lzLBdngxXaEaZ9g59MUlptRo=; b=quWcQE+48tMMjoAMAflJ1qKYeV+46goqhkwAWY9lnTYOuSAXTN2XsfJJhnD14y79q8 fq8QNcqwrJnCaNo/2RsycuwJA6cb8mH3KMXuPnplahfTgv48lBkdkPZi9c80F7Q+khlE zkrbzTGEwergNQNlk8f0YGZGpljszpnlMd0m6uUp/1bF/AGFIFoz29nuo5VVNDoygbDp wefDPtYqgas8wL6OiTsUXod56qCuXI57OpqYQg2OMDK8/CpPxLg6T83mt3ZFs46Jvu09 3Uw5qGvVG/fKn695cQMkAExqeJpqztuc/YPpi7OutObn+9vNbqkR7R5zi38j1wmyKxt1 S/nQ== X-Forwarded-Encrypted: i=1; AJvYcCUD48LvnZjvne6BmmQ1Um5oYp1OKweLHWsWFWBPycAIDV9qJIg+f45c6fMt2bPncxyFqWct7bVxgfLjNBqBYp/Gvyw= X-Gm-Message-State: AOJu0Yzj4uYzMu8k4us9dblzPnoGSBmwWvfNjiiTPgQA1dG7e4qDIpkh k4muPMdLy0X/IbvQnYA7u5EuSLxij20aU8JTs+YPf5Nk3ZjVrGiTibjNyKJ49/XnB65W0Dju7MX NOw== X-Google-Smtp-Source: AGHT+IF+lk/FYOD/Yxg3sPkq6eArvA9PdzVkhKYXiOVnRPx3H40+bQfIfbP0HZr0UMzCJhoN0p6KojopSmw= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:953b:9a4e:1e10:3f07]) (user=surenb job=sendgmr) by 2002:a05:6902:18d6:b0:dc6:dfc6:4207 with SMTP id ck22-20020a05690218d600b00dc6dfc64207mr68537ybb.10.1708544498016; Wed, 21 Feb 2024 11:41:38 -0800 (PST) Date: Wed, 21 Feb 2024 11:40:32 -0800 In-Reply-To: <20240221194052.927623-1-surenb@google.com> Mime-Version: 1.0 References: <20240221194052.927623-1-surenb@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240221194052.927623-20-surenb@google.com> Subject: [PATCH v4 19/36] 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, penguin-kernel@i-love.sakura.ne.jp, 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-Queue-Id: 53C8D16000D X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: fr8g6o1fqr1bq615e37t468uxqeke7ja X-HE-Tag: 1708544499-584360 X-HE-Meta: U2FsdGVkX1+wmtk98O9/oqOLivJGOKEUeX+GeSkCmhcHxUzR6QnegUttreg0A9g2CJoO9CvR/5iiyNotg9tgwAkM/N0mMHgsTndEUIbeVVtmZP8KOzkjDhgZkNDsVgGUDnf7E51o8CtMm298KI1+vHFt5y74dT88I+cqxJlj6g+YyNQ12q+qGZHFKOolnHwFq27tF8Goe/qYR9l07AULbpqBBQUaehnO4mZYo4jJgQfTppi8IYq3wa74zHOapWhobotWZA3YsFU2LRDSrpuHYUxHMG9wG04xcovuzH2ckGtLDtXjrOyFThCTnjk5ar3+/hAqsR+grZhSTI/Ekc1XtOZGk6g6cOI24m1SIfWxLQrGaGajwLlztAv+JWHSWtsqcg9+Pcr8RLUu7GAgc5R6oUasvodvJLNmDSIF5VW7RsKCxFR2Q39keYyVB5vzvn4vk+nqdUZZYTvZc3KAwkc0BcX0YNI17Hnu8f7qZB7GstZSK6XZUzNItpb9a34DO9SMDbt4NrdHep3Z4snaPUNPXmD0eY96fHkq1ifPOglE0+ZW1nMhchX0RIAi2eVjelxXmxNoZF3i9ok1VNQ1EZ5ZRxlani3RFctPNcdi3fMzpk4bxedxKqWqEoM1rtNQReLkfg8vhUlruDqOv5+LhJu3E/ojQXqu/xc/act4jZdJ7ps2KwUrE6ufxHlanbdR3sLV6EZGa8GBn7OOR3WydITLsuj8xK8/uW64FECrEp5J/3riq0MmI1VlXYJDTOrI0UKvxID8YghPsJZNcjYx7lKWRpM6HAUlhZ11LoknbaNmKUDuNZLwNNif0sKPfK+J4fHTacQ3k2gONf2jZHWg/CGlFUoXT+f1/Hj7mlKn2oXiqAig4vtmHNOIR+jMY1qpVVSmJdLw+VWGlyUlXzsRrvXaOdpw6BABL+4t5n2ttUGx4KWaDVT1YMzT/hmX18008ZQAQKASidyYuJbQhASKUOG JVkB1lwf goIcD385rzoMNpY6ZjXM1E/j4CgqyxIpPF/9DHVj/yvzYs6svSFte/uaLoFMzZNlgYcQeCxzI2aOCPRSY2pXaVM/m+PatLYBEyEAFY4Hl4kOjNQtSJOX30yZpuIzA/0kPyPbeqyXre1eZA8/KjabQzxP3mj7wJELnpIp2JbO73LvNIhlRJFCJG0lnMU9aO2UJ5megY2qY1AQ9TiKEVIowQObNkZ/wM4MFkQsPeD4lj+QO13gmWS4tWJaX/OsVlQBnxapifDHlZMzoobZJgKtmZ3lcIO46g5JkV5NKbJufwtXbwT0WGAzvTWSm+T1tlFwKc7HjicQBW2N9ELA3mvKPpq4qs2Fig0HMbWXfZYIN3iA2VZnToM6PIKhgX1/fUp2rp38TcpuerDG4pHl6msdLs3Uj+qcbUwFiMUiQNFSo8FKM/ns= 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 Reviewed-by: Vlastimil Babka --- 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 b49ab955300f..9e6ad8e0e4aa 100644 --- a/include/linux/pgalloc_tag.h +++ b/include/linux/pgalloc_tag.h @@ -67,11 +67,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++) { + /* Set new reference to point to the original tag */ + alloc_tag_ref_set(codetag_ref_from_page_ext(page_ext), tag); + 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);