From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380014; b=BZ4mh3zrBMNHiPdII+2sL8CaaahuYquwSl334I3ullpFAIr3EA6aZM0jxFRMEq9kZS0i fTkixWO2JvxuWn1XntFj4JqH49NHMQ3qyqPdBDKceTJR7JFKKPnikQTbe5kZGzJuXEdCu AZrPJp+nC8fTycqYyaVU7R8BV+kd81qGqgIzmRnqaO8VKLp7MC7TG7vc804Z6wPDnyvo6 bQsAPYKpPz9aiRfBAPyrE/RhDMfPOU6Z/2cLiiYf+2vZB3smC46fLFu4jbG/SY4nIahTh 4h6E57BqqQ5+QBYljmvFKplyRD5x+dVt6mZWQZWA1QEMKbgcKCIfrzwTAyC1OuTekBw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380014; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=C5ONqeKV6DduWy1M7bUIwMSLQTbf4E816RmFBZZOxQ8=; b=Mi9Bzay4JRxCGQKzrlu8frPcDfsZUokUYoT2dR6d6KYhr65dkebc1kN7LrzKsFDG0Yuh K+Hmuhkmo1V5ffiNt7YNu6pXd8/lwz3NlT+9lP5DFUUElocyQUFIz0DW/fmJ8YaSiUjXd mQwa11HpS9s+mAu60wE4nW53TVA0AXcZFQ8AyNqljg6cafKe0SHIaCN5ZqJpFOJVO5xu3 CdME0jmM9Wz+tWFZ/OY8k0G/pchOUrkkeLaDSf8IJTpGVYeXRsjkXXde3NXZeqN2t/iSr t8WmwUWtqE7Cz0l2wMqeW8wFFvOOXr3kBH5sGJEB6k23WsW7ykPi+2ctybgueSeIdQQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=M8WBGFFu; arc=none smtp.remote-ip=209.85.221.49 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63A81606A322 for ; Fri, 4 Dec 2026 10:26:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 63A81606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=M8WBGFFu Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-48dee593f18so780533f8f.3 for ; Fri, 04 Dec 2026 02:26:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796380012; x=1796984812; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=C5ONqeKV6DduWy1M7bUIwMSLQTbf4E816RmFBZZOxQ8=; b=M8WBGFFuNQJb/eSUbwWVbG9jeZzTGpL1qvwhkRjd+U/+05k+hsyqYuQ+A3maBfb4RR 42xusKY7zMgyoG2/9kZZTLR/V+Su87ZAjkYu3DrdAFM8c93NE1P48/r2PIueyyLwu52/ 3bnMxEX0b5/t4Px0SA3swveQzXt5wR4OrMLZFjUWljbJzvIqE9YTkdsikVvWsdXTO6Rs gilVHk6jY0wBL6sMrRMdiuj8nzm27FQCa92BOkYSZUhq5Ujc9y1r49iRujQ+vycUnB+G rlIs0Kw2flCkM7EmTsXirNxE4ykih+sk3jPrRQZcRNlK3DGKWVb6NF2T5DHkrtLt87nz QXeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796380012; x=1796984812; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=C5ONqeKV6DduWy1M7bUIwMSLQTbf4E816RmFBZZOxQ8=; b=u+aeX2M4cx8q3rpDszw2NHNXzNmH2bO9uSfDVH4cUH94F6zfVNNxXm5bwvFtEz0GaE 3yLHn2CQCpV89SATS5y9GXdh175iQoPEtn1jMSXJ8FZWuq7UrSalwK98bndBbt35C817 4HM41CN5AC6StB1mUFUBMDbhfBBU70LiUTOt2SVBsidRTyuaooiPF1HnUHRqAMnbBz4v LS0rglbCT1UjkBaFWZ5zAqNSWXlEr034NHLc+WOE5cmepAVMCIlqNmvbxFi8UbNbbKlR 2oqWHTR1DIJQ2LkssMvYQrvYFg0qYpH+VvuYwznbDHhTL8Luc6eoQ927yf1tlQQ9n8+e +wdQ== X-Forwarded-Encrypted: i=1; AL+hErFL6huuSxFtMv83EI//wWMGADlWzPMXcKAKaCYRhReZf4j7jThtn4zSju80g5pcdfD32LRjLJs+ZIIXYtA=@vger.kernel.org X-Gm-Message-State: APuU4Z94nVn6sqIHO+CZ5yyUu9K4mWdIErOS+TFvZmEh15yUG7Fg8NDD vV+nBo3dnoYlQgpcx0ygd5zaOoqantvH2/aUgX7newRxvg0qVgptAZAQ X-Gm-Gg: AZFdTZe0qiyhHxpNbK9DEZ1BHj6T5Y3g6NTFmbHHprdwQre9tfw0/NQHWpOlkP9MzGF SDH/ond8S5ZBRZjU9vcQaboo716lPOAvTUL7H8/h1wZ/S1ZI99HFZLmQVgY7QDQABMPX5ykPT4e zgF82GBGAuP8O5OCBCdCNAfYsRJb5m1wBJGfIxrfJHMrSCAObuRHEZvc2omEjX8gH0NeD4MMJzi gfKvpC1CC6od0F7PAl8X7b26CztbadZVWFuGzTAu8ZTyVZ0TS8HYOfth4taxG6A+QXgJbb6eAy3 Mex9jXzMBSBNliQdvvHb+4O2iRbhb5yzK2v2Tv65LOcNzwlZJgGSx2vRYR6SzkNaHYH72Dozpxu QYQ4Su0dZvVPN3EQw5EiQ617QtXzN97Dd709C3DMMA/m5m0SFmF/xswuzYsH6BqcrYnm5nHAlPt 5Q0/3DvXmm4mz2RDS4/Ow26MIQi7vp6Y+EaxLegB5KSrECwnwgli7UKLrpeRurTWYjBg7MxPX40 BJ3uHxweN2xWNzgfYoggiBbJ6JiBe0I9ikmBpCqnN5WegDi2Cho3rHe3jH5fMDjH048svz+udQA hoS02cn0gvFeuD/Yh8gvtJnB7aQiZJ/VgBe+pwGZzFD01vwW3eoDteY= X-Received: by 2002:a05:6000:619:b0:4a7:1fca:e52e with SMTP id ffacd0b85a97d-4d1ec91ba67mr3084653f8f.50.1796380011516; Fri, 04 Dec 2026 02:26:51 -0800 (PST) Received: from [192.168.1.22] ([83.231.69.9]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d1724ad3a5sm5677413f8f.9.2026.12.04.02.26.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Dec 2026 02:26:51 -0800 (PST) Message-ID: <8104662c-d870-49e2-a92c-4b4e7ea609f7@gmail.com> Date: Fri, 4 Dec 2026 11:26:47 +0100 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 04/35] mm/hugetlb: return the reservation to the subpool on error To: "David Hildenbrand (Arm)" , Muchun Song , Oscar Salvador , Andrew Morton , Hongfu Li , Jinmeng Zhou , Mina Almasry , Davidlohr Bueso , Naoya Horiguchi , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Michal Hocko , Jonathan Corbet , Shuah Khan , Randy Dunlap , Vivek Kasireddy , Mel Gorman , Hugh Dickins , Baolin Wang , Dave Airlie , Jason Gunthorpe , Andy Whitcroft , Roman Gushchin , Barry Song , Andrea Arcangeli , Lorenzo Stoakes , Suren Baghdasaryan , Shakeel Butt , Pedro Falcato , Jann Horn , Guillaume Morin , Yang Shi , James Houghton , Rik van Riel , Harry Yoo , Lance Yang , Axel Rasmussen , Peter Xu , Sasha Levin , Kiryl Shutsemau , Christian Brauner , "Steven Rostedt (Google)" , Hongbo Li , Gregory Price , Zi Yan , Joshua Hahn , Rakie Kim , Ying Huang , Matthew Brost , Byungchul Park , Alistair Popple , Andi Kleen , David Rientjes , Joern Engel , "Aneesh Kumar K.V" Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, Gerd Hoffmann , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Johannes Weiner , Chris Mason , Jiaqi Yan , Sashiko , stable@vger.kernel.org References: <20261203-hugetlb_fixes_2-v2-0-9bbeabb555d2@kernel.org> <20261203-hugetlb_fixes_2-v2-4-9bbeabb555d2@kernel.org> Content-Language: en-US From: "Jose A. Perez de Azpillaga" In-Reply-To: <20261203-hugetlb_fixes_2-v2-4-9bbeabb555d2@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/3/26 12:37 PM, David Hildenbrand (Arm) wrote: > When we fault in a folio in a shared hugetlb mapping at an index that is > not reserved yet on a min_size= mount, alloc_hugetlb_folio() can take the > reservation from the subpool minimum, and we perform the reservation for > the folio's index in the reserve map. > > If something goes wrong before adding the folio to the page cache, > restore_reserve_on_error() is supposed to undo the reservation in the > reserve map, and free_huge_folio() is supposed to return the reservation > to the subpool, like we do for CoW mappings already. > > However, as the folio consumed a global reservation, it has > HPG_restore_reserve set. So restore_reserve_on_error() keeps the > reservation in the reserve map, and free_huge_folio() restores the global > reservation instead of returning it to the subpool. > > Consequently, the reservation from the subpool minimum is stuck at that > index until truncation. As vma_commit_reservation() does not charge the > hugetlb cgroup reservation, a later fault at that index will consume it > without a cgroup charge. > > Reproduced with a failing UFFDIO_COPY on a min_size= mount, followed by > a fault at the same index, inside a hugetlb cgroup: > > hugetlb.2MB.rsvd.current: 0 instead of 2097152 > > Let's fix it by clearing HPG_restore_reserve in shared mappings as well. > On success, adding the folio to the page cache clears the flag. > > Note that we have to clear the flag before vma_commit_reservation() > now, such that the race handling can set it again when we raced with > another reservation. > > This has low urgency, as it only affects the subpool minimum and the > hugetlb cgroup reservation accounting on min_size= mounts. > > Fixes: 1c5ecae3a93f ("hugetlbfs: add minimum size accounting to subpools") > Reported-by: Sashiko > Cc: stable@vger.kernel.org > Signed-off-by: David Hildenbrand (Arm) with sashiko's points addressed: Reviewed-by: Jose A. Perez de Azpillaga -- cheers, jose a. p-a