All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Huang\, Ying" <ying.huang@intel.com>
To: Michal Hocko <mhocko@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,  <linux-mm@kvack.org>,
	 <linux-kernel@vger.kernel.org>,  Zi Yan <ziy@nvidia.com>,
	 Andrea Arcangeli <aarcange@redhat.com>,
	 "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
	 Vlastimil Babka <vbabka@suse.cz>,
	 "Alexey Dobriyan" <adobriyan@gmail.com>,
	 Konstantin Khlebnikov <khlebnikov@yandex-team.ru>,
	 Jérôme Glisse <jglisse@redhat.com>,
	 Yang Shi <yang.shi@linux.alibaba.com>
Subject: Re: [PATCH -V2] /proc/PID/smaps: Add PMD migration entry parsing
Date: Thu, 02 Apr 2020 15:03:23 +0800	[thread overview]
Message-ID: <87zhbufjyc.fsf@yhuang-dev.intel.com> (raw)
In-Reply-To: <20200402064437.GC22681@dhcp22.suse.cz> (Michal Hocko's message of "Thu, 2 Apr 2020 08:44:37 +0200")

Michal Hocko <mhocko@kernel.org> writes:

> On Thu 02-04-20 10:00:31, Huang, Ying wrote:
>> From: Huang Ying <ying.huang@intel.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.

>> 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.

Best Regards,
Huang, Ying


  reply	other threads:[~2020-04-02  7:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-02  2:00 [PATCH -V2] /proc/PID/smaps: Add PMD migration entry parsing Huang, Ying
2020-04-02  6:44 ` Michal Hocko
2020-04-02  7:03   ` Huang, Ying [this message]
2020-04-02  7:44     ` Michal Hocko
2020-04-02  8:10       ` Huang, Ying
2020-04-02  8:21         ` Michal Hocko
2020-04-02  8:27           ` Huang, Ying
2020-04-02  8:29           ` Konstantin Khlebnikov
2020-04-02  8:58             ` Michal Hocko
2020-04-02 15:52       ` Yang Shi
2020-04-02 12:53 ` Kirill A. Shutemov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zhbufjyc.fsf@yhuang-dev.intel.com \
    --to=ying.huang@intel.com \
    --cc=aarcange@redhat.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=jglisse@redhat.com \
    --cc=khlebnikov@yandex-team.ru \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=vbabka@suse.cz \
    --cc=yang.shi@linux.alibaba.com \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.