From patchwork Thu Jun 6 11:58:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13688376 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 8428EC27C54 for ; Thu, 6 Jun 2024 11:59:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ADD256B009B; Thu, 6 Jun 2024 07:59:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A8D746B009C; Thu, 6 Jun 2024 07:59:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 97C466B009D; Thu, 6 Jun 2024 07:59:18 -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 719EE6B009B for ; Thu, 6 Jun 2024 07:59:18 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 287EE1A15E6 for ; Thu, 6 Jun 2024 11:59:18 +0000 (UTC) X-FDA: 82200318396.03.A74A89A Received: from out30-97.freemail.mail.aliyun.com (out30-97.freemail.mail.aliyun.com [115.124.30.97]) by imf16.hostedemail.com (Postfix) with ESMTP id CFADA180003 for ; Thu, 6 Jun 2024 11:59:14 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=caBHPkLo; spf=pass (imf16.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.97 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=1717675156; 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:references:dkim-signature; bh=jM6eZe4x6k+egILzv89K9Z+MG/ZZ4Ym9gSqYkloSOdc=; b=ERl/OwpTCmm75Qc5YjB3ZyllXWq1iu/ryQTn84IyexhUYilSei4+TsjBqPeL8zOLwgwrgi s0mSqtq5YgHN2ck0DkUw4A0gibeRalQYrlAPd+HSHqFf2jlau22ajtanga/k7JgZk89trW SStOrOqYRyrgW6sUCOC5z9MNrSVq4BQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717675156; a=rsa-sha256; cv=none; b=s6JGFd+GekcAlnKz0GvbwsAV2v7iC1SEe7jLEmckxpMLY5ZI2SQFlvutJTEL9RDq/t9iEC 4hPf4xWqSKAXtPkcR+tTwSg+kEzOrmIuGT7Qt5o1ijsLv6qQLvmXMaQLhYIQod1UNm9m1y 5kG7ADVJevo/KQu25/gU32JrETJuSlY= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=caBHPkLo; spf=pass (imf16.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.97 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1717675152; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=jM6eZe4x6k+egILzv89K9Z+MG/ZZ4Ym9gSqYkloSOdc=; b=caBHPkLoL3jvQRFWoUk1n7jQa2VhnnEQ3W+UrXZ/KD30aG/PpOHfr+cKCRw1p3Q4OEmkC2hK+otsiYm29dbiAamhy/ID3UUHMdJh0eQeorCVN8f8Iqab4nrEn5NlcvWWYT0TzgY/mpGWTRRY3v0pSv55Mmnr0AiGD234jaD1FgI= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R551e4;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_---0W7y6tom_1717675149; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W7y6tom_1717675149) by smtp.aliyun-inc.com; Thu, 06 Jun 2024 19:59:10 +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 0/7] support large folio swap-out and swap-in for shmem Date: Thu, 6 Jun 2024 19:58:50 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: tchqd9ed59ewibxnyhx5ddxiyiph3zmp X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: CFADA180003 X-HE-Tag: 1717675154-199663 X-HE-Meta: U2FsdGVkX18vGMQHpkvajOIcYCifRLhBOfsRqPWHBICy8QmzYWGiV337riUP+ZjJ/qqc8eQjb0doUP7YJJEHMHhzaZI/m+I2p8tzxX+H6k8vLJdmHGQKysSKyTJlaSxnOQGIk7GzP0rDqMtiTVfrhOfZNLl8YiLKNQlSo1cELeVDoXPmLK5D9wxh/yrmCE29Cw0YUMWmbJjJ8j9MonchVna0PtiAkLEyYggWVypqUMlkK10ZCskwyGw2lY7b/4V34aEyWGtS2h7pbRaKVwflYgPgJcEYdD02LpgOUmRfI28wW0RA1CSH2a04jKUz6qBi3vQakLx8yk5bVgAkX4q//xlRp3X2KDYGTFFF4sbNDnyxlPOq5PhrZohQHjOeQA+xT1UB00ziYvlYoKUEjYCEMr2viaaMlEjYbHoatRsAui1afL6yR8+lthXsSKiFr2MBo/JlsTJNCUdE9D/qa3aXhLckGU6wff3H/8+ijXdcTTHEXbqowJhLMW4lcdmMynjjaeuB+38nROR5sf/gdA3YVg+qMJrq0yPHM+F4i1V3Dc8rXcx76dFE91ReM/SJrDysNyYpBhFZ4AwEMnNjkzxrzgfYDHn77KSb3gWczcgsbglInhmhCyoIPft8ZEMTHowndOb7fqkEZFdpIWlYoV94SmNHMELtPKjd0zHhDJqG5r8HbhXZiwhmZFx2OyQk3qKDLzGEgymZLte6wognSgLx5evB8Ri1rKbqHh2gjv2AgJppJ4B/RzLOhq8IlIvceOo6f3ve7iqCuAFzWnGSfLN/oJT4wxOgRkXOw/c4rmTjRGNWtoaUN56E4TAdTBXnsiWprcB+kZ7/Cv4WXVkxzKw/2vlQ4iMbNrrshqSXS69YFO0j0v4AIJFbRUwKoxDs545i3Liy/NmJLDfpQA0eJQiIX3hvK3qFAWbL3ZSG5UL1gxfX/boE+pJiMI1m2LnaFNvJK7L5frYOdMsl0P0Zpb6 PFVOzI2y sRdKD9/8pZKmk09brZBXCd3+MK00eSdK7qoaNz024wRd/Opz+nrhxQ5gqavC/arBpR0aIL8SSbXHCjWduJTKOctGe4LAvzMaPaO7txLg6r/cXBhtUijzgvUlqSZR5s0BpeQHYQGLUrfCbRySFzDWvONe8PTJtbUlBg3jUrKrV3XEyTfjZ+f2ap3xNMnY9sW3lGoW14GLTwT2CkAinXjYSidyF3jWski/lnp4iwjI73UpJpXUm67/mH3HupiXRui/3B7l5XnpoYfITdx2yRQqgWjsAK18cm6/sm4QgSLiI69N1E+6ukJ2WbTmBxKxz5GrrvYVRHXFfVmRbp3c= 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: Shmem will support large folio allocation [1] [2] to get a better performance, however, the memory reclaim still splits the precious large folios when trying to swap-out shmem, which may lead to the memory fragmentation issue and can not take advantage of the large folio for shmeme. Moreover, the swap code already supports for swapping out large folio without split, and large folio swap-in[3] series is queued into mm-unstable branch. Hence this patch set also supports the large folio swap-out and swap-in for shmem. [1] https://lore.kernel.org/all/cover.1717495894.git.baolin.wang@linux.alibaba.com/ [2] https://lore.kernel.org/all/20240515055719.32577-1-da.gomez@samsung.com/ [3] https://lore.kernel.org/all/20240508224040.190469-6-21cnbao@gmail.com/T/ Changes from RFC: - Rebased to the latest mm-unstable. - Drop the counter name fixing patch, which was queued into mm-hotfixes-stable branch. Baolin Wang (7): mm: vmscan: add validation before spliting shmem large folio mm: swap: extend swap_shmem_alloc() to support batch SWAP_MAP_SHMEM flag setting mm: shmem: support large folio allocation for shmem_replace_folio() mm: shmem: extend shmem_partial_swap_usage() to support large folio swap mm: add new 'orders' parameter for find_get_entries() and find_lock_entries() mm: shmem: use swap_free_nr() to free shmem swap entries mm: shmem: support large folio swap out drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 1 + include/linux/swap.h | 4 +- include/linux/writeback.h | 1 + mm/filemap.c | 27 ++++++- mm/internal.h | 4 +- mm/shmem.c | 58 ++++++++------ mm/swapfile.c | 98 ++++++++++++----------- mm/truncate.c | 8 +- mm/vmscan.c | 22 ++++- 9 files changed, 140 insertions(+), 83 deletions(-)