From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932308AbcIHSWY (ORCPT ); Thu, 8 Sep 2016 14:22:24 -0400 Received: from merlin.infradead.org ([205.233.59.134]:35696 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758241AbcIHSWU (ORCPT ); Thu, 8 Sep 2016 14:22:20 -0400 Date: Thu, 8 Sep 2016 20:22:15 +0200 From: Peter Zijlstra To: Tim Chen Cc: Srinivas Pandruvada , rjw@rjwysocki.net, tglx@linutronix.de, mingo@redhat.com, bp@suse.de, x86@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org Subject: Re: [PATCH v2 5/8] sched,x86: Enable Turbo Boost Max Technology Message-ID: <20160908182215.GA10153@twins.programming.kicks-ass.net> References: <1472762024-88771-1-git-send-email-srinivas.pandruvada@linux.intel.com> <1472762024-88771-6-git-send-email-srinivas.pandruvada@linux.intel.com> <20160908075955.GS10153@twins.programming.kicks-ass.net> <20160908180928.GB23509@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160908180928.GB23509@linux.intel.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 08, 2016 at 11:09:28AM -0700, Tim Chen wrote: > On Thu, Sep 08, 2016 at 09:59:55AM +0200, Peter Zijlstra wrote: > > I think there's a race here, if two tasks were to write to the sysctl > > they'd both change the value before getting stuck on the mutex in > > enable_sched_itmt(). > > > > One way around that is doing something like: > > > > > > struct ctl_table t; > > int val = sysctl_sched_itmt_enabled; > > > > t = *table; > > t.data = &val; > > > > proc_dointvec_minmax(&t, ...); > > > > /* and update the sysctl_sched_itmt_enabled value inside the mutex */ > > enable_sched_itmi(val); > > Peter, > > Since enable_sched_itmt is only used by sched_itmt_update_handler, > I've moved the mutex locking to sched_itmt_update_handler to eliminate > the race condition in the code path you mentioned. That is indeed simpler. Thanks!