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 C4CFCC433EF for ; Tue, 12 Jul 2022 17:30:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EB6F9400BC; Tue, 12 Jul 2022 13:30:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 29A3C940063; Tue, 12 Jul 2022 13:30:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13A4A9400BC; Tue, 12 Jul 2022 13:30:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0602B940063 for ; Tue, 12 Jul 2022 13:30:59 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id D11B8120DD0 for ; Tue, 12 Jul 2022 17:30:58 +0000 (UTC) X-FDA: 79679138196.08.79026CA Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by imf20.hostedemail.com (Postfix) with ESMTP id 632B41C00AC for ; Tue, 12 Jul 2022 17:30:58 +0000 (UTC) Received: by mail-pj1-f46.google.com with SMTP id o5-20020a17090a3d4500b001ef76490983so9034141pjf.2 for ; Tue, 12 Jul 2022 10:30:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=eelEE6BDC3DEv4vbMQGuffhTiCi6gmB7TuEgLDUuBp8=; b=lBHJFwugzBkmbIzRS0pOSFamYln7fK50Oor1qaM0qTBcGOaZMij0xquMd0kgOKaoz/ TLrTRUki5mpkBcWfpgWeSTpPqPyLo/QxL29xLEsmrXPaoEorRGIQdpwOJJWb9TaRNGWX IQ7IBZrpNImn8NWQCuwj52J7LwNb0DpvSTqy2yjeap+boFa1UQF1Ov+jM1QTZESuqpSY OVi4ZvX6xueVbHt3nq/zBZ3didZ7RN+v5BRMY1UXBjN4JQzBOxwZbq33bozWhaqC9JGp PgfCtouVdnkvg0qr87vQZgmu0joP19yA+o3/eLBt7cDffKq4yTXPDutbgSkTnKjV3Xyv hbUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=eelEE6BDC3DEv4vbMQGuffhTiCi6gmB7TuEgLDUuBp8=; b=hVnOrX5Mjqk+WGeAyRMGbiWITI2/9KK9y5gVrbXXeGhDlVETmdguJ0Qtn748X+tTWN na7V/OI8lFkrBDICTXEM1Ta+zNK3QJrtyF42KCJp5bl12NkNks8o20cuJ/idYPcP8+Lf WI7jWOfh92zvwqavoNSOg8j9k7c2eX0YDwZa7zjNxPclMNqZDzOi0/gS6ABtPBB3rDsQ 0lArz/fzNznqd2qQsR6wDV62N82SqW2TG9VoHTxYa645Ga0bP8jtp4uFHYuSVpTv3BAV in3jZ2du7ianY8mCYIPLnlMz7ft7QS5oXD5WiJWuQ2EgR+IH0Rx7/3l+GsQgPD47RuGd GVkQ== X-Gm-Message-State: AJIora+NbdTxu/oxYR5pJw+Y0oigCoOv5nnDoaHf3H1PtAdWD8sXutNN Msx2/x/alqaiCUXPIZIIg5xH5A== X-Google-Smtp-Source: AGRyM1t1jYnr+gUiVbh7k0yfYf2hZgR2fHW2qBmGNjFXYOn0DbO9HdTJ2lred4EfBLjwHzdvcEwYlQ== X-Received: by 2002:a17:90b:224b:b0:1ef:e06a:32f1 with SMTP id hk11-20020a17090b224b00b001efe06a32f1mr5657778pjb.197.1657647057049; Tue, 12 Jul 2022 10:30:57 -0700 (PDT) Received: from google.com (55.212.185.35.bc.googleusercontent.com. [35.185.212.55]) by smtp.gmail.com with ESMTPSA id s13-20020aa78bcd000000b0050dc762816dsm7063200pfd.71.2022.07.12.10.30.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 10:30:56 -0700 (PDT) Date: Tue, 12 Jul 2022 10:30:53 -0700 From: Zach O'Keefe To: Yang Shi 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 Subject: Re: [mm-unstable v7 11/18] mm/madvise: add huge_memory:mm_madvise_collapse tracepoint Message-ID: References: <20220706235936.2197195-1-zokeefe@google.com> <20220706235936.2197195-12-zokeefe@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657647058; 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=eelEE6BDC3DEv4vbMQGuffhTiCi6gmB7TuEgLDUuBp8=; b=j2Y7wn/NZj8zHN0qgrxkHu7o64oKsauwkoPAVku/h93PJb76xkDjJ9yiTY42w5eOcHPZgQ W3Ai5TLJRgnUfx0T7Qt9MfX+3khFNQPM5wu89maxjH6I8mQiM2uZnHUxe4TTGsbUasOuUS IFVZQ8b1uREs8DY+Ul5cDchRfgV9E/A= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=lBHJFwug; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf20.hostedemail.com: domain of zokeefe@google.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=zokeefe@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657647058; a=rsa-sha256; cv=none; b=dfD/q4RcqJWchfTO1Z1usE1mEq75rWeh8MsBlaEjZYB1JmvFh4/xIbNJVu26ebf389bXrB XOEn18z0jlJS9Zo4LLsGKDguRqaif7Vug49G8kIQeqDD76L8EQ/inR9PrKWVawphd8v5mz aht8/Fk0wMYFRFBqs4ls0JThp5VGpgw= X-Stat-Signature: eo5yctdwd4zftsxfjpcjnrt3aw4sy46c X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 632B41C00AC Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=lBHJFwug; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf20.hostedemail.com: domain of zokeefe@google.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=zokeefe@google.com X-Rspam-User: X-HE-Tag: 1657647058-540155 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 Jul 12 10:05, Yang Shi wrote: > 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? > That's true enough - it had been awhile since I actually did that ; I've been carrying some printk's for debugging that eventually I converted into a tracepoint here. Sorry about that. I'll drop this and add a relevant tracepoint to file collapse path that will benefit khugepaged too. Thanks again, Zach > > > > 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 > > > >