From patchwork Thu Oct 17 14:17:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13840111 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 AFF71D374A0 for ; Thu, 17 Oct 2024 14:18:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 470F96B0088; Thu, 17 Oct 2024 10:18:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F9776B008C; Thu, 17 Oct 2024 10:18:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 273A46B0099; Thu, 17 Oct 2024 10:18:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id EF3EC6B0088 for ; Thu, 17 Oct 2024 10:18:18 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id EFD401A141A for ; Thu, 17 Oct 2024 14:17:58 +0000 (UTC) X-FDA: 82683298446.17.09B52CF Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf15.hostedemail.com (Postfix) with ESMTP id 882A7A0012 for ; Thu, 17 Oct 2024 14:18:06 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729174578; a=rsa-sha256; cv=none; b=rlqK1k+6hrE5ugtSC7leertl8hDY7BFQ4skMwxilqFdpuav8a65AWN5tIRctm/Q63EgIkb S7JluExUNHWdu9oowJ6brckh6HAkp3AsMugWQQ3sfS7l9xODRGvNTGMlSQShUhfPOgsl0/ aeCodsScqEjXreMWK94Wqy0pZGQJ3P0= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729174578; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=12b5yBJCN07Llg6eIreAFZCqQvxvpjMFT86r4PxP0uY=; b=xYy3nd81f9ofTQELT5gjGCUmXR28e1N0gPvPjZzhPRNVoom72KW7oJC1XhnEkLSuhMnovm u/d1wjTIT6NfR0b+AMqrB1VXQElhUQYPUvAJiat9nw64rrWOBvZottGzPW/K+RRQFwCzL8 OGhYUG4z8dGO+fVuZ8hKv1oqHxlaIuQ= Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4XTqd96wrRz1T8g6; Thu, 17 Oct 2024 22:16:13 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id F0ED2140135; Thu, 17 Oct 2024 22:18:07 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 17 Oct 2024 22:18:07 +0800 From: Kefeng Wang To: Andrew Morton , Hugh Dickins CC: Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , , , Baolin Wang , David Hildenbrand , Kefeng Wang Subject: [PATCH v4] tmpfs: don't enable large folios if not supported Date: Thu, 17 Oct 2024 22:17:42 +0800 Message-ID: <20241017141742.1169404-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240920143654.1008756-1-wangkefeng.wang@huawei.com> References: <20240920143654.1008756-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemf100008.china.huawei.com (7.185.36.138) X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 882A7A0012 X-Stat-Signature: tts9zieci1s4jikp658uikqj7qy9z3pq X-Rspam-User: X-HE-Tag: 1729174686-497130 X-HE-Meta: U2FsdGVkX1+CA5ONyeEGZnxR8CLbU5EOKZKbOKcdzFzW+rHo9lxGJwGPwqih0bFXfRPv9Vt6nQlw1y1z1FqOGzLIFSqf/+tsKyFM3pU3PaD0KfkcfiFd81HAT8WanhTZHcNQwMk/b0TP/E3GbzPrK0l5ZxUliHJYfIGuuji5eG/r123NhLTsccofF95+LmV3cPaHWvHtD0O1MRYLOAMzBxlxtAIV9G9p/BjKbWBxQT/BS9B5cceiFQJMIFCQkUjxMlBKaA9pXgeNf6zomttDdmtw18ktmirrCopex30ogLGK61FsUMQtxB/00f7QxsUYksnWJ7DM50ZwirAaPeotTlelCkKBVhsrpFs/6o4ir2Krp6CfqcEe6Ie/KaIxzBY+5+8oqymqbcwDL5GZMMvO3eKBeRZ9cf9S+w9VkhvM4zD+taXgn2PlGwllIGotdO3hfmBomKvKxZa8EaQzH8hgpSKwmNvW8gTgWMPJGKoLn+xlvNKxtIbMScCQ4EKjAgm+j7psDl18rPYXl3vL3jqFfwt8u5b0amEmROiYj2PGufG++ZW79QMRM4nuAbAJZHrsDh2OWrkVynTsAt6cuEEnn6CIYP+w4QVLTZHDqXMg/C5mFAO0tTwv5ylcMxgPN8X2GK/MoI6gZC27VDhjFG5TF6eMFWoZEwjoSwnQnKDkeWKSh/zTKvMnNi7X1q1L/iT+caVUk3Qs8XCD3REpg57r8RkWfM5seeAqgqJeFUDgq0b2MgQvRaQfJzOhdlV3T1RrFdho6jYdYfVOeJPa5+b08UN9S0/6U++Da847IJaJ2M5qFJO1YqgfJty+1MnFSjLYtvgZDZgUWdH0z2yCtBubNLkKmG8Lm7Dj/U3VyxxXJegEKcWq2ZbXofDputrIkKu8Xy1GVkorFhzbZIvSwTo6ClmJjsG0JbHJkFiPqpRpXwVCNw2MfaTbnHBd7uH1rYzbwalP3+XdEZHFOBg18cI lkAwUO9p V6w+i5Px/LDqbAhbUrs8ThuRGAJhuj9g7DuZ14KlFcc7x7lxbjU7cf3kEhdGYuUWkvfOYoO1ieR6ZIipOxfOBVtxKb5X5xehPbhY8aZ97PL15vgywHiSensBk+72omOnyVSKxfvxnoCeIAiw= 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: The tmpfs could support large folio, but there is some configurable options(mount options and runtime deny/force) to enable/disable large folio allocation, so there is a performance issue when perform write without large folio, the issue is similar to commit 4e527d5841e2 ("iomap: fault in smaller chunks for non-large folio mappings"). Since 'deny' for emergencies and 'force' for testing, performence issue should not be a problem in the real production environments, so only don't call mapping_set_large_folios() in __shmem_get_inode() when large folio is disabled with mount huge=never option(default policy). Fixes: 9aac777aaf94 ("filemap: Convert generic_perform_write() to support large folios") Signed-off-by: Kefeng Wang Reviewed-by: Baolin Wang --- v4: - only fix mount huge=never since runtime deny/force just for emergencies/testing, suggested by Baolin v3: - don't enable large folio suppport in __shmem_get_inode() if disabled, suggested by Matthew. v2: - Don't use IOCB flags mm/shmem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index e933327d8dac..74ef214dc1a7 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2827,7 +2827,10 @@ static struct inode *__shmem_get_inode(struct mnt_idmap *idmap, cache_no_acl(inode); if (sbinfo->noswap) mapping_set_unevictable(inode->i_mapping); - mapping_set_large_folios(inode->i_mapping); + + /* Don't consider 'deny' for emergencies and 'force' for testing */ + if (sbinfo->huge) + mapping_set_large_folios(inode->i_mapping); switch (mode & S_IFMT) { default: