Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13F97C43331 for ; Thu, 2 Apr 2020 07:44:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D4A3320678 for ; Thu, 2 Apr 2020 07:44:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D4A3320678 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 881668E0009; Thu, 2 Apr 2020 03:44:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 858188E0007; Thu, 2 Apr 2020 03:44:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7948F8E0009; Thu, 2 Apr 2020 03:44:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0223.hostedemail.com [216.40.44.223]) by kanga.kvack.org (Postfix) with ESMTP id 5F8078E0007 for ; Thu, 2 Apr 2020 03:44:15 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2B99A5820 for ; Thu, 2 Apr 2020 07:44:15 +0000 (UTC) X-FDA: 76662126870.12.door18_42342743d014d X-HE-Tag: door18_42342743d014d X-Filterd-Recvd-Size: 5228 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Thu, 2 Apr 2020 07:44:14 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id m17so2898970wrw.11 for ; Thu, 02 Apr 2020 00:44:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=UBE7VI9FnbtBHIdXLo3J25c1IHbGbjYoWi7ozq8GSkw=; b=BDJhXyueAmhG9nAvA8sKEv2tGwGBqzdFEw0KfQtnDRLj5s/dCCsyLp69ue23dvIpqC Jb9wncUf7NGGDQb39Jf644dV6FRJHPItcyafIJJzYF/i77PQ+TiFB92c+bD4J3nd3nM3 D8gm0oiRNpFvfIAEgtVNtZUMf/p21asiZTduPvGXNWQYPjkeqRLGJuZRIQXLfo50IYfk GS2Dv8KVnEXOs1wO7R1XlLeFdPtVr7d/Ap4uOVcaMg5v8WUgtZwSaHtdsA1xoirSEqXk 7RUE+2NqT5TWFRsp9GqRREmwK11IAsDNiSrKONiVGdVWS2We07jCKQSNvlBmJt55zL+r 6rsg== X-Gm-Message-State: AGi0PuaNZr+bufy9CJCJYG4dFpnRtf4zRrHbQ9MO9scxtAHK1vwbYHVN EQRHeK83ia16xuBYRMboDkE= X-Google-Smtp-Source: APiQypJOKL1DlYFdbEbI7pmv8zN7vXNpYVXMFImDay+xICRSRWkSegzmOrEqJY4ZmITPMktXMxiZCQ== X-Received: by 2002:adf:97c8:: with SMTP id t8mr2054345wrb.319.1585813453828; Thu, 02 Apr 2020 00:44:13 -0700 (PDT) Received: from localhost (ip-37-188-180-223.eurotel.cz. [37.188.180.223]) by smtp.gmail.com with ESMTPSA id b82sm5518287wme.25.2020.04.02.00.44.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 00:44:12 -0700 (PDT) Date: Thu, 2 Apr 2020 09:44:11 +0200 From: Michal Hocko To: "Huang, Ying" Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zi Yan , Andrea Arcangeli , "Kirill A . Shutemov" , Vlastimil Babka , Alexey Dobriyan , Konstantin Khlebnikov , =?utf-8?B?Suly9G1l?= Glisse , Yang Shi Subject: Re: [PATCH -V2] /proc/PID/smaps: Add PMD migration entry parsing Message-ID: <20200402074411.GH22681@dhcp22.suse.cz> References: <20200402020031.1611223-1-ying.huang@intel.com> <20200402064437.GC22681@dhcp22.suse.cz> <87zhbufjyc.fsf@yhuang-dev.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87zhbufjyc.fsf@yhuang-dev.intel.com> 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 Thu 02-04-20 15:03:23, Huang, Ying wrote: > Michal Hocko writes: > > > On Thu 02-04-20 10:00:31, Huang, Ying wrote: > >> From: Huang Ying > >> > >> Now, when read /proc/PID/smaps, the PMD migration entry in page table is simply > >> ignored. To improve the accuracy of /proc/PID/smaps, its parsing and processing > >> is added. > >> > >> Before the patch, for a fully populated 400 MB anonymous VMA, sometimes some THP > >> pages under migration may be lost as follows. > > > > Interesting. How did you reproduce this? > > [...] > > I run the pmbench in background to eat memory, then run > `/usr/bin/migratepages` and `cat /proc/PID/smaps` every second. The > issue can be reproduced within 60 seconds. Please add that information to the changelog. I was probably too optimistic about the migration duration because I found it highly unlikely to be visible. I was clearly wrong here. > >> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c > >> index 8d382d4ec067..9c72f9ce2dd8 100644 > >> --- a/fs/proc/task_mmu.c > >> +++ b/fs/proc/task_mmu.c > >> @@ -546,10 +546,19 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, > >> struct mem_size_stats *mss = walk->private; > >> struct vm_area_struct *vma = walk->vma; > >> bool locked = !!(vma->vm_flags & VM_LOCKED); > >> - struct page *page; > >> + struct page *page = NULL; > >> > >> - /* FOLL_DUMP will return -EFAULT on huge zero page */ > >> - page = follow_trans_huge_pmd(vma, addr, pmd, FOLL_DUMP); > >> + if (pmd_present(*pmd)) { > >> + /* FOLL_DUMP will return -EFAULT on huge zero page */ > >> + page = follow_trans_huge_pmd(vma, addr, pmd, FOLL_DUMP); > >> + } else if (unlikely(thp_migration_supported() && is_swap_pmd(*pmd))) { > >> + swp_entry_t entry = pmd_to_swp_entry(*pmd); > >> + > >> + if (is_migration_entry(entry)) > >> + page = migration_entry_to_page(entry); > >> + else > >> + VM_WARN_ON_ONCE(1); > > > > Could you explain why do we need this WARN_ON? I haven't really checked > > the swap support for THP but cannot we have normal swap pmd entries? > > I have some patches to add the swap pmd entry support, but they haven't > been merged yet. > > Similar checks are for all THP migration code paths, so I follow the > same style. I haven't checked other migration code paths but what is the reason to add the warning here? Even if this shouldn't happen, smaps is perfectly fine to ignore that situation, no? -- Michal Hocko SUSE Labs