[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aA-HQ3YfLz28MnhZ@krava>
Date: Mon, 28 Apr 2025 15:48:51 +0200
From: Jiri Olsa <olsajiri@...il.com>
To: Oleg Nesterov <oleg@...hat.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Andrii Nakryiko <andrii@...nel.org>, bpf@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
x86@...nel.org, Song Liu <songliubraving@...com>,
Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
Hao Luo <haoluo@...gle.com>, Steven Rostedt <rostedt@...dmis.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Alan Maguire <alan.maguire@...cle.com>,
David Laight <David.Laight@...lab.com>,
Thomas Weißschuh <thomas@...ch.de>,
Ingo Molnar <mingo@...nel.org>
Subject: Re: [PATCH perf/core 08/22] uprobes/x86: Add mapping for optimized
uprobe trampolines
On Sun, Apr 27, 2025 at 07:34:56PM +0200, Oleg Nesterov wrote:
> On 04/27, Oleg Nesterov wrote:
> >
> > On 04/21, Jiri Olsa wrote:
> > >
> > > +static unsigned long find_nearest_page(unsigned long vaddr)
> > > +{
> > > + struct vm_area_struct *vma, *prev = NULL;
> > > + unsigned long prev_vm_end = PAGE_SIZE;
> > > + VMA_ITERATOR(vmi, current->mm, 0);
> > > +
> > > + vma = vma_next(&vmi);
> > > + while (vma) {
> > > + if (prev)
> > > + prev_vm_end = prev->vm_end;
> > > + if (vma->vm_start - prev_vm_end >= PAGE_SIZE) {
> > > + if (is_reachable_by_call(prev_vm_end, vaddr))
> > > + return prev_vm_end;
> > > + if (is_reachable_by_call(vma->vm_start - PAGE_SIZE, vaddr))
> > > + return vma->vm_start - PAGE_SIZE;
> > > + }
> > > + prev = vma;
> > > + vma = vma_next(&vmi);
> > > + }
> > > +
> > > + return 0;
> > > +}
> >
> > This can be simplified afaics... We don't really need prev, and we can
> > use for_each_vma(),
> >
> > static unsigned long find_nearest_page(unsigned long vaddr)
> > {
> > struct vm_area_struct *vma;
> > unsigned long prev_vm_end = PAGE_SIZE;
> > VMA_ITERATOR(vmi, current->mm, 0);
> >
> > for_each_vma(vmi, vma) {
> > if (vma->vm_start - prev_vm_end >= PAGE_SIZE) {
> > if (is_reachable_by_call(prev_vm_end, vaddr))
> > return prev_vm_end;
> > if (is_reachable_by_call(vma->vm_start - PAGE_SIZE, vaddr))
> > return vma->vm_start - PAGE_SIZE;
> > }
> > prev_vm_end = vma->vm_end;
> > }
> >
> > return 0;
> > }
>
> Either way it doesn't look nice. If nothing else, we should respect
> vm_start/end_gap(vma).
>
> Can't we do something like
>
> struct vm_unmapped_area_info info = {};
>
> info.length = PAGE_SIZE;
> info.low_limit = vaddr - INT_MIN + 5;
> info.high_limit = vaddr + INT_MAX;
>
> info.flags = VM_UNMAPPED_AREA_TOPDOWN; // makes sense?
so this would return highest available space right? current code goes from
bottom now, not sure what's preffered
>
> return vm_unmapped_area(&info);
>
> instead ?
yes, I did not realize we could use this, looks better, will try that
thanks,
jirka
Powered by blists - more mailing lists