From patchwork Mon Aug 12 07:42:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13760269 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78417C52D7C for ; Mon, 12 Aug 2024 07:42:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F6CE6B00A6; Mon, 12 Aug 2024 03:42:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 133D46B00A5; Mon, 12 Aug 2024 03:42:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 014F66B00A4; Mon, 12 Aug 2024 03:42:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D75746B00A2 for ; Mon, 12 Aug 2024 03:42:28 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 83CDB1608FE for ; Mon, 12 Aug 2024 07:42:28 +0000 (UTC) X-FDA: 82442800776.30.FF2F928 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by imf20.hostedemail.com (Postfix) with ESMTP id 88AC51C0020 for ; Mon, 12 Aug 2024 07:42:26 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b="TN9Bti/P"; spf=pass (imf20.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723448492; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=kqzOiSUcg37jmhpXPpVX6LPzNgjUKcTxKBX3p6fMXZU=; b=Rp2vWs79hI8kRsGQDoqdqlQ1QMm/4ObiPcA+gYu7CEXL40QSnK93oiMGTvqPeg9G42lfzh GOy2OAU9dzGvW60Cn+iQGPpAVxbuljJQKQ6Qn1BJR2LlsZYfhLwcpgX9W2bfcmHSsVxaIl t9K6UerxYy4EWBKsB4CM7ubxVG9Hbvc= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b="TN9Bti/P"; spf=pass (imf20.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723448492; a=rsa-sha256; cv=none; b=uo/GnyG4QMnIKCDihIx8nnp6WvktAX/6Eb3RBdCwt/jyksoTH2YqMn3cQpYuO/SvU6t4sz rfvMdD/gBbMlBm8LBjXQnIOpBu1okJJtbt2FFlBvbQLZ3k6Lj5pMFgW0bRcwejCLzHHPGq BxOtzL1lbHdZGXGLE5PbEtvph1JrLis= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1723448543; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=kqzOiSUcg37jmhpXPpVX6LPzNgjUKcTxKBX3p6fMXZU=; b=TN9Bti/PbtYAdna4Ta+AHAUoPUMngHXCbi9/ycTQjr9DtoiV3uBdqqaaEASO4xr+sYFPHWX6YAOxcbEuJhJYFZf04I29SI2qDouWWRLEeOqfKO9Ftfk0ucjp6UED4UyzRDY9ziwRlKJQhRYNwfUYnz8UEj8E1FYRegX7Kc1drjA= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WCbU5uG_1723448541) by smtp.aliyun-inc.com; Mon, 12 Aug 2024 15:42:22 +0800 From: Baolin Wang To: akpm@linux-foundation.org, hughd@google.com Cc: willy@infradead.org, david@redhat.com, wangkefeng.wang@huawei.com, chrisl@kernel.org, ying.huang@intel.com, 21cnbao@gmail.com, ryan.roberts@arm.com, shy828301@gmail.com, ziy@nvidia.com, ioworker0@gmail.com, da.gomez@samsung.com, p.raghav@samsung.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 4/9] mm: filemap: use xa_get_order() to get the swap entry order Date: Mon, 12 Aug 2024 15:42:05 +0800 Message-Id: <6876d55145c1cc80e79df7884aa3a62e397b101d.1723434324.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Stat-Signature: 8fjqgge9y7hmmc34akdzi17uub9b9ui9 X-Rspam-User: X-Rspamd-Queue-Id: 88AC51C0020 X-Rspamd-Server: rspam02 X-HE-Tag: 1723448546-310816 X-HE-Meta: U2FsdGVkX1+vl2+YQPZiIUeeJ/3zhiya6dqd8ZqV3nN6TN+DaaLhn2BmXxniH8aB8mYukRGfRpu/aT9rKVSyk3MJWPXof/7oavrKyFbzTS0o7/+JZc5Gns2Trcie50kLqMj4GATRNb7ghC1qaFEO6jmYgONEUdZi88SWJxwbPYHKSaxnB9MgWreZnpj+9T60xmuzg/MsrJJ3n+R7TKFbShLU6euCIXl2hctCc9PC+ujJyF630ecsKASxslceEIA0S/0WcAnyNZsEyhgreC9OTjD8pXLhOo/UJm8QKvIRkcUYRKUd0JZqM5BCfVrcpo7E2JFwtRCbO8I4T+TILxKhR7dtiIqc/2R0O/xLNZ75FBFVHkfsqrkawpTt3xeuJZQpLgk9aOWuIAVmQ51IkXB5U+Xnmt8kVAgWVEpjglVZjlHGktsUKtweNOCdxlKFpqARBGQ0DZrcZQ6rKJN8SKkYTA8NiFkLeTxfU2dziFoxkw+Y19QAc7mQ4htGTp8/eVBfnjgc0kmRmz5rkDNj67fYAKLRZsdaocvCFCvXAsPsFEZ5cSjp1JGP32Zj6qlMeTPVQyOIMpHm+17nkESwHbfN7uM+Pb1ieCG7KyG0BEPDFqWnw+gWFlK3GdcS1szZCrdUSWJNKZfAQCHJJUEi+9c10lQSpig3T1sP15I67awhQpqDbvtJeHd9NxJlEyYDJkbTrn0CKgobyWxYcCdA9bAPcmd8FOBf1xNFdJ1TOX0FOd7VC/yKIhUUOKDORPI1IXOOIC5jaJADcCCGSgdKBfQnR8eTQdKIGTkd8yF3XVdY1j4wStv9bpxR3QLbxl6Jn6wZ4/8hGx/5jX3KlHucM1kUUCAZ0esQWfENgyrgKHVA1ouWkI86+p6FMCX8zBDPoWObAr2KwQvkunfxhB+52ut3SqiodAIBsIS0G4KHridv5vI5vK1+/Mz9+X0q9Jgarz6hUyuHRQ+Yfd9H+JIZbBp B+TS7AKw w5T+HE0g+vvm5Z9kvxoZz5NJCbG7BilYNhaTDuTWSYMcff30coKFnvsgznJABvHdr09BZehM3CQED2hGitzNrTiHopt3W58eYwXHDQfjQeO/vxLXlBDGvzwB3QG7Zw4HHQIL2tAlJ1SCzNdAjsGUYIZh8A0x8/0syjkodo9cjl2tgOdZR26UxRMKsKUESjCcL2j+hDuLv9ZAugEHt+voNbHNT4tKFw5uKBqbnXIkNh/LxSstJ/ptrL6lJ/w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In the following patches, shmem will support the swap out of large folios, which means the shmem mappings may contain large order swap entries, so using xa_get_order() to get the folio order of the shmem swap entry to update the '*start' correctly. Signed-off-by: Baolin Wang Signed-off-by: Hugh Dickins --- mm/filemap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index 4130be74f6fd..4c312aab8b1f 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2056,6 +2056,8 @@ unsigned find_get_entries(struct address_space *mapping, pgoff_t *start, folio = fbatch->folios[idx]; if (!xa_is_value(folio)) nr = folio_nr_pages(folio); + else + nr = 1 << xa_get_order(&mapping->i_pages, indices[idx]); *start = indices[idx] + nr; } return folio_batch_count(fbatch); @@ -2120,6 +2122,8 @@ unsigned find_lock_entries(struct address_space *mapping, pgoff_t *start, folio = fbatch->folios[idx]; if (!xa_is_value(folio)) nr = folio_nr_pages(folio); + else + nr = 1 << xa_get_order(&mapping->i_pages, indices[idx]); *start = indices[idx] + nr; } return folio_batch_count(fbatch);