From: yangge1116 <yangge1116@126.com>
To: David Hildenbrand <david@redhat.com>,
Matthew Wilcox <willy@infradead.org>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>,
akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, liuzixing@hygon.cn
Subject: Re: [PATCH] mm/gup: don't check page lru flag before draining it
Date: Mon, 17 Jun 2024 17:50:27 +0800 [thread overview]
Message-ID: <7b69abe5-3782-965c-ec82-5baef84e2d06@126.com> (raw)
In-Reply-To: <a39c8602-3c9c-48fd-9bdb-2089ccccd6bc@redhat.com>
在 2024/6/12 下午3:32, David Hildenbrand 写道:
> On 11.06.24 13:20, yangge1116 wrote:
>>
>>
>> 在 2024/6/9 上午12:03, David Hildenbrand 写道:
>>> On 08.06.24 17:15, Matthew Wilcox wrote:
>>>> On Sat, Jun 08, 2024 at 12:38:49PM +0800, yangge1116 wrote:
>>>>> Can we add a PG_lru_batch flag to determine whether a page is in lru
>>>>> batch?
>>>>> If we can, seems this problem will be easier.
>>>>
>>>> Page flags are in short supply. You'd need a really good
>>>> justification.
>>>>
>>>
>>> A flag would not be able to handle the "part of multiple LRU batches"
>>> that should currently possible (when to clear the flag?). Well, if we
>>> have to keep supporting that. If we only to be part in a single LRU
>>> batch, a new flag could work and we could still allow isolating a folio
>>> from LRU while in some LRU batch.
>>
>> Yes, before adding a folio to LRU batch, check whether the folio has
>> been added. Add the folio to LRU batch only if the folio has not been
>> added.
>>
>>>
>>> If we could handle it using the existing flags, that would of course be
>>> better (wondering if we could store more information in the existing
>>> flags by using a different encoding for the different states).
>>
>> If a folio contains more than one page, the folio will not be added to
>> LRU batch. Can we use folio_test_large(folio) to filter?
>>
>> if (!folio_test_large(folio) && drain_allow) {
>> lru_add_drain_all();
>> drain_allow = false;
>> }
>
> I think we should do better than this, and not do arbitrary
> lru_add_drain_all() calls.
>
Thanks, I've got another idea.
If we add GUP_PIN_COUNTING_BIAS to folio's ref count before adding to
LRU batch, we can use folio_maybe_dma_pinned(folio) to check whether the
folio is in LRU batch. I wonder if it's feasible?
static void folio_batch_add_and_move(struct folio_batch *fbatch,
struct folio *folio, move_fn_t move_fn)
{
if (!folio_test_large(folio)) {
folio_ref_add(folio, GUP_PIN_COUNTING_BIAS);
if (folio_batch_add(fbatch, folio) && !lru_cache_disabled())
return;
}
folio_batch_move_lru(fbatch, move_fn);
}
if (!folio_test_large(folio) && folio_maybe_dma_pinned(folio) &&
drain_allow) {
lru_add_drain_all();
drain_allow = false;
}
next prev parent reply other threads:[~2024-06-17 9:51 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-04 10:48 yangge1116
2024-06-04 13:47 ` David Hildenbrand
2024-06-05 1:18 ` yangge1116
2024-06-05 9:41 ` David Hildenbrand
2024-06-05 9:53 ` David Hildenbrand
2024-06-05 11:37 ` Baolin Wang
2024-06-05 11:41 ` David Hildenbrand
2024-06-05 12:20 ` David Hildenbrand
2024-06-06 1:57 ` Baolin Wang
2024-06-06 7:56 ` David Hildenbrand
2024-06-08 4:38 ` yangge1116
2024-06-08 15:15 ` Matthew Wilcox
2024-06-08 16:03 ` David Hildenbrand
2024-06-11 11:20 ` yangge1116
2024-06-12 7:32 ` David Hildenbrand
2024-06-15 11:44 ` yangge1116
2024-06-17 9:50 ` yangge1116 [this message]
2024-06-17 9:52 ` David Hildenbrand
2024-06-17 11:22 ` yangge1116
2024-06-06 1:35 ` yangge1116
2024-06-06 7:39 ` David Hildenbrand
2024-06-06 8:50 ` yangge1116
-- strict thread matches above, loose matches on Subject: below --
2024-06-04 8:09 yangge1116
2024-06-04 8:56 ` Baolin Wang
2024-06-04 9:18 ` yangge1116
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=7b69abe5-3782-965c-ec82-5baef84e2d06@126.com \
--to=yangge1116@126.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liuzixing@hygon.cn \
--cc=willy@infradead.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