[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aXsMHy0rNreGmnLS@yjaykim-PowerEdge-T330>
Date: Thu, 29 Jan 2026 16:28:31 +0900
From: YoungJun Park <youngjun.park@....com>
To: Kairui Song <ryncsn@...il.com>
Cc: linux-mm@...ck.org, Andrew Morton <akpm@...ux-foundation.org>,
Kemeng Shi <shikemeng@...weicloud.com>,
Nhat Pham <nphamcs@...il.com>, Baoquan He <bhe@...hat.com>,
Barry Song <baohua@...nel.org>,
Johannes Weiner <hannes@...xchg.org>,
David Hildenbrand <david@...nel.org>,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
linux-kernel@...r.kernel.org, Chris Li <chrisl@...nel.org>,
Kairui Song <kasong@...cent.com>
Subject: Re: [PATCH v2 06/12] mm, swap: implement helpers for reserving data
in the swap table
On Wed, Jan 28, 2026 at 05:28:30PM +0800, Kairui Song wrote:
> From: Kairui Song <kasong@...cent.com>
> +static inline bool swp_tb_is_countable(unsigned long swp_tb)
> +{
> + return (swp_tb_is_shadow(swp_tb) || swp_tb_is_folio(swp_tb) ||
> + swp_tb_is_null(swp_tb));
> +}
What do you think about simplifying swp_tb_is_countable by just checking
!swp_tb_is_bad(swp_tb)?
Since this function appears to be called frequently, reducing the number of
comparisons would be beneficial for performance. If validation is
necessary for debugging perhaps we could introduce a separate version for debugging
purposes.
> +static inline int swp_tb_get_count(unsigned long swp_tb)
> +{
> + if (swp_tb_is_countable(swp_tb))
> + return __swp_tb_get_count(swp_tb);
> + return -EINVAL;
> }
Or, could we simply drop the check in swp_tb_get_count and call
__swp_tb_get_count directly?
If we define SWP_TB_BAD to have 0 in the count bits (MSB), it will
naturally yield a count of 0.
Thanks!
Youngjun Park
Powered by blists - more mailing lists