All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oscar Salvador <osalvador@suse.de>
To: David Hildenbrand <david@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Jonathan Corbet <corbet@lwn.net>
Subject: Re: [PATCH v1 2/6] fs/proc/task_mmu: don't indicate PM_MMAP_EXCLUSIVE without PM_PRESENT
Date: Mon, 10 Jun 2024 06:49:09 +0200	[thread overview]
Message-ID: <ZmaFxfQX3AVMIVkp@localhost.localdomain> (raw)
In-Reply-To: <20240607122357.115423-3-david@redhat.com>

On Fri, Jun 07, 2024 at 02:23:53PM +0200, David Hildenbrand wrote:
> Relying on the mapcount for non-present PTEs that reference pages
> doesn't make any sense: they are not accounted in the mapcount, so
> page_mapcount() == 1 won't return the result we actually want to know.
> 
> While we don't check the mapcount for migration entries already, we
> could end up checking it for swap, hwpoison, device exclusive, ...
> entries, which we really shouldn't.
> 
> There is one exception: device private entries, which we consider
> fake-present (e.g., incremented the mapcount). But we won't care about
> that for now for PM_MMAP_EXCLUSIVE, because indicating PM_SWAP for them
> although they are fake-present already sounds suspiciously wrong.
> 
> Let's never indicate PM_MMAP_EXCLUSIVE without PM_PRESENT.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>

Forgot to comment on something:

> @@ -1517,14 +1514,13 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end,
>  			if (pmd_swp_uffd_wp(pmd))
>  				flags |= PM_UFFD_WP;
>  			VM_BUG_ON(!is_pmd_migration_entry(pmd));
> -			migration = is_migration_entry(entry);
>  			page = pfn_swap_entry_to_page(entry);

We do not really need to get the page anymore here as that is the non-present
part.

Then we could get away without checking the flags as only page != NULL
would mean a present pmd.

Not that we gain much as this is far from being a hot-path, but just
saying..

-- 
Oscar Salvador
SUSE Labs

  parent reply	other threads:[~2024-06-10  4:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-07 12:23 [PATCH v1 0/6] fs/proc: move page_mapcount() to fs/proc/internal.h David Hildenbrand
2024-06-07 12:23 ` [PATCH v1 1/6] fs/proc/task_mmu: indicate PM_FILE for PMD-mapped file THP David Hildenbrand
2024-06-07 13:21   ` Kirill A . Shutemov
2024-06-07 13:36   ` Lance Yang
2024-06-10  4:32   ` Oscar Salvador
2024-06-07 12:23 ` [PATCH v1 2/6] fs/proc/task_mmu: don't indicate PM_MMAP_EXCLUSIVE without PM_PRESENT David Hildenbrand
2024-06-10  4:38   ` Oscar Salvador
2024-06-11  7:13     ` Oscar Salvador
2024-06-11 10:51       ` David Hildenbrand
2024-06-11 10:45     ` David Hildenbrand
2024-06-10  4:49   ` Oscar Salvador [this message]
2024-06-11 10:50     ` David Hildenbrand
2024-06-11 11:15       ` Oscar Salvador
2024-06-07 12:23 ` [PATCH v1 3/6] fs/proc/task_mmu: properly detect PM_MMAP_EXCLUSIVE per page of PMD-mapped THPs David Hildenbrand
2024-06-10  4:51   ` Oscar Salvador
2024-06-07 12:23 ` [PATCH v1 4/6] fs/proc/task_mmu: account non-present entries as "maybe shared, but no idea how often" David Hildenbrand
2024-06-07 12:23 ` [PATCH v1 5/6] fs/proc: move page_mapcount() to fs/proc/internal.h David Hildenbrand
2024-06-07 12:23 ` [PATCH v1 6/6] Documentation/admin-guide/mm/pagemap.rst: drop "Using pagemap to do something useful" David Hildenbrand
2024-06-07 13:18 ` [PATCH v1 0/6] fs/proc: move page_mapcount() to fs/proc/internal.h Oscar Salvador

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=ZmaFxfQX3AVMIVkp@localhost.localdomain \
    --to=osalvador@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=david@redhat.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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 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.