Re: [RFC][PATCH] x86/mm: Sync all vmalloc mappings before text_poke()

Steven Rostedt
2020-04-29T16:52:49Z

On Wed, 29 Apr 2020 18:20:26 +0200
Joerg Roedel <jroedel@suse.de> wrote:

> On Wed, Apr 29, 2020 at 06:17:47PM +0200, Joerg Roedel wrote:
> > On Wed, Apr 29, 2020 at 10:07:31AM -0400, Steven Rostedt wrote:
> > > Talking with Mathieu about this on IRC, he pointed out that my code does
> > > have a vzalloc() that is called:
> > >
> > > in trace_pid_write()
> > >
> > > pid_list->pids = vzalloc((pid_list->pid_max + 7) >> 3);
> > >
> > > This is done when -P1,2 is on the trace-cmd command line.
> >
> > And that buffer is written to at any function entry?
>
> What I meant to say, is it possible that the page-fault handler does not
> complete because at its beginning it calls into trace-code and faults
> again on the same address?
>

It should be read only at sched_switch.

Basically, it's a big bitmask, where each bit represents a possible process
id (can be 2 gigs if we allow all positive ints!).

Then, it is only written when setting it up. Bits 1 and 2 are set here
(-P1,2). At context switch, next->pid is checked against this bitmask, and
if it is set, it means we should allow this process to be traced.

This mask should only be accessed at sched_switch time, not at other times.
And it may read any possible page in that mask depending on the process id
of the next task to be scheduled in.

-- Steve