From mboxrd@z Thu Jan 1 00:00:00 1970 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 4C41DC43334 for ; Tue, 12 Jul 2022 17:05:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2AC39400B4; Tue, 12 Jul 2022 13:05:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DDBAD940063; Tue, 12 Jul 2022 13:05:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7D419400B4; Tue, 12 Jul 2022 13:05:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B77B4940063 for ; Tue, 12 Jul 2022 13:05:43 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 91E3F80E0F for ; Tue, 12 Jul 2022 17:05:43 +0000 (UTC) X-FDA: 79679074566.21.4170E4A Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by imf28.hostedemail.com (Postfix) with ESMTP id CCBD7C007A for ; Tue, 12 Jul 2022 17:05:42 +0000 (UTC) Received: by mail-pj1-f49.google.com with SMTP id z12-20020a17090a7b8c00b001ef84000b8bso12201961pjc.1 for ; Tue, 12 Jul 2022 10:05:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DVnG1lFh4rBGuQdxpd5HlrOm1WgCgYiChr55SI3Lnpc=; b=f9h+JjLZ3cUIjL10CbeR/yGZ7MKYi0tjyu6w3aAuALQxmUbr2MTKVOJKkE+SxMMUD1 IdcVAag2eQU5UzgnRs8T2+oqfpqXH7mxySprtiA+2NLP4WdjQPtgEruR9e5ySY3rBWxo ltv3Ahiz9T98Q+0+W8r+3kjuE2DZDy+vvEYiyigXDAcsunwu4YN99A+V4/Nqzhpzopda aEM0EqJW5oCcrTnT3n+8Z0StJlWsjXQgW00an4sE/ZCEQqn6N6T+O5dJn+Y1JLJb8j4F k3svdq6NKE2j2e0L4bprwE/TyUxYbbaJrc5rTjLDHKFuPxKB8q8VteP/6ZTB6DqGI0CY Mxgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DVnG1lFh4rBGuQdxpd5HlrOm1WgCgYiChr55SI3Lnpc=; b=u5wDt29NZdMkrzBisUML6/f9VlxK6T5ttmFCpqaq8iC/fOrvmMmnbOYVnNPGFHONIs 8H+D8deO0hKyp2jR4eLAV38l+nz8vwTIT00fadh3l6Wu3LBv6aMgmRXpj2BYmXKuoHST Lw45GPRo1dZxdJ4HrGIAIM1u9nQH3WWDX8SptCjMlwnpxlFDYMEn+5lMi/TWqCOCi6Gt t0Bgi6wY6Rvp6EopCI0zZvwzVJd103UGjwlbB2uX/w4GoBT1wCeWqDf5JXknL7KbVf/U FVnMaZMZ75ukvDPnhB/35AXe8uEiqU9HfVt+rFcuQ19QqCPxlQbcF4NVSNp1ObqIx8FR BfeA== X-Gm-Message-State: AJIora/mjfOz+XBy6kPZA9TDMK/0Vf462mMsT9LhLY8E+IbSTG6vLsxy WgHxmNKldVLE7EtDAITx7ZTMFzPfr7M2jyCUNSE= X-Google-Smtp-Source: AGRyM1uFfh2pnS3H3ustOAGFcPzgO+AZy/6TwoNUtJF8foSAzKZ6ZcHLYVdEbysxGZRwqjIhj45Evuo92CM3wFib0dE= X-Received: by 2002:a17:903:2405:b0:16a:8010:1e16 with SMTP id e5-20020a170903240500b0016a80101e16mr25001311plo.87.1657645542000; Tue, 12 Jul 2022 10:05:42 -0700 (PDT) MIME-Version: 1.0 References: <20220706235936.2197195-1-zokeefe@google.com> <20220706235936.2197195-12-zokeefe@google.com> In-Reply-To: From: Yang Shi Date: Tue, 12 Jul 2022 10:05:29 -0700 Message-ID: Subject: Re: [mm-unstable v7 11/18] mm/madvise: add huge_memory:mm_madvise_collapse tracepoint To: "Zach O'Keefe" Cc: Alex Shi , David Hildenbrand , David Rientjes , Matthew Wilcox , Michal Hocko , Pasha Tatashin , Peter Xu , Rongwei Wang , SeongJae Park , Song Liu , Vlastimil Babka , Zi Yan , Linux MM , 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 Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657645542; a=rsa-sha256; cv=none; b=O8LIK7jkAFztR4cq5pEDh9KFopHRSRLWPvPJiKvNDPz3jBlTkqFgm2IDF8cPI66UlQ33iN lqVe1xvKIjNE0kGhV1oCE81Ngvgymzo8V6MgWc2okXECBmsd+espKMF9x9myhYONt/uib/ CJSkTmdcoX5Yfhp1Zsb6TgfLKQIHFm0= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=f9h+JjLZ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of shy828301@gmail.com designates 209.85.216.49 as permitted sender) smtp.mailfrom=shy828301@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657645542; 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=DVnG1lFh4rBGuQdxpd5HlrOm1WgCgYiChr55SI3Lnpc=; b=BvwE3MC56ngrbFf5SQ8A0Mt1Bm+YqCBdmPUkRpm6WjA3zPuBD08F2CwyrkJLDp9fXbzFz1 bmkLWJRZw7KiN3ICtt2AH7gFsXTnEzKrJ2X/fSAVJCihvXI316rbp5g51emgITknYaofrJ Sc4Gr2T3HsgCPT8cxANab4Sfm9Iug54= Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=f9h+JjLZ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of shy828301@gmail.com designates 209.85.216.49 as permitted sender) smtp.mailfrom=shy828301@gmail.com X-Rspam-User: X-Stat-Signature: jfeesjmhc7976qw9azf9ayo37oejn5b8 X-Rspamd-Queue-Id: CCBD7C007A X-Rspamd-Server: rspam08 X-HE-Tag: 1657645542-455480 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: On Tue, Jul 12, 2022 at 9:21 AM Zach O'Keefe wrote: > > Hey Yang, > > Thanks for taking the time to review this series again. > > On Jul 11 14:32, Yang Shi wrote: > > On Wed, Jul 6, 2022 at 5:06 PM Zach O'Keefe wrote: > > > > > > Add a tracepoint to expose mm, address, and enum scan_result of each > > > hugepage attempted to be collapsed by call to madvise(MADV_COLLAPSE). > > > > Is this necessary? Isn't mm_khugepaged_scan_pmd tracepoint good > > enough? It doesn't have "address", but you should be able to calculate > > address from it with syscall trace together. > > > > I've also found this useful debugging along the file path. Perhaps the answer to > that is: add tracepoints to the file path - and we should probably do that - but > the other issue is that turning on these tracepoints (for the purposes of > debugging MADV_COLLAPSE) generates a lot of noise from khugepaged that is hard > to separate out. Augmenting existing tracepoints with .is_khugepaged data > incurred the risks associated with altering an existing kernel API. WDYT? Doesn't ftrace show process comm and ID? And I think you also could trace the specific processes, right? > > Thanks again, > Zach > > > > > > > > > > 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: > > > -- > > > 2.37.0.rc0.161.g10f37bed90-goog > > >