From patchwork Wed Jul 6 23:59:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zach O'Keefe X-Patchwork-Id: 12908935 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 AA955C43334 for ; Thu, 7 Jul 2022 00:06:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF8AC8E000B; Wed, 6 Jul 2022 20:06:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C2F798E0001; Wed, 6 Jul 2022 20:06:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AAA258E000B; Wed, 6 Jul 2022 20:06:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 8D0348E0001 for ; Wed, 6 Jul 2022 20:06:25 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 5AF4480497 for ; Thu, 7 Jul 2022 00:06:25 +0000 (UTC) X-FDA: 79658361930.18.8F86A24 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) by imf06.hostedemail.com (Postfix) with ESMTP id EEA6F18000F for ; Thu, 7 Jul 2022 00:06:24 +0000 (UTC) Received: by mail-pg1-f201.google.com with SMTP id s129-20020a632c87000000b00411564fe1feso6557131pgs.7 for ; Wed, 06 Jul 2022 17:06:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=9iaSDpn/v88iospRdmpPQ35IyRHiiBJVFeNpkZqtU1E=; b=cUosVoQHPAQYiOU7lEg06ydiDA3DJLWHbxdv33JJtc6RAzFEfDFuR4IuYTMAWnxYxv 48lq7DT2Vbim9t5oUQCJBLPp7zYrAHt2TEoia1R1zpVnyMHioqM02n2RlMBeAg4rnndg pb8zeA2bULolFWDxIF9MzWsnTz2RKmqFRSTGw6juCOjPZYxifzRDl9z4ip7UMU4+rnTs t0E05KBAhuHKgNilOCxkbi4Hao0pHBphAj2nEhM8nSUnOjY6fyaQVM7JxzcVMNXTp4/8 hWreRkZ9GL67LIIHGWQ+504QJymmYWmgPbW0Qva2nzg9ppjLLhlawOPFT38DyQWUOi7Q 2ptA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=9iaSDpn/v88iospRdmpPQ35IyRHiiBJVFeNpkZqtU1E=; b=eS49q4eeWXUCKOFCKZIEc3fCEKl4zGVuhJaoIySethwMRYefXQuH0ZJgWlrexwmtsn PuqNr99vLECVg4QGCR/8b8v7qI141RXhqYhgDQWwXjiGVHpj3AThm7Mg+TOb+Etv9Tcz wgyp6tYm8W33Km39Py3NGAVrNch87p8/RKSnGsyoZzf8IN7RKzZ5/8Ev1NGkqrjxOzTR eYXQROdXD2Wel3iuDTYgLzqFRX3yA00WAPVqa5+cdOd+bzdCKVPxDyurOU4HSoACO+7/ Jz1NHzjXTdu8JAgg+4wbAn2/fz10nqXPMR3A5+JYH0E/nmp2vObf2Tn3NQalsiBDgMnp WFRQ== X-Gm-Message-State: AJIora9+Tb5Szz2A8c0NM5nTEaRUjC/HBnAS8rld8L+M6opsmObIA0xK Ng8UGpaapfU9Dxe9pJHq3hXGmDfQxSXN X-Google-Smtp-Source: AGRyM1vD6qxE+V7dy75eF/SQqy8q7rwumvZVZUmd7JVi84rG2AREmyU22MkUr/B3gzCiVFTuklf5jWYUTFna X-Received: from zokeefe3.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1b6]) (user=zokeefe job=sendgmr) by 2002:a05:6a00:174b:b0:525:4eea:8ff2 with SMTP id j11-20020a056a00174b00b005254eea8ff2mr49130204pfc.23.1657152384031; Wed, 06 Jul 2022 17:06:24 -0700 (PDT) Date: Wed, 6 Jul 2022 16:59:29 -0700 In-Reply-To: <20220706235936.2197195-1-zokeefe@google.com> Message-Id: <20220706235936.2197195-12-zokeefe@google.com> Mime-Version: 1.0 References: <20220706235936.2197195-1-zokeefe@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [mm-unstable v7 11/18] mm/madvise: add huge_memory:mm_madvise_collapse tracepoint From: "Zach O'Keefe" To: Alex Shi , David Hildenbrand , David Rientjes , Matthew Wilcox , Michal Hocko , Pasha Tatashin , Peter Xu , Rongwei Wang , SeongJae Park , Song Liu , Vlastimil Babka , Yang Shi , Zi Yan , linux-mm@kvack.org Cc: Andrea Arcangeli , Andrew Morton , Arnd Bergmann , Axel Rasmussen , Chris Kennelly , Chris Zankel , Helge Deller , Hugh Dickins , Ivan Kokshaysky , "James E.J. Bottomley" , Jens Axboe , "Kirill A. Shutemov" , Matt Turner , Max Filippov , Miaohe Lin , Minchan Kim , Patrick Xia , Pavel Begunkov , Thomas Bogendoerfer , "Zach O'Keefe" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657152385; 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=9iaSDpn/v88iospRdmpPQ35IyRHiiBJVFeNpkZqtU1E=; b=jw5tUc39sjhMJS8gVunPMCoXZ4jAKSX6Oio87LOAebhQD1JYRHhm3Tvtxdo2KvfIerg9bn PeXh+kyQXgtSvxDvk0ZOzSOyOEVARGY5pATRUqBO5ib33ViAVPU6aeNmthnHsFkhGmU7cy Gp63Ed/5b4W7l6wRIzRGnTHEEUbf+PE= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=cUosVoQH; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of 3gCPGYgcKCPs2rnhhihjrrjoh.frpolqx0-ppnydfn.ruj@flex--zokeefe.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=3gCPGYgcKCPs2rnhhihjrrjoh.frpolqx0-ppnydfn.ruj@flex--zokeefe.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657152385; a=rsa-sha256; cv=none; b=nHIkgZYDmF3fKqIb2GPkYdzmTBmeg/jsCsXKoYr/Lym7k4AhiilbBezkKvLpoB+NYJldgv hkQLxff9lIYFxLuRt+lDq5e++cBTb1Y5jStrAFZRZMBdkyH9aJPxz4mtRblRQCnkP9I56C BHaJLB3IvPtQTXo9+dwOeEXXdxUEorc= X-Rspamd-Server: rspam11 X-Rspam-User: X-Stat-Signature: 3dgq8e9pzhog9bzbyixn775z8d9pkdne X-Rspamd-Queue-Id: EEA6F18000F Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=cUosVoQH; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of 3gCPGYgcKCPs2rnhhihjrrjoh.frpolqx0-ppnydfn.ruj@flex--zokeefe.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=3gCPGYgcKCPs2rnhhihjrrjoh.frpolqx0-ppnydfn.ruj@flex--zokeefe.bounces.google.com X-HE-Tag: 1657152384-335875 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: Add a tracepoint to expose mm, address, and enum scan_result of each hugepage attempted to be collapsed by call to madvise(MADV_COLLAPSE). Signed-off-by: Zach O'Keefe --- include/trace/events/huge_memory.h | 22 ++++++++++++++++++++++ mm/khugepaged.c | 2 ++ 2 files changed, 24 insertions(+) diff --git a/include/trace/events/huge_memory.h b/include/trace/events/huge_memory.h index 55392bf30a03..38d339ffdb16 100644 --- a/include/trace/events/huge_memory.h +++ b/include/trace/events/huge_memory.h @@ -167,5 +167,27 @@ TRACE_EVENT(mm_collapse_huge_page_swapin, __entry->ret) ); +TRACE_EVENT(mm_madvise_collapse, + + TP_PROTO(struct mm_struct *mm, unsigned long addr, int result), + + TP_ARGS(mm, addr, result), + + TP_STRUCT__entry(__field(struct mm_struct *, mm) + __field(unsigned long, addr) + __field(int, result) + ), + + TP_fast_assign(__entry->mm = mm; + __entry->addr = addr; + __entry->result = result; + ), + + TP_printk("mm=%p addr=%#lx result=%s", + __entry->mm, + __entry->addr, + __print_symbolic(__entry->result, SCAN_STATUS)) +); + #endif /* __HUGE_MEMORY_H */ #include diff --git a/mm/khugepaged.c b/mm/khugepaged.c index e0d00180512c..0207fc0a5b2a 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -2438,6 +2438,8 @@ int madvise_collapse(struct vm_area_struct *vma, struct vm_area_struct **prev, if (!mmap_locked) *prev = NULL; /* Tell caller we dropped mmap_lock */ + trace_mm_madvise_collapse(mm, addr, result); + switch (result) { case SCAN_SUCCEED: case SCAN_PMD_MAPPED: