Re: [PATCH v2 01/12] uprobes: update outdated comment

2024-07-10 Thread Andrii Nakryiko
On Wed, Jul 10, 2024 at 6:33 AM Oleg Nesterov  wrote:
>
> On 07/03, Oleg Nesterov wrote:
> >
> > > /*
> > > -* The NULL 'tsk' here ensures that any faults that occur here
> > > -* will not be accounted to the task.  'mm' *is* current->mm,
> > > -* but we treat this as a 'remote' access since it is
> > > -* essentially a kernel access to the memory.
> > > +* 'mm' *is* current->mm, but we treat this as a 'remote' access since
> > > +* it is essentially a kernel access to the memory.
> > >  */
> > > result = get_user_pages_remote(mm, vaddr, 1, FOLL_FORCE, , NULL);
> >
> > OK, this makes it less confusing, so
> >
> > Acked-by: Oleg Nesterov 
> >
> > -
> > but it still looks confusing to me. This code used to pass tsk = NULL
> > only to avoid tsk->maj/min_flt++ in faultin_page().
> >
> > But today mm_account_fault() increments these counters without checking
> > FAULT_FLAG_REMOTE, mm == current->mm, so it seems it would be better to
> > just use get_user_pages() and remove this comment?
>
> Well, yes, it still looks confusing, imo.
>
> Andrii, I hope you won't mind if I redo/resend this and the next cleanup?
>
> The next one only updates the comment above uprobe_write_opcode(), but
> it would be nice to explain mmap_write_lock() in register_for_each_vma().
>

I don't mind a bit, thanks for sending the patches!

> Oleg.
>
>



Re: [PATCH v2 01/12] uprobes: update outdated comment

2024-07-10 Thread Oleg Nesterov
On 07/03, Oleg Nesterov wrote:
>
> > /*
> > -* The NULL 'tsk' here ensures that any faults that occur here
> > -* will not be accounted to the task.  'mm' *is* current->mm,
> > -* but we treat this as a 'remote' access since it is
> > -* essentially a kernel access to the memory.
> > +* 'mm' *is* current->mm, but we treat this as a 'remote' access since
> > +* it is essentially a kernel access to the memory.
> >  */
> > result = get_user_pages_remote(mm, vaddr, 1, FOLL_FORCE, , NULL);
>
> OK, this makes it less confusing, so
>
> Acked-by: Oleg Nesterov 
>
> -
> but it still looks confusing to me. This code used to pass tsk = NULL
> only to avoid tsk->maj/min_flt++ in faultin_page().
>
> But today mm_account_fault() increments these counters without checking
> FAULT_FLAG_REMOTE, mm == current->mm, so it seems it would be better to
> just use get_user_pages() and remove this comment?

Well, yes, it still looks confusing, imo.

Andrii, I hope you won't mind if I redo/resend this and the next cleanup?

The next one only updates the comment above uprobe_write_opcode(), but
it would be nice to explain mmap_write_lock() in register_for_each_vma().

Oleg.




Re: [PATCH v2 01/12] uprobes: update outdated comment

2024-07-03 Thread Andrii Nakryiko
On Wed, Jul 3, 2024 at 4:40 AM Oleg Nesterov  wrote:
>
> Sorry for the late reply. I'll try to read this version/discussion
> when I have time... yes, I have already promised this before, sorry :/
>

No worries, there will be v3 next week (I'm going on short PTO
starting tomorrow). So you still have time. I appreciate you looking
at it, though!

> On 07/01, Andrii Nakryiko wrote:
> >
> > There is no task_struct passed into get_user_pages_remote() anymore,
> > drop the parts of comment mentioning NULL tsk, it's just confusing at
> > this point.
>
> Agreed.
>
> > @@ -2030,10 +2030,8 @@ static int is_trap_at_addr(struct mm_struct *mm, 
> > unsigned long vaddr)
> >   goto out;
> >
> >   /*
> > -  * The NULL 'tsk' here ensures that any faults that occur here
> > -  * will not be accounted to the task.  'mm' *is* current->mm,
> > -  * but we treat this as a 'remote' access since it is
> > -  * essentially a kernel access to the memory.
> > +  * 'mm' *is* current->mm, but we treat this as a 'remote' access since
> > +  * it is essentially a kernel access to the memory.
> >*/
> >   result = get_user_pages_remote(mm, vaddr, 1, FOLL_FORCE, , NULL);
>
> OK, this makes it less confusing, so
>
> Acked-by: Oleg Nesterov 
>
>
> -
> but it still looks confusing to me. This code used to pass tsk = NULL
> only to avoid tsk->maj/min_flt++ in faultin_page().
>
> But today mm_account_fault() increments these counters without checking
> FAULT_FLAG_REMOTE, mm == current->mm, so it seems it would be better to
> just use get_user_pages() and remove this comment?
>
> Oleg.
>



Re: [PATCH v2 01/12] uprobes: update outdated comment

2024-07-03 Thread Andrii Nakryiko
On Wed, Jul 3, 2024 at 4:40 AM Oleg Nesterov  wrote:
>
> Sorry for the late reply. I'll try to read this version/discussion
> when I have time... yes, I have already promised this before, sorry :/
>
> On 07/01, Andrii Nakryiko wrote:
> >
> > There is no task_struct passed into get_user_pages_remote() anymore,
> > drop the parts of comment mentioning NULL tsk, it's just confusing at
> > this point.
>
> Agreed.
>
> > @@ -2030,10 +2030,8 @@ static int is_trap_at_addr(struct mm_struct *mm, 
> > unsigned long vaddr)
> >   goto out;
> >
> >   /*
> > -  * The NULL 'tsk' here ensures that any faults that occur here
> > -  * will not be accounted to the task.  'mm' *is* current->mm,
> > -  * but we treat this as a 'remote' access since it is
> > -  * essentially a kernel access to the memory.
> > +  * 'mm' *is* current->mm, but we treat this as a 'remote' access since
> > +  * it is essentially a kernel access to the memory.
> >*/
> >   result = get_user_pages_remote(mm, vaddr, 1, FOLL_FORCE, , NULL);
>
> OK, this makes it less confusing, so
>
> Acked-by: Oleg Nesterov 
>
>
> -
> but it still looks confusing to me. This code used to pass tsk = NULL
> only to avoid tsk->maj/min_flt++ in faultin_page().
>
> But today mm_account_fault() increments these counters without checking
> FAULT_FLAG_REMOTE, mm == current->mm, so it seems it would be better to
> just use get_user_pages() and remove this comment?

I don't know, it was a drive-by cleanup which I'm starting to regret already :)

>
> Oleg.
>



Re: [PATCH v2 01/12] uprobes: update outdated comment

2024-07-03 Thread Oleg Nesterov
Sorry for the late reply. I'll try to read this version/discussion
when I have time... yes, I have already promised this before, sorry :/

On 07/01, Andrii Nakryiko wrote:
>
> There is no task_struct passed into get_user_pages_remote() anymore,
> drop the parts of comment mentioning NULL tsk, it's just confusing at
> this point.

Agreed.

> @@ -2030,10 +2030,8 @@ static int is_trap_at_addr(struct mm_struct *mm, 
> unsigned long vaddr)
>   goto out;
>
>   /*
> -  * The NULL 'tsk' here ensures that any faults that occur here
> -  * will not be accounted to the task.  'mm' *is* current->mm,
> -  * but we treat this as a 'remote' access since it is
> -  * essentially a kernel access to the memory.
> +  * 'mm' *is* current->mm, but we treat this as a 'remote' access since
> +  * it is essentially a kernel access to the memory.
>*/
>   result = get_user_pages_remote(mm, vaddr, 1, FOLL_FORCE, , NULL);

OK, this makes it less confusing, so

Acked-by: Oleg Nesterov 


-
but it still looks confusing to me. This code used to pass tsk = NULL
only to avoid tsk->maj/min_flt++ in faultin_page().

But today mm_account_fault() increments these counters without checking
FAULT_FLAG_REMOTE, mm == current->mm, so it seems it would be better to
just use get_user_pages() and remove this comment?

Oleg.




[PATCH v2 01/12] uprobes: update outdated comment

2024-07-01 Thread Andrii Nakryiko
There is no task_struct passed into get_user_pages_remote() anymore,
drop the parts of comment mentioning NULL tsk, it's just confusing at
this point.

Signed-off-by: Andrii Nakryiko 
---
 kernel/events/uprobes.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 99be2adedbc0..081821fd529a 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -2030,10 +2030,8 @@ static int is_trap_at_addr(struct mm_struct *mm, 
unsigned long vaddr)
goto out;
 
/*
-* The NULL 'tsk' here ensures that any faults that occur here
-* will not be accounted to the task.  'mm' *is* current->mm,
-* but we treat this as a 'remote' access since it is
-* essentially a kernel access to the memory.
+* 'mm' *is* current->mm, but we treat this as a 'remote' access since
+* it is essentially a kernel access to the memory.
 */
result = get_user_pages_remote(mm, vaddr, 1, FOLL_FORCE, , NULL);
if (result < 0)
-- 
2.43.0