From patchwork Wed Jul 31 05:46:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13748078 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 EE415C3DA64 for ; Wed, 31 Jul 2024 05:46:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59A3A6B0082; Wed, 31 Jul 2024 01:46:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 54A226B0083; Wed, 31 Jul 2024 01:46:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4119B6B0085; Wed, 31 Jul 2024 01:46:40 -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 238546B0082 for ; Wed, 31 Jul 2024 01:46:40 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8C175120143 for ; Wed, 31 Jul 2024 05:46:39 +0000 (UTC) X-FDA: 82398963318.11.33BD799 Received: from out30-98.freemail.mail.aliyun.com (out30-98.freemail.mail.aliyun.com [115.124.30.98]) by imf16.hostedemail.com (Postfix) with ESMTP id 73801180005 for ; Wed, 31 Jul 2024 05:46:36 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=KkdqdOMl; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf16.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.98 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722404793; a=rsa-sha256; cv=none; b=SN3sdPxhnpMCuAkj41DgZNhbN+xgExjvTBQeCptucgSKDOXln3/BrjQEg+ir+SCTKPT+sN iUw7ktDLd7ORvPXI9LHr/s7M+qIyqTONfCO2sc9xpnfc1EGeCqxx3D1gGN3uNg9NzGBXKY 3y1RAzWHn5Ag5LYtfJ3+TR4TK5MlUck= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=KkdqdOMl; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf16.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.98 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722404793; 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=9iYPuftUH8jdllTlmDLAs9X/H1+vtZ8NK0gmpMdbLv4=; b=TVSDZZVxYuPHiQKNp24kZJhn27+sD9dC0IL8Zk3uyLQYTQBSGPU6MLdi2xA9jLlXhcdzs1 iuAHGd9Bf1y7U3REYbb/rT/+yA6uyb8KuT82WKbAwWZ2QpfL/TdklUBtsQQUKVQWqUBjyC jUT/CxAo94m3goxdV2+eQRgLQALn3V0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1722404793; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=9iYPuftUH8jdllTlmDLAs9X/H1+vtZ8NK0gmpMdbLv4=; b=KkdqdOMlpXI2YQCtyWXJIBGNZfBh1SfDkAxvKPoA1KErdyi8F9/gT7vxiFcv3f2GjG15lkHc2lzYbiberFSmKqo5fTo0hyqXWv/z4t3gQxYE11gZf79dlQB3rKdqds7ECBfCPCCNLAcXU428uRXJlSPXyjAybxKqC8sQAVllRes= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R681e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037067109;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0WBi1RBW_1722404790; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WBi1RBW_1722404790) by smtp.aliyun-inc.com; Wed, 31 Jul 2024 13:46:31 +0800 From: Baolin Wang To: akpm@linux-foundation.org, hughd@google.com Cc: willy@infradead.org, david@redhat.com, 21cnbao@gmail.com, ryan.roberts@arm.com, ziy@nvidia.com, gshan@redhat.com, ioworker0@gmail.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] mm: shmem: avoid allocating huge pages larger than MAX_PAGECACHE_ORDER for shmem Date: Wed, 31 Jul 2024 13:46:19 +0800 Message-Id: <117121665254442c3c7f585248296495e5e2b45c.1722404078.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 73801180005 X-Rspamd-Server: rspam01 X-Stat-Signature: gigomf53zsihoi5wn1w4ez7xf9h8orrz X-HE-Tag: 1722404796-65849 X-HE-Meta: U2FsdGVkX18uJ4Us3FcIv61EXgONyJIdUiyN63AIMUO8uuSoUtyH8TqpJyJmO85MUDsLdApQZhlBWb3qdNVFFh1aMsR5ox3eEcorq5RrKenDJA1uwmoY9qy8PfotqeYg6bbeHkIDxVyIq/5ZNwu/fuTV9NHOTGEuCl5qLcmrs+Yqo3VJW0memjGLkIqAaueaQFJvHmf4NodUhYQ17ajhxq+lJjf1TO4Mts3ozFFyKep1RY/SQdfqOHS8hTYXrL65qQyoSpA2+iwRwzdXgBPBCRPnQeHNy2dHiHhlNUpKiZe4Bb+5dKdEc8eQx/kE2Aukf1Mu9ERDSw3fGE4hvFYbB+PiLnXSOcy8LM4eOvaYh8vK884GzU7CfKbR2TuDeia4RKZgVYILHRbDoxBWkiEhZvCd+xkmI/lCKkeW+Nad9kasFhYUSxETqMwBU00grBXHykvde7Wu3PtPOJFcx9z6Y0FSStVjiGuK3F+07Y0H0M2bZW6yKXocbGFLp7k+Hx6ZDDNGyb5oupjqhgHA0kfPtq3FE6iGDvWzb4794WxdEtlVvFZ1SBzfhs/xYCgi9oX8fSraj9US/sDay5DITv/Z2YG3T8xP0Q280snCsteGbJ7uowqUmrPbtBulqqrbdY5qgWLrn+JbSbHmqHqmFpirDdHbI+2k9WJZw0wAyfQ6djoCpYzRaRZiZpcb3U2Z/SKpN4MdSSZ2QSKFNuN7AOV/o43NdxpG8hXcajeqYXAoeAXrvuDqOxuox++UBjNVkcUMjwhrZUDCWUM0q6R9iQmJAXAhVQrhgpFRjsLj5ImLvVxP2gw2n7MJ62NNI19E2v6Ba6f13C1uK+8V6WNOaZ805psqbybfs2GOOIOzeEzV+WNcGa/FNBMyJ5dcS+ZtNPIsXJISI5/GMvpoAfedYVwRfPKghgu/YcoC2SJX4Gk4ewsKt0c0WEhKW1XAOnR7/aiNKoh/0sx6+esXrUfEC0M PX+0hG8z CZ6F6htu0kSRKBfiovQYj+s5fbXb/u+PHopvwo7oECKJQU/EFQOFjViIIz9KWXX4glQANZ9KVALyU/9zA60NT9IhUurymf8+35YVQbi1asMK4wAvpjgB1L/mR47Rq04/TFxvoivwFwNj1/Sswy69tAr2v61HGjcHHzVxbckUg9QEEVw6kcd9Rvcd0B+w3/WV1SfDuhOqsSNY5aaquc3tsKqWhSlwYJcUelMwsBBMqLyTLF7oFVOpMoghfhg== 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: Similar to commit d659b715e94ac ("mm/huge_memory: avoid PMD-size page cache if needed"), ARM64 can support 512MB PMD-sized THP when the base page size is 64KB, which is larger than the maximum supported page cache size MAX_PAGECACHE_ORDER. This is not expected. To fix this issue, use THP_ORDERS_ALL_FILE_DEFAULT for shmem to filter allowable huge orders. Fixes: e7a2ab7b3bb5 ("mm: shmem: add mTHP support for anonymous shmem") Signed-off-by: Baolin Wang Reviewed-by: Barry Song Acked-by: David Hildenbrand Acked-by: Zi Yan --- mm/shmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 2faa9daaf54b..a4332a97558c 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1630,10 +1630,10 @@ unsigned long shmem_allowable_huge_orders(struct inode *inode, unsigned long within_size_orders = READ_ONCE(huge_shmem_orders_within_size); unsigned long vm_flags = vma->vm_flags; /* - * Check all the (large) orders below HPAGE_PMD_ORDER + 1 that + * Check all the (large) orders below MAX_PAGECACHE_ORDER + 1 that * are enabled for this vma. */ - unsigned long orders = BIT(PMD_ORDER + 1) - 1; + unsigned long orders = THP_ORDERS_ALL_FILE_DEFAULT; loff_t i_size; int order;