From patchwork Tue Jan 25 03:08:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 12723214 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 E08D2C433EF for ; Tue, 25 Jan 2022 03:08:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BB326B0087; Mon, 24 Jan 2022 22:08:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 76C036B0088; Mon, 24 Jan 2022 22:08:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 633F96B0089; Mon, 24 Jan 2022 22:08:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0091.hostedemail.com [216.40.44.91]) by kanga.kvack.org (Postfix) with ESMTP id 554D36B0087 for ; Mon, 24 Jan 2022 22:08:44 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 1F89B180E1E3F for ; Tue, 25 Jan 2022 03:08:44 +0000 (UTC) X-FDA: 79067326968.11.DCE71FE Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf14.hostedemail.com (Postfix) with ESMTP id 9E545100012 for ; Tue, 25 Jan 2022 03:08:43 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 138C0101E; Mon, 24 Jan 2022 19:08:43 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.42.113]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id F048D3F766; Mon, 24 Jan 2022 19:08:37 -0800 (PST) From: Anshuman Khandual To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, naoya.horiguchi@linux.dev, rostedt@goodmis.org, Anshuman Khandual , Ingo Molnar , Zi Yan , Naoya Horiguchi , John Hubbard , Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH V2 2/2] mm/migration: Add trace events for base page and HugeTLB migrations Date: Tue, 25 Jan 2022 08:38:25 +0530 Message-Id: <1643080105-11416-3-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1643080105-11416-1-git-send-email-anshuman.khandual@arm.com> References: <1643080105-11416-1-git-send-email-anshuman.khandual@arm.com> X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 9E545100012 X-Stat-Signature: e6jw1kohnmqso1te88y566eodmsamzrw X-Rspam-User: nil Authentication-Results: imf14.hostedemail.com; dkim=none; spf=pass (imf14.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com X-HE-Tag: 1643080123-410907 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: This adds two trace events for base page and HugeTLB page migrations. These events, closely follow the implementation details like setting and removing of PTE migration entries, which are essential operations for migration. Cc: Steven Rostedt Cc: Ingo Molnar Cc: Andrew Morton Cc: Zi Yan Cc: Naoya Horiguchi Cc: John Hubbard Cc: Matthew Wilcox Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual Reported-by: kernel test robot Reported-by: kernel test robot Reported-by: kernel test robot --- include/trace/events/migrate.h | 31 +++++++++++++++++++++++++++++++ mm/migrate.c | 3 +++ mm/rmap.c | 5 +++++ 3 files changed, 39 insertions(+) diff --git a/include/trace/events/migrate.h b/include/trace/events/migrate.h index 779f3fad9ecd..061b5128f335 100644 --- a/include/trace/events/migrate.h +++ b/include/trace/events/migrate.h @@ -105,6 +105,37 @@ TRACE_EVENT(mm_migrate_pages_start, __print_symbolic(__entry->reason, MIGRATE_REASON)) ); +DECLARE_EVENT_CLASS(migration_pte, + + TP_PROTO(unsigned long addr, unsigned long pte, int order), + + TP_ARGS(addr, pte, order), + + TP_STRUCT__entry( + __field(unsigned long, addr) + __field(unsigned long, pte) + __field(int, order) + ), + + TP_fast_assign( + __entry->addr = addr; + __entry->pte = pte; + __entry->order = order; + ), + + TP_printk("addr=%lx, pte=%lx order=%d", __entry->addr, __entry->pte, __entry->order) +); + +DEFINE_EVENT(migration_pte, set_migration_pte, + TP_PROTO(unsigned long addr, unsigned long pte, int order), + TP_ARGS(addr, pte, order) +); + +DEFINE_EVENT(migration_pte, remove_migration_pte, + TP_PROTO(unsigned long addr, unsigned long pte, int order), + TP_ARGS(addr, pte, order) +); + #endif /* _TRACE_MIGRATE_H */ /* This part must be outside protection */ diff --git a/mm/migrate.c b/mm/migrate.c index c7da064b4781..253dc5812949 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -257,6 +257,9 @@ static bool remove_migration_pte(struct page *page, struct vm_area_struct *vma, if (PageTransHuge(page) && PageMlocked(page)) clear_page_mlock(page); + trace_remove_migration_pte(pvmw.address, pte_val(pte), + compound_order(new)); + /* No need to invalidate - it was non-present before */ update_mmu_cache(vma, pvmw.address, pvmw.pte); } diff --git a/mm/rmap.c b/mm/rmap.c index 6a1e8c7f6213..cce5dbae07f2 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -77,6 +77,7 @@ #include #include +#include #include "internal.h" @@ -1861,6 +1862,8 @@ static bool try_to_migrate_one(struct page *page, struct vm_area_struct *vma, if (pte_swp_uffd_wp(pteval)) swp_pte = pte_swp_mkuffd_wp(swp_pte); set_pte_at(mm, pvmw.address, pvmw.pte, swp_pte); + trace_set_migration_pte(pvmw.address, pte_val(swp_pte), + compound_order(page)); /* * No need to invalidate here it will synchronize on * against the special swap migration pte. @@ -1929,6 +1932,8 @@ static bool try_to_migrate_one(struct page *page, struct vm_area_struct *vma, if (pte_uffd_wp(pteval)) swp_pte = pte_swp_mkuffd_wp(swp_pte); set_pte_at(mm, address, pvmw.pte, swp_pte); + trace_set_migration_pte(address, pte_val(swp_pte), + compound_order(page)); /* * No need to invalidate here it will synchronize on * against the special swap migration pte.