From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FD30C00140 for ; Fri, 29 Jul 2022 02:29:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233744AbiG2C3A (ORCPT ); Thu, 28 Jul 2022 22:29:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233686AbiG2C25 (ORCPT ); Thu, 28 Jul 2022 22:28:57 -0400 Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1C707AC16 for ; Thu, 28 Jul 2022 19:28:55 -0700 (PDT) Received: from fsav315.sakura.ne.jp (fsav315.sakura.ne.jp [153.120.85.146]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 26T2SfTE079144; Fri, 29 Jul 2022 11:28:41 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav315.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav315.sakura.ne.jp); Fri, 29 Jul 2022 11:28:41 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav315.sakura.ne.jp) Received: from [192.168.1.9] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 26T2SebN079141 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Fri, 29 Jul 2022 11:28:40 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Message-ID: Date: Fri, 29 Jul 2022 11:28:40 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] workqueue: don't skip lockdep wq dependency in cancel_work_sync() Content-Language: en-US From: Tetsuo Handa To: Johannes Berg Cc: Lai Jiangshan , Hillf Danton , LKML , Tejun Heo References: <21b9c1ac-64b7-7f4b-1e62-bf2f021fffcd@I-love.SAKURA.ne.jp> <0ad532b2-df5f-331a-ae7f-21460fc62fe2@I-love.SAKURA.ne.jp> <97cbf8a9-d5e1-376f-6a49-3474871ea6b4@I-love.SAKURA.ne.jp> In-Reply-To: <97cbf8a9-d5e1-376f-6a49-3474871ea6b4@I-love.SAKURA.ne.jp> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thinking more, I might be confused by difference between the lockdep "struct work_struct" dependency handling and the lockdep "struct work" dependency handling . In an example that work3_function() { /* nothing */ } work4_function() { mutex_lock(&mutex); ... } other_function() { queue_work(ordered_wq, &work3); queue_work(ordered_wq, &work4); mutex_lock(&mutex); cancel_work_sync(&work4); } , possibility of deadlock must be reported by lockdep via the lockdep "struct work" dependency handling. Then, prior to commit d6e89786bed977f3, lockdep flagging the lockdep "struct work_struct" dependency handling as if cancel_work_sync() was flush_work() is a problem, and lockdep not flagging the lockdep "struct work" dependency handling from cancel_work_sync() as if flush_work() is also a problem. Then, commit d6e89786bed977f3 might be OK, but commit 87915adc3f0acdf0 was wrong in that it preserved lockdep not flagging the lockdep "struct work" dependency handling from cancel_work_sync() as if flush_work().