linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lance Yang <ioworker0@gmail.com>
To: David Hildenbrand <david@redhat.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>,
	akpm@linux-foundation.org, 21cnbao@gmail.com,  mhocko@suse.com,
	fengwei.yin@intel.com, zokeefe@google.com,  shy828301@gmail.com,
	xiehuan09@gmail.com, wangkefeng.wang@huawei.com,
	 songmuchun@bytedance.com, peterx@redhat.com, minchan@kernel.org,
	 linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 3/3] mm/madvise: optimize lazyfreeing with mTHP in madvise_free
Date: Wed, 17 Apr 2024 12:35:33 +0800	[thread overview]
Message-ID: <CAK1f24nxfaRBaD+88shL75wOCQG8LbUu1QDWKGWitUuZ+epTDQ@mail.gmail.com> (raw)
In-Reply-To: <3a0d1d1c-97f4-4c9d-bc25-9de3f3659b67@redhat.com>

Hey Ryan, David,

Thanks for taking time to review!

On Wed, Apr 17, 2024 at 12:52 AM David Hildenbrand <david@redhat.com> wrote:
>
> >> +                    nr = madvise_folio_pte_batch(addr, end, folio, pte,
> >> +                                                 ptent, &any_young, &any_dirty);
> >> +
> >> +                    if (nr < folio_nr_pages(folio)) {
> >> +                            if (folio_likely_mapped_shared(folio))
> >> +                                    continue;
> >> +
> >> +                            arch_leave_lazy_mmu_mode();
> >> +                            if (madvise_pte_split_folio(mm, pmd, addr,
> >> +                                                        folio, &start_pte, &ptl))
> >> +                                    nr = 0;
> >> +                            if (!start_pte)
> >> +                                    break;
> >> +                            pte = start_pte;
> >> +                            arch_enter_lazy_mmu_mode();
> >> +                            continue;
> >> +                    }
> >> +
> >> +                    if (any_young)
> >> +                            ptent = pte_mkyoung(ptent);
> >> +                    if (any_dirty)
> >> +                            ptent = pte_mkdirty(ptent);
> >>              }
> >>
> >> +            if (folio_mapcount(folio) != folio_nr_pages(folio))
> >> +                    continue;
> >
> > Why is this here? I thought we had previously concluded to only do this test
> > inside the below if statement (where you have it duplicated).

My bad for this mistake - sorry!

>
> I stumbled over these same while reviewing. It's not exactly duplicate,
> because it's unreliable without the folio lock. It looks more like an
> best-effort early check.
>
> But then, we also add it to cases where we previously wouldn't check the
> mapcount at all: when the folio was added to the swapcache or is already
> dirty.
>
> In that case, we would even see a change for order-0 folios with that
> new check.

Thanks for pointing that out! I'll remove this check here in the next version.

I overlooked that this is a new check for order-0 folios :(

Thanks,
Lance

>
> --
> Cheers,
>
> David / dhildenb
>


      reply	other threads:[~2024-04-17  4:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16  3:34 [PATCH v7 0/3] mm/madvise: enhance lazyfreeing with mTHP in madvise_free Lance Yang
2024-04-16  3:34 ` [PATCH v7 1/3] mm/madvise: introduce clear_young_dirty_ptes() batch helper Lance Yang
2024-04-16 16:25   ` Ryan Roberts
2024-04-17  4:13     ` Lance Yang
     [not found]   ` <a0d9e198-8799-47b9-ac20-8460b984afee@redhat.com>
2024-04-17  4:12     ` Lance Yang
2024-04-17  5:04       ` Lance Yang
2024-04-17  8:19         ` David Hildenbrand
2024-04-17  9:01           ` Lance Yang
2024-04-17 10:53             ` Ryan Roberts
2024-04-16  3:34 ` [PATCH v7 2/3] mm/arm64: override " Lance Yang
2024-04-16 15:02   ` David Hildenbrand
2024-04-16 16:29   ` Ryan Roberts
2024-04-17  4:16     ` Lance Yang
2024-04-16  3:34 ` [PATCH v7 3/3] mm/madvise: optimize lazyfreeing with mTHP in madvise_free Lance Yang
2024-04-16 16:35   ` Ryan Roberts
2024-04-16 16:52     ` David Hildenbrand
2024-04-17  4:35       ` Lance Yang [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=CAK1f24nxfaRBaD+88shL75wOCQG8LbUu1QDWKGWitUuZ+epTDQ@mail.gmail.com \
    --to=ioworker0@gmail.com \
    --cc=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=fengwei.yin@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=minchan@kernel.org \
    --cc=peterx@redhat.com \
    --cc=ryan.roberts@arm.com \
    --cc=shy828301@gmail.com \
    --cc=songmuchun@bytedance.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=xiehuan09@gmail.com \
    --cc=zokeefe@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).