Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1599823
| Path | csiph.com!goblin2!goblin.stu.neva.ru!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Andy Lutomirski <luto@kernel.org> |
| Newsgroups | linux.kernel |
| Subject | Re: perf: race with automatic rdpmc() disabling |
| Date | Mon, 13 Mar 2017 22:10:03 +0100 |
| Message-ID | <tkFo7-6nZ-29@gated-at.bofh.it> (permalink) |
| References | <tkyFZ-1ik-29@gated-at.bofh.it> <tkBku-3fs-17@gated-at.bofh.it> <tkBu9-3kO-5@gated-at.bofh.it> |
| X-Original-To | Peter Zijlstra <peterz@infradead.org> |
| X-Gm-Message-State | AMke39mVcitfoZvfMonwlax3tBOwAsw+Z1Gt+EByA1FLIvpCA3zSz/05+oQu+xCaX9n1uMZsytyyKB7/DvfVo2Mo |
| X-Received | by 10.31.108.89 with SMTP id h86mr15617825vkc.27.1489439148142; Mon, 13 Mar 2017 14:05:48 -0700 (PDT) |
| MIME-Version | 1.0 |
| X-Gmail-Original-Message-ID | <CALCETrVRzPwxnHmron_J+6nkBy24cm_G8kX=cxa5+qYoeQLcsw@mail.gmail.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 27 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Andy Lutomirski <luto@kernel.org>, Vince Weaver <vincent.weaver@maine.edu>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@redhat.com>, Arnaldo Carvalho de Melo <acme@kernel.org> |
| X-Original-Date | Mon, 13 Mar 2017 14:05:27 -0700 |
| X-Original-Message-ID | <CALCETrVRzPwxnHmron_J+6nkBy24cm_G8kX=cxa5+qYoeQLcsw@mail.gmail.com> |
| X-Original-References | <alpine.DEB.2.20.1703130945120.12942@macbook-air> <CALCETrWoB9UNThOdbMjquA0uBhU74DqF2RB9ERX1Xi_ujyOwEA@mail.gmail.com> <20170313165507.GJ3312@twins.programming.kicks-ass.net> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1599823 |
Show key headers only | View raw
On Mon, Mar 13, 2017 at 9:55 AM, Peter Zijlstra <peterz@infradead.org> wrote:
> On Mon, Mar 13, 2017 at 09:44:02AM -0700, Andy Lutomirski wrote:
>> static void x86_pmu_event_mapped(struct perf_event *event)
>> {
>> if (!(event->hw.flags & PERF_X86_EVENT_RDPMC_ALLOWED))
>> return;
>>
>> if (atomic_inc_return(¤t->mm->context.perf_rdpmc_allowed) == 1)
>>
>> <-- thread 1 stalls here
>>
>> on_each_cpu_mask(mm_cpumask(current->mm), refresh_pce, NULL, 1);
>> }
>>
>> Suppose you start with perf_rdpmc_allowed == 0. Thread 1 runs
>> x86_pmu_event_mapped and gets preempted (or just runs slowly) where I
>> marked. Then thread 2 runs the whole function, does *not* update CR4,
>> returns to userspace, and GPFs.
>>
>> The big hammer solution is to stick a per-mm mutex around it. Let me
>> ponder whether a smaller hammer is available.
>
> Reminds me a bit of what we ended up with in kernel/jump_label.c:static_key_slow_inc().
>
>
One thing I don't get: isn't mmap_sem held for write the whole time?
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
perf: race with automatic rdpmc() disabling Vince Weaver <vincent.weaver@maine.edu> - 2017-03-13 15:00 +0100
Re: perf: race with automatic rdpmc() disabling Andy Lutomirski <luto@kernel.org> - 2017-03-13 17:50 +0100
Re: perf: race with automatic rdpmc() disabling Peter Zijlstra <peterz@infradead.org> - 2017-03-13 18:00 +0100
Re: perf: race with automatic rdpmc() disabling Andy Lutomirski <luto@kernel.org> - 2017-03-13 22:10 +0100
Re: perf: race with automatic rdpmc() disabling Andy Lutomirski <luto@amacapital.net> - 2017-03-14 17:00 +0100
Re: perf: race with automatic rdpmc() disabling Vince Weaver <vincent.weaver@maine.edu> - 2017-03-14 17:50 +0100
Re: perf: race with automatic rdpmc() disabling Andy Lutomirski <luto@amacapital.net> - 2017-03-15 21:20 +0100
Re: perf: race with automatic rdpmc() disabling Vince Weaver <vincent.weaver@maine.edu> - 2017-03-16 06:50 +0100
csiph-web