From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 EDDEF17A305; Fri, 9 Oct 2026 14:16:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791555407; cv=none; b=fBZtN1ZgjzfagTnt9EUnnF/Ts4DDESpplzHgy3KnDdE+DdP8oFj23FwjJsq4g9238C/HqyGD8+7lUMfo83msRgVebKkaJT8VOgWjjoivTNPpnRJh7CC4HMmMkOwpj82PgzqXKx3MVu8sm7GWzNSlO3aXDMzhvaUlztRZqfrEtN0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791555407; c=relaxed/simple; bh=5S2b8d/BLyeBM+1mqNtDmwvrd/eL3XqRRxvMsVEfW4g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KBArUL2qPnAtUdNi8/EvsUldvQwaMzoLfxytmD4CIIvGBU/v5b6ClJqWdlScJCQfZDSUHDGigy01orqgZUax1vkjuUnZ10O6eKTyCwAQIVk83hjBsHDPbADg7r7WHWt+ZosFdv7WRmPCC2/fT5/J66RW5lcV/5F9USUuzlfGms4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xZ6fPtl1; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="xZ6fPtl1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4C331F00898; Fri, 9 Oct 2026 14:16:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791555401; bh=oxNI1Lx7XEoi5A58N0lKT5t4tE5xUv5Z22/+eugRGL0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xZ6fPtl16Ta31IqnTO2IYAosQXbrWvuLk97BLTNbN+McsE6BWhS2svlZXAAx0AQlV fL+lrq33T4D/NoW1dMOZ8yY7MdV/y86agklc7C6RTGg/i0hdSRJlDCgVts/8Klv1e+ I1XAvgRBQrXbDYv9Stby5aGkjixK4wUZSO6VImbo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Baolin Wang , Andrew Morton , "Kiryl Shutsemau (Meta)" , Zi Yan , Lance Yang , Barry Song , Qi Zheng , "David Hildenbrand (Arm)" , "Lorenzo Stoakes (ARM)" , Dev Jain , Hugh Dickins , "Liam R. Howlett" , Ryan Roberts Subject: [PATCH 6.18 045/403] mm: shmem: ignore sysfs configs for shmem forced collapse Date: Fri, 9 Oct 2026 16:06:46 +0200 Message-ID: <20261009140953.158458976@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261009140952.119038291@linuxfoundation.org> References: <20261009140952.119038291@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Baolin Wang commit 72c3d682c165b836b54a3d07a01f72e39c47022c upstream. According to Documentation/mm/transhuge.rst, MADV_COLLAPSE is expected to ignore any THP or mTHP interface settings. However, after commit 26c7d8413aaf ("mm: thp: support "THPeligible" semantics for mTHP with anonymous shmem"), performing MADV_COLLAPSE on shmem will depend on /sys/.../hugepages-2048kB/shmem_enabled being set to "inherit" (although that is the default), which can cause MADV_COLLAPSE to fail unexpectedly. This could cause a userspace-visible performance regression. Fix this by returning the result of shmem_huge_global_enabled() directly when MADV_COLLAPSE is requested, allowing PMD-order collapse while ignoring shmem THP/mTHP settings. Link: https://lore.kernel.org/063f655b4d6c4234f3aa27ed6ecab10283ecb880.1789351825.git.baolin.wang@linux.alibaba.com Fixes: 26c7d8413aaf ("mm: thp: support "THPeligible" semantics for mTHP with anonymous shmem") Signed-off-by: Baolin Wang Signed-off-by: Andrew Morton Reported-by: Kiryl Shutsemau (Meta) Closes: https://lore.kernel.org/all/20260908125105.1510704-7-kirill@shutemov.name/ Reviewed-by: Kiryl Shutsemau (Meta) Acked-by: Zi Yan Reviewed-by: Lance Yang Reviewed-by: Barry Song Acked-by: Qi Zheng Acked-by: David Hildenbrand (Arm) Reviewed-by: Lorenzo Stoakes (ARM) Cc: Dev Jain Cc: Hugh Dickins Cc: Liam R. Howlett Cc: Ryan Roberts Cc: Signed-off-by: Greg Kroah-Hartman --- mm/shmem.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1812,8 +1812,11 @@ unsigned long shmem_allowable_huge_order global_orders = shmem_huge_global_enabled(inode, index, write_end, shmem_huge_force, vma, vm_flags); - /* Tmpfs huge pages allocation */ - if (!vma || !vma_is_anon_shmem(vma)) + /* + * Tmpfs huge pages allocation or forced collapse ignores + * sysfs configs. + */ + if (!vma || !vma_is_anon_shmem(vma) || shmem_huge_force) return global_orders; /*