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 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 71A48C43331 for ; Thu, 2 Apr 2020 06:44:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1BF3620784 for ; Thu, 2 Apr 2020 06:44:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BF3620784 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 996C68E000C; Thu, 2 Apr 2020 02:44:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9476E8E0008; Thu, 2 Apr 2020 02:44:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85D928E000C; Thu, 2 Apr 2020 02:44:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0238.hostedemail.com [216.40.44.238]) by kanga.kvack.org (Postfix) with ESMTP id 6F4D88E0008 for ; Thu, 2 Apr 2020 02:44:41 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 26AE04821 for ; Thu, 2 Apr 2020 06:44:41 +0000 (UTC) X-FDA: 76661976762.24.flame42_802e7a1fbbf44 X-HE-Tag: flame42_802e7a1fbbf44 X-Filterd-Recvd-Size: 4624 Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Thu, 2 Apr 2020 06:44:40 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id h9so2770714wrc.8 for ; Wed, 01 Apr 2020 23:44:40 -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=7x56Yl6IYss7cUYz/OjtuSd8iPo+r2To7flTG3SFpZg=; b=cbMjQiFtrMGhMf8aVVWbmCa6KkeYgDvD/aXoZKYakEPGqNiEltVLCEYtTqd+LbBPeb XQbclYc1dUv+C2wr2Nl/0HixGTiTEmNWtCwYFA7lsfKNFzfw/myhaSDov7uKJyfX1tfw PBcYOY6DVACccffT5fMhSzXv/ukLV98c5IHwZFkBCzHfGpufUCyamIt3gfjnBC0Xx0nv VD0UJ28AGft/AfF8hgkew1rGZ4owY7fQDR0AZQ59odzlooTgSSu6pG1w8Uyu0tUX+aIr yDgbDUn7TZeXAM0Q2GgLAzuc69+sgW5nLj+lDb+WsXng6l1upLh5Vm2zI2+5Co5SU4p/ X2zA== X-Gm-Message-State: AGi0Pua7x5+BPIHFVhCijRPD3S0Lvej04ZmuvVSQrl1VW3nNgk/VRqIm 6liW/WmkUkpOmbcLlPi07tc= X-Google-Smtp-Source: APiQypJrtfd7qxASliBR8WfzCMddT44zDZWaD36dMrltK5ZOKe2i2CLK+OZDysVOVr363kmFLkylQw== X-Received: by 2002:adf:bc4a:: with SMTP id a10mr1841600wrh.7.1585809879583; Wed, 01 Apr 2020 23:44:39 -0700 (PDT) Received: from localhost (ip-37-188-180-223.eurotel.cz. [37.188.180.223]) by smtp.gmail.com with ESMTPSA id t17sm1165030wrv.53.2020.04.01.23.44.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2020 23:44:38 -0700 (PDT) Date: Thu, 2 Apr 2020 08:44:37 +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 , =?iso-8859-1?B?Suly9G1l?= Glisse , Yang Shi Subject: Re: [PATCH -V2] /proc/PID/smaps: Add PMD migration entry parsing Message-ID: <20200402064437.GC22681@dhcp22.suse.cz> References: <20200402020031.1611223-1-ying.huang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200402020031.1611223-1-ying.huang@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 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? [...] > 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? > + } > if (IS_ERR_OR_NULL(page)) > return; > if (PageAnon(page)) > @@ -578,8 +587,7 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, > > ptl = pmd_trans_huge_lock(pmd, vma); > if (ptl) { > - if (pmd_present(*pmd)) > - smaps_pmd_entry(pmd, addr, walk); > + smaps_pmd_entry(pmd, addr, walk); > spin_unlock(ptl); > goto out; > } > -- > 2.25.0 -- Michal Hocko SUSE Labs