Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp3000441lqo; Tue, 21 May 2024 04:04:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWSbi/nziL2QvwcIOQL8x6IamJp50bc9BamJKiG0DNkrx/mPcuA1sPQvBW1mUbfT5e0rBtsKTdOEFf3bvrrg5ro6hbTk8x4l73Sdz4nxQ== X-Google-Smtp-Source: AGHT+IEmOK8F1WEDxVN2ps33UN8E1Hn8Znk9eHeBRE7nvDmX9Qer0O349ahVcauwCBed6pSmJ1XR X-Received: by 2002:a05:6358:280c:b0:183:f634:104 with SMTP id e5c5f4694b2df-193bb50c50emr3428767955d.7.1716289463278; Tue, 21 May 2024 04:04:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716289463; cv=pass; d=google.com; s=arc-20160816; b=ujueUnk5F+Q/RsgrCEnGbjzwqcyV4IJOCr5TCN3itsOy9MGDuL/W8m+BTczva6C0yJ Aaw+TK8BQK3jAqDvkccM4opODLmdFNlhCH4YYXPihrABeyEvzxlGPhhlQ+OtcZbYr0y1 uRP/2f1eWU3hcxvjeAmpqzhsFxU97tp2NYNqrYoAJLUGvXT0SypFvWWIuTPkNzPdu/Ns rd03er/aknDBWG0+uhKP6fog8cOmBeLi5oX8IP5VmjvZm7LZWLyDTVjp3TYpyxsqNN1N PDG88f+5C61yDXJ9xG8lmtD9SI3qudKYdv+Y18Y+5HAm+9fWVre2M4fYIqX+wMJbOFFG Wuig== 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=eLWM5LDYn4qmAcvClqJJz7Ry6ODVE2l8ecGnrwuiQN0=; fh=yZfW+BHkES0D7lqXNSviUM/H3M0u/i+axAcBKiPVoLw=; b=sZmVAwXY9LxHGz0dFxHWp4uzErmjkTCNfB6yJOAFHUFlU4hgqa9OjRKgDz7w2s+dgk SWi9K9xkPYHtD/rsG9RlrV6GcvC34Eo1aEx1Jaie4iuSOno7EycyGHQ5m4rc3FP0/zzm 1XgUNmDtxMCRLUefSI60bm5r8YS8d1W/VfsRbNvLfx4B8xv6NjxoOSLK2lY6l9xm7Axm xI5NdGb+BJiXbvR/S8YgvG3kW0scLbjt7Xv6/ofHvMTVBxuH+CvW6yzvoLFX9tN5QiU2 /5X1p4uKoeV5cKwVwX4slJ4GgTJOyHGU+T/rbCRdmEz08wghDR9FBZ8Of4mw7UZ488DI Zmzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=oVY+upUy; 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-184850-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184850-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-662f18a12aesi6206411a12.852.2024.05.21.04.04.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 04:04:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184850-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=oVY+upUy; 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-184850-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184850-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 DCB662817EA for ; Tue, 21 May 2024 11:04:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6968E763EC; Tue, 21 May 2024 11:03:44 +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="oVY+upUy" Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) (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 3FB62612EB for ; Tue, 21 May 2024 11:03:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.119 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716289423; cv=none; b=Wzb9fNTbJHeK1q3fsP5/mh6V7ioi8AJi/yJtSWslJM48px9BjOL/Il3dqEaCuKcRE7ds6X9DEjzbNeo2KRLGM5ffPfjyCEnG8txOJfsUNf/LkHI+jFpdojAvBqzGIZhCUinHce3EsgwBCAFyGU6ONtCJkWofdqi6sVoQ88YlCn0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716289423; c=relaxed/simple; bh=QktWnmZza0+8gvOpDIgJiQ9JxnbnzLBik8mUH7+XnKQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QRl3RX6E0KvV8m5l3/gWwYrGw6ERdxaxqMsducs3IMsuI3ywj+Qeu5ieJQvInOSuaMm4vV0+IcO/fHkH3W9/HjEyG4KZLy+v93w+BbLKJUkXuKkUrX4wsPKHjz+t4LA6K6m0VBU+MMgGRI1uhTnxmtOBgOqbZAs7BkfKglsnIzA= 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=oVY+upUy; arc=none smtp.client-ip=115.124.30.119 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=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: 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 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()) { -- 2.39.3