fs: hugetlb: simplify remove_inode_hugepages() return type
Subsystems (2)
PATCH 1/1 fs: hugetlb: simplify remove_inode_hugepages() return type
When remove_inode_hugepages is introduced in
commit c86272287bc6 ("hugetlb: create remove_inode_single_folio to remove single file folio") it used to return a boolean to indicate if it bailed out due to race with
page faults. However, since the race is already solved by [1], remove_inode_hugepages() doesn't have any path to return false anymore.
Simplify remove_inode_hugepages() return type to void, remove the unnecessary ret variable, and adjust the call site in remove_inode_hugepages(). No functional change in this commit.
[1] https://lore.kernel.org/all/[email protected]
--- fs/hugetlbfs/inode.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
fs/hugetlbfs/inode.c +7 -11
@@ -515,13 +515,11 @@ hugetlb_vmdelete_list(struct rb_root_cached *root, pgoff_t start, pgoff_t end,* Called with hugetlb fault mutex held. * Returns true if page was actually removed, false otherwise. */ -static bool remove_inode_single_folio (struct hstate *h,struct inode *inode, -struct address_space *mapping, -struct folio *folio,pgoff_t index, -bool truncate_op) +static void remove_inode_single_folio (struct hstate *h,struct inode *inode, +struct address_space *mapping, +struct folio *folio,pgoff_t index, +bool truncate_op) { -bool ret = false; -/* * If folio is mapped, it was faulted in after being * unmapped in caller or hugetlb_vmdelete_list() skips
@@ -543,7 +541,6 @@ static bool remove_inode_single_folio(struct hstate *h, struct inode *inode,*/ VM_BUG_ON_FOLIO (folio_test_hugetlb_restore_reserve (folio), folio);hugetlb_delete_from_page_cache (folio); - ret = true;if (!truncate_op) {if (unlikely (hugetlb_unreserve_pages (inode, index, index +1 ,1 )))
@@ -551,7 +548,6 @@ static bool remove_inode_single_folio(struct hstate *h, struct inode *inode, }folio_unlock (folio); -return ret; }/*
@@ -599,9 +595,9 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,/* * Remove folio that was part of folio_batch. */ -if (remove_inode_single_folio (h, inode, mapping, folio, - index, truncate_op)) - freed++; +remove_inode_single_folio (h, inode, mapping, folio, + index, truncate_op); + freed++;mutex_unlock (&hugetlb_fault_mutex_table[hash]); }
Signature · 1 line
2.53.0.rc1.225.gd81095ad13-goog
Quoted 59 lines · Jiaqi Yan
When
remove_inode_hugepagesis introduced in
commitc86272287bc6("hugetlb: createremove_inode_single_folioto remove single file folio") it used to return a boolean to indicate if it bailed out due to race with
page faults. However, since the race is already solved by [1],remove_inode_hugepages()doesn't have any path to return false anymore.Simplify
remove_inode_hugepages()return type to void, remove the unnecessary ret variable, and adjust the call site inremove_inode_hugepages(). No functional change in this commit.[1] https://lore.kernel.org/all/[email protected]
Suggested-by Jane Chu <[email protected]>Signed-off-by Jiaqi Yan <[email protected]>--- fs/hugetlbfs/inode.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)fs/hugetlbfs/inode.c +4
-8@@ -515,13 +515,11 @@ hugetlb_vmdelete_list(struct rb_root_cached *root, pgoff_t start, pgoff_t end,* Called with hugetlb fault mutex held. * Returns true if page was actually removed, false otherwise. */ -static bool remove_inode_single_folio (struct hstate *h,struct inode *inode, -struct address_space *mapping, -struct folio *folio,pgoff_t index, -bool truncate_op) +static void remove_inode_single_folio (struct hstate *h,struct inode *inode, +struct address_space *mapping, +struct folio *folio,pgoff_t index, +bool truncate_op) { -bool ret = false; -/* * If folio is mapped, it was faulted in after being * unmapped in caller or hugetlb_vmdelete_list() skips @@ -543,7 +541,6 @@ static bool remove_inode_single_folio(struct hstate *h, struct inode *inode,*/ VM_BUG_ON_FOLIO (folio_test_hugetlb_restore_reserve (folio), folio);hugetlb_delete_from_page_cache (folio); - ret = true;if (!truncate_op) {if (unlikely (hugetlb_unreserve_pages (inode, index, index +1 ,1 )))@@ -551,7 +548,6 @@ static bool remove_inode_single_folio(struct hstate *h, struct inode *inode, }folio_unlock (folio); -return ret; }/* @@ -599,9 +595,9 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,/* * Remove folio that was part of folio_batch.
fs/hugetlbfs/inode.c static void remove_inode_hugepages(struct inode *inode, loff_t lstart, · line 603
Quoted 10 lines
fs/hugetlbfs/inode.c +3
-3*/ -if (remove_inode_single_folio (h, inode, mapping, folio, - index, truncate_op)) - freed++; +remove_inode_single_folio (h, inode, mapping, folio, + index, truncate_op); + freed++;mutex_unlock (&hugetlb_fault_mutex_table[hash]); }
Looks good, thanks for the clean up.
-jane
Re: [PATCH v1] hugetlb: simplify remove_inode_hugepages() return type
In reply to Jiaqi YanQuoted 10 lines · Jiaqi Yan
When
remove_inode_hugepagesis introduced in
commitc86272287bc6("hugetlb: createremove_inode_single_folioto remove single file folio") it used to return a boolean to indicate if it bailed out due to race with
page faults. However, since the race is already solved by [1],remove_inode_hugepages()doesn't have any path to return false anymore.
Quoted 8 lines
Simplify
remove_inode_hugepages()return type to void, remove the unnecessary ret variable, and adjust the call site inremove_inode_hugepages(). No functional change in this commit.[1] https://lore.kernel.org/all/[email protected]
Suggested-by Jane Chu <[email protected]>Signed-off-by Jiaqi Yan <[email protected]>
Quoted 24 lines · Jiaqi Yan
When
remove_inode_hugepagesis introduced in
commitc86272287bc6("hugetlb: createremove_inode_single_folioto remove single file folio") it used to return a boolean to indicate if it bailed out due to race with
page faults. However, since the race is already solved by [1],remove_inode_hugepages()doesn't have any path to return false anymore.Simplify
remove_inode_hugepages()return type to void, remove the unnecessary ret variable, and adjust the call site inremove_inode_hugepages(). No functional change in this commit.[1] https://lore.kernel.org/all/[email protected]
Suggested-by Jane Chu <[email protected]>Signed-off-by Jiaqi Yan <[email protected]>--- fs/hugetlbfs/inode.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)fs/hugetlbfs/inode.c +0
-0@@ -515,13 +515,11 @@ hugetlb_vmdelete_list(struct rb_root_cached *root, pgoff_t start, pgoff_t end,* Called with hugetlb fault mutex held.
fs/hugetlbfs/inode.c hugetlb_vmdelete_list(struct rb_root_cached *root, pgoff_t start, pgoff_t end, · line 521
Quoted 10 lines
fs/hugetlbfs/inode.c +4
-4* Returns true if page was actually removed, false otherwise. */ -static bool remove_inode_single_folio (struct hstate *h,struct inode *inode, -struct address_space *mapping, -struct folio *folio,pgoff_t index, -bool truncate_op) +static void remove_inode_single_folio (struct hstate *h,struct inode *inode, +struct address_space *mapping, +struct folio *folio,pgoff_t index, +bool truncate_op)
While you are touching this, this would look better with two-tab alignment on second parameter line.
Signature · 3 lines
Cheers, David
Thanks for your reviews, Jane, Muchun, and David
Quoted 31 lines · David Hildenbrand (arm)
Quoted 29 lines · Jiaqi Yan
When
remove_inode_hugepagesis introduced in
commitc86272287bc6("hugetlb: createremove_inode_single_folioto remove single file folio") it used to return a boolean to indicate if it bailed out due to race with
page faults. However, since the race is already solved by [1],remove_inode_hugepages()doesn't have any path to return false anymore.Simplify
remove_inode_hugepages()return type to void, remove the unnecessary ret variable, and adjust the call site inremove_inode_hugepages(). No functional change in this commit.[1] https://lore.kernel.org/all/[email protected]
Suggested-by Jane Chu <[email protected]>Signed-off-by Jiaqi Yan <[email protected]>--- fs/hugetlbfs/inode.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)fs/hugetlbfs/inode.c +0
-3@@ -515,13 +515,11 @@ hugetlb_vmdelete_list(struct rb_root_cached *root, pgoff_t start, pgoff_t end,* Called with hugetlb fault mutex held. * Returns true if page was actually removed, false otherwise. */ -static bool remove_inode_single_folio(struct hstate *h, struct inode *inode, - struct address_space *mapping, - struct folio *folio, pgoff_t index,
Quoted 8 lines
fs/hugetlbfs/inode.c hugetlb_vmdelete_list(struct rb_root_cached *root, pgoff_t start, pgoff_t end, · line 521
Quoted 5 lines
fs/hugetlbfs/inode.c +4
-1- bool truncate_op) +static void remove_inode_single_folio (struct hstate *h,struct inode *inode, +struct address_space *mapping, +struct folio *folio,pgoff_t index, +bool truncate_op)While you are touching this, this would look better with two-tab alignment on second parameter line.
For sure, it is adjusted in v2:
https://lore.kernel.org/linux-mm/[email protected]
Quoted 7 lines
--
Cheers,David