All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yang Shi <shy828301@gmail.com>
To: Hugh Dickins <hughd@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Alistair Popple <apopple@nvidia.com>,
	Jason Gunthorpe <jgg@nvidia.com>,
	Ralph Campbell <rcampbell@nvidia.com>,
	Christoph Hellwig <hch@lst.de>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Shakeel Butt <shakeelb@google.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux MM <linux-mm@kvack.org>
Subject: Re: [PATCH 1/4] mm/rmap: fix comments left over from recent changes
Date: Wed, 7 Jul 2021 14:26:36 -0700	[thread overview]
Message-ID: <CAHbLzkpRfJOssBaNpch1OjJbgLc-BbSa+N9Ntay2NixNiQb0pg@mail.gmail.com> (raw)
In-Reply-To: <563ce5b2-7a44-5b4d-1dfd-59a0e65932a9@google.com>

On Wed, Jul 7, 2021 at 1:06 PM Hugh Dickins <hughd@google.com> wrote:
>
> Parallel developments in mm/rmap.c have left behind some out-of-date
> comments: try_to_migrate_one() also accepts TTU_SYNC (already commented
> in try_to_migrate() itself), and try_to_migrate() returns nothing at all.
>
> TTU_SPLIT_FREEZE has just been deleted, so reword the comment about it in
> mm/huge_memory.c; and TTU_IGNORE_ACCESS was removed in 5.11, so delete

I just realized this. Currently unmap_page() just unmaps file pages
when splitting THP. But it seems this may cause some trouble for page
cache speculative get for the below case IIUC. Am I missing something?

    CPU A                  CPU B
unmap_page()
...
freeze refcount
                              find_get_page() ->
                                  __page_cache_add_speculative() ->
                                      VM_BUG_ON_PAGE(page_count(page)
== 0, page); //When CONFIG_TINY_RCU is enabled


The race is acceptable, I think we could replace the VM_BUG_ON to
page_ref_add_unless(), just like !CONFIG_TINY_RCU case.


> the "recently referenced" comment from try_to_unmap_one() (once upon a
> time the comment was near the removed codeblock, but they drifted apart).
>
> Signed-off-by: Hugh Dickins <hughd@google.com>
> ---
>  mm/huge_memory.c | 2 +-
>  mm/rmap.c        | 7 +------
>  2 files changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 8b731d53e9f4..afff3ac87067 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -2331,7 +2331,7 @@ static void remap_page(struct page *page, unsigned int nr)
>  {
>         int i;
>
> -       /* If TTU_SPLIT_FREEZE is ever extended to file, remove this check */
> +       /* If unmap_page() uses try_to_migrate() on file, remove this check */
>         if (!PageAnon(page))
>                 return;
>         if (PageTransHuge(page)) {
> diff --git a/mm/rmap.c b/mm/rmap.c
> index 37c24672125c..746013e282c3 100644
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -1439,8 +1439,6 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
>         while (page_vma_mapped_walk(&pvmw)) {
>                 /*
>                  * If the page is mlock()d, we cannot swap it out.
> -                * If it's recently referenced (perhaps page_referenced
> -                * skipped over this mm) then we should reactivate it.
>                  */
>                 if (!(flags & TTU_IGNORE_MLOCK)) {
>                         if (vma->vm_flags & VM_LOCKED) {
> @@ -1687,8 +1685,7 @@ void try_to_unmap(struct page *page, enum ttu_flags flags)
>   * @arg: enum ttu_flags will be passed to this argument.
>   *
>   * If TTU_SPLIT_HUGE_PMD is specified any PMD mappings will be split into PTEs
> - * containing migration entries. This and TTU_RMAP_LOCKED are the only supported
> - * flags.
> + * containing migration entries.
>   */
>  static bool try_to_migrate_one(struct page *page, struct vm_area_struct *vma,
>                      unsigned long address, void *arg)
> @@ -1928,8 +1925,6 @@ static bool try_to_migrate_one(struct page *page, struct vm_area_struct *vma,
>   *
>   * Tries to remove all the page table entries which are mapping this page and
>   * replace them with special swap entries. Caller must hold the page lock.
> - *
> - * If is successful, return true. Otherwise, false.
>   */
>  void try_to_migrate(struct page *page, enum ttu_flags flags)
>  {
> --
> 2.26.2
>

  parent reply	other threads:[~2021-07-07 21:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-07 20:06 [PATCH 1/4] mm/rmap: fix comments left over from recent changes Hugh Dickins
2021-07-07 20:06 ` Hugh Dickins
2021-07-07 20:08 ` [PATCH 2/4] mm/rmap: fix old bug: munlocking THP missed other mlocks Hugh Dickins
2021-07-07 20:08   ` Hugh Dickins
2021-07-07 20:53   ` Shakeel Butt
2021-07-07 20:53     ` Shakeel Butt
2021-07-08 13:58   ` Kirill A. Shutemov
2021-07-09  2:50     ` Hugh Dickins
2021-07-09  2:50       ` Hugh Dickins
2021-07-09 10:56       ` Kirill A. Shutemov
2021-07-07 20:11 ` [PATCH 3/4] mm/rmap: fix new bug: premature return from page_mlock_one() Hugh Dickins
2021-07-07 20:11   ` Hugh Dickins
2021-07-07 20:22   ` Shakeel Butt
2021-07-07 20:22     ` Shakeel Butt
2021-07-07 23:14   ` Alistair Popple
2021-07-07 20:13 ` [PATCH 4/4] mm/rmap: try_to_migrate() skip zone_device !device_private Hugh Dickins
2021-07-07 20:13   ` Hugh Dickins
2021-07-07 20:54   ` Shakeel Butt
2021-07-07 20:54     ` Shakeel Butt
2021-07-07 23:25   ` Alistair Popple
2021-07-07 20:22 ` [PATCH 1/4] mm/rmap: fix comments left over from recent changes Shakeel Butt
2021-07-07 20:22   ` Shakeel Butt
2021-07-07 21:26 ` Yang Shi [this message]
2021-07-07 21:26   ` Yang Shi
2021-07-07 21:29   ` Yang Shi
2021-07-07 21:29     ` Yang Shi
2021-07-07 23:34 ` Alistair Popple

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=CAHbLzkpRfJOssBaNpch1OjJbgLc-BbSa+N9Ntay2NixNiQb0pg@mail.gmail.com \
    --to=shy828301@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=hch@lst.de \
    --cc=hughd@google.com \
    --cc=jgg@nvidia.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rcampbell@nvidia.com \
    --cc=shakeelb@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.