On Mon, 13 Nov 2017, Dey, Megha wrote: > >-----Original Message----- > >From: Peter Zijlstra [mailto:peterz@xxxxxxxxxxxxx] > >Sent: Monday, November 13, 2017 1:00 AM > >To: Megha Dey <megha.dey@xxxxxxxxxxxxxxx> > >Cc: x86@xxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; linux- Please fix your mail client so it does not add this complete useless information to the reply. > >On Sat, Nov 11, 2017 at 01:20:05PM -0800, Megha Dey wrote: > >> +/* > >> + * Unmask the NMI bit of the local APIC the first time task is > >> +scheduled > >> + * on a particular CPU. > >> + */ > >> +static void intel_bm_unmask_nmi(void) { > >> + this_cpu_write(bm_unmask_apic, 0); > >> + > >> + if (!(this_cpu_read(bm_unmask_apic))) { > >> + apic_write(APIC_LVTPC, APIC_DM_NMI); > >> + this_cpu_inc(bm_unmask_apic); > >> + } > >> +} > > > >What? Why? > > Normally, other drivers using perf create an event on every CPU (thereby > calling perf_init on every CPU), where this bit(APIC_DM_NMI)is explicitly > unmasked. In our driver, we do not do this (since we are worried only > about a particular task) and hence this bit is only disabled on the local > APIC where the perf event is initialized. > > As such, if the task is scheduled out to some other CPU, this bit is set > and hence would stop the interrupt from reaching the processing core. Still that code makes no sense at all and certainly does not do what you claim it does: > >> + this_cpu_write(bm_unmask_apic, 0); > >> + > >> + if (!(this_cpu_read(bm_unmask_apic))) { So first you write the per cpu variable to 0 and then you check whether it is zero, which is pointless obviously. > > > >> +static int intel_bm_event_add(struct perf_event *event, int mode) { Please move the opening bracket of the function into the next line. See the kernel coding style documentation. Thanks, tglx -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html