From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380013; b=j/N56cP4YXP5g99HfMJd0w2m836uBwZ0bqbXSRECqTqiz0rZvgxhVdnsfJ8tqZ/s72BN HVdWa2f0TyAgdJeaMAM/tOIc8AxWOVWXLeVmdY90ZcsGzcQTxZ/jcP+EMe0SqJ6ItsWE0 t33pXNccLHR9JOiuL5KySftOMAvRNLChvjOa+H7fk2ngCMyKEegd0UAydmgSowYOsq1kj 4lzW9Sl8o5ZMgXJydfybcgBVtqsvZaYHp7AyVrtsTrgIZQ38pWlGDuSd3WGCoViJkETRn PcTAjWqa1p/rnWXdjXf357zDiXu/6wGEBg/BeB0FZHsx4ieDm6Qklr5OO5ea/lblwmQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380013; 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=z8HAH6hDwTE3HqUzDe9P/WouojL1Rb3fvHGCv9hNpTTW+JNBrfehag+XfexgOQKacJos OMKSDlDjbyfXx4akU7kQSLKKTTQtSI9qUUJ9Hgmy2fNQAdWs/FkVkWR4dRm6uPEh1b6qh oruxdiTNw/o20i0E5qJOoDAbAcevz2CPXfMlesYfdEOzBr8AGKxJWQtZIDExCrNNOd7kz p/pQBr86zW02D3BzV01wXWAlT0ZLH1i59RipP1F4GlbCxp0HVKCWgqltZNLkU95CShCST A/8+k5bKn+ov40L0yYCkBWMSztup9kQP4AtIWXQiRux/2qYbgiE3Uqhftute7o3xgdg== 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.51 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 65EAB606A330 for ; Fri, 4 Dec 2026 10:26:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 65EAB606A330 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, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=M8WBGFFu Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-4aa5833c263so583103f8f.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=ZOTbl4DzrAODxLXz39954e+hgwBOmO3RezCP1sdkUHPWLULL/iFgH2TcbHo4NCwpA3 Ax6Ir97kWyHW+W4A1GQK1soN7vaZNNO0zRve2PoEiTrPZPu8UUYPGe36f2YjNX+RLwa1 2xFHYQHZnnjWT2UVYdyZZNBLLkcdlSPvejWtJzcX0DCsqB5ZaSGEymlLZiIACsBdZuSa 4DDYND/LVVrq9KEJd3qXVRvPIBundAMUigB8X/tMEVaG+cCc2g8p3bSsoEDcGsGbyenN D77N7HPdVgy7rOOqbiL4lLFtMAjJZOP6+8duNz7QecOEQ0wzk/Wyd5IKZH3LZNjEpOUE lALA== X-Forwarded-Encrypted: i=1; AL+hErHrRbzBlq/gxDJhvLSxbzKjpuONaH/q/PwaL/NzCycEscgsMyxySNzH2st8drFgIyRVvYje1vk=@vger.kernel.org X-Gm-Message-State: APuU4Z9bFSpj2R1pFr03TchUHsJE/4eF8vie6PpbEH3AiWo7oiQnNwBw foLNcJGviDJYFf6dY4gCaYAy5Lcmv41TWlWivbWo/sEq5WplTq43I4w2 X-Gm-Gg: AZFdTZe12E0zh4sCnYt3DBt4hBxItG4U9PhNBklTwjq9MWZ/xG33dnVBOlsdPVsrFUV ZoIdeY6ADIr/F3W7T8yEJVd5UVEWFZCV5GGpbFaQSjPSjVxAwQ7SZGjxYp7NefdzbEvct7T1Rfx O7lhhbRNtT96qTHI8CXmGohSdvAMHmiF0ls+tn58ZHBo7544qgagn4g46nw9QFXhVu0aQtDHe06 +efLp6SwnG6cJDwja0D+8EzWcfVUUyPjFrXbA88fxW1bL6742yKkmvZ4peC/pYNZ8VfxN1le9ig Dh8WPyyrTUag5Qlg8jNjjCZ+kKPMVXkQEU1jzOAzsdYvYUbUAlrRPgD6p3PRParXa6bybXmIwyO 4I+CA8UwcBHC3PJGg1TdhibVKoMQcJ3BI1USpD+IPNlaEyeL4tqGLpHCZ1pN9CPkvomnIhCdwX7 LQGTqfLKXe4OfeRY69Rg6NnnDfwe83w3MwcVtSqqx4l+cyZGaxLoKGva4yq0aMAAuwwAmsidvVT MwzJ9aBLT17H/jNDqm2xQfUlG0FBQPQH4w/ZA3xPwGv8wHSL5LBNhmYR+HJyPzRDyf+6f8zAkik hPo20PbhOeCNUfNIE/VmaG1hkvCsqV4CKBNRIS8395GTxH5HNacOLG4= 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: stable@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