From patchwork Tue Jan 7 20:39:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13929590 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82129E77197 for ; Tue, 7 Jan 2025 20:40:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DAF726B009B; Tue, 7 Jan 2025 15:40:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D5DDA6B009D; Tue, 7 Jan 2025 15:40:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C25856B00A3; Tue, 7 Jan 2025 15:40:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A3E536B009B for ; Tue, 7 Jan 2025 15:40:10 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4ACC31C7C5A for ; Tue, 7 Jan 2025 20:40:10 +0000 (UTC) X-FDA: 82981822980.24.9288751 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 004D440006 for ; Tue, 7 Jan 2025 20:40:07 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="W0n/H4MV"; spf=pass (imf11.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736282408; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=oXSaxIGrBHbOX/JDeWthayCloueSD2Pd/sShB7OcJNc=; b=sW1BVvlJ4QfGSDryOc4UhF1fqAANXpp32UDK+b1BBcZMhJnzKkg5IAV2PqenHnj/iU/DVF a8vYp23yPtsAsvP9y2QIanoZ6nJdChC5N3GQjsq4iX6u6wAHE7RDNt4dddnDTap7QZzOdy LJzSYjdvqgdrHclL/hDeijhJt2/aDmY= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="W0n/H4MV"; spf=pass (imf11.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736282408; a=rsa-sha256; cv=none; b=2yNfFO7Q0+s34JP3m4Cu0/6uYM12QyWNV3iEjSHcgquYAgD1Vv0LX/EzF1hmlZXBZGDUZ2 akpeAwZeFMHD7NZCquzkZtyy70bu8463+a6Xf0TMCm+0r03vpW/B1jgshcJTujy+kr1WE9 ykCfgk84JIkFDpsszofjj9U0teWQaQ8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736282407; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oXSaxIGrBHbOX/JDeWthayCloueSD2Pd/sShB7OcJNc=; b=W0n/H4MV4YvSXYSrFJk+z2vlTOAWV/v/J9khmUtYNSvAjaQ2GPE0MZI84/P8TU2VwtjsDw lyyxwUuwjFRUPvcTGkCMWk8AxNtwP2y0YmInStGA2+HtOQCT9twfgslG4GcRCG212f3+j8 IpDjDG2QXHzVN5NSXpbqckWAjshbF34= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-615-jC8lVLahO3i4CD6w-UxcHw-1; Tue, 07 Jan 2025 15:40:06 -0500 X-MC-Unique: jC8lVLahO3i4CD6w-UxcHw-1 X-Mimecast-MFC-AGG-ID: jC8lVLahO3i4CD6w-UxcHw Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6d8844560e9so355612486d6.3 for ; Tue, 07 Jan 2025 12:40:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736282405; x=1736887205; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oXSaxIGrBHbOX/JDeWthayCloueSD2Pd/sShB7OcJNc=; b=NUg6FKQFKoc3V4Lr/FrA3G0z5Vq2LTtVHGA061FWr17oTvQLZFL0o/3JEvsomf5oW5 7OE1UIbStDeWaI/qhaPywk4NKBKT0s7myqN2YPTsYO8HTMGCnWprBR6CiU2/jasxal5V NBbgEmnCSsdT+//jeJ6WKsdnrGo0ORwaASAlUtOcysafu12d3qOLsiBLtiH3EeeqBq0a tUNgh2DRvip4jJ6LiWoiUopJ90zbo25dtDvcbzoNHXeUOkCOHbVV1HaJZyO8+nAMbjBK o5iMJ/S9XxW96SrImrqEc3Uajt0y/vQVBGRwFsQ2tplPa1t3TBaxt/tlxB7R3o3u1P0v FUaw== X-Gm-Message-State: AOJu0YwruwJ2YNFr5G08FrH63kZ1RP0aUsdZ2u4bcqBM5jhoobw9DSwM ZZjQpsag+mBjdAO9VBbIavduO8IDTJQzXBHGRWQ+DoSKPxIGDXyrO1cjk9RvP1viEzyPj+Rqg4x i3YneVSAK0eoBE5UnkfSdkuLos7ybxeLZkBKOICVi4huUwF+CAYdph4HzE5Q7ofrPIpn2aqaFKI LBv7YikQdCgB1hqOGE78s8die9uN+Qcw== X-Gm-Gg: ASbGnctarCaN3GDT9AKXXAvnB/KcphkZbLJk2Ut4djNtndZEh86xOK0/7jhHTl2G3Pf 6o7x+y9KNeVAqjJoGUyc1aHxyNGLwg1YRN4vR/UbzPmrMUNu4Gk42K99/7R0QAKdDNT9+VEwVto 61OI4VnDygFdNsI9qiYbdyzQ6CfoTyxxJ9PWX7IChPfVSuBq9aMR4Z0lIE9J8Fe8NS3L7zW48uW vbXlX96E+9vYFQKI7BAfTbEkNpNTwiB0m/ctcw/HfeBwaAExhIqDCWbuWvdctj9QgipCgICnmhn 0FQdX3UZOgkTVby+eiqj/iZQfU7DDf4E X-Received: by 2002:a05:6214:c8c:b0:6d8:a486:e87e with SMTP id 6a1803df08f44-6df9b33ded1mr6995866d6.49.1736282405539; Tue, 07 Jan 2025 12:40:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdrE6BHRlIB1SxuFQxwDqebIsWVKLARnXTWgDNEswCASHOe56LNxGGA+8+cFSe2wf+B55Zxg== X-Received: by 2002:a05:6214:c8c:b0:6d8:a486:e87e with SMTP id 6a1803df08f44-6df9b33ded1mr6995406d6.49.1736282405119; Tue, 07 Jan 2025 12:40:05 -0800 (PST) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6dd181373f6sm184478306d6.62.2025.01.07.12.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 12:40:04 -0800 (PST) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Breno Leitao , Rik van Riel , Muchun Song , Naoya Horiguchi , Roman Gushchin , Ackerley Tng , Andrew Morton , peterx@redhat.com, Oscar Salvador Subject: [PATCH v2 0/7] mm/hugetlb: Refactor hugetlb allocation resv accounting Date: Tue, 7 Jan 2025 15:39:55 -0500 Message-ID: <20250107204002.2683356-1-peterx@redhat.com> X-Mailer: git-send-email 2.47.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: eIi8SqGpoC4F2g3QaIwKuWPhdaacZ8jJnxIK6eHwmao_1736282406 X-Mimecast-Originator: redhat.com X-Rspamd-Queue-Id: 004D440006 X-Stat-Signature: 4sk76cntzi1e9r9c5iw1ynacq8dnatzc X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1736282407-118891 X-HE-Meta: U2FsdGVkX18FQrvsRVPpoYibriKrpi+RGYs/K7r1ISUpSwc5atvPm0LavIkXlXTBkfdI0ppT4GJDEFI3h8dr00vk3QY+1ucFDQbxgFl6gjp+qKm7Z+I3k5QZQHwbo9wAV+b3g27Mt73sHbMxAUDqFoHxZTk9HeA5WhHPk4zuGDEOquHO5ykpLqQ1Rno2/SOci+7aXR1xCEJDyHIjUmTgKTHUK4U+Lg7W4nXRsj6CWyzlDi5Cg+dLNnpmR5ni2j+2tn/CLwB3DnQvbDMcWSe6roQH3GJuLRmAP1uweFj96SMm/K31yp7qaagV/XBzHFuSRAzx059lt/pu8/UQrCU6GTaJN+QKUaM9AfxESbAZCGQdqgOUUjeiVx0cJXruS62wgckVa5tz9Hz6Kt3TX1rry5JXQ86JiWJj+EF9pZT126Kre2bW5j/4lHKZf9hDC6dOCaglNI52kz3M5cW5vXSoyhcDJo0ZY7zXAhAmaR8f53t6aho3gCFsry3Sm8vA6z2f9m030XNnGlpW+Wxs+GImA/e/Ipzc5L7m2OSlbWCdRNRUQI2iD8NCExN1aXWloquA53GOYhwRH6ZAjQajg65yMVtoLeelkCgFJYAyPEUbhGcS9WXZEKX76oOML7zWYH5cwo3yhvvbAuvHRGRzxf5mX0RWWmrVewv3qMW8zFUDfTsD3x83ygbSXhtvLc2v4OhGNen6YAHVi64g47KrTQl3QSrjTfP+nBDcTazyxtpP+JZ/m/KMGjCvrdXjFZ37u59rOd12q4cOnTamoTbG8wjvj9BunedvZHFyN+9WynNxpnF6tL+VxsBCRHp0cIeF+DmfAoVSev3f104riZmd5UJ7pgyALsZYM4b9ajTDt+9vFwC/6VVpY8dmftiVhZoM/cW8P4UeFLU6WlAB6x6JgotocXvrdvA3NvOrFzWlpMaML0NaX2a+hc7l4GZ6e1kbGNXpj/6iuHIqMkNfduLr2Uq YiPjjQ40 wltB0Q5aggtYexhU4M8hVEOtn+RjcBQ/rdSxGe45Ef2gXIs9A0YnOOlX6maY1IbZPW0KsQfleNrSLK7bs6Z1qrHPkTKlhZXusU+b9ZnknTeAXv/olC4ZYibYZBs5pAl/RKv+QHRBkhdIyp8V4HvqVTmGGS2tzhHvLDsYTKvIa/nAPjZeFkhQgAAhf3EZrOQws+B0r+LKYUZ7nUOQZUd9ihM+z2q8C49ZmWIv7mxQIlZtOn/i2CMcNOgkr37hIfV1P3yqRTvxCmU3hloTwS19mo35myMAxDccKnc03fsmpajqhq6oTkLH7tpIZEyu141JpVJZffVSSsxbyPSPSfuKq8pmJcGX+6ta8v+3QFyh4vgan3WLMqTN4Ndq6PtAAWhkfz41kOjX0jcXDy4TLnrzC6Fr/RC3JoyHkJdYg2jDvkBOK/rb8jlfHyiuM+p7rpfcfWXLV2MaR3nJMhoA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: [based on akpm/mm-unstable, latest ca95745c20ad, of Jan 7th 2025] v2: - Rebase to latest mm-unstable - Added R-b and T-b for Ackerley on patch 1 (Ackerley: I was conservative on the tags here to only attach them in patch 1, even though it seems you mentioned you agree/tested with the whole series. Please feel free to provide your tag again on the cover letter if you want, thanks) This is a follow up on Ackerley's series here as replacement: https://lore.kernel.org/r/cover.1728684491.git.ackerleytng@google.com The goal of this series is to cleanup hugetlb resv accounting, especially during folio allocation, to decouple a few things: - Hugetlb folios v.s. Hugetlbfs: IOW, the hope is in the future hugetlb folios can be allocated completely without hugetlbfs. - Decouple VMA v.s. hugetlb folio allocations: allocating a hugetlb folio should not always require a hugetlbfs VMA. For example, either it got allocated from the inode level (see hugetlbfs_fallocate() where it used a pesudo VMA for allocation), or it can be allocated by other kernel subsystems. It paves way for other users to allocate hugetlb folios out of either system reservations, or subpools (instead of hugetlbfs, as a file system). For longer term, this prepares hugetlb as a separate concept versus hugetlbfs, so that hugetlb folios can be allocated by not only hugetlbfs and other things. Tests I've done: - I had a reproducer in patch 1 for the bug I found, this will start to work after patch 1 or the whole set applied. - Hugetlb regression tests (on x86_64 2MBs), includes: - All vmtests on hugetlbfs - libhugetlbfs test suite (which may fail some tests, but no new failures will be introduced by this series, so all such failures happen before this series so shouldn't be relevant). Comments welcomed, thanks. Peter Xu (7): mm/hugetlb: Fix avoid_reserve to allow taking folio from subpool mm/hugetlb: Stop using avoid_reserve flag in fork() mm/hugetlb: Rename avoid_reserve to cow_from_owner mm/hugetlb: Clean up map/global resv accounting when allocate mm/hugetlb: Simplify vma_has_reserves() mm/hugetlb: Drop vma_has_reserves() mm/hugetlb: Unify restore reserve accounting for new allocations fs/hugetlbfs/inode.c | 2 +- include/linux/hugetlb.h | 4 +- mm/hugetlb.c | 237 ++++++++++++++++++---------------------- 3 files changed, 107 insertions(+), 136 deletions(-)