Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756713AbdCXIeD (ORCPT ); Fri, 24 Mar 2017 04:34:03 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:36404 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754167AbdCXIbp (ORCPT ); Fri, 24 Mar 2017 04:31:45 -0400 Date: Fri, 24 Mar 2017 09:31:25 +0100 (CET) From: Thomas Gleixner To: Peter Zijlstra cc: kan.liang@intel.com, 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 In-Reply-To: <20170323203255.kps67homffxhl3cv@hirez.programming.kicks-ass.net> Message-ID: 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> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 712 Lines: 23 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. Thanks, tglx