From: "Huang, Ying" <ying.huang@intel.com>
To: Nhat Pham <nphamcs@gmail.com>
Cc: akpm@linux-foundation.org, hannes@cmpxchg.org,
yosryahmed@google.com, hughd@google.com,
shakeel.butt@linux.dev, ryan.roberts@arm.com,
chrisl@kernel.org, david@redhat.com, kasong@tencent.com,
willy@infradead.org, viro@zeniv.linux.org.uk,
baohua@kernel.org, chengming.zhou@linux.dev,
v-songbaohua@oppo.com, linux-mm@kvack.org,
kernel-team@meta.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/1] swap: shmem: remove SWAP_MAP_SHMEM
Date: Fri, 11 Oct 2024 14:35:55 +0800 [thread overview]
Message-ID: <87cyk79mes.fsf@yhuang6-desk2.ccr.corp.intel.com> (raw)
In-Reply-To: <20241002012042.2753174-2-nphamcs@gmail.com> (Nhat Pham's message of "Tue, 1 Oct 2024 18:20:42 -0700")
Nhat Pham <nphamcs@gmail.com> writes:
[snip]
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index 0cded32414a1..9bb94e618914 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -1381,12 +1381,6 @@ static unsigned char __swap_entry_free_locked(struct swap_info_struct *si,
> if (usage == SWAP_HAS_CACHE) {
> VM_BUG_ON(!has_cache);
> has_cache = 0;
> - } else if (count == SWAP_MAP_SHMEM) {
> - /*
> - * Or we could insist on shmem.c using a special
> - * swap_shmem_free() and free_shmem_swap_and_cache()...
> - */
> - count = 0;
> } else if ((count & ~COUNT_CONTINUED) <= SWAP_MAP_MAX) {
> if (count == COUNT_CONTINUED) {
> if (swap_count_continued(si, offset, count))
> @@ -3626,7 +3620,6 @@ static int __swap_duplicate(swp_entry_t entry, unsigned char usage, int nr)
>
> offset = swp_offset(entry);
> VM_WARN_ON(nr > SWAPFILE_CLUSTER - offset % SWAPFILE_CLUSTER);
> - VM_WARN_ON(usage == 1 && nr > 1);
> ci = lock_cluster_or_swap_info(si, offset);
>
> err = 0;
> @@ -3652,6 +3645,13 @@ static int __swap_duplicate(swp_entry_t entry, unsigned char usage, int nr)
> err = -EEXIST;
> } else if ((count & ~COUNT_CONTINUED) > SWAP_MAP_MAX) {
> err = -EINVAL;
> + } else {
> + /*
> + * The only swap_duplicate_nr() caller that passes nr > 1 is shmem,
> + * who never re-duplicates any swap entry it owns. So this should
> + * not happen.
> + */
> + VM_WARN_ON(nr > 1 && (count & ~COUNT_CONTINUED) == SWAP_MAP_MAX);
Why not
VM_WARN_ON_ONCE(nr > 1 && count);
?
IIUC, count == 0 is always true for shmem swap entry allocation. Then
developers who use __swap_duplicate() with nr > 1 without noticing the
unsupported feature can get warning during development immediately.
"(count & ~COUNT_CONTINUED) == SWAP_MAP_MAX" is hard to be triggered
during common swap test.
> }
>
> if (err)
> @@ -3686,27 +3686,28 @@ static int __swap_duplicate(swp_entry_t entry, unsigned char usage, int nr)
> return err;
> }
[snip]
--
Best Regards,
Huang, Ying
next prev parent reply other threads:[~2024-10-11 6:39 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-02 1:20 [PATCH v2 0/1] " Nhat Pham
2024-10-02 1:20 ` [PATCH v2 1/1] swap: shmem: " Nhat Pham
2024-10-02 1:33 ` Yosry Ahmed
2024-10-02 1:58 ` Nhat Pham
2024-10-02 2:04 ` Nhat Pham
2024-10-02 2:06 ` Yosry Ahmed
2024-10-02 2:13 ` Yosry Ahmed
2024-10-02 18:01 ` Nhat Pham
2024-10-02 18:06 ` Yosry Ahmed
2024-10-02 2:11 ` Yosry Ahmed
2024-10-11 6:35 ` Huang, Ying [this message]
2024-10-11 15:56 ` Nhat Pham
2024-10-02 1:22 ` [PATCH v2 0/1] " Nhat Pham
2024-10-02 1:25 ` Nhat Pham
2024-10-08 9:27 ` Baolin Wang
2024-10-10 8:53 ` Baolin Wang
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=87cyk79mes.fsf@yhuang6-desk2.ccr.corp.intel.com \
--to=ying.huang@intel.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=chengming.zhou@linux.dev \
--cc=chrisl@kernel.org \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=kasong@tencent.com \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=ryan.roberts@arm.com \
--cc=shakeel.butt@linux.dev \
--cc=v-songbaohua@oppo.com \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
--cc=yosryahmed@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox