From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752988AbbF2I44 (ORCPT ); Mon, 29 Jun 2015 04:56:56 -0400 Received: from casper.infradead.org ([85.118.1.10]:39871 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752547AbbF2I4u (ORCPT ); Mon, 29 Jun 2015 04:56:50 -0400 Date: Mon, 29 Jun 2015 10:56:46 +0200 From: Peter Zijlstra To: Oleg Nesterov Cc: paulmck@linux.vnet.ibm.com, tj@kernel.org, mingo@redhat.com, der.herr@hofr.at, dave@stgolabs.net, riel@redhat.com, viro@ZenIV.linux.org.uk, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 6/6] stop_machine: optimize stop_work_alloc() Message-ID: <20150629085646.GC3644@twins.programming.kicks-ass.net> References: <20150626021455.GA5675@redhat.com> <20150626021526.GA5717@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150626021526.GA5717@redhat.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 26, 2015 at 04:15:26AM +0200, Oleg Nesterov wrote: > wait_event()/wake_up_all() in stop_work_alloc/stop_work_free logic > is very suboptimal because of non-exclusive wakeups. So we add the > wait_queue_func_t alloc_wake() helper which wakes the waiter up only > a) if it actually waits for a stop_work in the "freed" cpumask, and > b) only after we already set ->stop_owner = waiter. > > So if 2 stop_machine()'s race with each other, the loser will likely > call schedule() only once and we will have a single wakeup. So I think I can beat lockdep into submission (ugly but still) do we want to use an actual per-cpu mutex instead?