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

From: Mathieu Desnoyers
Date: Wed Apr 29 2020 - 13:29:49 EST


----- On Apr 29, 2020, at 12:52 PM, rostedt rostedt@xxxxxxxxxxx wrote:

> On Wed, 29 Apr 2020 18:20:26 +0200
> Joerg Roedel <jroedel@xxxxxxx> 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!).

I think you mean 2 giga-bit, for 256MB worth of memory, right ?

And AFAIU the PID_MAX_LIMIT is at a maximum of 4 million PIDs in
include/linux/threads.h, which means 512MB worth of memory for a
bitmask.

> 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.

Not sure how relevant it is, but I notice that it is also touched from IPI
context, see:

on_each_cpu(ignore_task_cpu, tr, 1);

Thanks,

Mathieu

--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com