[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87cyk79mes.fsf@yhuang6-desk2.ccr.corp.intel.com>
Date: Fri, 11 Oct 2024 14:35:55 +0800
From: "Huang, Ying" <ying.huang@...el.com>
To: Nhat Pham <nphamcs@...il.com>
Cc: akpm@...ux-foundation.org, hannes@...xchg.org, yosryahmed@...gle.com,
hughd@...gle.com, shakeel.butt@...ux.dev, ryan.roberts@....com,
chrisl@...nel.org, david@...hat.com, kasong@...cent.com,
willy@...radead.org, viro@...iv.linux.org.uk, baohua@...nel.org,
chengming.zhou@...ux.dev, v-songbaohua@...o.com, linux-mm@...ck.org,
kernel-team@...a.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/1] swap: shmem: remove SWAP_MAP_SHMEM
Nhat Pham <nphamcs@...il.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
Powered by blists - more mailing lists