From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 02A2C2FF66A for ; Wed, 19 Aug 2026 15:46:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787154377; cv=none; b=pZji9q+zp8ltCVCv/ZX/LYGVRdRyNTHpYPF0z6l7a5L5wO5XM3WPMVF5tTiGtmFDzbJ0npvG66xDxFRLs6BMru92gQVQFZSkE2nwQlKOsoRAy0sThfc/AEbd/3sk12CpQnBrVsnqGLiHc7idgtOiqVridJlO+BK6hDv2oLwOrGE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787154377; c=relaxed/simple; bh=LxMZsIyTOBheJDXL90pjLA8EpyQbobvovE2+1hu1/bs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WNE2TLwBs8cAcNRswNvlZYQ6KC2XcULvZTuIsJYHZN51SwMdce5gwrpDlj35kujq4b+KHR+G7MPPwE0l6wzorxRdy2Qm1n+WiRBGDXe8roKKGrS17L2v90nIxOk1Okw+NU9H2KnuLujDJPRLSHyaovHUDvinsTZBOKgTGKgCy3Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TWFdlP3C; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TWFdlP3C" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DB5C1F000E9; Wed, 19 Aug 2026 15:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787154373; bh=FF4elongAZg7/M4cE7UQIpRWN92NIlJQ0JhAOJdFdWo=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=TWFdlP3C/pUSFUyS4z0RosyUzwRkBJ7n3YSwFwIspeM6G/dODiGy9Fl743wq4vWTg hWGfXFxMwQ6kmZuYua5g5r7n2e4gUxONQY3uNTZeXoQXYTCpyw+B2cOTefJjfnlEU7 dxGIlqVnMFMq5UJFtUyvH58joiDQxTU4P59ubz7coxHbyIscx82nO33iAAvfmWz2pc xORtnV3dSj5nIhU5BAx2z6dbYwBbjOCPjFmxW8W+FCI8F6aHJHEaF2XvGowk6cPwns 0Q8+D+Fy3ctbJao7MpQVVZPw+IeUcGjLI28eWBcx3RGINGClFg8WZY079Dx6TBYVs8 OMmeq6YU1QOPQ== Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfauth.ams.internal (Postfix) with ESMTP id A7CC11980075; Wed, 19 Aug 2026 11:46:05 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Wed, 19 Aug 2026 11:46:10 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFbQc/DxeUvuB0ahiyLxyyzwA7xvHem8nISRpZYhrkBn90a3JvF73UYxxLmxqP6gl HAD13bvVkUVYopLRFEOet4GfhE73tEpKnye8r+on/mQ2oQQ+M7IVk2wJUbxzISfh8HmLr8 ahbajLBp9qphjB2cSdNgglL7+2My4LcMn6kBE2LUDggd692MQSAE3K1URYroIcKnEegv41 javIZkHHFTEOx/alKV/4o+HgJgprEyz6hYOWI/vwwUWTNVTUBg+cM0wfOAhH6r03rR6cNx MGdC9xzMsa/69UOJgaYjdxb9+/s6rLmig4carmArzqPZKWvhju0iHPG4dUHViA8GYSEYY9 JUxg8/ABPgb3SMJZvYAycam3gpIJLA2cJmr5tssdDzRoaIjnMRqrafkG93Ta74eq0bASIR a5ky8gbmDFEnx4GAJw+laGz2qmrkp1rpRF0P/2Mkm8fNxtVhamxAjhnmWDCLPWgNJF/hoa 2NsDZz27A5VHlr9lZKZeaMStg5cgqTSyh+14cwQsEH+cWBnf/LXMnrv9AwSOeu8Dj8sTIT o/Kwtipfs7cc4rg0QVYOK5r5Iid7oCt58naSjMN4bYfNgJxYc8FSzOe3pJOnPn+RiVZaGs htoUGWSlG2RucRmSAAFVbcpVLQoNZYjl1xfBbyUxB3Y6455NAT/VzUDJYM+A X-ME-Proxy: Feedback-ID: i10464835:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 19 Aug 2026 11:46:04 -0400 (EDT) Date: Wed, 19 Aug 2026 16:46:03 +0100 From: Kiryl Shutsemau To: Usama Arif Cc: Andrew Morton , david@kernel.org, chrisl@kernel.org, kasong@tencent.com, ljs@kernel.org, ziy@nvidia.com, linux-mm@kvack.org, ying.huang@linux.alibaba.com, Baoquan He , willy@infradead.org, youngjun.park@lge.com, hannes@cmpxchg.org, riel@surriel.com, shakeel.butt@linux.dev, alex@ghiti.fr, baohua@kernel.org, dev.jain@arm.com, baolin.wang@linux.alibaba.com, Nico Pache , "Liam R. Howlett" , ryan.roberts@arm.com, Vlastimil Babka , lance.yang@linux.dev, linux-kernel@vger.kernel.org, nphamcs@gmail.com, shikemeng@huaweicloud.com, yosry@kernel.org, kernel-team@meta.com Subject: Re: [PATCH v6 04/12] mm: handle PMD swap entries in fork path Message-ID: References: <20260818131202.494754-1-usama.arif@linux.dev> <20260818131202.494754-5-usama.arif@linux.dev> 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: <20260818131202.494754-5-usama.arif@linux.dev> On Tue, Aug 18, 2026 at 06:09:45AM -0700, Usama Arif wrote: > Teach copy_huge_pmd()/copy_huge_non_present_pmd() about swap entries, > mirroring copy_nonpresent_pte(). > > swap_dup_entry_direct() gains a nr parameter (and is renamed to > swap_dup_entries_direct()) so it can duplicate a contiguous range of > swap slots in one call, matching the existing > swap_put_entries_direct(entry, nr) API. Existing callers pass 1. ... > @@ -3955,7 +3967,7 @@ int swap_dup_entry_direct(swp_entry_t entry) > */ > VM_WARN_ON_ONCE(!swap_entry_swapped(si, entry)); > > - return swap_dup_entries_cluster(si, swp_offset(entry), 1); > + return swap_dup_entries_cluster(si, swp_offset(entry), nr); > } swap_put_entries_direct() bounds end_offset against si->max and walks the range cluster by cluster. Here nr goes straight into the cluster helper, which does ci_end = offset % SWAPFILE_CLUSTER + nr and indexes up to ci_end - 1. __swap_table_get() VM_WARN_ON_ONCE()s on off >= SWAPFILE_CLUSTER, but still reads table[off]. So is the range required to sit inside one cluster? I assume it works out because a PMD swap entry is cluster-aligned and SWAPFILE_CLUSTER == HPAGE_PMD_NR, but I don't see it stated anywhere. -- Kiryl Shutsemau / Kirill A. Shutemov