From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380014; b=fZ/AQlrNSr5xYPFribnFdvSevP0jD/IISp3hjusx1w5EHtIGiH4vo5EE8LAZzgCj19+N DlIQV1KPaVD3udTcbWw8cfnhmhXSkAGIz0ufvE1BaeXhH3sFiZ8cYlcgyvQMCxdy1wLq5 pHyoqX+4P23PMj3QM4ue7lPacwHQjp9KeVoWOZ4vTmewvrj5kjJOETYS1u/mPyCDeYjXd H1zgxsi35JS6Rl1ZWz5mm7pqRyvKt2LBpTFQ1fWKvawKyAtccJtAxWjzv1SmB0YbCRnQ0 kBKkKWtB86Ezb7K5dZDh7EquInjvjb88Ba1GuHAsxNF3uy40nGDiz4uQ+kmatvmG2LA== 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=KF/iPECJygF9BXtRckpf44ttM99HIyZQnQaTL6mCA5DCJ70A8dYLFm+xOCvJJE+H+6PY ey/E0PZ7ZHHPT8D4bAGUDhHYjNRoSYL3Suij72yoQsMOwA0iaodi6jqGlmv3qbDUdBE4C PqmnoU6ehX3u2KP1CP0h1cOhTm14bJfs9joXJ9XyIfZkDyxwQkR/S182fysk9kSZLIuf5 4XVDfqma4/LXnnQXPWm7k5xUFfcieZq7bQYzTkpGMDzEkLi5mQple4CeJzFvrqoS/4IGC BczfEO1wHS/HLIkwYta6DJOEENAyUlC+BAgEP7sSOdlBLLMOITuePhXtV01ajOtc+hw== 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.50 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 63F35606A32C for ; Fri, 4 Dec 2026 10:26:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 63F35606A32C 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-f50.google.com with SMTP id ffacd0b85a97d-4aa5833c263so583102f8f.2 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=1PraP8B69ru2dsi3EgikuNHXgJ2cvKBwqh+V6ZkXVLS24h2FNSSSSE3xa01nkPdFB8 FaDsaeYDOulUiefOmQKp9ee4Zk4AL5J20PlBMBu3NBnVrw86rEFvx47PFf+MFVaXoGEq hbKixQuB01e2xPRh6s9KKmvI1OT/LkSU5Hi30Ro/GkMCybUE3WEI81iLnf8q8f+iNSCU FxFAZaRdRKbWLXqgD+SdFLPxdudN4n17P+lyL+Fh2tJkgOkYKA1PrbR4gtq/XhVhNLNn Z7DhWJoMzYuhzdscDr9FU6aTp5GeUQYZnlbrXXVn5vKP1HZMFVmLwQQiCa6RJ9VnLNp7 G3lg== X-Forwarded-Encrypted: i=1; AL+hErHY3SzHuBY+jtWf1VNM0mH2gc/SO6++wKNq8xWP93rw/noOTJN1QcgIuDHZmvJV2aIlBxMbHBz2J4ncjKwb@vger.kernel.org X-Gm-Message-State: APuU4Z+zRymS6egrMwvWNkfeAJ2viwDgpEDnk5IPSk1QcCN7EvK40ayI fI2QjcyoUoYgudSvHOnGw/1+bDhFYusOR3hENc7dQNIT0pu7ZtGSsmLX X-Gm-Gg: AZFdTZdQL1HOZ+fknO/TAhhxnYzmW4xATJqm7eZs9MfWMWw1H29XEBqAb70VwaMF49L wBspRt+yCTvtQOv3dElzOh/lRvvFBNxKcX0rmMQWQeR27cySdOAhAJLho5740W1wlJrh03fPCUo dE62WTuLIIaKaRghEzljbV+tDa5+HP5iYGpmhXbeCMuCVie2ugfkn0EzPMgylLNBOBIhmdK3LA0 adFwco+wz1bIb+aTn4ZeXKjKbsdNQXdtjV1LZq2R/VTXK8VqajApmyYIy+qI67XNrcV/A4Fra+f IzlByt2Zrum6Ap2PSDFNzy7dLkzx+z7OyPqWp0bAtEfDsySZnvc+Q6JtekNqIzK4R8boQTljqvx zpDqhXKt4PvNvcwk+V4tyrUorPnz/2bNEbdF7klLX04GIsmGcSHnK8qv/MVcwjL/Yp+CyIGMsUc TwGT7sIhzd2JpeJ9nQSFq1ua0SyXi9rg3JtoEFxknJFQiASYY3j9ek69fbJz/2TQ69hdS2zYqot uyAm0/GRufRlzhfZn+SdfQzB2FldeVa4TNMi//oJT+g69SkniQmf03SW6WnHsHQIbWnGGJKIKZ4 tkGZLNCfemeo2vp8Mo+hHpbtKnDQDgA8MzzIQcceijRB43GgeX4mA18= 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-fsdevel@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