From patchwork Tue Jan 25 03:08:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 12723213 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 7B600C433EF for ; Tue, 25 Jan 2022 03:08:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C28F66B0085; Mon, 24 Jan 2022 22:08:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BD83C6B0087; Mon, 24 Jan 2022 22:08:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA00D6B0088; Mon, 24 Jan 2022 22:08:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id 9CA626B0085 for ; Mon, 24 Jan 2022 22:08:38 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 57BA318026129 for ; Tue, 25 Jan 2022 03:08:38 +0000 (UTC) X-FDA: 79067326716.15.D88ABEE Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf05.hostedemail.com (Postfix) with ESMTP id E2CBA10001C for ; Tue, 25 Jan 2022 03:08:37 +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 2D88B1FB; Mon, 24 Jan 2022 19:08:37 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.42.113]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E671C3F766; Mon, 24 Jan 2022 19:08:31 -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 1/2] mm/migration: Add trace events for THP migrations Date: Tue, 25 Jan 2022 08:38:24 +0530 Message-Id: <1643080105-11416-2-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: rspam06 X-Rspamd-Queue-Id: E2CBA10001C X-Stat-Signature: r33jsyhbdqojqjzd6gsmoxpojuj4dka1 Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf05.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com X-Rspam-User: nil X-HE-Tag: 1643080117-11658 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 PMD based THP migration without split. These events closely follow the implementation details like setting and removing of PMD migration entries, which are essential operations for THP 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 --- include/trace/events/thp.h | 27 +++++++++++++++++++++++++++ mm/huge_memory.c | 5 +++++ 2 files changed, 32 insertions(+) diff --git a/include/trace/events/thp.h b/include/trace/events/thp.h index ca3f2767828a..202b3e3e67ff 100644 --- a/include/trace/events/thp.h +++ b/include/trace/events/thp.h @@ -48,6 +48,33 @@ TRACE_EVENT(hugepage_update, TP_printk("hugepage update at addr 0x%lx and pte = 0x%lx clr = 0x%lx, set = 0x%lx", __entry->addr, __entry->pte, __entry->clr, __entry->set) ); +DECLARE_EVENT_CLASS(migration_pmd, + + TP_PROTO(unsigned long addr, unsigned long pmd), + + TP_ARGS(addr, pmd), + + TP_STRUCT__entry( + __field(unsigned long, addr) + __field(unsigned long, pmd) + ), + + TP_fast_assign( + __entry->addr = addr; + __entry->pmd = pmd; + ), + TP_printk("addr=%lx, pmd=%lx", __entry->addr, __entry->pmd) +); + +DEFINE_EVENT(migration_pmd, set_migration_pmd, + TP_PROTO(unsigned long addr, unsigned long pmd), + TP_ARGS(addr, pmd) +); + +DEFINE_EVENT(migration_pmd, remove_migration_pmd, + TP_PROTO(unsigned long addr, unsigned long pmd), + TP_ARGS(addr, pmd) +); #endif /* _TRACE_THP_H */ /* This part must be outside protection */ diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 406a3c28c026..ab49f9a3e420 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -39,6 +39,9 @@ #include #include "internal.h" +#define CREATE_TRACE_POINTS +#include + /* * By default, transparent hugepage support is disabled in order to avoid * risking an increased memory footprint for applications that are not @@ -3173,6 +3176,7 @@ void set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw, set_pmd_at(mm, address, pvmw->pmd, pmdswp); page_remove_rmap(page, true); put_page(page); + trace_set_migration_pmd(address, pmd_val(pmdswp)); } void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) @@ -3206,5 +3210,6 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) if ((vma->vm_flags & VM_LOCKED) && !PageDoubleMap(new)) mlock_vma_page(new); update_mmu_cache_pmd(vma, address, pvmw->pmd); + trace_remove_migration_pmd(address, pmd_val(pmde)); } #endif