From nobody Wed Nov 27 06:37:21 2024 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9678D1E0B6D for ; Fri, 11 Oct 2024 23:22:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728688978; cv=none; b=Z/nafZFwxjIww+lHiaMoYp97T7zB+ZHCionsOre2Cf4NC/QCEM3hDJ/Ti6nOcif/y0DoS/tx08kFzge7EH4AzFqPHpaxRp1QkRlEFbcG96lsrIjf353z7bGE08xSNBxwZC9HC7hs3w/bhbPtypRbDNWb6wHqcc3s00bTNn8hY3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728688978; c=relaxed/simple; bh=Gau1ydTYGuCvwtKgP2KlmKQaOwOGpCa5RoKlrazqx2Q=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=OffLzh2r02ckXXsPAdHAcGJSBpHQqP6uI16RoIQgOcl38OmookLcL8YmjkeW0d+RjGuJMKQ3H6lGBmgfrMYF06/TXZCaWadPVC4gqYHKcorpMBnH3kA1wWg65oucb8vGrh6TurnCArUsnHcC4jj+GQN4Kks7he/40edS9U1Yrus= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ackerleytng.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=3Q67KLpj; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ackerleytng.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="3Q67KLpj" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-71e49ae1172so531285b3a.2 for ; Fri, 11 Oct 2024 16:22:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728688976; x=1729293776; darn=vger.kernel.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=5z/uTVdP5L9L1RuFDdlTqhHJV3lmY38mQBJGe8OEp3E=; b=3Q67KLpj+aNbjUX5LCuovoNjmxYYBTIzxWyuyMWFeaPs1Xt5OSCRz3x/DKxcTG4Imq 1I+PIwBCx2GL+0YX11IlYTFpJh/yQeChGWFw53B4XuHWVooLZjk1XBypUSeyWRLoWjmu jmRQQhyPKnFB48XKHY+4kleR3Zku5XkH9d23IIiocffqnXeBR5hVcX3o8ubbzD1z80uo hdkKqAvWfRYUY68pcVKMXdyg2ioJfH+9Uw61xMzLhOZEHqOMZbEwybQW4kkB7YM51ITz tXUEQDGTin9tVr33YXX7ZDL7esmcA/Xp5pBMZ1fpTBMaAGm+aF7QA5q0k/vy+O+VB0eH lpBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728688976; x=1729293776; 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=5z/uTVdP5L9L1RuFDdlTqhHJV3lmY38mQBJGe8OEp3E=; b=WNemm+wtmSZqFpeQ4Tyi5LnnQ8a+jMyc7pqO51rieQBAy0rlG+9LYRrvX3PlaeqvF3 9DE6pHNvSL8yipYZISO+hIDnZe3Wv2EzWomIv+M89A2V+Ll3cpvzJdnVIAiBLz7zm/PV KxVXypf35FSAkr9ZVPoKgX4lXSnL8HVtf/tEIjyP9kaKVQ6SBpLPvzogPhDPwn5vC+xZ HGiDB+ivR5rTeYU4UfYdgj4qz25fRIoW5c6O684iurjRqkfzgchKmgPmdmWpteGUhGQj 8qNBSFX6CVccLAXvvpMY5DDC25nevkAmfFFAwgC8OoeqVIXJsyfPYWo6a58AwVFyGKkO 6CwQ== X-Forwarded-Encrypted: i=1; AJvYcCXTSP8lJ7sCsr8YJRIwOS6ONc8mLWslkyDL3acbFDJcZgvDoUzIFC4jZ5EF82GGy9xij9A08+RJtO9duew=@vger.kernel.org X-Gm-Message-State: AOJu0YzrCvQKF+f9FwRj9jO4jph4KwPlqHLFIg0akZfWk4mumA5To6ge Y/9Q5m6qeJh2wDHu++tmIyQ9cxFVk27GmUvBfLv+drs359NvBfgRQdPK20t8rxURnajCEC7PL17 U+2iggSVF+DRCzlW/X5S1Og== X-Google-Smtp-Source: AGHT+IFfT7z16+ucRzSRkvBaeFJLnd4Fcce7MUMDnNMVo0kKP75g66nPfjELWNwdxuLQm7HYU5qKFyPa9P3bxM35iw== X-Received: from ackerleytng-ctop.c.googlers.com ([fda3:e722:ac3:cc00:146:b875:ac13:a9fc]) (user=ackerleytng job=sendgmr) by 2002:a05:6a00:6f60:b0:70d:fba:c51c with SMTP id d2e1a72fcca58-71e380c6404mr6646b3a.3.1728688975598; Fri, 11 Oct 2024 16:22:55 -0700 (PDT) Date: Fri, 11 Oct 2024 23:22:36 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Message-ID: Subject: [RFC PATCH 1/3] mm: hugetlb: Simplify logic in dequeue_hugetlb_folio_vma() From: Ackerley Tng To: muchun.song@linux.dev, peterx@redhat.com, akpm@linux-foundation.org, rientjes@google.com, fvdl@google.com, jthoughton@google.com, david@redhat.com Cc: isaku.yamahata@intel.com, zhiquan1.li@intel.com, fan.du@intel.com, jun.miao@intel.com, tabba@google.com, quic_eberman@quicinc.com, roypat@amazon.co.uk, jgg@nvidia.com, jhubbard@nvidia.com, seanjc@google.com, pbonzini@redhat.com, erdemaktas@google.com, vannapurve@google.com, ackerleytng@google.com, pgonda@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace arguments avoid_reserve and chg in dequeue_hugetlb_folio_vma() so dequeue_hugetlb_folio_vma() is more understandable. The new argument, use_hstate_resv, indicates whether the folio to be dequeued should be taken from reservations in hstate. If use_hstate_resv is true, the folio to be dequeued should be taken from reservations in hstate and hence h->resv_huge_pages is decremented, and the folio is marked so that the reservation is restored. If use_hstate_resv is false, then a folio needs to be taken from the pool and hence there must exist available_huge_pages(h), failing which, goto err. The bool use_hstate_resv can be reused within dequeue_hugetlb_folio_vma()'s caller, alloc_hugetlb_folio(). No functional changes are intended. As proof, the original two if conditions !vma_has_reserves(vma, chg) && !available_huge_pages(h) and avoid_reserve && !available_huge_pages(h) can be combined into (avoid_reserve || !vma_has_reserves(vma, chg)) && !available_huge_pages(h). Applying de Morgan's theorem on avoid_reserve || !vma_has_reserves(vma, chg) yields !avoid_reserve && vma_has_reserves(vma, chg), hence the simplification is correct. Signed-off-by: Ackerley Tng Acked-by: Peter Xu Reviewed-by: Oscar Salvador --- mm/hugetlb.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 190fa05635f4..73165c670739 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1281,8 +1281,9 @@ static bool vma_has_reserves(struct vm_area_struct *v= ma, long chg) } /* - * Only the process that called mmap() has reserves for - * private mappings. + * Only the process that called mmap() has reserves for private + * mappings. A child process with MAP_PRIVATE mappings created by their + * parent have no page reserves. */ if (is_vma_resv_set(vma, HPAGE_RESV_OWNER)) { /* @@ -1394,8 +1395,7 @@ static unsigned long available_huge_pages(struct hsta= te *h) static struct folio *dequeue_hugetlb_folio_vma(struct hstate *h, struct vm_area_struct *vma, - unsigned long address, int avoid_reserve, - long chg) + unsigned long address, bool use_hstate_resv) { struct folio *folio =3D NULL; struct mempolicy *mpol; @@ -1403,16 +1403,7 @@ static struct folio *dequeue_hugetlb_folio_vma(struc= t hstate *h, nodemask_t *nodemask; int nid; - /* - * A child process with MAP_PRIVATE mappings created by their parent - * have no page reserves. This check ensures that reservations are - * not "stolen". The child may still get SIGKILLed - */ - if (!vma_has_reserves(vma, chg) && !available_huge_pages(h)) - goto err; - - /* If reserves cannot be used, ensure enough pages are in the pool */ - if (avoid_reserve && !available_huge_pages(h)) + if (!use_hstate_resv && !available_huge_pages(h)) goto err; gfp_mask =3D htlb_alloc_mask(h); @@ -1430,7 +1421,7 @@ static struct folio *dequeue_hugetlb_folio_vma(struct= hstate *h, folio =3D dequeue_hugetlb_folio_nodemask(h, gfp_mask, nid, nodemask); - if (folio && !avoid_reserve && vma_has_reserves(vma, chg)) { + if (folio && use_hstate_resv) { folio_set_hugetlb_restore_reserve(folio); h->resv_huge_pages--; } @@ -2973,6 +2964,7 @@ struct folio *alloc_hugetlb_folio(struct vm_area_stru= ct *vma, struct mem_cgroup *memcg; bool deferred_reserve; gfp_t gfp =3D htlb_alloc_mask(h) | __GFP_RETRY_MAYFAIL; + bool use_hstate_resv; memcg =3D get_mem_cgroup_from_current(); memcg_charge_ret =3D mem_cgroup_hugetlb_try_charge(memcg, gfp, nr_pages); @@ -3033,20 +3025,17 @@ struct folio *alloc_hugetlb_folio(struct vm_area_st= ruct *vma, if (ret) goto out_uncharge_cgroup_reservation; + use_hstate_resv =3D !avoid_reserve && vma_has_reserves(vma, gbl_chg); + spin_lock_irq(&hugetlb_lock); - /* - * glb_chg is passed to indicate whether or not a page must be taken - * from the global free pool (global change). gbl_chg =3D=3D 0 indicates - * a reservation exists for the allocation. - */ - folio =3D dequeue_hugetlb_folio_vma(h, vma, addr, avoid_reserve, gbl_chg); + folio =3D dequeue_hugetlb_folio_vma(h, vma, addr, use_hstate_resv); if (!folio) { spin_unlock_irq(&hugetlb_lock); folio =3D alloc_buddy_hugetlb_folio_with_mpol(h, vma, addr); if (!folio) goto out_uncharge_cgroup; spin_lock_irq(&hugetlb_lock); - if (!avoid_reserve && vma_has_reserves(vma, gbl_chg)) { + if (use_hstate_resv) { folio_set_hugetlb_restore_reserve(folio); h->resv_huge_pages--; } -- 2.47.0.rc1.288.g06298d1525-goog From nobody Wed Nov 27 06:37:21 2024 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C8DC1E282B for ; Fri, 11 Oct 2024 23:22:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728688979; cv=none; b=Atl0wxZ4wq7CzfC919DgbKQyYy0Dz6cz2Er8cq0B4dvc2yuyh+iuLQlrGKW1zO8VrAa5B8AildlfnAQiMrKnf6fDGadJ+XFY/vpBkTqeITkzYc6xDBS8Xfx5Vbo2S3F5XIXH4v3fX/8dFbHjnUnfJpx5RHszfDvXwKVYY19T0L4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728688979; c=relaxed/simple; bh=VLWDTCmywSyTYwNHGbNc22jp0cSi/jdVaczUtrYClPI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mKWQF6ILCx1cGpLRVHjWGaWZ2GcbJasA2C22+oKhB/zz1Yn9esC8ytwwatE8kZ4xWyA7QSXAVFZPjohjkwIDj84WKOa2KfbUHp/wLzq7iz7/u5VNQ7pO/dwwAcf+uRSpp4c5feVKc6K4A5UlRiQ7eUchAXoQd+DiHud0pCcgIeI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ackerleytng.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Q0S+Ycl5; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ackerleytng.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Q0S+Ycl5" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-71e46373148so852306b3a.2 for ; Fri, 11 Oct 2024 16:22:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728688977; x=1729293777; darn=vger.kernel.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=nJE7PzBze7zAcfbdc8FDy9pk9WnzblcaKcmb3qltDsU=; b=Q0S+Ycl5Wc+bh4Wbi02CZRtLWAA3ee/SK0MurH6fMoi0oOs5hxYufUCSMKQTDRhnGg LCHvU/0JDoXOgpyY3oQdPzOv9ZbQCHDLtg/+JxrVuekt7Nq0n7ZgCd1w0fDEriEbiwU9 6l5ocBrRDv+5Xo6GPB8oA02SqcBcC/h/YnSNgV+gf6yrEg/85Det5Y0fORnyXBZe9MOv if9pCJQvRF0+iYCHlHRZLbnSbzPwMv5Rq32bJrU+0onb9J0t6fY5448gE1lfH4cx2Zcj hpNy05lLFOBIdP9DtVG+6tTfj5IagtoGkJNF3rYaggva/NTNvwzTi4YS8ZeCsLr0fEyT x7XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728688977; x=1729293777; 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=nJE7PzBze7zAcfbdc8FDy9pk9WnzblcaKcmb3qltDsU=; b=fFWEa6diatBiHHSyP4/ASdsEUv7WVPotPcaKLOJeTQCWoDWx4LLVkrhfbvGnJ0DGgw caanSFNv+Dh7mf4WjHjhqhT6A1h5xppdJHRpNXZ68aFeEctEDUdUlpTeWYQWTUuXDx6B /cJm8ChiA08g9JBoX5Yb6hvg04GLIzn5GDcgZTRvW14zKR2e9jajZlsV9O9v4wfgsNya bOFopaIekUtqFeP4FCMdaVOHjsZd3GEMyq5GQCMvnUW6wDTrGiTjwLgQdjwXwUCd9JHX k4DWLyZcxgvIO/1z8I5og+qTmOes1E92QVIxND41DeazngbE0vntbz8bEUUM5GAfX7fa Y7nQ== X-Forwarded-Encrypted: i=1; AJvYcCVRqHvuoXaYyyVBIXrtjoVqnErcCTDWR6NV5EWhvu78Bwwp78neeCugbPHXqWXPZ/xCidrGiBgjhTQT2R4=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9Y+oG93Kl7YGDr591XWhiaFjtVmx/oMwQ2QHe8hwCYA6GOu85 wWIh2nrqOF+sK6xVUWfjZqOvitDl2gIqTDzyttXPlMMTxFybECSYiZ34QWC2t21QiKLyzWyQFcJ dH6unjc3ubwOK8QuLjShp0A== X-Google-Smtp-Source: AGHT+IF8BpvRbiiW7MMpoPgSGCVrmxKRcOQNff2W1WyN3coN7ji1l7zEFJG8+MRsUOFufoc4FZXZrVo9qdPjRKOSmQ== X-Received: from ackerleytng-ctop.c.googlers.com ([fda3:e722:ac3:cc00:146:b875:ac13:a9fc]) (user=ackerleytng job=sendgmr) by 2002:a05:6a00:870b:b0:71e:4ec7:aed8 with SMTP id d2e1a72fcca58-71e4ec7afb8mr435b3a.6.1728688977169; Fri, 11 Oct 2024 16:22:57 -0700 (PDT) Date: Fri, 11 Oct 2024 23:22:37 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Message-ID: <3d1946d01f63104de913c0979b5a596e2add1672.1728684491.git.ackerleytng@google.com> Subject: [RFC PATCH 2/3] mm: hugetlb: Refactor vma_has_reserves() to should_use_hstate_resv() From: Ackerley Tng To: muchun.song@linux.dev, peterx@redhat.com, akpm@linux-foundation.org, rientjes@google.com, fvdl@google.com, jthoughton@google.com, david@redhat.com Cc: isaku.yamahata@intel.com, zhiquan1.li@intel.com, fan.du@intel.com, jun.miao@intel.com, tabba@google.com, quic_eberman@quicinc.com, roypat@amazon.co.uk, jgg@nvidia.com, jhubbard@nvidia.com, seanjc@google.com, pbonzini@redhat.com, erdemaktas@google.com, vannapurve@google.com, ackerleytng@google.com, pgonda@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- mm/hugetlb.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 73165c670739..47c421eba112 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1246,9 +1246,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 reser= vations + * @avoid_reserve: Whether allocation was requested to avoid using reserva= tions + */ +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 =3D=3D 0), @@ -3025,7 +3035,7 @@ struct folio *alloc_hugetlb_folio(struct vm_area_stru= ct *vma, if (ret) goto out_uncharge_cgroup_reservation; - use_hstate_resv =3D !avoid_reserve && vma_has_reserves(vma, gbl_chg); + use_hstate_resv =3D should_use_hstate_resv(vma, gbl_chg, avoid_reserve); spin_lock_irq(&hugetlb_lock); folio =3D dequeue_hugetlb_folio_vma(h, vma, addr, use_hstate_resv); -- 2.47.0.rc1.288.g06298d1525-goog From nobody Wed Nov 27 06:37:21 2024 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 070121E5727 for ; Fri, 11 Oct 2024 23:22:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728688981; cv=none; b=eEqPuHZu3X0UXcMnE6y072+RKXUZpL9l9NU99a+QKC3eyFlOdYvfJZC/cR5ZXwCOsEsQ2hzlCL568ZP4O7KUQ4g6pWfIUJIUaqWxc+RHnKkMOJbu/4Hz/gdk/FEhvtVYJCIA5iEsEcBMjT0+Zq+QETWA0D1xcvhzq0Fnoa5jl+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728688981; c=relaxed/simple; bh=+kciZjkG1zgQ1GzAf57ieD5PgpdjTvBx38Optd1M2hQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bg/d1TIWyEZkimbiWdIuzXqIWgPbmLjWd+85AVZJl3+Cy7/kRs8AyyJmJSaJT25bLziJ7RznkPJl4P7oCjsFIz4uaZ18N1/cOtNRqIsU5Xmrm17qX32XC7Apy1N4LniOipSrthD1iOpv9WoYYwwQckUJ8RooHdvh7T/3ao/ef6k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ackerleytng.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=QFeQxSeV; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ackerleytng.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QFeQxSeV" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2e2e2e02817so1628112a91.1 for ; Fri, 11 Oct 2024 16:22:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728688979; x=1729293779; darn=vger.kernel.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=zQ3fy9ApFdIx/13nHC/ZJce/ALnWJIL4G1B3hOB5L24=; b=QFeQxSeVEBx321Be0evGhZ9VfxvjE/1G1QeEZF9DARRTe7wSJEg+S7sjxQM80Wb5tl VARpmbLPx/WCq3uK7F/QXsumccw/eT8C/xkRbgISxezYE/1rSy0N7LC18i2GeN/cXEF8 GjFLod/pERL9s9Ukm8v49bk90u5Rin596StEETKxWziVpTxU2U9z7wYq6gerZzNrwQ4U BKmQRxf1uPYptDrlBOjUU+YNvQzOBcioryq+kThVXGdoQ6JGFMkXS48XnDIMZvld4+RS ILjVWMNMwa/vKg9sPzMFMfxnrCplPmGcBkmWtlyfH9NjWoXauHsE0l6PhXI44WbK4ICr vekw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728688979; x=1729293779; 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=zQ3fy9ApFdIx/13nHC/ZJce/ALnWJIL4G1B3hOB5L24=; b=UrvdOOkcIAreYnrUigMAnRy3IHpicLY5DkOnCoDy9lack8hZUahY/y+dOMe4npkU7x lECwlfGM4IWOfLYmZUfzxtr08RyTmbYvMnLwEh6XMMNF5UW1fUco9zBuzwcZqj654pmP DOOvCKN42LkpT74MyrrX/C/KoxZte2AzlvbTaB31ae32uzAlYOB4gXUuhej3M3xVzok2 em7tv1SIs6awmVJv1Mr7N2gbOG9W9lMjUGXOuAPnOb1QEMctSrMCBt5jdlZknVr4ULPw YDrKpZsdcS8yap5rBRGBlyi79uo5ImgkcVvJKqXPOWNXcGzXy4PbeP6kl7wAkiwxe49l YBkA== X-Forwarded-Encrypted: i=1; AJvYcCXhQlxelVU8WvGjfpelNWm5ce4WQcT29ClKxfP2vLXP/SYVpW9ertfbQH34DmebqzMyOmiZ/wVK3Y4AcYs=@vger.kernel.org X-Gm-Message-State: AOJu0YxQ1ShZIV7Au/KREonx1c/dTob3lkWBDC45QF4BCka2iuABBSME OrZFXVd9+lAfXa2fDYnsl7oqYaG5s56G1Q7XGrq5+j8RzzHHjREhAz5+jBLnzkD6vbtGivsoTl5 5+MRipOs1IzWDvXeEwqNpHw== X-Google-Smtp-Source: AGHT+IFr0sptcozt+ZrAH3WS4hJI40RdtRwKwkDb7kVtF/SqVh1nyxpm+MDJx1CARv2yQw1qWp7ccQL5vo9X2qDvGw== X-Received: from ackerleytng-ctop.c.googlers.com ([fda3:e722:ac3:cc00:146:b875:ac13:a9fc]) (user=ackerleytng job=sendgmr) by 2002:a17:90b:3109:b0:2e2:9984:802b with SMTP id 98e67ed59e1d1-2e2c81bd68cmr13813a91.3.1728688978977; Fri, 11 Oct 2024 16:22:58 -0700 (PDT) Date: Fri, 11 Oct 2024 23:22:38 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Message-ID: <5d0ededd93c4cd33a78c43c12d5075be2eea9674.1728684491.git.ackerleytng@google.com> Subject: [RFC PATCH 3/3] mm: hugetlb: Remove unnecessary check for avoid_reserve From: Ackerley Tng To: muchun.song@linux.dev, peterx@redhat.com, akpm@linux-foundation.org, rientjes@google.com, fvdl@google.com, jthoughton@google.com, david@redhat.com Cc: isaku.yamahata@intel.com, zhiquan1.li@intel.com, fan.du@intel.com, jun.miao@intel.com, tabba@google.com, quic_eberman@quicinc.com, roypat@amazon.co.uk, jgg@nvidia.com, jhubbard@nvidia.com, seanjc@google.com, pbonzini@redhat.com, erdemaktas@google.com, vannapurve@google.com, ackerleytng@google.com, pgonda@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If avoid_reserve is true, gbl_chg is not used anyway, so there is no point in setting gbl_chg. Signed-off-by: Ackerley Tng --- mm/hugetlb.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 47c421eba112..a2e2b770a018 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3009,16 +3009,6 @@ struct folio *alloc_hugetlb_folio(struct vm_area_str= uct *vma, if (gbl_chg < 0) goto out_end_reservation; - /* - * Even though there was no reservation in the region/reserve - * map, there could be reservations associated with the - * subpool that can be used. This would be indicated if the - * return value of hugepage_subpool_get_pages() is zero. - * However, if avoid_reserve is specified we still avoid even - * the subpool reservations. - */ - if (avoid_reserve) - gbl_chg =3D 1; } /* If this allocation is not consuming a reservation, charge it now. -- 2.47.0.rc1.288.g06298d1525-goog