Some cleanups and improvements for hugetlb
Subsystems (2)
PATCH 2/4 hugetlb: Replace the obsolete hugetlb_instantiation_mutex in the comments
In reply to Baolin WangAfter commit 8382d914ebf7 ("mm, hugetlb: improve page-fault scalability"), the hugetlb_instantiation_mutex lock had been replaced by hugetlb_fault_mutex_table to serializes faults on the same logical page. Thus update the obsolete hugetlb_instantiation_mutex related comments.
--- mm/hugetlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/hugetlb.c +1 -1
@@ -5012,7 +5012,7 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,/* * Hugetlb_cow() should be called with page lock of the original hugepage held. -* Called with hugetlb_instantiation_mutex held and pte_page locked so we +* Called with hugetlb_fault_mutex_table held and pte_page locked so we * cannot race with other handlers or page migration. * Keep the pte_same checks anyway to make transition from the mutex easier. */
Signature · 1 line
1.8.3.1
cover Some cleanups and improvements for hugetlb
Hi,
This patchset did some cleanups and improvements for the hugetlb and hugetlb_cgroup. Please help to review. Thanks.
Baolin Wang (4):
hugetlb_cgroup: Remove unused hugetlb_cgroup_from_counter macro
hugetlb: Replace the obsolete hugetlb_instantiation_mutex in the
comments
hugetlb: Remove redundant validation in has_same_uncharge_info()
hugetlb: Remove redundant VM_BUG_ON() in add_reservation_in_range()
mm/hugetlb.c | 6 ++---- mm/hugetlb_cgroup.c | 3 --- 2 files changed, 2 insertions(+), 7 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/4 hugetlb_cgroup: Remove unused hugetlb_cgroup_from_counter macro
Since commit 726b7bbe ("hugetlb_cgroup: fix illegal access to memory"), the hugetlb_cgroup_from_counter() macro is not used any more, remove it.
--- mm/hugetlb_cgroup.c | 3 --- 1 file changed, 3 deletions(-)
mm/hugetlb_cgroup.c +0 -3
@@ -27,9 +27,6 @@#define MEMFILE_IDX (val) (((val) >> 16) & 0xffff)#define MEMFILE_ATTR (val) ((val) & 0xffff) -#define hugetlb_cgroup_from_counter (counter, idx) \ - container_of(counter, struct hugetlb_cgroup, hugepage[idx]) -static struct hugetlb_cgroup *root_h_cgroup__read_mostly ; static inline struct page_counter *
Signature · 1 line
1.8.3.1
PATCH 3/4 hugetlb: Remove redundant validation in has_same_uncharge_info()
In reply to Baolin WangThe callers of has_same_uncharge_info() has accessed the original file_region and new file_region, and they are impossible to be NULL now. So we can remove the file_region validation in has_same_uncharge_info() to simplify the code.
--- mm/hugetlb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
mm/hugetlb.c +1 -2
@@ -333,8 +333,7 @@ static bool has_same_uncharge_info(struct file_region *rg, struct file_region *org) {#ifdef CONFIG_CGROUP_HUGETLB -return rg && org && - rg->reservation_counter == org->reservation_counter && +return rg->reservation_counter == org->reservation_counter && rg->css == org->css;#else
Signature · 1 line
1.8.3.1
PATCH 4/4 hugetlb: Remove redundant VM_BUG_ON() in add_reservation_in_range()
In reply to Baolin WangWhen calling hugetlb_resv_map_add(), we've guaranteed that the parameter 'to' is always larger than 'from', so it never returns a negative value from hugetlb_resv_map_add(). Thus remove the redundant VM_BUG_ON().
--- mm/hugetlb.c | 1 - 1 file changed, 1 deletion(-)
mm/hugetlb.c +0 -1
@@ -446,7 +446,6 @@ static long add_reservation_in_range(struct resv_map *resv, long f, long t, add +=hugetlb_resv_map_add (resv, rg, last_accounted_offset, t, h, h_cg, regions_needed); -VM_BUG_ON (add <0 );return add; }
Signature · 1 line
1.8.3.1
Re: [PATCH 1/4] hugetlb_cgroup: Remove unused hugetlb_cgroup_from_counter macro
In reply to Baolin WangQuoted 7 lines · Baolin Wang
Since commit
726b7bbe("hugetlb_cgroup: fix illegal access to memory"), thehugetlb_cgroup_from_counter()macro is not used any more, remove it.Signed-off-by Baolin Wang <[email protected]>--- mm/hugetlb_cgroup.c | 3 --- 1 file changed, 3 deletions(-)
Thanks!
Signature · 1 line
Mike Kravetz
Quoted 16 lines
mm/hugetlb_cgroup.c +0
-3@@ -27,9 +27,6 @@#define MEMFILE_IDX (val) (((val) >> 16) & 0xffff)#define MEMFILE_ATTR (val) ((val) & 0xffff) -#define hugetlb_cgroup_from_counter (counter, idx) \ - container_of(counter, struct hugetlb_cgroup, hugepage[idx]) -static struct hugetlb_cgroup *root_h_cgroup__read_mostly ; static inline struct page_counter *
Re: [PATCH 2/4] hugetlb: Replace the obsolete hugetlb_instantiation_mutex in the comments
In reply to Baolin WangQuoted 9 lines · Baolin Wang
After commit
8382d914ebf7("mm, hugetlb: improve page-fault scalability"), thehugetlb_instantiation_mutexlock had been replaced byhugetlb_fault_mutex_tableto serializes faults on the same logical page. Thus update the obsoletehugetlb_instantiation_mutexrelated comments.Signed-off-by Baolin Wang <[email protected]>--- mm/hugetlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks!
Signature · 1 line
Mike Kravetz
Quoted 15 lines
mm/hugetlb.c +1
-1@@ -5012,7 +5012,7 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,/* * Hugetlb_cow() should be called with page lock of the original hugepage held. -* Called with hugetlb_instantiation_mutex held and pte_page locked so we +* Called with hugetlb_fault_mutex_table held and pte_page locked so we * cannot race with other handlers or page migration. * Keep the pte_same checks anyway to make transition from the mutex easier. */
Re: [PATCH 3/4] hugetlb: Remove redundant validation in has_same_uncharge_info()
In reply to Baolin WangQuoted 8 lines · Baolin Wang
The callers of
has_same_uncharge_info()has accessed the originalfile_regionand newfile_region, and they are impossible to be NULL now. So we can remove thefile_regionvalidation inhas_same_uncharge_info()to simplify the code.Signed-off-by Baolin Wang <[email protected]>--- mm/hugetlb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Thanks!
Signature · 1 line
Mike Kravetz
Quoted 16 lines
mm/hugetlb.c +1
-2@@ -333,8 +333,7 @@ static bool has_same_uncharge_info(struct file_region *rg, struct file_region *org) {#ifdef CONFIG_CGROUP_HUGETLB -return rg && org && - rg->reservation_counter == org->reservation_counter && +return rg->reservation_counter == org->reservation_counter && rg->css == org->css;#else
Re: [PATCH 4/4] hugetlb: Remove redundant VM_BUG_ON() in add_reservation_in_range()
In reply to Baolin WangQuoted 8 lines · Baolin Wang
When calling
hugetlb_resv_map_add(), we've guaranteed that the parameter 'to' is always larger than 'from', so it never returns a negative value fromhugetlb_resv_map_add(). Thus remove the redundantVM_BUG_ON().Signed-off-by Baolin Wang <[email protected]>--- mm/hugetlb.c | 1 - 1 file changed, 1 deletion(-)
Thanks! You are correct, we could never trigger that VM_BUG_ON.
Signature · 1 line
Mike Kravetz
Quoted 14 lines
mm/hugetlb.c +0
-1@@ -446,7 +446,6 @@ static long add_reservation_in_range(struct resv_map *resv, long f, long t, add +=hugetlb_resv_map_add (resv, rg, last_accounted_offset, t, h, h_cg, regions_needed); -VM_BUG_ON (add <0 );return add; }