Linux-mm Archive mirror
 help / color / mirror / Atom feed
From: Ryan Roberts <ryan.roberts@arm.com>
To: David Hildenbrand <david@redhat.com>,
	Barry Song <21cnbao@gmail.com>,
	akpm@linux-foundation.org, linux-mm@kvack.org
Cc: baolin.wang@linux.alibaba.com, chrisl@kernel.org,
	hanchuanhua@oppo.com, hannes@cmpxchg.org, hughd@google.com,
	kasong@tencent.com, surenb@google.com, v-songbaohua@oppo.com,
	willy@infradead.org, xiang@kernel.org, ying.huang@intel.com,
	yosryahmed@google.com, yuzhao@google.com, ziy@nvidia.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/5] mm: swap_pte_batch: add an output argument to reture if all swap entries are exclusive
Date: Thu, 11 Apr 2024 16:36:16 +0100	[thread overview]
Message-ID: <ccbcbbb5-24eb-4503-ac7b-3171d39536e7@arm.com> (raw)
In-Reply-To: <a5a55919-46bc-4107-a0fc-14dc404e8c90@redhat.com>

On 11/04/2024 16:00, David Hildenbrand wrote:
> On 11.04.24 16:54, Ryan Roberts wrote:
>> On 09/04/2024 09:26, Barry Song wrote:
>>> From: Barry Song <v-songbaohua@oppo.com>
>>>
>>> Add a boolean argument named any_shared. If any of the swap entries are
>>> non-exclusive, set any_shared to true. The function do_swap_page() can
>>> then utilize this information to determine whether the entire large
>>> folio can be reused.
>>>
>>> Signed-off-by: Barry Song <v-songbaohua@oppo.com>
>>> ---
>>>   mm/internal.h | 9 ++++++++-
>>>   mm/madvise.c  | 2 +-
>>>   mm/memory.c   | 2 +-
>>>   3 files changed, 10 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/mm/internal.h b/mm/internal.h
>>> index 9d3250b4a08a..cae39c372bfc 100644
>>> --- a/mm/internal.h
>>> +++ b/mm/internal.h
>>> @@ -238,7 +238,8 @@ static inline pte_t pte_next_swp_offset(pte_t pte)
>>>    *
>>>    * Return: the number of table entries in the batch.
>>>    */
>>> -static inline int swap_pte_batch(pte_t *start_ptep, int max_nr, pte_t pte)
>>> +static inline int swap_pte_batch(pte_t *start_ptep, int max_nr, pte_t pte,
>>> +                bool *any_shared)
>>
>> Please update the docs in the comment above this for the new param; follow
>> folio_pte_batch()'s docs as a template.
>>
>>>   {
>>>       pte_t expected_pte = pte_next_swp_offset(pte);
>>>       const pte_t *end_ptep = start_ptep + max_nr;
>>> @@ -248,12 +249,18 @@ static inline int swap_pte_batch(pte_t *start_ptep, int
>>> max_nr, pte_t pte)
>>>       VM_WARN_ON(!is_swap_pte(pte));
>>>       VM_WARN_ON(non_swap_entry(pte_to_swp_entry(pte)));
>>>   +    if (any_shared)
>>> +        *any_shared |= !pte_swp_exclusive(pte);
>>
>> This is different from the approach in folio_pte_batch(). It inits *any_shared
>> to false and does NOT include the value of the first pte. I think that's odd,
>> personally and I prefer your approach. I'm not sure if there was a good reason
>> that David chose the other approach?
> 
> Because in my case calling code does
> 
> nr = folio_pte_batch(folio, addr, src_pte, pte, max_nr, flags,
>              &any_writable);
> 
> ...
> 
> if (any_writable)
>     pte = pte_mkwrite(pte, src_vma);
> 
> ...
> 
> and later checks in another function pte_write().
> 
> So if the common pattern is that the original PTE will be used for checks, then
> it doesn't make sense to unnecessary checks+setting for the first PTE.

Yep understood. And I think adopting your semantics for any_shared actually
simplifies the code in patch 4 too; I've just commented that.





  reply	other threads:[~2024-04-11 15:36 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-09  8:26 [PATCH v2 0/5] large folios swap-in: handle refault cases first Barry Song
2024-04-09  8:26 ` [PATCH v2 1/5] mm: swap: introduce swap_free_nr() for batched swap_free() Barry Song
2024-04-10 23:37   ` SeongJae Park
2024-04-11  1:27     ` Barry Song
2024-04-11 14:30   ` Ryan Roberts
2024-04-12  2:07     ` Chuanhua Han
2024-04-12 11:28       ` Ryan Roberts
2024-04-12 11:38         ` Chuanhua Han
2024-04-15  6:17   ` Huang, Ying
2024-04-15  7:04     ` Barry Song
2024-04-15  8:06       ` Barry Song
2024-04-15  8:19       ` Huang, Ying
2024-04-15  8:34         ` Barry Song
2024-04-15  8:51           ` Huang, Ying
2024-04-15  9:01             ` Barry Song
2024-04-16  1:40               ` Huang, Ying
2024-04-16  2:08                 ` Barry Song
2024-04-16  3:11                   ` Huang, Ying
2024-04-16  4:32                     ` Barry Song
2024-04-17  0:32                       ` Huang, Ying
2024-04-17  1:35                         ` Barry Song
2024-04-18  5:27                           ` Barry Song
2024-04-18  8:55                             ` Huang, Ying
2024-04-18  9:14                               ` Barry Song
2024-05-02 23:05                                 ` Barry Song
2024-04-09  8:26 ` [PATCH v2 2/5] mm: swap: make should_try_to_free_swap() support large-folio Barry Song
2024-04-15  7:11   ` Huang, Ying
2024-04-09  8:26 ` [PATCH v2 3/5] mm: swap_pte_batch: add an output argument to reture if all swap entries are exclusive Barry Song
2024-04-11 14:54   ` Ryan Roberts
2024-04-11 15:00     ` David Hildenbrand
2024-04-11 15:36       ` Ryan Roberts [this message]
2024-04-09  8:26 ` [PATCH v2 4/5] mm: swap: entirely map large folios found in swapcache Barry Song
2024-04-11 15:33   ` Ryan Roberts
2024-04-11 23:30     ` Barry Song
2024-04-12 11:31       ` Ryan Roberts
2024-04-15  8:37   ` Huang, Ying
2024-04-15  8:53     ` Barry Song
2024-04-16  2:25       ` Huang, Ying
2024-04-16  2:36         ` Barry Song
2024-04-16  2:39           ` Huang, Ying
2024-04-16  2:52             ` Barry Song
2024-04-16  3:17               ` Huang, Ying
2024-04-16  4:40                 ` Barry Song
2024-04-18  9:55           ` Barry Song
2024-04-09  8:26 ` [PATCH v2 5/5] mm: add per-order mTHP swpin_refault counter Barry Song
2024-04-10 23:15   ` SeongJae Park
2024-04-11  1:46     ` Barry Song
2024-04-11 16:14       ` SeongJae Park
2024-04-11 15:53   ` Ryan Roberts
2024-04-11 23:01     ` Barry Song
2024-04-17  0:45   ` Huang, Ying
2024-04-17  1:16     ` Barry Song
2024-04-17  1:38       ` Huang, Ying
2024-04-17  1:48         ` Barry Song

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=ccbcbbb5-24eb-4503-ac7b-3171d39536e7@arm.com \
    --to=ryan.roberts@arm.com \
    --cc=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=chrisl@kernel.org \
    --cc=david@redhat.com \
    --cc=hanchuanhua@oppo.com \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=kasong@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=surenb@google.com \
    --cc=v-songbaohua@oppo.com \
    --cc=willy@infradead.org \
    --cc=xiang@kernel.org \
    --cc=ying.huang@intel.com \
    --cc=yosryahmed@google.com \
    --cc=yuzhao@google.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 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 read-only IMAP folder(s) and NNTP newsgroup(s).