From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lgeamrelo03.lge.com (lgeamrelo03.lge.com [156.147.51.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64E95379973 for ; Thu, 29 Jan 2026 07:43:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.147.51.102 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769672617; cv=none; b=UNhKJ7p2qw+BfXd/YvRhnny2GRZ6dDVUoUcuJsUgkYc9+U1nXYjVmKNDbzAqb4JMXpgxPmK5n2ZtjRg0Eujk0egDXzqYKsiKG+DX/lVclzT24Wefi13l4kL4ywVXTrNoPHk2cnZoxv0BR60a8Y3DANxfIAA24kb4P0S1DW/KOy8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769672617; c=relaxed/simple; bh=0J46VINvafu3DEPdH2S5EEll7dj87KJvUM3MMVeb5kY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=E1Q6iDhDrK1BNTYhp8lmxxlHcSnSQu6zOb/N3JT9NcdQgGzA98FdOKGsXyJzUSU7tCRbE+iWpzcWh2SXC+3+CQBJ2APP0UtAi8KvdZCVS65c8kSJCGoZQUhz9LzcxAAHGPvQyp+keYCQ+WsLOq8/2UqXkQ1yx8BFRcQJPUhy9sE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lge.com; spf=pass smtp.mailfrom=lge.com; arc=none smtp.client-ip=156.147.51.102 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lge.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lge.com Received: from unknown (HELO yjaykim-PowerEdge-T330) (10.177.112.156) by 156.147.51.102 with ESMTP; 29 Jan 2026 16:28:31 +0900 X-Original-SENDERIP: 10.177.112.156 X-Original-MAILFROM: youngjun.park@lge.com Date: Thu, 29 Jan 2026 16:28:31 +0900 From: YoungJun Park To: Kairui Song Cc: linux-mm@kvack.org, Andrew Morton , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , Johannes Weiner , David Hildenbrand , Lorenzo Stoakes , linux-kernel@vger.kernel.org, Chris Li , Kairui Song Subject: Re: [PATCH v2 06/12] mm, swap: implement helpers for reserving data in the swap table Message-ID: References: <20260128-swap-table-p3-v2-0-fe0b67ef0215@tencent.com> <20260128-swap-table-p3-v2-6-fe0b67ef0215@tencent.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260128-swap-table-p3-v2-6-fe0b67ef0215@tencent.com> On Wed, Jan 28, 2026 at 05:28:30PM +0800, Kairui Song wrote: > From: Kairui Song > +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