Message ID | 416274da1bb0f07db37944578f9e7d96dac3873c.1726009989.git.ackerleytng@google.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 41D94EE01F4 for <linux-mm@archiver.kernel.org>; Tue, 10 Sep 2024 23:44:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F38A8D00CD; Tue, 10 Sep 2024 19:44:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 57BEE8D0002; Tue, 10 Sep 2024 19:44:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F59E8D00CD; Tue, 10 Sep 2024 19:44:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 196B88D0002 for <linux-mm@kvack.org>; Tue, 10 Sep 2024 19:44:40 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CFE241C4D96 for <linux-mm@kvack.org>; Tue, 10 Sep 2024 23:44:39 +0000 (UTC) X-FDA: 82550460678.14.A005ABE Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) by imf20.hostedemail.com (Postfix) with ESMTP id 106461C0002 for <linux-mm@kvack.org>; Tue, 10 Sep 2024 23:44:37 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Cgx3YFqI; spf=pass (imf20.hostedemail.com: domain of 35NngZgsKCFk13B5IC5PKE77FF7C5.3FDC9ELO-DDBM13B.FI7@flex--ackerleytng.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=35NngZgsKCFk13B5IC5PKE77FF7C5.3FDC9ELO-DDBM13B.FI7@flex--ackerleytng.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726011774; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=J90/0IHODiFrv0z5R6WYA4Y44jSC3bFJWxuZTo3OsX8=; b=axf0Tm5NK/dAY0FICm6cw3QEMueuS58AuWTQwXvz1J9n17BUtSEfxr2A7LG8AEw67P3LYx jrLPVeuJLiekykk0Xbwiz+tp8i7gMu9KhdEFPuICJLaiRTOALiL1POXzLXFlVzHAHdrX9E XJqzLYiHkJFEUXWVDDlhrPwIgTJY3no= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726011774; a=rsa-sha256; cv=none; b=IT4cGOfbrzYucKI2CptPpPKl8M4iKZrUKZ7xe884y/wDpXwG7CEzn2S3zV183q8tErv4Ne /Mg3xX3yt9Or+aWNzPBbsMN7jo1fcmHalqCs6z3dFkGyrXQw0RboH/r2JIVESkdvggfPjS 0O/W4XfhwKlyUliPdrYO7a/m2KavfQQ= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Cgx3YFqI; spf=pass (imf20.hostedemail.com: domain of 35NngZgsKCFk13B5IC5PKE77FF7C5.3FDC9ELO-DDBM13B.FI7@flex--ackerleytng.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=35NngZgsKCFk13B5IC5PKE77FF7C5.3FDC9ELO-DDBM13B.FI7@flex--ackerleytng.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2073498f269so28757755ad.3 for <linux-mm@kvack.org>; Tue, 10 Sep 2024 16:44:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726011877; x=1726616677; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=J90/0IHODiFrv0z5R6WYA4Y44jSC3bFJWxuZTo3OsX8=; b=Cgx3YFqIgT6DOAh7VWYhKhr/VOeIgJh/p/Kl+ST9HmTE3S05gAVVktCcmGLb61tT5t ecrQ9KiEXTl/vyf7eso0hW/8/8gPGQhbpLXtZSxgPSttUUioatXbGOZBWicPgKHSHCQa C6EAZn5414424l+1V4pPzYrpDA8ZNONOxPLneLTqKInUU0drvgm6n6n8Ib1PVMvxjvIR NFjRhFZqy0BcudOgsxpQf3q/emyitaWfRVyhHMRMtwNqh+O24+g8JtxpRv1vYy39DUen r068wt1m/pnA+rTg/FcmQi+P61VH8y6gnyTMFRmHmi5edl0gmMu3/cBCuK532Yoab6od WX9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726011877; x=1726616677; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=J90/0IHODiFrv0z5R6WYA4Y44jSC3bFJWxuZTo3OsX8=; b=wZG7+wTCd09cwtXM63aTSrH2zozA+gUF+uUugqyoa20sxVwtTwJBGm9avuvX4nZbbH zE0PhT6B9uKUv0O7wJPmp6Tp1638pdaWvwAai+afWe1sUa5lxLfcEapcGwf7OVWQ1/fG C5e31lo1fWyiHXmusdqJ+MshjsgTlXqKaDxnilb+v4ulZ9nqBYhQFtk9GHgcEId3LCFI LRmNcDPnjAq80+0yXwioxtHCIdePhHUScFSxTfPUle33Mj/BE3gXHEMKIZqzxMnoTYlL DJWyJoWwHK/Z8AKvpv8h2IpxfXNjshd2LBl42gEZckeSzgf5++9nam0z20ylrNpK4lLh pziA== X-Forwarded-Encrypted: i=1; AJvYcCVEfMLhXu4qBUe7Frtz564e/IaZKxAXkxuUDBH+dI++bY6XRlmwvcnCCcTejaxs5pNKTG5yaXhLXQ==@kvack.org X-Gm-Message-State: AOJu0YwGvgPV2D5iKfjwY2xDJ/3bveAXEWSD4BTcLmzMGXwY8WLYWPt7 gWTeGfoabxA/JyzfZ1kGAF7kGXWCatpiouw/sEy2n/X3YbvC9j0LewxRSG2a22ZbGqqsUIbuzDl FuUneBhOCeejsAw2DMwG/pw== X-Google-Smtp-Source: AGHT+IH+P75b7qdmkP6eoZLmeGyUgGCW8nOF1XpFIdx3c0B8s35iOw3gNUn1NvFFrnEnCdwtnZF761N+oNC8hfEQ5Q== X-Received: from ackerleytng-ctop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:13f8]) (user=ackerleytng job=sendgmr) by 2002:a17:902:c40f:b0:205:4d27:6164 with SMTP id d9443c01a7336-2074c5e71f2mr248205ad.5.1726011876473; Tue, 10 Sep 2024 16:44:36 -0700 (PDT) Date: Tue, 10 Sep 2024 23:43:33 +0000 In-Reply-To: <cover.1726009989.git.ackerleytng@google.com> Mime-Version: 1.0 References: <cover.1726009989.git.ackerleytng@google.com> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog Message-ID: <416274da1bb0f07db37944578f9e7d96dac3873c.1726009989.git.ackerleytng@google.com> Subject: [RFC PATCH 02/39] mm: hugetlb: Refactor vma_has_reserves() to should_use_hstate_resv() From: Ackerley Tng <ackerleytng@google.com> To: tabba@google.com, quic_eberman@quicinc.com, roypat@amazon.co.uk, jgg@nvidia.com, peterx@redhat.com, david@redhat.com, rientjes@google.com, fvdl@google.com, jthoughton@google.com, seanjc@google.com, pbonzini@redhat.com, zhiquan1.li@intel.com, fan.du@intel.com, jun.miao@intel.com, isaku.yamahata@intel.com, muchun.song@linux.dev, mike.kravetz@oracle.com Cc: erdemaktas@google.com, vannapurve@google.com, ackerleytng@google.com, qperret@google.com, jhubbard@nvidia.com, willy@infradead.org, shuah@kernel.org, brauner@kernel.org, bfoster@redhat.com, kent.overstreet@linux.dev, pvorel@suse.cz, rppt@kernel.org, richard.weiyang@gmail.com, anup@brainfault.org, haibo1.xu@intel.com, ajones@ventanamicro.com, vkuznets@redhat.com, maciej.wieczor-retman@intel.com, pgonda@google.com, oliver.upton@linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-fsdevel@kvack.org Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: 3bkcp4aujfyoj7894uqqhwsxgrgfyykr X-Rspamd-Queue-Id: 106461C0002 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1726011877-446572 X-HE-Meta: U2FsdGVkX1+cCx+Jyh1pufsUD9QVvdqiF7TQTK0THW83m4bIobsWEl1LKoA+iD0LbIlGv3R0QnBCxp5FeCNVxOR1R0EZUO7fMRXD2e1DWjeijeXZ1T9MQY6YbiksubwpeUkHNNPnxNEsrwtOtvP34uqTeuyr10I5EYba7VtgL4SPnat6o5xhW56v7xDJ6IFgbjdL2Eui2lu53an3ma3vU0lT0IO0pvkmMmA6v6M4O8l+Vl4X7AkT3aZz8bVpbUjsh30VFEHWN2nZjE+fMUlvsawueypZyuh6hvV6AjaV/O5o2FpYInbpRWM/umy6eh6P9IkVjGDJ2rbqm0f21GEH/66NhWlmkuivVwfwkOACG0lADqaw2E/uZO9cz3F5oApBWRGIm9fLIKTRaq9IHlRm8PlqbXbS/4kpG4KvIJ4qSDxCIAmANsJspePHiOB20MZy0F6PMYOuKLIl0Zkwq2za2I/MBy4Sd/+mQBQFJztiaUMgJo8mOY0pPlI/Wjj09s1mU+13gQWYiLG/uLDpuGSGm2aSPOPb8d5gl5t6NWFrtaQLTv7UqYbI6E2oIjHUnlXSptBZJ5O/bLzG0KNiLfT1uUhclbMYddTKZXp2QGvmhUAbKxN82EZv90S+0zFz3VhN4I2bI1ELgUTqexhvgotbxBBmNyZV9gEBZ+xdWj4pW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: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
1G page support for guest_memfd
|
expand
|
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index af5c6bbc9ff0..597102ed224b 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1245,9 +1245,19 @@ void clear_vma_resv_huge_pages(struct vm_area_struct *vma) hugetlb_dup_vma_private(vma); } -/* Returns true if the VMA has associated reserve pages */ -static bool vma_has_reserves(struct vm_area_struct *vma, long chg) +/* + * Returns true if this allocation should use (debit) hstate reservations, based on + * + * @vma: VMA config + * @chg: Whether the page requirement can be satisfied using subpool reservations + * @avoid_reserve: Whether allocation was requested to avoid using reservations + */ +static bool should_use_hstate_resv(struct vm_area_struct *vma, long chg, + bool avoid_reserve) { + if (avoid_reserve) + return false; + if (vma->vm_flags & VM_NORESERVE) { /* * This address is already reserved by other process(chg == 0), @@ -3182,7 +3192,7 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma, if (ret) goto out_uncharge_cgroup_reservation; - use_hstate_resv = !avoid_reserve && vma_has_reserves(vma, gbl_chg); + use_hstate_resv = should_use_hstate_resv(vma, gbl_chg, avoid_reserve); spin_lock_irq(&hugetlb_lock); folio = dequeue_hugetlb_folio_vma(h, vma, addr, use_hstate_resv);
With the addition of the chg parameter, vma_has_reserves() no longer just determines whether the vma has reserves. The comment in the vma->vm_flags & VM_NORESERVE block indicates that this function actually computes whether or not the reserved count should be decremented. This refactoring also takes into account the allocation's request parameter avoid_reserve, which helps to further simplify the calling function alloc_hugetlb_folio(). Signed-off-by: Ackerley Tng <ackerleytng@google.com> --- mm/hugetlb.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)