linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Ryan Roberts <ryan.roberts@arm.com>,
	Lance Yang <ioworker0@gmail.com>,
	akpm@linux-foundation.org
Cc: 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: Tue, 16 Apr 2024 18:52:40 +0200	[thread overview]
Message-ID: <3a0d1d1c-97f4-4c9d-bc25-9de3f3659b67@redhat.com> (raw)
In-Reply-To: <d833efd7-28fd-42f0-83cd-e29f0f343909@arm.com>

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

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.

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2024-04-16 16:52 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 " 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 [this message]
2024-04-17  4:35       ` Lance Yang

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=3a0d1d1c-97f4-4c9d-bc25-9de3f3659b67@redhat.com \
    --to=david@redhat.com \
    --cc=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=fengwei.yin@intel.com \
    --cc=ioworker0@gmail.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