Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936250AbdCXOXp (ORCPT ); Fri, 24 Mar 2017 10:23:45 -0400 Received: from merlin.infradead.org ([205.233.59.134]:56326 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935938AbdCXOXg (ORCPT ); Fri, 24 Mar 2017 10:23:36 -0400 Date: Fri, 24 Mar 2017 15:23:29 +0100 From: Peter Zijlstra To: "Liang, Kan" Cc: Thomas Gleixner , "mingo@redhat.com" , "acme@kernel.org" , "linux-kernel@vger.kernel.org" , "eranian@google.com" , "jolsa@kernel.org" , "ak@linux.intel.com" Subject: Re: [PATCH 1/3] perf/x86: add sysfs entry to freeze counter on SMI Message-ID: <20170324142329.lclrwpy5kuo4ekua@hirez.programming.kicks-ass.net> References: <1490293551-5552-1-git-send-email-kan.liang@intel.com> <1490293551-5552-2-git-send-email-kan.liang@intel.com> <20170323203255.kps67homffxhl3cv@hirez.programming.kicks-ass.net> <37D7C6CF3E00A74B8858931C1DB2F077536C3CCB@SHSMSX103.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <37D7C6CF3E00A74B8858931C1DB2F077536C3CCB@SHSMSX103.ccr.corp.intel.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1029 Lines: 28 On Fri, Mar 24, 2017 at 02:15:16PM +0000, Liang, Kan wrote: > > > > On Thu, 23 Mar 2017, Peter Zijlstra wrote: > > > On Thu, Mar 23, 2017 at 11:25:49AM -0700, kan.liang@intel.com wrote: > > > > + for_each_possible_cpu(cpu) { > > > > + rdmsrl_on_cpu(cpu, MSR_IA32_DEBUGCTLMSR, > > &debugctlmsr); > > > > + if (val) > > > > + wrmsrl_on_cpu(cpu, MSR_IA32_DEBUGCTLMSR, > > debugctlmsr | DEBUGCTLMSR_FREEZE_WHILE_SMM); > > > > + else > > > > + wrmsrl_on_cpu(cpu, MSR_IA32_DEBUGCTLMSR, > > debugctlmsr & ~DEBUGCTLMSR_FREEZE_WHILE_SMM); > > > > + } > > > > > > No; that's just disgusting. Also {rd,wr}msr_on_cpu() should die, > > > exactly because people end up writing crap like this. > > > > Aside of that this is completely broken against other users of > > DEBUGCTLMSR because it's not atomic vs. the other modifications. > > > > OK. I will change it. > I guess I need a way/function which can atomically rd,wr msr on all cpus. > Are there existing alternative ways/functions to do that? No; also don't forget hotplug.