lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200402074411.GH22681@dhcp22.suse.cz>
Date:   Thu, 2 Apr 2020 09:44:11 +0200
From:   Michal Hocko <mhocko@...nel.org>
To:     "Huang, Ying" <ying.huang@...el.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org, Zi Yan <ziy@...dia.com>,
        Andrea Arcangeli <aarcange@...hat.com>,
        "Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
        Vlastimil Babka <vbabka@...e.cz>,
        Alexey Dobriyan <adobriyan@...il.com>,
        Konstantin Khlebnikov <khlebnikov@...dex-team.ru>,
        Jérôme Glisse <jglisse@...hat.com>,
        Yang Shi <yang.shi@...ux.alibaba.com>
Subject: Re: [PATCH -V2] /proc/PID/smaps: Add PMD migration entry parsing

On Thu 02-04-20 15:03:23, Huang, Ying wrote:
> Michal Hocko <mhocko@...nel.org> writes:
> 
> > On Thu 02-04-20 10:00:31, Huang, Ying wrote:
> >> From: Huang Ying <ying.huang@...el.com>
> >> 
> >> 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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ