Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp322162lqt; Thu, 6 Jun 2024 04:59:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXZk2xUPUjNsIv5cdanpjvGWZaV/Hxd1O/Mgnp17CKYwlG0TId21sMzSWh+FxZfso3WxhIgxZznbVp6h7ps0smvoFbwQ2gbRXlaTgY2BA== X-Google-Smtp-Source: AGHT+IHwH6nysQiCoL+MF19PwRLjDVF1u8jlLe8+fphIzwqjrwLkTkuEJ8zJ6JAIGEODZvEZRmjX X-Received: by 2002:a17:902:ecc2:b0:1f6:30e8:aae5 with SMTP id d9443c01a7336-1f6a59ffc7emr65923805ad.4.1717675196483; Thu, 06 Jun 2024 04:59:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717675196; cv=pass; d=google.com; s=arc-20160816; b=Ffg8Hs+736aSTY7flTBtTFy2sIn3PAgUxNG/F1526TxouspKVooWMW1UUwpAITOrZp KcXiCaUiAVxeIxT/dNXOy8bQF7agGYyhyVFHmRNQNum35XxqFj/Had60mxPwVJWPFBEs sjCXHKLKDU4Sb/zbxiZBE1PkU2r3dBqLElES4ti1Enjk2QxMsvqZLjL+Y6vvkAf3g7ag g2duG+q4ooNxduQ0ObQ+lsDUlvUlg8oSvA+HjfG4/0cXuRMSH11dIbTsk9lDUA+PHr9I iYI2NS1uy5vj330O8g+ZsW6nWxF99DgdwmseBozSnDjuQCXEcYRyQGR7W55Sbv9nNC34 aTrQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Hca3mk3oMk8MShvCe5e0YS4gCuYYhtWQR6R7w3SOo+g=; fh=Ga7JTaoZDeof86+j9POZ6Xv2e481OdNpwFcgcgBxajo=; b=kLIzRULYg1EabJZd/JAJt3ARHsK7pVi2BsFFlecH+g9xNN/u2lrs502j6CHcwBVjgJ Qs7mOWXKcGW2QH9R2HzMLprQFXW4LFL+LNLup3RuVAjDyZFXP2VzuexQ3rkMIiMsenOd mJy6hlpcDsmF5OhrN7jhO5YlL2V1wm7081gQ5YiQ5R27RWTPsy+TxFGkm/82g0huX1Q2 6AMKDhC0A/FgHqTe5RTsh/APzPXxri0JPwozlbQXrU99fSsA2vWhHprZW7EXzb0t3dB5 SruTX8YGD91hgWSFJG4aeA5ZAoGrKi3x16r9FZFKukHofKZgcTydGqD3akrrwH81qRns 5uxQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=xM+MAmJZ; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-204218-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204218-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f6bd8207d1si10601665ad.590.2024.06.06.04.59.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 04:59:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204218-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=xM+MAmJZ; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-204218-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204218-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7885B288D1C for ; Thu, 6 Jun 2024 11:59:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C9A9C195F15; Thu, 6 Jun 2024 11:59:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="xM+MAmJZ" Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) (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 1923E19597D for ; Thu, 6 Jun 2024 11:59:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.100 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675160; cv=none; b=jbs91EqszfVMepWiFl7bR86xbWSCsT4x/ZaqR+oiQlzI8RIXxmQjJMCBWJePdzcvVyAlZbQfKNiKrEsA1nxyvNKGd38cGOUNYm1qoitac5G6zwpzpab1MPMC/qNSODaAdD7KwQWHKl8AWke657Gtq8CvZE/vRoVtXEWfuy8qLzw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675160; c=relaxed/simple; bh=mqoKQ1GfEhJx0cp42B5Os63IdbIrLevXHR83MBqrQO0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=L+ihKo+amiV4zlRxrq/95W1qN7ZqViOKfOdPBbQHai2gYewQD4TSK6n4FJcsGjc6Sra5XOp2Z/dpOoUrRZm+2fwZqjXkAB6ChdmBs0StUBsjHvSVCtdQrB8m7CPNipCXBDEpUyPdqVqjKngh0/bF2IG6RXCwIVB+CMhcYC6wOP0= 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=xM+MAmJZ; arc=none smtp.client-ip=115.124.30.100 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 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: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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()) { -- 2.39.3