From patchwork Tue Oct 24 13:46:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13434589 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 CB1EDC25B48 for ; Tue, 24 Oct 2023 13:47:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3CB626B027C; Tue, 24 Oct 2023 09:47:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 353FF6B027D; Tue, 24 Oct 2023 09:47:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 133BE6B027E; Tue, 24 Oct 2023 09:47:29 -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 E88746B027C for ; Tue, 24 Oct 2023 09:47:28 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C9B6F405EF for ; Tue, 24 Oct 2023 13:47:28 +0000 (UTC) X-FDA: 81380482176.27.EDE2A65 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf08.hostedemail.com (Postfix) with ESMTP id 09615160029 for ; Tue, 24 Oct 2023 13:47:26 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=NdAo3mJH; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf08.hostedemail.com: domain of 37co3ZQYKCJIEGD09x2AA270.yA8749GJ-886Hwy6.AD2@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=37co3ZQYKCJIEGD09x2AA270.yA8749GJ-886Hwy6.AD2@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698155247; a=rsa-sha256; cv=none; b=UNMefj5uM7ZSH4n7ZLj9K9vjHRo//nKDZRPY4YzZ597vbeKo5U5BUaZamAjUMZGa6QSvMO z9PLPUgfoxNnuOieXxRp3VgBZjmfKq7KZZNdpRzVudF0dcvgjIeK5vt96WL9+juBBdoNS/ HXUnkjAzvSAY2Yx+AQccsvitgksLaFw= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=NdAo3mJH; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf08.hostedemail.com: domain of 37co3ZQYKCJIEGD09x2AA270.yA8749GJ-886Hwy6.AD2@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=37co3ZQYKCJIEGD09x2AA270.yA8749GJ-886Hwy6.AD2@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698155247; 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=zhzOhwHQcxJuZ74GpFe9sYgSfMOEl4CWCuHOL/zyxyA=; b=0V+2+G9XMrlKG+eCR7qAq8s7zCd6nkQPxyBnIdbeowj4l3iWcwxpAYgL7LRs9bE3IJccDy KryvQ7KT/RWWfm7ceGdRRQG61hPCDuRcUQ9ceeRNXmapiT8kc9FYCQSVbqf4051IgaxqA6 jC42jWKHLIAVxRc13BNR3tCAtrQ7DhM= Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-d815354ea7fso4177407276.1 for ; Tue, 24 Oct 2023 06:47:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698155246; x=1698760046; 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=zhzOhwHQcxJuZ74GpFe9sYgSfMOEl4CWCuHOL/zyxyA=; b=NdAo3mJH2Fn3LeIN+MKj18UmE8F4TYc2rJgcwV1KxROLoGZql6rqFrujG9AvL2pJn7 WzO9m1cdOxrvqL+mP2ShquUXjWxP72eFI0/E7wtTcJoJ1Si1eOP2iHQEfeeYSs7nlpCl raRNlC4XSPMsJzsV0W32WZ88MbguP6B0A9PBErkLoVQ3e2SuvdPrrbynd+HhVwXAOCpF BD318F7xwdSpj8Posd5h3hhnYMRnYTCcpRSAchZxqBdLObUgORrctw+8R+b7Og4Z9Onv C7k1KwsM05OyXpjag3h+gjzhKDnZ0XqdyIPo5NLjLm58FXqMfSqzC8pqcdrkXs9wEblc hy4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698155246; x=1698760046; 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=zhzOhwHQcxJuZ74GpFe9sYgSfMOEl4CWCuHOL/zyxyA=; b=t4E2Jm/lb9YqkedDfu6JA38O9a55sgC0Elvf+kH7gd7VQpZezyAWW7xDzyv6BU2wDR zJfbpdzFTycVSFNEtTD/3CpGikysES0WJB5xBkmDGvhhdwG1tqQ7CtxFgLs9d8t0FgPm GQtKcJMT1/BdsD6mOhuzgGJbP6d42PkPzcD8oQ/wD0cDYO6oAeQLZAllX9QOHMHyhap3 aZN/2ux8G8KRIHhPq1YMBeyiL7IHscAL3BgFZa6vxM0vwU79yTovmppydqYdsmfg0Isz uRsOA4oNxTI6crMEAly/g7N9TpU6D0/LuQy4oHGmFDF2QeoaBl6nlOghHuYqc9agGQx7 o9vg== X-Gm-Message-State: AOJu0Yx1dAeo/SjjLGJRhUppCCgjv/d91aVRImblrtecPJb7lx1PB3dv Co5NTNkz5O/B/SdQYlj9YeilIE84iKk= X-Google-Smtp-Source: AGHT+IGqbReHwIMnajbCAyyRpg4FWyctkHXB3WgJzXU7P7J0pPMsKbVadURacVWEffWX34fNon1x9kvs7DE= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:45ba:3318:d7a5:336a]) (user=surenb job=sendgmr) by 2002:a25:42c9:0:b0:d9a:bce6:acf3 with SMTP id p192-20020a2542c9000000b00d9abce6acf3mr225566yba.0.1698155245951; Tue, 24 Oct 2023 06:47:25 -0700 (PDT) Date: Tue, 24 Oct 2023 06:46:17 -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-21-surenb@google.com> Subject: [PATCH v2 20/39] 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, 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-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 09615160029 X-Stat-Signature: um37zt5qdrisnqoat61kqfwz9p1ynasi X-HE-Tag: 1698155246-983956 X-HE-Meta: U2FsdGVkX18cOYX4vkNQ0REegUt06xEElhBKqifNrZSMlrQj5d6v/OiJhUBry2vxz6Bh80d08tBVLUpl1Pctzk4o7cSy2EMuhaTFcSLvkQjbd1gOb0axQsDSFvoAr8e/cvmL0wo079IzzYNuDIw7TB6Ph9t/97iri39aGSE5lW5eSQa5zHEQ8vP6qtBBIt1dVRb+ce/y4S7vuomlF2U8mfZFKuym1MIbTd5uJLo4VcchczM5ISNb1P50N1axJWQm7+drrznsm8+GnRLfLB289HT0FnYqDQ80kDP+/6QvEe4zT+3s1phviX++6L6mYu4shG4k7vmfv+O8556MR5bZzGcYVoE7IKdINfd2l0GvH76nSRXGipmqCgpdfzVcVc+5M1wP4vDfWluLPm+7P+8uzTcRwt++Gy+D+97Nan+Ov4jwhlmOvSWNI/pEqfSMCmqtqkHLcHTN1sU1LjIAJFslr7CuygSDhoDjIeROEeWNhHN+oMkAJTMa+3UBk7Kj9erHvErlt2zNooMNG2IJ1YgdQ0f+XlVx8+/6SpYc9BTFTYAdTSMv79ZVkx9b+6E30Nv9ZFVkyduJ6x8id+/ed8Y+JR4suHUvLttVjqJ2KCYCOMW9QT7eSwuxj6J2oJ07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000, 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 064fbd90822b..392b6907d875 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -2545,6 +2546,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 63dc2f8c7901..c4f0cd127e14 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2540,6 +2540,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); @@ -4669,6 +4670,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);