linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yang Shi <yang.shi@linux.alibaba.com>
To: Hugh Dickins <hughd@google.com>
Cc: aarcange@redhat.com, kirill.shutemov@linux.intel.com,
	gavin.dg@linux.alibaba.com, akpm@linux-foundation.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: thp: handle page cache THP correctly in PageTransCompoundMap
Date: Wed, 23 Oct 2019 10:02:06 -0700	[thread overview]
Message-ID: <b4e320b7-d152-779a-8456-263e711f69b6@linux.alibaba.com> (raw)
In-Reply-To: <alpine.LSU.2.11.1910221802270.2748@eggly.anvils>



On 10/22/19 6:31 PM, Hugh Dickins wrote:
> On Tue, 22 Oct 2019, Yang Shi wrote:
>> On 10/22/19 3:27 PM, Hugh Dickins wrote:
>>> I completely agree that the current PageTransCompoundMap() is wrong.
>>>
>>> A fix for that is one of many patches I've not yet got to upstreaming.
>>> Comparing yours and mine, I'm worried by your use of PageDoubleMap(),
>>> because really that's a flag for anon THP, and not properly supported
>>> on shmem (or now I suppose file) THP - I forget the details, is it
>>> that it sometimes gets set, but never cleared?  Generally, we just
>>> don't refer to PageDoubleMap() on shmem THPs (but there may be
>>> exceptions: sorting out the THP mapcount maze, and eliminating
>>> PageDoubleMap(), is one of my long-held ambitions, not yet reached).
>>>
>>> Here's the patch I've been carrying, but it's from earlier, so I
>>> should warn that I've done no more than build-testing it on 5.4,
>>> and I'm too far away from these issues at the moment to be able to
>>> make a good judgement or argue for it - I hope you and others can
>>> decide which patch is the better.  I should also add that we're
>>> barely using PageTransCompoundMap() at all: at best it can only
>>> give a heuristic guess as to whether the page is pmd-mapped in
>>> any particular case, and we preferred to take forward the KVM
>>> patches we posted back in April 2016, plumbing hva down to where
>>> it's needed - though of course those are somewhat different now.
>> Thanks for catching this. I was definitely thinking about using
>> compount_mapcount instead of DoubleMap flag when I was working the patch. I
>> just simply thought it would change less file by using DoubleMap flag but I
>> didn't notice it was kind of unbalanced for file THP.
>>
>> With the unbalanced DoubleMap flag, it sounds better to use
>> compound_mapcount.
> Yes: no doubt PageDoubleMap could be fixed on shmem+file, but I have no
> interest in doing that, because it's just unnecessary overhead for them.
> (They have their own overhead, of subpage mapcounting for pmd: which is
> something to eliminate and unify with anon when I get around to it.)

It might be worth fixing the unbalance since mlock depends on this flag 
too. There should be a little bit overhead when handling PTE rmap remove 
since we have to iterate every subpage to check if _mapcount is same 
with compound_mapcount or not in order to clear DoubleMap flag. It is 
easy to handle this when the last PMD map is gone.

>
>> Thanks for sharing your patch, I'm going to rework v2 by using
>> compound_mapcount. Do you mind I might steal your patch?
> Please do! One less for me to worry about, thanks.
>
>> I'm supposed we'd better fix this bug regardless of whether you would like to
>> move forward your KVM patches.
> Absolutely. There remain a few other uses of PageTransCompoundMap
> anyway, and I really wanted this outright mm fix to go in before
> re-submitting AndresLC's KVM patch (I'll ask a KVM-savvy colleague
> to take that over, Cc'ing you, once the mm end is correct).

Thanks.

>
> Hugh



      reply	other threads:[~2019-10-23 17:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-22 18:39 Yang Shi
2019-10-22 22:27 ` Hugh Dickins
2019-10-22 23:38   ` Yang Shi
2019-10-23  1:31     ` Hugh Dickins
2019-10-23 17:02       ` Yang Shi [this message]

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=b4e320b7-d152-779a-8456-263e711f69b6@linux.alibaba.com \
    --to=yang.shi@linux.alibaba.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=gavin.dg@linux.alibaba.com \
    --cc=hughd@google.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox