linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Ge Yang <yangge1116@126.com>, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, 21cnbao@gmail.com,
	baolin.wang@linux.alibaba.com, liuzixing@hygon.cn
Subject: Re: [PATCH V2] mm/gup: Clear the LRU flag of a page before adding to LRU batch
Date: Tue, 30 Jul 2024 09:45:15 +0200	[thread overview]
Message-ID: <9e018975-8a80-46a6-ab38-f3e2945c8878@redhat.com> (raw)
In-Reply-To: <79234eac-d7cc-424b-984d-b78861a5e862@126.com>

>> Looking at this in more detail, I wonder if we can turn that to
>>
>> if (!folio_test_clear_lru(folio))
>>       return;
>> folio_get(folio);
>>
>> In all cases? The caller must hold a reference, so this should be fine.
>>
> 
> Seems the caller madvise_free_pte_range(...), calling
> folio_mark_lazyfree(...), doesn't hold a reference on folio.
> 

If that would be the case and the folio could get freed concurrently, 
the folio_get(folio) would be completely broken.

In madvise_free_pte_range() we hold the PTL, so the folio cannot get 
freed concurrently.

folio_get() is only allowed when we are sure the folio cannot get freed 
concurrently, because we know there is a reference that cannot go away.


-- 
Cheers,

David / dhildenb



  reply	other threads:[~2024-07-30  7:45 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-22  6:48 yangge1116
2024-07-03  9:46 ` Barry Song
2024-07-03 11:15   ` Ge Yang
2024-07-03 12:02 ` David Hildenbrand
2024-07-04  6:24   ` Ge Yang
2024-07-27 22:33 ` Chris Li
2024-07-29  0:34   ` Ge Yang
2024-07-29  3:49   ` Ge Yang
2024-07-29 22:06     ` Chris Li
2024-08-02  1:51       ` Ge Yang
2024-08-02 20:18         ` Chris Li
2024-08-03  8:25           ` Ge Yang
2024-08-03 17:08             ` Yu Zhao
2024-08-03 20:03               ` Kairui Song
2024-08-04 12:21                 ` Kairui Song
2024-08-04 17:51                   ` Chris Li
2024-08-04 19:11                     ` Chris Li
2024-09-02 12:53                       ` Linux regression tracking (Thorsten Leemhuis)
2024-09-05  5:00                         ` Chris Li
2024-07-29 14:04 ` David Hildenbrand
2024-07-30  0:57   ` Ge Yang
2024-07-30  7:45     ` David Hildenbrand [this message]
2024-07-30  9:36       ` Ge Yang
2024-07-30  9:41         ` David Hildenbrand
2024-07-30  9:56           ` Ge Yang
2024-07-30  9:58             ` David Hildenbrand
2024-07-30 10:01               ` Ge Yang
2024-12-26  0:31 Andy amonte

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=9e018975-8a80-46a6-ab38-f3e2945c8878@redhat.com \
    --to=david@redhat.com \
    --cc=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liuzixing@hygon.cn \
    --cc=stable@vger.kernel.org \
    --cc=yangge1116@126.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