Re: Kernel broken on processors without performance counters

2015-07-24 Thread Jason Baron
On 07/24/2015 08:36 AM, Peter Zijlstra wrote: > On Fri, Jul 24, 2015 at 12:56:02PM +0200, Peter Zijlstra wrote: >> On Thu, Jul 23, 2015 at 03:14:13PM -0400, Jason Baron wrote: +static enum jump_label_type jump_label_type(struct jump_entry *entry) +{ + struct static_key *key = stat

Re: Kernel broken on processors without performance counters

2015-07-24 Thread Peter Zijlstra
On Fri, Jul 24, 2015 at 12:56:02PM +0200, Peter Zijlstra wrote: > On Thu, Jul 23, 2015 at 03:14:13PM -0400, Jason Baron wrote: > > > +static enum jump_label_type jump_label_type(struct jump_entry *entry) > > > +{ > > > + struct static_key *key = static_key_cast(iter->key); > > > + bool true_branch

Re: Kernel broken on processors without performance counters

2015-07-24 Thread Peter Zijlstra
On Thu, Jul 23, 2015 at 03:14:13PM -0400, Jason Baron wrote: > > +static enum jump_label_type jump_label_type(struct jump_entry *entry) > > +{ > > + struct static_key *key = static_key_cast(iter->key); > > + bool true_branch = jump_label_get_branch_default(key); > > + bool state = static_key_

Re: Kernel broken on processors without performance counters

2015-07-24 Thread Peter Zijlstra
On Fri, Jul 24, 2015 at 07:29:05AM +0200, Borislav Petkov wrote: > On Thu, Jul 23, 2015 at 09:02:14PM +0200, Peter Zijlstra wrote: > > On Thu, Jul 23, 2015 at 07:54:36PM +0200, Borislav Petkov wrote: > > > On Thu, Jul 23, 2015 at 07:08:11PM +0200, Peter Zijlstra wrote: > > > > That would be bad, ho

Re: Kernel broken on processors without performance counters

2015-07-23 Thread Borislav Petkov
On Thu, Jul 23, 2015 at 09:02:14PM +0200, Peter Zijlstra wrote: > On Thu, Jul 23, 2015 at 07:54:36PM +0200, Borislav Petkov wrote: > > On Thu, Jul 23, 2015 at 07:08:11PM +0200, Peter Zijlstra wrote: > > > That would be bad, how can we force it to emit 5 bytes? > > > > .byte 0xe9 like we used to do

Re: Kernel broken on processors without performance counters

2015-07-23 Thread Jason Baron
On 07/23/2015 10:49 AM, Peter Zijlstra wrote: > On Thu, Jul 23, 2015 at 04:33:08PM +0200, Peter Zijlstra wrote: >> Lemme finish this and I'll post it. > Compile tested on x86_64 only.. > > Please have a look, I think you said I got some of the logic wrong, I've > not double checked that. > > I'll g

Re: Kernel broken on processors without performance counters

2015-07-23 Thread Peter Zijlstra
On Thu, Jul 23, 2015 at 01:33:36PM -0400, Jason Baron wrote: > > That would be bad, how can we force it to emit 5 bytes? > hmmI don't think that's an issue, the patching code can > detect if its a 2-byte jump - 0xeb, or 5-byte: 0xe9, and do > the correct no-op. Same going the other way. See th

Re: Kernel broken on processors without performance counters

2015-07-23 Thread Peter Zijlstra
On Thu, Jul 23, 2015 at 07:54:36PM +0200, Borislav Petkov wrote: > On Thu, Jul 23, 2015 at 07:08:11PM +0200, Peter Zijlstra wrote: > > That would be bad, how can we force it to emit 5 bytes? > > .byte 0xe9 like we used to do in static_cpu_has_safe(). Like so then? static __always_inline bool arc

Re: Kernel broken on processors without performance counters

2015-07-23 Thread Steven Rostedt
On Thu, 23 Jul 2015 13:33:36 -0400 Jason Baron wrote: > On 07/23/2015 01:08 PM, Peter Zijlstra wrote: > > On Thu, Jul 23, 2015 at 11:34:50AM -0400, Steven Rostedt wrote: > >> On Thu, 23 Jul 2015 12:42:15 +0200 > >> Peter Zijlstra wrote: > >> > >>> static __always_inline bool arch_static_branch_j

Re: Kernel broken on processors without performance counters

2015-07-23 Thread Borislav Petkov
On Thu, Jul 23, 2015 at 07:08:11PM +0200, Peter Zijlstra wrote: > That would be bad, how can we force it to emit 5 bytes? .byte 0xe9 like we used to do in static_cpu_has_safe(). Or you can copy the insn sizing from the alternatives macros which I added recently. -- Regards/Gruss, Boris. EC

Re: Kernel broken on processors without performance counters

2015-07-23 Thread Andy Lutomirski
On Jul 23, 2015 10:08 AM, "Peter Zijlstra" wrote: > > On Thu, Jul 23, 2015 at 11:34:50AM -0400, Steven Rostedt wrote: > > On Thu, 23 Jul 2015 12:42:15 +0200 > > Peter Zijlstra wrote: > > > > > static __always_inline bool arch_static_branch_jump(struct static_key > > > *key, bool inv) > > > { > >

Re: Kernel broken on processors without performance counters

2015-07-23 Thread Jason Baron
On 07/23/2015 01:08 PM, Peter Zijlstra wrote: > On Thu, Jul 23, 2015 at 11:34:50AM -0400, Steven Rostedt wrote: >> On Thu, 23 Jul 2015 12:42:15 +0200 >> Peter Zijlstra wrote: >> >>> static __always_inline bool arch_static_branch_jump(struct static_key *key, >>> bool inv) >>> { >>> if (!inv) {

Re: Kernel broken on processors without performance counters

2015-07-23 Thread Steven Rostedt
On Thu, 23 Jul 2015 19:08:11 +0200 Peter Zijlstra wrote: > On Thu, Jul 23, 2015 at 11:34:50AM -0400, Steven Rostedt wrote: > > On Thu, 23 Jul 2015 12:42:15 +0200 > > Peter Zijlstra wrote: > > > > > static __always_inline bool arch_static_branch_jump(struct static_key > > > *key, bool inv) > >

Re: Kernel broken on processors without performance counters

2015-07-23 Thread Peter Zijlstra
On Thu, Jul 23, 2015 at 11:34:50AM -0400, Steven Rostedt wrote: > On Thu, 23 Jul 2015 12:42:15 +0200 > Peter Zijlstra wrote: > > > static __always_inline bool arch_static_branch_jump(struct static_key *key, > > bool inv) > > { > > if (!inv) { > > asm_volatile_goto("1:" > >

Re: Kernel broken on processors without performance counters

2015-07-23 Thread Steven Rostedt
On Thu, 23 Jul 2015 12:42:15 +0200 Peter Zijlstra wrote: > static __always_inline bool arch_static_branch_jump(struct static_key *key, > bool inv) > { > if (!inv) { > asm_volatile_goto("1:" > "jmp %l[l_yes]\n\t" And what happens when this gets converted

Re: Kernel broken on processors without performance counters

2015-07-23 Thread Peter Zijlstra
On Thu, Jul 23, 2015 at 10:19:52AM -0400, Jason Baron wrote: > > > > #define static_branch_likely(x) > > \ > > ({ > > \ > > bool branch;

Re: Kernel broken on processors without performance counters

2015-07-23 Thread Steven Rostedt
On Tue, 21 Jul 2015 12:57:08 -0400 Jason Baron wrote: > On 07/21/2015 12:12 PM, Peter Zijlstra wrote: > > On Tue, Jul 21, 2015 at 08:51:51AM -0700, Andy Lutomirski wrote: > >> To clarify my (mis-)understanding: > >> > >> There are two degrees of freedom in a static_key. They can start out > >>

Re: Kernel broken on processors without performance counters

2015-07-23 Thread Peter Zijlstra
On Thu, Jul 23, 2015 at 04:33:08PM +0200, Peter Zijlstra wrote: > Lemme finish this and I'll post it. Compile tested on x86_64 only.. Please have a look, I think you said I got some of the logic wrong, I've not double checked that. I'll go write comments and double check things. --- arch/arm/i

Re: Kernel broken on processors without performance counters

2015-07-23 Thread Peter Zijlstra
On Thu, Jul 23, 2015 at 10:19:52AM -0400, Jason Baron wrote: > > And I think it'll all work. Hmm? > > Cool. This also gives an extra degree of freedom in that it allows keys to > be arbitrarily mixed with the likely/unlikely branch types. I'm not sure > that's > come up as a use-case, but seems l

Re: Kernel broken on processors without performance counters

2015-07-23 Thread Jason Baron
On 07/23/2015 06:42 AM, Peter Zijlstra wrote: > On Wed, Jul 22, 2015 at 01:06:44PM -0400, Jason Baron wrote: >> Ok, >> >> So we could add all 4 possible initial states, where the >> branches would be: >> >> static_likely_init_true_branch(struct static_likely_init_true_key *key) >> static_likely_ini

Re: Kernel broken on processors without performance counters

2015-07-23 Thread Borislav Petkov
On Thu, Jul 23, 2015 at 12:42:15PM +0200, Peter Zijlstra wrote: > > static_likely_init_true_branch(struct static_likely_init_true_key *key) > > static_likely_init_false_branch(struct static_likely_init_false_key *key) > > static_unlikely_init_false_branch(struct static_unlikely_init_false_key > >

Re: Kernel broken on processors without performance counters

2015-07-23 Thread Peter Zijlstra
On Wed, Jul 22, 2015 at 01:06:44PM -0400, Jason Baron wrote: > Ok, > > So we could add all 4 possible initial states, where the > branches would be: > > static_likely_init_true_branch(struct static_likely_init_true_key *key) > static_likely_init_false_branch(struct static_likely_init_false_key *k

Re: Kernel broken on processors without performance counters

2015-07-22 Thread Mikulas Patocka
On Wed, 22 Jul 2015, Borislav Petkov wrote: > On Tue, Jul 21, 2015 at 02:50:25PM -0400, Jason Baron wrote: > > hmmm...so this is a case where need to the default the branch > > to the out-of-line branch at boot. That is, we can't just enable > > the out-of-line branch at boot time, b/c it might

Re: Kernel broken on processors without performance counters

2015-07-22 Thread Jason Baron
On 07/22/2015 12:24 AM, Borislav Petkov wrote: > On Tue, Jul 21, 2015 at 02:50:25PM -0400, Jason Baron wrote: >> hmmm...so this is a case where need to the default the branch >> to the out-of-line branch at boot. That is, we can't just enable >> the out-of-line branch at boot time, b/c it might be

Re: Kernel broken on processors without performance counters

2015-07-21 Thread Borislav Petkov
On Tue, Jul 21, 2015 at 02:50:25PM -0400, Jason Baron wrote: > hmmm...so this is a case where need to the default the branch > to the out-of-line branch at boot. That is, we can't just enable > the out-of-line branch at boot time, b/c it might be too late at > that point? IE native_sched_clock() ge

Re: Kernel broken on processors without performance counters

2015-07-21 Thread Valdis . Kletnieks
On Tue, 21 Jul 2015 12:29:21 -0700, Andy Lutomirski said: > That's not what I meant. We do something in the C code that tells the > build step which way the initial state goes. At link time, we make > the initial state actually work like that. Then, at run time, we can > still switch it again i

Re: Kernel broken on processors without performance counters

2015-07-21 Thread Andy Lutomirski
On Tue, Jul 21, 2015 at 12:00 PM, wrote: > On Tue, 21 Jul 2015 11:54:30 -0700, Andy Lutomirski said: > >> Could this be done at link time, or perhaps when compressing the >> kernel image, instead of at boot time? > > That's only safe to do if the kernel is built for one specific CPU - if it's > a

Re: Kernel broken on processors without performance counters

2015-07-21 Thread Valdis . Kletnieks
On Tue, 21 Jul 2015 11:54:30 -0700, Andy Lutomirski said: > Could this be done at link time, or perhaps when compressing the > kernel image, instead of at boot time? That's only safe to do if the kernel is built for one specific CPU - if it's a generic kernel that boots on multiple hardware desig

Re: Kernel broken on processors without performance counters

2015-07-21 Thread Andy Lutomirski
On Tue, Jul 21, 2015 at 11:50 AM, Jason Baron wrote: > > > On 07/21/2015 02:15 PM, Borislav Petkov wrote: >> On Tue, Jul 21, 2015 at 06:12:15PM +0200, Peter Zijlstra wrote: >>> Yes, if you start out false, you must be unlikely. If you start out >>> true, you must be likely. >>> >>> We could maybe

Re: Kernel broken on processors without performance counters

2015-07-21 Thread Jason Baron
On 07/21/2015 02:15 PM, Borislav Petkov wrote: > On Tue, Jul 21, 2015 at 06:12:15PM +0200, Peter Zijlstra wrote: >> Yes, if you start out false, you must be unlikely. If you start out >> true, you must be likely. >> >> We could maybe try and untangle that if there really is a good use case, >> bu

Re: Kernel broken on processors without performance counters

2015-07-21 Thread Borislav Petkov
On Tue, Jul 21, 2015 at 06:12:15PM +0200, Peter Zijlstra wrote: > Yes, if you start out false, you must be unlikely. If you start out > true, you must be likely. > > We could maybe try and untangle that if there really is a good use case, > but this is the current state. > > The whole reason this

Re: Kernel broken on processors without performance counters

2015-07-21 Thread Jason Baron
On 07/21/2015 12:12 PM, Peter Zijlstra wrote: > On Tue, Jul 21, 2015 at 08:51:51AM -0700, Andy Lutomirski wrote: >> To clarify my (mis-)understanding: >> >> There are two degrees of freedom in a static_key. They can start out >> true or false, and they can be unlikely or likely. Are those two >

Re: Kernel broken on processors without performance counters

2015-07-21 Thread Peter Zijlstra
On Tue, Jul 21, 2015 at 08:51:51AM -0700, Andy Lutomirski wrote: > To clarify my (mis-)understanding: > > There are two degrees of freedom in a static_key. They can start out > true or false, and they can be unlikely or likely. Are those two > degrees of freedom in fact tied together? Yes, if y

Re: Kernel broken on processors without performance counters

2015-07-21 Thread Peter Zijlstra
On Tue, Jul 21, 2015 at 05:49:59PM +0200, Peter Zijlstra wrote: > On Tue, Jul 21, 2015 at 05:43:27PM +0200, Thomas Gleixner wrote: > > On Tue, 21 Jul 2015, Peter Zijlstra wrote: > > > > > > -#endif /* _LINUX_JUMP_LABEL_H */ > > > > +static inline void static_key_enable(struct static_key *key) > >

Re: Kernel broken on processors without performance counters

2015-07-21 Thread Thomas Gleixner
On Tue, 21 Jul 2015, Peter Zijlstra wrote: > On Tue, Jul 21, 2015 at 05:43:27PM +0200, Thomas Gleixner wrote: > > > > +#define static_branch_inc(_k) static_key_slow_inc(&(_k)->key) > > > > +#define static_branch_dec(_k) static_key_slow_dec(&(_k)->key) > > > > Inlines please > > > > > > +/* > >

Re: Kernel broken on processors without performance counters

2015-07-21 Thread Andy Lutomirski
On Tue, Jul 21, 2015 at 8:49 AM, Peter Zijlstra wrote: > On Tue, Jul 21, 2015 at 05:43:27PM +0200, Thomas Gleixner wrote: >> On Tue, 21 Jul 2015, Peter Zijlstra wrote: >> >> > > -#endif /* _LINUX_JUMP_LABEL_H */ >> > > +static inline void static_key_enable(struct static_key *key) >> > > +{ >> >

Re: Kernel broken on processors without performance counters

2015-07-21 Thread Peter Zijlstra
On Tue, Jul 21, 2015 at 05:43:27PM +0200, Thomas Gleixner wrote: > On Tue, 21 Jul 2015, Peter Zijlstra wrote: > > > > -#endif /* _LINUX_JUMP_LABEL_H */ > > > +static inline void static_key_enable(struct static_key *key) > > > +{ > > > + int count = static_key_count(key); > > > + > > > + WARN_ON_

Re: Kernel broken on processors without performance counters

2015-07-21 Thread Thomas Gleixner
On Tue, 21 Jul 2015, Peter Zijlstra wrote: > On Fri, Jul 10, 2015 at 04:13:59PM +0200, Peter Zijlstra wrote: > > On Wed, Jul 08, 2015 at 05:36:43PM -0700, Andy Lutomirski wrote: > > > >> In what universe is "static_key_false" a reasonable name for a > > > >> function that returns true if a static

Re: Kernel broken on processors without performance counters

2015-07-21 Thread Peter Zijlstra
On Fri, Jul 10, 2015 at 04:13:59PM +0200, Peter Zijlstra wrote: > On Wed, Jul 08, 2015 at 05:36:43PM -0700, Andy Lutomirski wrote: > > >> In what universe is "static_key_false" a reasonable name for a > > >> function that returns true if a static key is true? > > > I think the current naming is al

Re: Kernel broken on processors without performance counters

2015-07-14 Thread Mikulas Patocka
On Tue, 14 Jul 2015, Borislav Petkov wrote: > On Wed, Jul 08, 2015 at 11:17:38AM -0400, Mikulas Patocka wrote: > > Hi > > > > I found out that the patch a66734297f78707ce39d756b656bfae861d53f62 breaks > > the kernel on processors without performance counters, such as AMD K6-3. > > Out of curi

Re: Kernel broken on processors without performance counters

2015-07-14 Thread Borislav Petkov
On Wed, Jul 08, 2015 at 11:17:38AM -0400, Mikulas Patocka wrote: > Hi > > I found out that the patch a66734297f78707ce39d756b656bfae861d53f62 breaks > the kernel on processors without performance counters, such as AMD K6-3. Out of curiosity: are you actually using this piece of computer history

Re: Kernel broken on processors without performance counters

2015-07-10 Thread Jason Baron
On 07/10/2015 10:13 AM, Peter Zijlstra wrote: > On Wed, Jul 08, 2015 at 05:36:43PM -0700, Andy Lutomirski wrote: In what universe is "static_key_false" a reasonable name for a function that returns true if a static key is true? >> I think the current naming is almost maximally bad. The n

Re: Kernel broken on processors without performance counters

2015-07-10 Thread Peter Zijlstra
On Wed, Jul 08, 2015 at 05:36:43PM -0700, Andy Lutomirski wrote: > >> In what universe is "static_key_false" a reasonable name for a > >> function that returns true if a static key is true? > I think the current naming is almost maximally bad. The naming would > be less critical if it were typesa

Re: Kernel broken on processors without performance counters

2015-07-09 Thread Jason Baron
On 07/09/2015 01:11 PM, Peter Zijlstra wrote: > On Wed, Jul 08, 2015 at 04:04:32PM -0400, Jason Baron wrote: >> So the 'static_key_false' is really branch is initially false. We had >> a naming discussion before, but if ppl think its confusing, >> 'static_key_init_false', or 'static_key_default_fal

Re: Kernel broken on processors without performance counters

2015-07-09 Thread Peter Zijlstra
On Wed, Jul 08, 2015 at 04:04:32PM -0400, Jason Baron wrote: > So the 'static_key_false' is really branch is initially false. We had > a naming discussion before, but if ppl think its confusing, > 'static_key_init_false', or 'static_key_default_false' might be better, > or other ideas I agree i

Re: Kernel broken on processors without performance counters

2015-07-08 Thread Andy Lutomirski
On Wed, Jul 8, 2015 at 1:04 PM, Jason Baron wrote: > On 07/08/2015 01:37 PM, Andy Lutomirski wrote: >> On Wed, Jul 8, 2015 at 9:07 AM, Peter Zijlstra wrote: >>> On Wed, Jul 08, 2015 at 11:17:38AM -0400, Mikulas Patocka wrote: Hi I found out that the patch a66734297f78707ce39d756b65

Re: Kernel broken on processors without performance counters

2015-07-08 Thread Jason Baron
On 07/08/2015 01:37 PM, Andy Lutomirski wrote: > On Wed, Jul 8, 2015 at 9:07 AM, Peter Zijlstra wrote: >> On Wed, Jul 08, 2015 at 11:17:38AM -0400, Mikulas Patocka wrote: >>> Hi >>> >>> I found out that the patch a66734297f78707ce39d756b656bfae861d53f62 breaks >>> the kernel on processors without

Re: Kernel broken on processors without performance counters

2015-07-08 Thread Andy Lutomirski
On Wed, Jul 8, 2015 at 9:07 AM, Peter Zijlstra wrote: > On Wed, Jul 08, 2015 at 11:17:38AM -0400, Mikulas Patocka wrote: >> Hi >> >> I found out that the patch a66734297f78707ce39d756b656bfae861d53f62 breaks >> the kernel on processors without performance counters, such as AMD K6-3. >> Reverting t

Re: Kernel broken on processors without performance counters

2015-07-08 Thread Mikulas Patocka
On Wed, 8 Jul 2015, Peter Zijlstra wrote: > On Wed, Jul 08, 2015 at 11:17:38AM -0400, Mikulas Patocka wrote: > > Hi > > > > I found out that the patch a66734297f78707ce39d756b656bfae861d53f62 breaks > > the kernel on processors without performance counters, such as AMD K6-3. > > Reverting the

Re: Kernel broken on processors without performance counters

2015-07-08 Thread Peter Zijlstra
On Wed, Jul 08, 2015 at 11:17:38AM -0400, Mikulas Patocka wrote: > Hi > > I found out that the patch a66734297f78707ce39d756b656bfae861d53f62 breaks > the kernel on processors without performance counters, such as AMD K6-3. > Reverting the patch fixes the problem. > > The static key rdpmc_alway