From patchwork Fri Dec 24 06:46:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 12698835 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 0E297C433EF for ; Fri, 24 Dec 2021 06:46:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6080E6B0073; Fri, 24 Dec 2021 01:46:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B8306B0074; Fri, 24 Dec 2021 01:46:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A66E6B0075; Fri, 24 Dec 2021 01:46:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id 371206B0073 for ; Fri, 24 Dec 2021 01:46:55 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E0C6E8249980 for ; Fri, 24 Dec 2021 06:46:54 +0000 (UTC) X-FDA: 78951755148.02.9B1C2ED Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf31.hostedemail.com (Postfix) with ESMTP id 0B0BD2002B for ; Fri, 24 Dec 2021 06:46:39 +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 473421FB; Thu, 23 Dec 2021 22:46:53 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.70.117]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 946433F718; Thu, 23 Dec 2021 22:46:50 -0800 (PST) From: Anshuman Khandual To: linux-mm@kvack.org Cc: Anshuman Khandual , Steven Rostedt , Ingo Molnar , Andrew Morton , Zi Yan , Naoya Horiguchi , John Hubbard , linux-kernel@vger.kernel.org Subject: [RFC] mm/migration: Add trace events for THP migrations Date: Fri, 24 Dec 2021 12:16:38 +0530 Message-Id: <1640328398-20698-1-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 X-Rspamd-Queue-Id: 0B0BD2002B X-Stat-Signature: se3bnthu94eed8wcowxte6h3j48kyykx Authentication-Results: imf31.hostedemail.com; dkim=none; spf=pass (imf31.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-Rspamd-Server: rspam10 X-HE-Tag: 1640328399-343975 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: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- This applies on v5.16-rc6 include/trace/events/thp.h | 61 ++++++++++++++++++++++++++++++++++++++ mm/huge_memory.c | 5 ++++ 2 files changed, 66 insertions(+) diff --git a/include/trace/events/thp.h b/include/trace/events/thp.h index d7fbbe551841..be5aeb783af1 100644 --- a/include/trace/events/thp.h +++ b/include/trace/events/thp.h @@ -83,6 +83,67 @@ TRACE_EVENT(hugepage_splitting, __entry->addr, __entry->pte) ); +TRACE_EVENT(set_migration_pmd, + + TP_PROTO(struct mm_struct *mm, unsigned long address, + pmd_t *pmdp, struct page *page, unsigned long pmdval), + + TP_ARGS(mm, address, pmdp, page, pmdval), + + TP_STRUCT__entry( + __field(struct mm_struct *, mm) + __field(unsigned long, address) + __field(pmd_t *, pmdp) + __field(struct page *, page) + __field(unsigned long, pmdval) + ), + + TP_fast_assign( + __entry->mm = mm; + __entry->address = address; + __entry->pmdp = pmdp; + __entry->page = page; + __entry->pmdval = pmdval; + ), + + TP_printk("mm=%p, address=%lx, pmdp=%p, page=%p pmdval=%lx", + __entry->mm, + __entry->address, + __entry->pmdp, + __entry->page, + __entry->pmdval) +); + +TRACE_EVENT(remove_migration_pmd, + + TP_PROTO(struct mm_struct *mm, unsigned long address, + pmd_t *pmdp, struct page *page, unsigned long pmdval), + + TP_ARGS(mm, address, pmdp, page, pmdval), + + TP_STRUCT__entry( + __field(struct mm_struct *, mm) + __field(unsigned long, address) + __field(pmd_t *, pmdp) + __field(struct page *, page) + __field(unsigned long, pmdval) + ), + + TP_fast_assign( + __entry->mm = mm; + __entry->address = address; + __entry->pmdp = pmdp; + __entry->page = page; + __entry->pmdval = pmdval; + ), + + TP_printk("mm=%p, address=%lx, pmdp=%p, page=%p pmdval=%lx", + __entry->mm, + __entry->address, + __entry->pmdp, + __entry->page, + __entry->pmdval) +); #endif /* _TRACE_THP_H */ /* This part must be outside protection */ diff --git a/mm/huge_memory.c b/mm/huge_memory.c index e5483347291c..611de486e095 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(mm, address, pvmw->pmd, page, 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(mm, address, pvmw->pmd, new, pmd_val(pmde)); } #endif