Received: by 10.223.164.202 with SMTP id h10csp80003wrb; Mon, 13 Nov 2017 13:59:54 -0800 (PST) X-Google-Smtp-Source: AGs4zMYVO0yNHZWZFWkQ+sc/1oB1HGRw7LnWW1lEcdiXIHoLs+MGoCmgSS3mx3dvMJ6JVVsL6jDK X-Received: by 10.99.106.137 with SMTP id f131mr10110420pgc.334.1510610394256; Mon, 13 Nov 2017 13:59:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510610394; cv=none; d=google.com; s=arc-20160816; b=lGin6XgBgb+1BUprKq+NEuloOu7+XjzkxiLiSIu0GJ7J7aAkqZDkHAeHiuPBEpcAh1 oyQt7OrNBDlxiYLH1scXI9mpc3vZyirgqYbe5m7aN84EOVOJxWXuBqu1mmeHwLVvg0XZ unQ8PCFM9y9Hi1EyCWoWc++rSV9b8t3HJdTnMOJuHT7dRQvbeZHvnhzRG19e6P2ah4wC 6COrwCRn1fmA9noha5OKo/tS0zHtoFsWMp6muXpXFxwbDrdvJJFzddVVcuH2KfPJfZCK ZnoDCr0LPUerRY/P0AGVPIisyKQO/pldkeiBuiVSZ9Dg2kuMpnAODnwNvpJMsoTgcHQH KRXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=9QCqS9JGhi0/WClT5mxi3wB1wVXgmkZIbiJDJAvtPJE=; b=n113WcMvnUF5nlLTUYmxhA/D3qZGwUCpuWnnSQEOzk8uCSlZoVFChk2i4U8/vpwA6Z HOJd+kBqQkC1MXWFJ48BDJTTwUWmt8xPZuITy5i198V0184PQsFVg2kUr2+3Hx8fOCAQ qCwqj6aTGghzMbCNHGg4kynh4qMM0oNPfZfi2KGe2Y/cROirAErrdagQk94ODgJg20h/ aWPfAdWcOMdRp67l1ZrkgBifu6Apy074C20nY43DL8ZuPdZgqwmIh3LVmX51Sg2XEKz1 DpEdFw2i2/SHBUmEOLYU0KxY11tm3FoOTi/dPETQLVUF0rsUzaUcVzR7eCP4xccaw4kp kv3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c2si14835164plb.787.2017.11.13.13.59.42; Mon, 13 Nov 2017 13:59:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753128AbdKMV6u (ORCPT + 88 others); Mon, 13 Nov 2017 16:58:50 -0500 Received: from mga07.intel.com ([134.134.136.100]:30396 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753086AbdKMV6s (ORCPT ); Mon, 13 Nov 2017 16:58:48 -0500 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Nov 2017 13:58:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,389,1505804400"; d="scan'208";a="1873948" Received: from megha-z97x-ud7-th.sc.intel.com (HELO [143.183.85.162]) ([143.183.85.162]) by orsmga003.jf.intel.com with ESMTP; 13 Nov 2017 13:58:46 -0800 Message-ID: <1510611246.2515.8.camel@megha-Z97X-UD7-TH> Subject: Re: [PATCH V1 2/3] perf/x86/intel/bm.c: Add Intel Branch Monitoring support From: Megha Dey To: Thomas Gleixner Cc: Peter Zijlstra , "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-doc@vger.kernel.org" , "mingo@redhat.com" , "hpa@zytor.com" , "andriy.shevchenko@linux.intel.com" , "kstewart@linuxfoundation.org" , "Yu, Yu-cheng" , "Brown, Len" , "gregkh@linuxfoundation.org" , "acme@kernel.org" , "alexander.shishkin@linux.intel.com" , "jolsa@redhat.com" , "namhyung@kernel.org" , "vikas.shivappa@linux.intel.com" , "pombredanne@nexb.com" , "me@kylehuey.com" , "bp@suse.de" , "Andrejczuk, Grzegorz" , "Luck, Tony" , "corbet@lwn.net" , "Shankar, Ravi V" Date: Mon, 13 Nov 2017 14:14:06 -0800 In-Reply-To: References: <1510435206-16110-1-git-send-email-megha.dey@linux.intel.com> <1510435206-16110-3-git-send-email-megha.dey@linux.intel.com> <20171113090016.o2l6356ktkgan7ch@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2017-11-13 at 21:25 +0100, Thomas Gleixner wrote: > On Mon, 13 Nov 2017, Dey, Megha wrote: > > >-----Original Message----- > > >From: Peter Zijlstra [mailto:peterz@infradead.org] > > >Sent: Monday, November 13, 2017 1:00 AM > > >To: Megha Dey > > >Cc: x86@kernel.org; linux-kernel@vger.kernel.org; linux- > > Please fix your mail client so it does not add this complete useless > information to the reply. Will fix this. > > > >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. yes, I see your point. The logic is flawed. Will fix this. > > > > > > >> +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. Will do. > > Thanks, > > tglx From 1583983932995730171@xxx Mon Nov 13 20:26:34 +0000 2017 X-GM-THRID: 1583805290382379451 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread