lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230413231452.84529-4-sidhartha.kumar@oracle.com>
Date:   Thu, 13 Apr 2023 16:14:51 -0700
From:   Sidhartha Kumar <sidhartha.kumar@...cle.com>
To:     linux-kernel@...r.kernel.org, linux-mm@...ck.org
Cc:     akpm@...ux-foundation.org, songmuchun@...edance.com,
        mike.kravetz@...cle.com, willy@...radead.org,
        Sidhartha Kumar <sidhartha.kumar@...cle.com>
Subject: [RFC PATCH 3/4] mm/hugetlbfs: remove huge_page_shift in hugetlbfs_file_mmap

Remove shifting the vma->vm_pgoff and len arguments in
the call to hugetlb_reserve_pages() within hugetlbfs_file_mmap().
Adjust the chg variable within hugetlb_reserve_pages() to match previous
values which are expected by cgroup accounting code.

Signed-off-by: Sidhartha Kumar <sidhartha.kumar@...cle.com>
---
 fs/hugetlbfs/inode.c | 4 ++--
 mm/hugetlb.c         | 7 ++++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 702d79639c0df..9f2e71f2e9f52 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -165,8 +165,8 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
 
 	ret = -ENOMEM;
 	if (!hugetlb_reserve_pages(inode,
-				vma->vm_pgoff >> huge_page_order(h),
-				len >> huge_page_shift(h), vma,
+				vma->vm_pgoff,
+				len, vma,
 				vma->vm_flags))
 		goto out;
 
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 011020a30f4ac..a28fbdff886ff 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -6752,6 +6752,7 @@ bool hugetlb_reserve_pages(struct inode *inode,
 {
 	long chg = -1, add = -1;
 	struct hstate *h = hstate_inode(inode);
+	unsigned long hpage_shift = huge_page_shift(h);
 	struct hugepage_subpool *spool = subpool_inode(inode);
 	struct resv_map *resv_map;
 	struct hugetlb_cgroup *h_cg = NULL;
@@ -6791,14 +6792,14 @@ bool hugetlb_reserve_pages(struct inode *inode,
 		 */
 		resv_map = inode_resv_map(inode);
 
-		chg = region_chg(resv_map, from, to, &regions_needed);
+		chg = region_chg(resv_map, from, to, &regions_needed) >> hpage_shift;
 	} else {
 		/* Private mapping. */
 		resv_map = resv_map_alloc();
 		if (!resv_map)
 			goto out_err;
 
-		chg = to - from;
+		chg = (to - from) >> hpage_shift;
 
 		set_vma_resv_map(vma, resv_map);
 		set_vma_resv_flags(vma, HPAGE_RESV_OWNER);
@@ -6823,7 +6824,7 @@ bool hugetlb_reserve_pages(struct inode *inode,
 	 * the subpool has a minimum size, there may be some global
 	 * reservations already in place (gbl_reserve).
 	 */
-	gbl_reserve = hugepage_subpool_get_pages(spool, chg);
+	gbl_reserve = hugepage_subpool_get_pages(spool, chg) >> hpage_shift;
 	if (gbl_reserve < 0)
 		goto out_uncharge_cgroup;
 
-- 
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ