mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] mm: clean up redundant code
@ 2025-05-08 14:01 Feng Lee
  2025-05-09  2:44 ` Barry Song
  0 siblings, 1 reply; 4+ messages in thread
From: Feng Lee @ 2025-05-08 14:01 UTC (permalink / raw)
  To: david, baohua, 21cnbao, akpm, mingo, jgg, jhubbard, peterx
  Cc: maobibo, trivial, linux-kernel, lance.yang, anshuman.khandual, Feng Lee

Remove pgd_offset_gate() completely and simply make the single
caller use pgd_offset()

It appears that the gate area resides in the kernel-mapped segment
exclusively on IA64. Therefore, removing pgd_offset_k is safe since
IA64 is now obsolete.

Signed-off-by: Feng Lee <379943137@qq.com>

---
Changes in v2:
  - remove pgd_offset_gate completely
  - remove pgd_offset_k from the get_gate_page function completely
---
 include/linux/pgtable.h | 4 ----
 mm/gup.c                | 5 +----
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index b50447ef1c92..f1e890b60460 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -1164,10 +1164,6 @@ static inline void arch_swap_restore(swp_entry_t entry, struct folio *folio)
 }
 #endif
 
-#ifndef __HAVE_ARCH_PGD_OFFSET_GATE
-#define pgd_offset_gate(mm, addr)	pgd_offset(mm, addr)
-#endif
-
 #ifndef __HAVE_ARCH_MOVE_PTE
 #define move_pte(pte, old_addr, new_addr)	(pte)
 #endif
diff --git a/mm/gup.c b/mm/gup.c
index f32168339390..0685403fe510 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1101,10 +1101,7 @@ static int get_gate_page(struct mm_struct *mm, unsigned long address,
 	/* user gate pages are read-only */
 	if (gup_flags & FOLL_WRITE)
 		return -EFAULT;
-	if (address > TASK_SIZE)
-		pgd = pgd_offset_k(address);
-	else
-		pgd = pgd_offset_gate(mm, address);
+	pgd = pgd_offset(mm, address);
 	if (pgd_none(*pgd))
 		return -EFAULT;
 	p4d = p4d_offset(pgd, address);
-- 
2.49.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mm: clean up redundant code
  2025-05-08 14:01 [PATCH v2] mm: clean up redundant code Feng Lee
@ 2025-05-09  2:44 ` Barry Song
  2025-05-09  3:06   ` Feng Lee
  2025-05-09  8:22   ` David Hildenbrand
  0 siblings, 2 replies; 4+ messages in thread
From: Barry Song @ 2025-05-09  2:44 UTC (permalink / raw)
  To: Feng Lee
  Cc: david, akpm, mingo, jgg, jhubbard, peterx, maobibo, trivial,
	linux-kernel, lance.yang, anshuman.khandual

On Fri, May 9, 2025 at 1:54 PM Feng Lee <379943137@qq.com> wrote:
>
> Remove pgd_offset_gate() completely and simply make the single
> caller use pgd_offset()

 "."

>
> It appears that the gate area resides in the kernel-mapped segment
> exclusively on IA64. Therefore, removing pgd_offset_k is safe since
> IA64 is now obsolete.
>
> Signed-off-by: Feng Lee <379943137@qq.com>
>

Better to rename the subject to be more specific, e.g.  "mm: remove
obsolete  pgd_offset_gate()" or similar. Otherwise,

Reviewed-by: Barry Song <baohua@kernel.org>

> ---
> Changes in v2:
>   - remove pgd_offset_gate completely
>   - remove pgd_offset_k from the get_gate_page function completely
> ---
>  include/linux/pgtable.h | 4 ----
>  mm/gup.c                | 5 +----
>  2 files changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
> index b50447ef1c92..f1e890b60460 100644
> --- a/include/linux/pgtable.h
> +++ b/include/linux/pgtable.h
> @@ -1164,10 +1164,6 @@ static inline void arch_swap_restore(swp_entry_t entry, struct folio *folio)
>  }
>  #endif
>
> -#ifndef __HAVE_ARCH_PGD_OFFSET_GATE
> -#define pgd_offset_gate(mm, addr)      pgd_offset(mm, addr)
> -#endif
> -
>  #ifndef __HAVE_ARCH_MOVE_PTE
>  #define move_pte(pte, old_addr, new_addr)      (pte)
>  #endif
> diff --git a/mm/gup.c b/mm/gup.c
> index f32168339390..0685403fe510 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -1101,10 +1101,7 @@ static int get_gate_page(struct mm_struct *mm, unsigned long address,
>         /* user gate pages are read-only */
>         if (gup_flags & FOLL_WRITE)
>                 return -EFAULT;
> -       if (address > TASK_SIZE)
> -               pgd = pgd_offset_k(address);
> -       else
> -               pgd = pgd_offset_gate(mm, address);
> +       pgd = pgd_offset(mm, address);
>         if (pgd_none(*pgd))
>                 return -EFAULT;
>         p4d = p4d_offset(pgd, address);
> --
> 2.49.0
>

Thanks
barry

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mm: clean up redundant code
  2025-05-09  2:44 ` Barry Song
@ 2025-05-09  3:06   ` Feng Lee
  2025-05-09  8:22   ` David Hildenbrand
  1 sibling, 0 replies; 4+ messages in thread
From: Feng Lee @ 2025-05-09  3:06 UTC (permalink / raw)
  To: 21cnbao
  Cc: 379943137, akpm, anshuman.khandual, david, jgg, jhubbard,
	lance.yang, linux-kernel, maobibo, mingo, peterx, trivial

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 2154 bytes --]

>On Fri, May 9, 2025 at 1:54 PM Feng Lee <379943137@qq.com> wrote:
>>
>> Remove pgd_offset_gate() completely and simply make the single
>> caller use pgd_offset()
>
> "."
>
>>
>> It appears that the gate area resides in the kernel-mapped segment
>> exclusively on IA64. Therefore, removing pgd_offset_k is safe since
>> IA64 is now obsolete.
>>
>> Signed-off-by: Feng Lee <379943137@qq.com>
>>
>
>Better to rename the subject to be more specific, e.g.  "mm: remove
>obsolete  pgd_offset_gate()" or similar. Otherwise,
>
>Reviewed-by: Barry Song <baohua@kernel.org>

Thank you very much for your review comments. I will promptly implement 
the suggested revisions.

>> ---
>> Changes in v2:
>>   - remove pgd_offset_gate completely
>>   - remove pgd_offset_k from the get_gate_page function completely
>> ---
>>  include/linux/pgtable.h | 4 ----
>>  mm/gup.c                | 5 +----
>>  2 files changed, 1 insertion(+), 8 deletions(-)
>>
>> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
>> index b50447ef1c92..f1e890b60460 100644
>> --- a/include/linux/pgtable.h
>> +++ b/include/linux/pgtable.h
>> @@ -1164,10 +1164,6 @@ static inline void arch_swap_restore(swp_entry_t entry, struct folio *folio)
>>  }
>>  #endif
>>
>> -#ifndef __HAVE_ARCH_PGD_OFFSET_GATE
>> -#define pgd_offset_gate(mm, addr)      pgd_offset(mm, addr)
>> -#endif
>> -
>>  #ifndef __HAVE_ARCH_MOVE_PTE
>>  #define move_pte(pte, old_addr, new_addr)      (pte)
>>  #endif
>> diff --git a/mm/gup.c b/mm/gup.c
>> index f32168339390..0685403fe510 100644
>> --- a/mm/gup.c
>> +++ b/mm/gup.c
>> @@ -1101,10 +1101,7 @@ static int get_gate_page(struct mm_struct *mm, unsigned long address,
>>         /* user gate pages are read-only */
>>         if (gup_flags & FOLL_WRITE)
>>                 return -EFAULT;
>> -       if (address > TASK_SIZE)
>> -               pgd = pgd_offset_k(address);
>> -       else
>> -               pgd = pgd_offset_gate(mm, address);
>> +       pgd = pgd_offset(mm, address);
>>         if (pgd_none(*pgd))
>>                 return -EFAULT;
>>         p4d = p4d_offset(pgd, address);
>> --
>> 2.49.0
>>
>
>Thanks
>barry

Best regards,
Feng


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mm: clean up redundant code
  2025-05-09  2:44 ` Barry Song
  2025-05-09  3:06   ` Feng Lee
@ 2025-05-09  8:22   ` David Hildenbrand
  1 sibling, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2025-05-09  8:22 UTC (permalink / raw)
  To: Barry Song, Feng Lee
  Cc: akpm, mingo, jgg, jhubbard, peterx, maobibo, trivial,
	linux-kernel, lance.yang, anshuman.khandual

On 09.05.25 04:44, Barry Song wrote:
> On Fri, May 9, 2025 at 1:54 PM Feng Lee <379943137@qq.com> wrote:
>>
>> Remove pgd_offset_gate() completely and simply make the single
>> caller use pgd_offset()
> 
>   "."
> 
>>
>> It appears that the gate area resides in the kernel-mapped segment
>> exclusively on IA64. Therefore, removing pgd_offset_k is safe since
>> IA64 is now obsolete.
>>
>> Signed-off-by: Feng Lee <379943137@qq.com>
>>
> 
> Better to rename the subject to be more specific, e.g.  "mm: remove
> obsolete  pgd_offset_gate()" or similar. Otherwise,

With that

Acked-by: David Hildenbrand <david@redhat.com>

Thanks!

-- 
Cheers,

David / dhildenb


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-05-09  8:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-08 14:01 [PATCH v2] mm: clean up redundant code Feng Lee
2025-05-09  2:44 ` Barry Song
2025-05-09  3:06   ` Feng Lee
2025-05-09  8:22   ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®