[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJD7tkYK3ecG7cuJcxSF-cw-0K=JPnoE3L4Y=7xUp_R8apqueg@mail.gmail.com>
Date: Wed, 4 Sep 2024 16:57:11 -0700
From: Yosry Ahmed <yosryahmed@...gle.com>
To: Barry Song <21cnbao@...il.com>
Cc: Usama Arif <usamaarif642@...il.com>, akpm@...ux-foundation.org,
chengming.zhou@...ux.dev, david@...hat.com, hannes@...xchg.org,
hughd@...gle.com, kernel-team@...a.com, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, nphamcs@...il.com, shakeel.butt@...ux.dev,
willy@...radead.org, ying.huang@...el.com, hanchuanhua@...o.com
Subject: Re: [PATCH v4 1/2] mm: store zero pages to be swapped out in a bitmap
[..]
> well. i feel i have a much cheaper way to implement this, which
> can entirely iteration even in your original code:
>
> +/*
> + * Return the number of entries which are zero-filled according to
> + * swap_info_struct->zeromap. It isn't precise if the return value
> + * is 1 for nr > 1. In this case, it means entries have inconsistent
> + * zeromap.
> + */
> +static inline unsigned int swap_zeromap_entries_count(swp_entry_t
> entry, int nr)
FWIW I am not really a fan of the count() function not returning an
actual count. I think an enum with three states is more appropriate
here, and renaming the function to swap_zeromap_entries_check() or
similar.
> +{
> + struct swap_info_struct *sis = swp_swap_info(entry);
> + unsigned long start = swp_offset(entry);
> + unsigned long end = start + nr;
> + unsigned long idx = 0;
> +
> + idx = find_next_bit(sis->zeromap, end, start);
> + if (idx == end)
> + return 0;
> + if (idx > start)
> + return 1;
> + return nr;
> +}
> +
>
>
Powered by blists - more mailing lists