From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) (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 98977EEBB for ; Tue, 2 Dec 2025 07:05:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.119 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764659114; cv=none; b=kn9zRAPmf9tClJzQW74/qC/kBti4kPVnJBlwluuw7z0PdaMsznS4Az03NyCf7Aj5YuYgqxsgOgRKUTq46T1tc8CllGqc4OeKkXoW5P+p0H/WE8uxbWqg1cIpSlCKlpDdvhV1fD7dK005SOS7o0MYSViy/EugnWonOvuJCod4GKA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764659114; c=relaxed/simple; bh=lcU8Zx49YX0eYKxhqlMD87nc+nRW2rrVfFK4UxKXN3A=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=BXtiqBKqbHndk69gBUu6w51GyFZXoyjbrH9ijz8PEyJxH5ZW/JpGqyTBxD8Z98UU3skWKtWSKrCkZz7W8Iw7PLUZ0grDGcRYlYduASSRls1Qpy2QhcLKNgywHkNCnQALjakc1NB2GXp0LZZuJ3ALKd3ysJR60W3JjiDXR+hAG1k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=nXDf7hUc; arc=none smtp.client-ip=115.124.30.119 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="nXDf7hUc" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1764659101; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=VvDgagAu6wE9yEAqSHaqkrBQJzEb+xI9kOIEYjd5Lf8=; b=nXDf7hUcd4RhiQrmMakCgU0mLJ3Y+uA7xel1XsprYpehaa7AGvi8uKsrab4t0O4dA2dObPxS64RFgY+eTy01MukEEoR5TjTssOo2AeaJwMcH/Xh/3T1CF+QO6+27Z3UcXpL+n3iYcxjSjeMMatk9FpzuCi+iFoFeP87Tk61k6w4= Received: from 30.74.144.119(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WtvRP2I_1764659098 cluster:ay36) by smtp.aliyun-inc.com; Tue, 02 Dec 2025 15:04:59 +0800 Message-ID: <1937798a-1f63-44ea-8c30-1040174eb1c9@linux.alibaba.com> Date: Tue, 2 Dec 2025 15:04:58 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 08/19] mm/shmem, swap: remove SWAP_MAP_SHMEM To: Kairui Song , linux-mm@kvack.org Cc: Andrew Morton , Baoquan He , Barry Song , Chris Li , Nhat Pham , Yosry Ahmed , David Hildenbrand , Johannes Weiner , Youngjun Park , Hugh Dickins , Ying Huang , Kemeng Shi , Lorenzo Stoakes , "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, Kairui Song References: <20251125-swap-table-p2-v3-0-33f54f707a5c@tencent.com> <20251125-swap-table-p2-v3-8-33f54f707a5c@tencent.com> From: Baolin Wang In-Reply-To: <20251125-swap-table-p2-v3-8-33f54f707a5c@tencent.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2025/11/25 03:13, Kairui Song wrote: > From: Nhat Pham > > The SWAP_MAP_SHMEM state was introduced in the commit aaa468653b4a > ("swap_info: note SWAP_MAP_SHMEM"), to quickly determine if a swap entry > belongs to shmem during swapoff. > > However, swapoff has since been rewritten in the commit b56a2d8af914 > ("mm: rid swapoff of quadratic complexity"). Now having swap count == > SWAP_MAP_SHMEM value is basically the same as having swap count == 1, > and swap_shmem_alloc() behaves analogously to swap_duplicate(). The only > difference of note is that swap_shmem_alloc() does not check for > -ENOMEM returned from __swap_duplicate(), but it is OK because shmem > never re-duplicates any swap entry it owns. This will stil be safe if we > use (batched) swap_duplicate() instead. > > This commit adds swap_duplicate_nr(), the batched variant of > swap_duplicate(), and removes the SWAP_MAP_SHMEM state and the > associated swap_shmem_alloc() helper to simplify the state machine (both > mentally and in terms of actual code). We will also have an extra > state/special value that can be repurposed (for swap entries that never > gets re-duplicated). > > Signed-off-by: Nhat Pham > Signed-off-by: Kairui Song > --- LGTM. Thanks. Reviewed-by: Baolin Wang Tested-by: Baolin Wang