From patchwork Thu Jun 6 11:58:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13688380 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 8AB8DC25B75 for ; Thu, 6 Jun 2024 11:59:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4ECC16B00A0; Thu, 6 Jun 2024 07:59:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 49A1E6B00A1; Thu, 6 Jun 2024 07:59:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33AB66B00A2; Thu, 6 Jun 2024 07:59:21 -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 119AE6B00A0 for ; Thu, 6 Jun 2024 07:59:21 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B95341A0473 for ; Thu, 6 Jun 2024 11:59:20 +0000 (UTC) X-FDA: 82200318480.09.37F1FAE Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) by imf25.hostedemail.com (Postfix) with ESMTP id B04B7A0003 for ; Thu, 6 Jun 2024 11:59:18 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=xM+MAmJZ; spf=pass (imf25.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.101 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=1717675159; a=rsa-sha256; cv=none; b=d5+FNBfuGbvPBq+NLiSdXVgMJffbXsSgpcCzd2JZjURwPb2r7KP4hMn7WL7XEH5LkZgEv6 hKcIyqCvEbxbD5HYcXcNfR3rJGT6lmfGBbjxbjFFLOfeHZeN+USeZfcsB2EVF+1QYhzenL 1UU6zElLhxVDff5sp7jKCuLoYmtns8U= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=xM+MAmJZ; spf=pass (imf25.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.101 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=1717675159; 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=Hca3mk3oMk8MShvCe5e0YS4gCuYYhtWQR6R7w3SOo+g=; b=7XkX8Y24JF2yMXGhdspqavXWc8ojcyVy+dsQABwbLtvlynx6k0QjedTfk8VeiFNZVOGwFg wJ+DDq9CkUkTVo2Kf+KdlPwRi/zPLslF/+5hKVt21a95Dx/WNGfD7YdDWTeqrdEcLY/nk4 fzlwW7bojvAbM0dr0qgMfW/gY3VNpOE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1717675156; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=Hca3mk3oMk8MShvCe5e0YS4gCuYYhtWQR6R7w3SOo+g=; b=xM+MAmJZd/2MaO81nJ5EfVwaYed064+ao9HZyGpPISym6h0Qh+J8hEaUYpqteCDhE5D6IKq7cCxVz6Ip8aKzQVbcBu21NJIYqVcsGAxd9iMr6L19vE06garvORzou1fR2y5O757O5r0sOOHqiDsqYdhM7bKMp1PFvE7ULlH6ZJg= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037067113;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=17;SR=0;TI=SMTPD_---0W7y5mvU_1717675154; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W7y5mvU_1717675154) by smtp.aliyun-inc.com; Thu, 06 Jun 2024 19:59:15 +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 4/7] mm: shmem: extend shmem_partial_swap_usage() to support large folio swap Date: Thu, 6 Jun 2024 19:58:54 +0800 Message-Id: <358924679107339e6b17a5d8b1b2e10ae6306227.1717673614.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: B04B7A0003 X-Stat-Signature: fhfosmrtuu7erp1u66jeg3m7e9ekxc1m X-HE-Tag: 1717675158-609653 X-HE-Meta: U2FsdGVkX19fWks5q98Wy7V2fleJ7LaEseTycCIVeix2Cj3CpmHxt5EpgMsNEzL7ajWdBUQ2l8oBGEmscg9lL2W79m9HHQOyzhiR3X8iwvwlVe+R/GkLpW8rbMHBPZI8RyZiM9JGqbRLPzEgYhdSpiqVwoni0lMFZIAEyJ5pa81EGSp59YMDvD1cfcMfYZEnj2UO8YtDA+JbkPfaH8VZFPTX9cXmEO0G2gMiC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sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: To support shmem large folio swapout in the following patches, using xa_get_order() to get the order of the swap entry to calculate the swap usage of shmem. Signed-off-by: Baolin Wang --- mm/shmem.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index eefdf5c61c04..0ac71580decb 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -865,13 +865,16 @@ unsigned long shmem_partial_swap_usage(struct address_space *mapping, struct page *page; unsigned long swapped = 0; unsigned long max = end - 1; + int order; rcu_read_lock(); xas_for_each(&xas, page, max) { if (xas_retry(&xas, page)) continue; - if (xa_is_value(page)) - swapped++; + if (xa_is_value(page)) { + order = xa_get_order(xas.xa, xas.xa_index); + swapped += 1 << order; + } if (xas.xa_index == max) break; if (need_resched()) {