* [PATCH -next] mm: use helper function put_resv_map()
@ 2023-08-03 12:03 Ruan Jinjie
2023-08-03 12:31 ` Matthew Wilcox
0 siblings, 1 reply; 3+ messages in thread
From: Ruan Jinjie @ 2023-08-03 12:03 UTC (permalink / raw)
To: linux-mm, Mike Kravetz, Muchun Song, Andrew Morton; +Cc: ruanjinjie
This code is already duplicated 3 times, use helper function
put_resv_map() to release reserved and allocated regions instead of
open code it to help improve code readability a bit.
No functional change involved.
Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
---
mm/hugetlb.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index e327a5a7602c..bf1c900b753b 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1100,6 +1100,11 @@ void resv_map_release(struct kref *ref)
kfree(resv_map);
}
+static inline int put_resv_map(struct resv_map *resv)
+{
+ return kref_put(&resv->refs, resv_map_release);
+}
+
static inline struct resv_map *inode_resv_map(struct inode *inode)
{
/*
@@ -1201,7 +1206,7 @@ void clear_vma_resv_huge_pages(struct vm_area_struct *vma)
if (reservations && is_vma_resv_set(vma, HPAGE_RESV_OWNER)) {
resv_map_put_hugetlb_cgroup_uncharge_info(reservations);
- kref_put(&reservations->refs, resv_map_release);
+ put_resv_map(reservations);
}
hugetlb_dup_vma_private(vma);
@@ -4905,7 +4910,7 @@ static void hugetlb_vm_op_close(struct vm_area_struct *vma)
hugetlb_acct_memory(h, -gbl_reserve);
}
- kref_put(&resv->refs, resv_map_release);
+ put_resv_map(resv);
}
static int hugetlb_vm_op_split(struct vm_area_struct *vma, unsigned long addr)
@@ -6850,7 +6855,7 @@ bool hugetlb_reserve_pages(struct inode *inode,
if (chg >= 0 && add < 0)
region_abort(resv_map, from, to, regions_needed);
if (vma && is_vma_resv_set(vma, HPAGE_RESV_OWNER))
- kref_put(&resv_map->refs, resv_map_release);
+ put_resv_map(resv_map);
return false;
}
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next] mm: use helper function put_resv_map()
2023-08-03 12:03 [PATCH -next] mm: use helper function put_resv_map() Ruan Jinjie
@ 2023-08-03 12:31 ` Matthew Wilcox
2023-08-03 13:06 ` David Hildenbrand
0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2023-08-03 12:31 UTC (permalink / raw)
To: Ruan Jinjie; +Cc: linux-mm, Mike Kravetz, Muchun Song, Andrew Morton
On Thu, Aug 03, 2023 at 08:03:12PM +0800, Ruan Jinjie wrote:
> This code is already duplicated 3 times, use helper function
> put_resv_map() to release reserved and allocated regions instead of
> open code it to help improve code readability a bit.
I do not think this is an improvement.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next] mm: use helper function put_resv_map()
2023-08-03 12:31 ` Matthew Wilcox
@ 2023-08-03 13:06 ` David Hildenbrand
0 siblings, 0 replies; 3+ messages in thread
From: David Hildenbrand @ 2023-08-03 13:06 UTC (permalink / raw)
To: Matthew Wilcox, Ruan Jinjie
Cc: linux-mm, Mike Kravetz, Muchun Song, Andrew Morton
On 03.08.23 14:31, Matthew Wilcox wrote:
> On Thu, Aug 03, 2023 at 08:03:12PM +0800, Ruan Jinjie wrote:
>> This code is already duplicated 3 times, use helper function
>> put_resv_map() to release reserved and allocated regions instead of
>> open code it to help improve code readability a bit.
>
> I do not think this is an improvement.
Agreed.
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-03 13:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-03 12:03 [PATCH -next] mm: use helper function put_resv_map() Ruan Jinjie
2023-08-03 12:31 ` Matthew Wilcox
2023-08-03 13:06 ` David Hildenbrand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox