From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753266AbbKWVxo (ORCPT ); Mon, 23 Nov 2015 16:53:44 -0500 Received: from mail-yk0-f180.google.com ([209.85.160.180]:36530 "EHLO mail-yk0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751093AbbKWVxn (ORCPT ); Mon, 23 Nov 2015 16:53:43 -0500 Date: Mon, 23 Nov 2015 16:53:39 -0500 From: Tejun Heo To: Oleg Nesterov Cc: Ingo Molnar , Peter Zijlstra , Rik van Riel , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/1] stop_machine: Remove stop_cpus_lock and lg_double_lock/unlock() Message-ID: <20151123215339.GF19072@mtj.duckdns.org> References: <20151121181129.GA425@redhat.com> <20151121181148.GA433@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151121181148.GA433@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Oleg. On Sat, Nov 21, 2015 at 07:11:48PM +0100, Oleg Nesterov wrote: > stop_two_cpus() and stop_cpus() use stop_cpus_lock to avoid the deadlock, > we need to ensure that the stopper functions can't be queued "backwards" > from one another. This doesn't look nice; if we use lglock then we do not > really need stopper->lock, cpu_stop_queue_work() could use lg_local_lock() > under local_irq_save(). Yeah, removing stopper->lock would be nice. > OTOH it would be even better to avoid lglock in stop_machine.c and remove > lg_double_lock(). This patch adds "bool stop_cpus_in_progress" set/cleared > by queue_stop_cpus_work(), and changes cpu_stop_queue_two_works() to busy > wait until it is cleared. > > queue_stop_cpus_work() sets stop_cpus_in_progress = T lockless, but after > it queues a work on CPU1 it must be visible to stop_two_cpus(CPU1, CPU2) > which checks it under the same lock. And since stop_two_cpus() holds the > 2nd lock too, queue_stop_cpus_work() can not clear stop_cpus_in_progress > if it is also going to queue a work on CPU2, it needs to take that 2nd > lock to do this. Isn't this a lot more subtler than the other direction? Unless there's a clear performance advantage to removing stopper->lock, using lglock for both stop_two and stop_machine seems like an easier-to-follow approach to me. Thanks. -- tejun