Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755552AbaJXWO5 (ORCPT ); Fri, 24 Oct 2014 18:14:57 -0400 Received: from mail-la0-f51.google.com ([209.85.215.51]:47291 "EHLO mail-la0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751397AbaJXWOz (ORCPT ); Fri, 24 Oct 2014 18:14:55 -0400 MIME-Version: 1.0 In-Reply-To: References: <20141021160411.GF3219@twins.programming.kicks-ass.net> <20141023114228.GB12706@worktop.programming.kicks-ass.net> From: Andy Lutomirski Date: Fri, 24 Oct 2014 15:14:33 -0700 Message-ID: Subject: Re: [RFC 0/5] CR4 handling improvements To: Vince Weaver Cc: Peter Zijlstra , Valdis Kletnieks , "linux-kernel@vger.kernel.org" , Paul Mackerras , Arnaldo Carvalho de Melo , Ingo Molnar , Kees Cook , Andrea Arcangeli , Erik Bosman Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 24, 2014 at 5:41 AM, Vince Weaver wrote: > On Thu, 23 Oct 2014, Peter Zijlstra wrote: > >> On Tue, Oct 21, 2014 at 01:05:49PM -0400, Vince Weaver wrote: > >> > There are various reasons why you might want to start events at times >> > other than the beginning of the program. Some people don't like kernel >> > multiplexing so they start/stop manually if they want to switch eventsets. >> >> I suppose you could pre-create all events and use ioctl()s to start/stop >> them where/when desired, this should be faster I think. But yes, this is >> not a use-case I've though much about. > > The scheduling step is most of what makes the perf_event start call have > high overhead. The other annoyance is the fact that due to the NMI > watchdog your can successfully perf_event_open() an event group but still > have it fail at start time, so a lot of code has to be done that does > extraneous open/start/close calls to make sure the events really fit. > >> MAP_POPULATE is your friend there, but yes manually prefaulting is >> perfectly fine too, and the HPC people are quite familiar with the >> concept, they do it for a lot of things. > > MAP_POPULATE actually has noticably more overhead than manually > prefaulting. It's on my todo list to drop ftrace on there and find out > why, but I've been stuck chasing kernel-crashing fuzzer bugs instead in my > spare time. Have you checked recently? IIRC Michael Lespinasse put some effort into improving MAP_POPULATE recently. > > perfctr and possibly perfmon2 would automatically pre-fault the mmap page > for you in the kernel, so there was no need for the user to do it. > > > In any case I wasn't really trying to make trouble here, it's just I came > across the people using rdpmc w/o perf_event just the other day (on USENET > of all places). They were so happy it worked w/o patches now, that I felt > bad breaking it to them that there were patches floating around that were > going to make their usecase not work anymore. > > I guess like all things though, you can't have anything fun and useful in > the kernel without the security people taking it away. I'm sympathetic enough to this use case that I don't really mind adding a bit of code to support rdpmc=2 meaning that rdpmc is always allowed. Switching in and out of rdpmc=2 mode will be expensive (static key and IPI to all CPUs). PeterZ, is that OK with you? --Andy > > Vince -- Andy Lutomirski AMA Capital Management, LLC -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/