From patchwork Thu Sep 26 08:27:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13813029 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 70B47CCF9E9 for ; Thu, 26 Sep 2024 08:27:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F2576B00A0; Thu, 26 Sep 2024 04:27:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 879126B00A3; Thu, 26 Sep 2024 04:27:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 663A26B00A5; Thu, 26 Sep 2024 04:27:54 -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 405256B00A0 for ; Thu, 26 Sep 2024 04:27:54 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id DA36AC0927 for ; Thu, 26 Sep 2024 08:27:53 +0000 (UTC) X-FDA: 82606211226.27.E5F3ACE Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) by imf28.hostedemail.com (Postfix) with ESMTP id A4359C0009 for ; Thu, 26 Sep 2024 08:27:49 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=RsqqoUUT; spf=pass (imf28.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.110 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=1727339150; 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=F+79Mmm9ctdCoF8VYkFvLVzQiHBgINg2lBAfCIV45Jg=; b=e7VBJWivsBJNPyZ8FC3yeA4cYHQl6/+9SSDTU62fKTzWbHNLB4sG1QZ1miOxTnOtoxf+1o kioBjfmSTDeHbJdfmdtgJe3Of8JKM8nA1+LrpVaJEYp107iDpG9Da8T/O6wLFRDKvKeYKe N8XYR4VJM6x5nu7uP6tLCEVvGPXNuSQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727339150; a=rsa-sha256; cv=none; b=qOyYhVEB9Jm51RPpGOjy6Ibzef8PeVArLwTkLwrpmZuZcmfr2Ng4UMm3jqFJoIC+7oluzh g6NNqAtlC+qI+eGgVq1d9kEb00wBsnk6p46um8dTnKJI61nr6KGjS2t6ftuwpnDjGZe9EU o2Mvww+5QiEFRVjnwV3046SdNAlqizI= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=RsqqoUUT; spf=pass (imf28.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.110 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=1727339259; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=F+79Mmm9ctdCoF8VYkFvLVzQiHBgINg2lBAfCIV45Jg=; b=RsqqoUUTryF2gYQg+hO9CY8E2SENGcyLCafuWDzoslqgfO3ODTckTAoS1SXwW0/MuKJgJD7HSNht7bY2pwCJDmisDDvK0jlmX7usLi7hjbO/IeyjG0OOqhHHjfh4gL1G91wonejgxAbDjBreRW7PESLaStSe0PtM7wUJ91dNXxY= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WFmgaSC_1727339257) by smtp.aliyun-inc.com; Thu, 26 Sep 2024 16:27:38 +0800 From: Baolin Wang To: akpm@linux-foundation.org, hughd@google.com Cc: willy@infradead.org, david@redhat.com, wangkefeng.wang@huawei.com, 21cnbao@gmail.com, ryan.roberts@arm.com, ioworker0@gmail.com, da.gomez@samsung.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 0/2] Support large folios for tmpfs Date: Thu, 26 Sep 2024 16:27:25 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: A4359C0009 X-Stat-Signature: 36kbyaa45mgpnzsg8r5uzfmh8hmf1nfz X-HE-Tag: 1727339269-646458 X-HE-Meta: U2FsdGVkX1+iEoRUY/OChCLICIeaOuPBdIOiOKQXceEGQEeXn+STvq/WURiNHlZ8/jRr1gg/HmuLrfzThQWKQEbpqETIqdKAM1HUfY/A1pFgU3c/dY95AFWKP4bxnf1l4GeXRdDdvFRIWYhZnBQQXvKQFedGDAOnxRn1PS1xse2wMbVFAGeXiXHAJYgH062RdNyG7eRjXm+PgVsbS5aP8fU9vTHAgQG0Wz21ePzG2CqRwHaYo1ZVtGpl8jWZ0Mo+u/rmY5JIecJVS/2AcjgzO30l9TAHOpq2UTvLzWhlsxz2E8f8ft3bpGtFqphFX8HOHuO37CeKzVDyF/3X3SmtXTwc4proPerWapiKWrNh3WjzAQm8dbtMFDWkHMjCB+ZgGZdwtXQr5Gnd02c39QYZwSuLrSGpXU0toCKIIXp4WpiF7q+38Y1+OfkbDSWz9E4IBJmtqICwqOukV6bt6KZm9rMDd7DGJn5J/Fvjko+5u5bYdMbrrpBnf/Wy9fYlflhCNY9/25bfUQB+7TnSAJF6qIfvp19N1dpTYWJxEf8AkJflkcYPTaCfq/YdkgoCOanJ5c2J97SB/JqpkJRajCdVTj8k1QK7wCv17RDVrandNzzV87pwFBUVoGxAMCINL8pCHFp1JOee/FixtNS6I5xFrqeVO+bxgH4RXG4ZwYiqXxhLdhlOBi3JC3Xh6eUOxSz8hqI7w13cl+pXq1QfphAetexMGw6MEu45/u9hbS329y+xBOe+EgKMqfrPV8tCOtKEqm3mX26mhTTikIhfxyYHHFx1ygrLoYAezbcVCLH1p1ACpdXogwrJ4byhcBVW5ggoYgPTsJSH+bq1/OlATNHJbsqCEnBsAoylUJrHiolxWyMN+uqxP01cy0qAChpW2jDbo//+vC6Was8yqfMm7VuVhIUs/ZQFQ24bfX7puxEslNZ6lX3Yem0az8AxFacGnlk4XA5ad9fa91fHuWQ14Nq dsU6/y37 InICywo3a3tRVJOMd5ogapGwmXHnGIATUg6PNDNSg1fd1h4TyDkK3ldtx5PEZGVcsroND3v6SOCC+hRHlOI+uPdjTXoumxJBEe79sw8WWG+JRXrwq5+YJTQg7ZcM31uai3lsTYoHQaeaZhKrbo8JZGgd81hxAJQ9nq1vYMmV4s5rilQj9LkocMl4z04J5E4RgSZd1n745Jku2KJHC3/fPmdTk1Tj26H3ONb+fhpYi/pxVHyayoNqS29W/hxZGkg2tMlmld97y3ZYjcwSfGcG7C+eGJVBS9Qvac6UryNAxVSxk+meYE3aXwymaig== 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: Hi, This RFC patch series attempts to support large folios for tmpfs. The first patch is based on Daniel's previous patches in [1], mainly using the length in the write and fallocate paths to get a highest order hint for large order allocation. The last patch adds mTHP filter control for tmpfs if mTHP is set for the following reasons: 1. Maintain backward compatibility for the control interface. Tmpfs already has a global 'huge=' mount option and '/sys/kernel/mm/transparent_hugepage/shmem_enabled' interface to control large order allocations. mTHP extends this capability to a per-size basis while maintaining good interface compatibility. 2. For the large order allocation of writable mmap() faults in tmpfs, we need something like the mTHP interfaces to control large orders, as well as ensuring consistent interfaces with shmem. 3. Ryan pointed out that large order allocations based on write length could lead to memory fragmentation issue. Just quoting Ryan's comment [2]: "And it's possible (likely even, in my opinion) that allocating lots of different folio sizes will exacerbate memory fragmentation, leading to more order-0 fallbacks, which would hurt the overall system performance in the long run, vs restricting to a couple of folio sizes." 4. Some hardware preferences, such as for the ARM64 architecture, can better utilize the cont-pte feature to reduce TLB pressure and optimize performance with a 64K size folio. Using mTHP can better leverage these hardware advantages. Any comments and suggestions are appreciated. Thanks. [1] https://lore.kernel.org/all/20240515055719.32577-1-da.gomez@samsung.com/ [2] https://lore.kernel.org/all/e83e1687-3e3c-40d0-bf0e-225871647092@arm.com/ Changes from RFC v1: - Drop patch 1. - Use 'write_end' to calculate the length in shmem_allowable_huge_orders(). - Update shmem_mapping_size_order() per Daniel. Baolin Wang (1): mm: shmem: use mTHP interface to control huge orders for tmpfs Daniel Gomez (1): mm: shmem: add large folio support to the write and fallocate paths mm/memory.c | 4 ++-- mm/shmem.c | 66 +++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 58 insertions(+), 12 deletions(-)