diff mbox series

[03/16] mm/huge_memory: fix comment of __pud_trans_huge_lock

Message ID 20220622170627.19786-4-linmiaohe@huawei.com (mailing list archive)
State New
Headers show
Series A few cleanup patches for huge_memory | expand

Commit Message

Miaohe Lin June 22, 2022, 5:06 p.m. UTC
__pud_trans_huge_lock returns page table lock pointer if a given pud maps
a thp instead of 'true' since introduced. Fix corresponding comments.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/huge_memory.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Muchun Song June 23, 2022, 6:32 a.m. UTC | #1
On Thu, Jun 23, 2022 at 01:06:14AM +0800, Miaohe Lin wrote:
> __pud_trans_huge_lock returns page table lock pointer if a given pud maps
> a thp instead of 'true' since introduced. Fix corresponding comments.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Acked-by: Muchun Song <songmuchun@bytedance.com>

Thanks.
Zach O'Keefe June 24, 2022, 6:47 p.m. UTC | #2
On 23 Jun 01:06, Miaohe Lin wrote:
> __pud_trans_huge_lock returns page table lock pointer if a given pud maps
> a thp instead of 'true' since introduced. Fix corresponding comments.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  mm/huge_memory.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 83fb6c3442ff..a26580da8011 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -1903,10 +1903,10 @@ spinlock_t *__pmd_trans_huge_lock(pmd_t *pmd, struct vm_area_struct *vma)
>  }
>  
>  /*
> - * Returns true if a given pud maps a thp, false otherwise.
> + * Returns page table lock pointer if a given pud maps a thp, NULL otherwise.
>   *
> - * Note that if it returns true, this routine returns without unlocking page
> - * table lock. So callers must unlock it.
> + * Note that if it returns page table lock pointe, this routine returns without

s/pointe/pointer

> + * unlocking page table lock. So callers must unlock it.
>   */
>  spinlock_t *__pud_trans_huge_lock(pud_t *pud, struct vm_area_struct *vma)
>  {
> -- 
> 2.23.0
>
Matthew Wilcox June 24, 2022, 6:56 p.m. UTC | #3
On Thu, Jun 23, 2022 at 01:06:14AM +0800, Miaohe Lin wrote:
> __pud_trans_huge_lock returns page table lock pointer if a given pud maps
> a thp instead of 'true' since introduced. Fix corresponding comments.

I think the comments here are rather wasted.  I think this comment
should be moved to pud_trans_huge_lock() and turned into kernel-doc
format.

> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  mm/huge_memory.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 83fb6c3442ff..a26580da8011 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -1903,10 +1903,10 @@ spinlock_t *__pmd_trans_huge_lock(pmd_t *pmd, struct vm_area_struct *vma)
>  }
>  
>  /*
> - * Returns true if a given pud maps a thp, false otherwise.
> + * Returns page table lock pointer if a given pud maps a thp, NULL otherwise.
>   *
> - * Note that if it returns true, this routine returns without unlocking page
> - * table lock. So callers must unlock it.
> + * Note that if it returns page table lock pointe, this routine returns without
> + * unlocking page table lock. So callers must unlock it.
>   */
>  spinlock_t *__pud_trans_huge_lock(pud_t *pud, struct vm_area_struct *vma)
>  {
> -- 
> 2.23.0
>
Miaohe Lin June 25, 2022, 3:32 a.m. UTC | #4
On 2022/6/25 2:56, Matthew Wilcox wrote:
> On Thu, Jun 23, 2022 at 01:06:14AM +0800, Miaohe Lin wrote:
>> __pud_trans_huge_lock returns page table lock pointer if a given pud maps
>> a thp instead of 'true' since introduced. Fix corresponding comments.
> 
> I think the comments here are rather wasted.  I think this comment
> should be moved to pud_trans_huge_lock() and turned into kernel-doc
> format.

Do you mean something like below? If so, __pmd_trans_huge_lock might need to do the
similar work?

diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index ae3d8e2fd9e2..b73fe864de13 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -238,6 +238,12 @@ static inline spinlock_t *pmd_trans_huge_lock(pmd_t *pmd,
        else
                return NULL;
 }
+/**
+ * Returns true if a given pud maps a thp, false otherwise.
+ *
+ * Note that if it returns true, this routine returns without unlocking page
+ * table lock. So callers must unlock it.
+ */
 static inline spinlock_t *pud_trans_huge_lock(pud_t *pud,
                struct vm_area_struct *vma)
 {
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index eb2e4ecb76aa..ae4c2116be07 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2006,12 +2006,6 @@ spinlock_t *__pmd_trans_huge_lock(pmd_t *pmd, struct vm_area_struct *vma)
        return NULL;
 }

-/*
- * Returns true if a given pud maps a thp, false otherwise.
- *
- * Note that if it returns true, this routine returns without unlocking page
- * table lock. So callers must unlock it.
- */
 spinlock_t *__pud_trans_huge_lock(pud_t *pud, struct vm_area_struct *vma)
 {
        spinlock_t *ptl;

Thanks!
> 
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>> ---
>>  mm/huge_memory.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>> index 83fb6c3442ff..a26580da8011 100644
>> --- a/mm/huge_memory.c
>> +++ b/mm/huge_memory.c
>> @@ -1903,10 +1903,10 @@ spinlock_t *__pmd_trans_huge_lock(pmd_t *pmd, struct vm_area_struct *vma)
>>  }
>>  
>>  /*
>> - * Returns true if a given pud maps a thp, false otherwise.
>> + * Returns page table lock pointer if a given pud maps a thp, NULL otherwise.
>>   *
>> - * Note that if it returns true, this routine returns without unlocking page
>> - * table lock. So callers must unlock it.
>> + * Note that if it returns page table lock pointe, this routine returns without
>> + * unlocking page table lock. So callers must unlock it.
>>   */
>>  spinlock_t *__pud_trans_huge_lock(pud_t *pud, struct vm_area_struct *vma)
>>  {
>> -- 
>> 2.23.0
>>
> 
> .
>
Miaohe Lin June 25, 2022, 3:33 a.m. UTC | #5
On 2022/6/25 2:47, Zach O'Keefe wrote:
> On 23 Jun 01:06, Miaohe Lin wrote:
>> __pud_trans_huge_lock returns page table lock pointer if a given pud maps
>> a thp instead of 'true' since introduced. Fix corresponding comments.
>>
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>> ---
>>  mm/huge_memory.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>> index 83fb6c3442ff..a26580da8011 100644
>> --- a/mm/huge_memory.c
>> +++ b/mm/huge_memory.c
>> @@ -1903,10 +1903,10 @@ spinlock_t *__pmd_trans_huge_lock(pmd_t *pmd, struct vm_area_struct *vma)
>>  }
>>  
>>  /*
>> - * Returns true if a given pud maps a thp, false otherwise.
>> + * Returns page table lock pointer if a given pud maps a thp, NULL otherwise.
>>   *
>> - * Note that if it returns true, this routine returns without unlocking page
>> - * table lock. So callers must unlock it.
>> + * Note that if it returns page table lock pointe, this routine returns without
> 
> s/pointe/pointer

Thanks for catching this.

> 
>> + * unlocking page table lock. So callers must unlock it.
>>   */
>>  spinlock_t *__pud_trans_huge_lock(pud_t *pud, struct vm_area_struct *vma)
>>  {
>> -- 
>> 2.23.0
>>
> .
>
diff mbox series

Patch

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 83fb6c3442ff..a26580da8011 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1903,10 +1903,10 @@  spinlock_t *__pmd_trans_huge_lock(pmd_t *pmd, struct vm_area_struct *vma)
 }
 
 /*
- * Returns true if a given pud maps a thp, false otherwise.
+ * Returns page table lock pointer if a given pud maps a thp, NULL otherwise.
  *
- * Note that if it returns true, this routine returns without unlocking page
- * table lock. So callers must unlock it.
+ * Note that if it returns page table lock pointe, this routine returns without
+ * unlocking page table lock. So callers must unlock it.
  */
 spinlock_t *__pud_trans_huge_lock(pud_t *pud, struct vm_area_struct *vma)
 {