From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta1.migadu.com (out-211.mta1.migadu.com [95.215.58.211]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F5463B442B for ; Mon, 17 Aug 2026 07:39:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.211 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786952393; cv=none; b=K25S1F+5c//OGXmhOF9KsqGVbiI+6+ZzaZ3b+DYTPWDTbyA4IwL0zGTIskc/E65noVTIjGe96K0u5A2e+kfPjkNWG69hPnf4mWH28lcy4nxDr0nVHtNQGorEd/mzZxjNTqCIEP0gDSbYKz5G6TsN/uorn8comR4ehj9vnOSEdTQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786952393; c=relaxed/simple; bh=T7n46oyF9uMYAvescm6EbD1SiXnZCBlOdjs6H1Md6CA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TfWdA2C8EpOWbbvMEB13wRG5L+WvSWEI98RTiAFxjnmXyT6EZHVEBPkSohn7c+yFxvsKWaE8YE7aUf8w8go2kOTJsmxAkYZEwzlFlE6HNbyx7kI7MnbSEoL1bde/9h00l/Vbcr/1U7gdcHpJSkB5ZmmAHpCOb4O6tEdL/UCHNmc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=rMEliuDM; arc=none smtp.client-ip=95.215.58.211 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="rMEliuDM" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=T7n46oyF9uMYAvescm6EbD1SiXnZCBlOdjs6H1Md6CA=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1786952390; v=1; x=1787557190; b=rMEliuDMGDk66yf0sh99HTgxUbHfh1wm8rxF+U7WX4hGNyX4LFynEc4u+skXy1TtrrnPSMDx ZeniCzuazGQPFTUcANjvv/Mfztnb3rEgEd4X+I7gC5UqUcjUUPrsq/l40tMunbFRhvxCaUzMooR WHvGRkS5ySo8tZJHedCN1GLc= X-Envelope-To: linux-kernel@vger.kernel.org Received: from [10.244.244.3] (2602:fce1:44f:115e::) by smtp.migadu.com with ESMTPS id 43d45dcbdeaa6b07; Mon, 17 Aug 2026 07:39:50 +0000 X-Migadu-Flow: FLOW_OUT Message-ID: <9255fa58-1fda-48d5-9353-f234fb35b78c@linux.dev> Date: Mon, 17 Aug 2026 15:39:35 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm: shmem: fix incorrect vm_flags usage when checking allowable orders To: Baolin Wang Cc: ziy@nvidia.com, liam@infradead.org, hughd@google.com, david@kernel.org, akpm@linux-foundation.org, nico.pache@linux.dev, dev.jain@arm.com, ryan.roberts@arm.com, baohua@kernel.org, usama.arif@linux.dev, ljs@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: Content-Language: en-US From: Lance Yang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2026/8/17 15:16, Baolin Wang wrote: > Lance reported that when MADV_HUGEPAGE is set on a tmpfs file mounted with > huge=advise option, khugepaged fails the allowable order check and does not > scan the tmpfs file for collapse. > > After commit 6beeab870e70 ("mm: shmem: move shmem_huge_global_enabled() into > shmem_allowable_huge_orders()"), the shmem/tmpfs allowable order check reads > vma->vm_flags directly. However, when MADV_HUGEPAGE is handled, > khugepaged_enter_vma() is called before the VMA's vm_flags have been updated, > so the check uses stale flags and incorrectly rejects the VMA for collapse. > As a result, khugepaged does not collapse the tmpfs file into PMD order in time. > > Fix this by passing vm_flags as a parameter to shmem_allowable_huge_orders() > instead of reading it from the vm_area_struct. > > Reported-by: Lance Yang > Closes: https://lore.kernel.org/all/20260815181632.21453-1-lance.yang@linux.dev/ > Fixes: 6beeab870e70 ("mm: shmem: move shmem_huge_global_enabled() into shmem_allowable_huge_orders()") > Cc: stable@vger.kernel.org > Signed-off-by: Baolin Wang > --- LGTM. Reviewed-by: Lance Yang