From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751806AbdHXIMO (ORCPT ); Thu, 24 Aug 2017 04:12:14 -0400 Received: from LGEAMRELO13.lge.com ([156.147.23.53]:54200 "EHLO lgeamrelo13.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751250AbdHXILF (ORCPT ); Thu, 24 Aug 2017 04:11:05 -0400 X-Original-SENDERIP: 156.147.1.126 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 10.177.222.33 X-Original-MAILFROM: byungchul.park@lge.com Date: Thu, 24 Aug 2017 17:11:01 +0900 From: Byungchul Park To: Peter Zijlstra Cc: Oleg Nesterov , mingo@kernel.org, linux-kernel@vger.kernel.org, kernel-team@lge.com, Arnaldo Carvalho de Melo , Dave Chinner , Tejun Heo , johannes@sipsolutions.net Subject: Re: [PATCH v3 1/3] lockdep: Make LOCKDEP_CROSSRELEASE configs all part of PROVE_LOCKING Message-ID: <20170824081101.GI6772@X58A-UD3R> References: <20170822085100.GH20323@X58A-UD3R> <20170822092141.fjmr74xhfid7vu7h@hirez.programming.kicks-ass.net> <20170822093337.GJ20323@X58A-UD3R> <20170822100840.eababgjcu76iois5@hirez.programming.kicks-ass.net> <20170822134922.m2g6kqsqo2eojrg7@hirez.programming.kicks-ass.net> <20170822144602.uh5jzkkchvdgzs3s@hirez.programming.kicks-ass.net> <20170823163903.GA12973@redhat.com> <20170823174714.in4mv7uc3rdheygg@hirez.programming.kicks-ass.net> <20170824061153.GF6772@X58A-UD3R> <20170824073713.GH6772@X58A-UD3R> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170824073713.GH6772@X58A-UD3R> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 24, 2017 at 04:37:13PM +0900, Byungchul Park wrote: > On Thu, Aug 24, 2017 at 03:11:53PM +0900, Byungchul Park wrote: > > On Wed, Aug 23, 2017 at 07:47:14PM +0200, Peter Zijlstra wrote: > > > Those are fine and are indeed the flush_work() vs work inversion. > > > > > > The two straight forward annotations are: > > > > > > flush_work(work) process_one_work(wq, work) > > > A(work) A(work) > > > R(work) work->func(work); > > > R(work) > > > > > > Which catches: > > > > > > Task-1: work: > > > > > > mutex_lock(&A); mutex_lock(&A); > > > flush_work(work); > > > > I'm not sure but, with LOCKDEP_COMPLETE enabled, this issue would > > automatically be covered w/o additional A(work)/R(work). Right? > > > > A(work)/R(work) seem to be used for preventing wait_for_completion() > > in flush_work() from waiting for the completion forever because of the > > work using mutex_lock(&A). Am I understanding correctly? > > > > If yes, we can use just LOCKDEP_COMPLETE for that purpose. > > I'm not familiar with workqueue but, the manual lockdep_map_acquire() in > workqueue code seems to be introduced to do what LOCKDEP_COMPLETE does > for wait_for_completion() and complete(). > > Wrong? As I understand how workqueue code works more, thanks to Peterz, I get convinced. What they want to detect with acquire(w/wq) is a deadlock caused by wait_for_completion() mixed with typical locks. We have to detect it with _variables_ which it actually waits for, i.e. completion variable, neither _work_ nor _workqueue_ which we are currently using.