From patchwork Tue May 21 11:03:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13669303 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 63E24C25B74 for ; Tue, 21 May 2024 11:03:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F2476B009C; Tue, 21 May 2024 07:03:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 87B846B009D; Tue, 21 May 2024 07:03:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6F61D6B009E; Tue, 21 May 2024 07:03:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4D38A6B009C for ; Tue, 21 May 2024 07:03:45 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0C50B1A10EC for ; Tue, 21 May 2024 11:03:45 +0000 (UTC) X-FDA: 82142117610.15.31C5B62 Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) by imf30.hostedemail.com (Postfix) with ESMTP id DE8E880015 for ; Tue, 21 May 2024 11:03:41 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=oVY+upUy; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf30.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.118 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716289422; 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=eLWM5LDYn4qmAcvClqJJz7Ry6ODVE2l8ecGnrwuiQN0=; b=E3j3/ORnW4vr30DqgpTJ6D2/Rz83sAK+f05VsR2TUuQoshMO4fvdMnDcaGqKjMcyP33hR3 VnhxpGhMgGkbaYHD8UPnBVkBDP8HqlMNzTXyHBLT4ivHmvdXiJ7jCzCTpTwOSrjrIkTHqQ qdyb1GKUbTCMXyXmyQkthjdYCZG+uM0= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=oVY+upUy; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf30.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.118 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716289422; a=rsa-sha256; cv=none; b=dcbkNHIBWvdJPvuYYLjtlWsg1jFbUdbrksX2lWgp5JWXA+Ey8X241ahO8MiQLr8WcNt3pv X2IRml+jrD5pcHDjulhsmlEijf3+ci+FDcvfgRfTmOfYjATRcmXtlgOO830uIrOkAIFR8j ivT6EiJFwNNQJFSneVvi2gUd/SI9fHA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1716289419; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=eLWM5LDYn4qmAcvClqJJz7Ry6ODVE2l8ecGnrwuiQN0=; b=oVY+upUyau3AQlXbvwgwJy9gBbrTKIB2NAPxsZlcumizQeO0ndU8eaqP9jB7AlXnTaLq8n1TFWXbA0y4ezsBb0BnZw0xAat0wdSTXX5eHwWeGlQGzdBxehKlA2v0SRDpqZhLOG93CSVGys6ziT/166ghuf8Z6WcD3acwgLqVjFU= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R261e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037067111;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=17;SR=0;TI=SMTPD_---0W6xeTDd_1716289416; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W6xeTDd_1716289416) by smtp.aliyun-inc.com; Tue, 21 May 2024 19:03:37 +0800 From: Baolin Wang To: akpm@linux-foundation.org, hughd@google.com Cc: willy@infradead.org, david@redhat.com, ioworker0@gmail.com, hrisl@kernel.org, p.raghav@samsung.com, da.gomez@samsung.com, wangkefeng.wang@huawei.com, ying.huang@intel.com, 21cnbao@gmail.com, ryan.roberts@arm.com, shy828301@gmail.com, ziy@nvidia.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 5/8] mm: shmem: extend shmem_partial_swap_usage() to support large folio swap Date: Tue, 21 May 2024 19:03:15 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: DE8E880015 X-Stat-Signature: 51aqkx9n8jsrbntwu9zb1ircaa4usbxo X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1716289421-495668 X-HE-Meta: U2FsdGVkX19V0ZxWakA/CN2+GU7PQC0sl/saGmuw659JiJgCES+5iY+/QBXSAw395fHXij6qM7sUHRsdWXtlEPLVcxsCLDBhw47gVUeRaHq1ueVo14BjzIZBIAbAw8iN9F3l/prTjuvv8KSU3tUFtN01XtOc869So/qmCJ+NcNLtD2nuLDszl0gQyPFJc2qPbv7Qa69wz1L9DIM6/35pMD3nxu6MV+gj4jFG1rMO7s4xiP5oHsWtauPWMxG5AIyvMXxe9ZmoAEvutxc4+1QfCaGziBO4S/pcCkVEseErAe6rE0Fck+y0k/2SSRGu9+h0iDvr+NICanBHkY6ue9LgnWoPcdnSm2YWivVcqeOYJmihFOwcAeDZSOxAIPPysAwYP0r/BgONDLxRDcOTewWr2VGgEOzQaz6pBk8Hs7dAvr9QJTzbI+KCW5mnawLBVSkIi4zy8JQZCDvixoVt6OxGiugqXfdIquLjlOARFGcpx9Z0HIgPLyPOdAgBxZTGuCS1b1nHam9Za/xU4Dt6hVO1vsbBztiFaaPSRvg3dMwI9VyXXDmN27KOuvJFpOcsYwt/KlvK87fxQhynuG/N4GxohqiaEaBsb9ljgTYdPBAJf1hTf5SnzBYszzuXHOJiuRvRqH2Tqe1xs6NorRajArQ+UM9fjUv8HiSXSiOv0m4dXMqfNTYre45ZsXUdGhPC+zUsMur2hmhsTG7CKDfezx71gNEg9RobwwpodTdDp36kEJNsCL20q+5NUj4LKyLLo1lqXpOcgt2l3WJutTKs+dv6wzZ4bqPT0UMxQl0Dt+oX4SbSLYo7fNQwhOc8f3Z+BD4z7P9Vn+bzyVa0VUQujqUeE6pkvF2lfHyMMtEbiYzcQ+4sbcwjXJR/cq107SHx28aPLc//mKdZjIHada5IquESAIjQPlCTLmkk/hxQ/HOQ2hgUSP3c9SUvNaLTDgpmfplW7DOPpJLWU0tRFB9OQ8N o7KxUaCd y48Q1lZwfoS4RGlXPs81L2xFHLE1oxabnKzd1X+YFpQPjIuaVBYrd5Lo/If8R51C2wikldsKcRYB6OdiTIJ5kmr4Rz600WwCBD5zNpVADZCZT/xZJAt3UlBRPlLnktxaP9aqZ04yQbj2omWHD2GzKaD8kpGegqPmhl6hr8Qu4XX+FcoXtYjYqo7ycSZtmB/ZeU9lqyBHIb10HmHk8cRiCSPmsQflUAFDyOdtQobSGI6MsciYKaTUfzPDw4IYBwQ8joFRIrWeC3rPKL1FgQTyPUlBxvk/l6bCcp3Kh 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: 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 74821a7031b8..bc099e8b9952 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()) {