From patchwork Fri Jan 7 04:59:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 12706206 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 1E581C433F5 for ; Fri, 7 Jan 2022 05:00:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 115666B0085; Fri, 7 Jan 2022 00:00:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 09D9F6B0087; Fri, 7 Jan 2022 00:00:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA6B56B0088; Fri, 7 Jan 2022 00:00:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0206.hostedemail.com [216.40.44.206]) by kanga.kvack.org (Postfix) with ESMTP id DB3336B0085 for ; Fri, 7 Jan 2022 00:00:03 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 814D4181CAC56 for ; Fri, 7 Jan 2022 05:00:03 +0000 (UTC) X-FDA: 79002289086.19.FDEECA7 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf11.hostedemail.com (Postfix) with ESMTP id DB1DC40007 for ; Fri, 7 Jan 2022 05:00:02 +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 EBD611042; Thu, 6 Jan 2022 21:00:01 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.72.124]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DE7C23F66F; Thu, 6 Jan 2022 20:59:58 -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 , Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH] mm/migration: Add trace events for THP migrations Date: Fri, 7 Jan 2022 10:29:35 +0530 Message-Id: <1641531575-28524-1-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf11.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: DB1DC40007 X-Stat-Signature: npnu9ne59kzbg7o6rznoj8rp5gqd6kx9 X-HE-Tag: 1641531602-708983 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 --- This applies on v5.16-rc8 Changes in V1: - Dropped mm, pmdp, page arguments from trace - Updated trace argument names and output format Changes in RFC: https://lore.kernel.org/all/1640328398-20698-1-git-send-email-anshuman.khandual@arm.com/ include/trace/events/thp.h | 37 +++++++++++++++++++++++++++++++++++++ mm/huge_memory.c | 5 +++++ 2 files changed, 42 insertions(+) diff --git a/include/trace/events/thp.h b/include/trace/events/thp.h index d7fbbe551841..193a555aa2ea 100644 --- a/include/trace/events/thp.h +++ b/include/trace/events/thp.h @@ -83,6 +83,43 @@ TRACE_EVENT(hugepage_splitting, __entry->addr, __entry->pte) ); +TRACE_EVENT(set_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("create pmd migration entry addr=%lx, pmd=%lx", __entry->addr, __entry->pmd) +); + +TRACE_EVENT(remove_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("remove pmd migration entry addr=%lx, val=%lx", __entry->addr, __entry->pmd) +); #endif /* _TRACE_THP_H */ /* This part must be outside protection */ diff --git a/mm/huge_memory.c b/mm/huge_memory.c index e5483347291c..d0adc019afe0 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