Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2458398pxb; Thu, 11 Feb 2021 12:55:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1r2Aitrrjn4P6euEhnH0Mob9hk3c7BVmOUH3zWOT4z22P5+ZBMLDF4xuNX2HNWBsfhfj/ X-Received: by 2002:a50:d90a:: with SMTP id t10mr3590edj.162.1613076933289; Thu, 11 Feb 2021 12:55:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613076933; cv=none; d=google.com; s=arc-20160816; b=jjkrMesT3bUTiP3xHrXE2BuYwyJsZmFVfuA1441Xc2IOcWLJ4jkLdfAddYUnCakHfF 1FGF4lpze/3uLfqIQjk1P6/Qas4+6TjsRTi5SIhN4ygIm69kAeWbnuyigqUPB5pdqJ+j ha8a4wpsezkpFBHVyzWZMB2hNJ6GItCTV0GUQOL2EO5wKUi6C6VTRIjMZNa81oayVJtJ x19D6vM2t7tKicuFbedCoISkEGflqFxhfdtIGHYjzz7veoR7Kipy6b6ojmNy6v2U2LP+ xTV7aFHpl+WUN0SMg99cR/EgiBJLzat2zGeOoLg4HjdHQhD1D5kQc8Oqlbc/gN+Z5o0N //ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=Z6ZG5Dmpcr3dphEuMXhR4ohnjOhh91pyYZOXK8YBBQ8=; b=0dw2+gwa+mFhhC3AhJUmCxmZ7Vtu6zql2D2ygAg9JAbmgRlQAuAB3aT2r/5spC1TV7 cNePNbzB5uVzYGuCZQmwTYjP4PB3NrKgSY0ZS4AaCKgQF1QVtCEf5O5nxIBjrFbCviUv 5ZpzIh0R2YjBTa5XPZ7TqVMh2zm7NQMDPfN/qp6e5l4F+bwzcNIYDPdnLTXCcHGvDuYF yrez+XtAhdl4lF2zlnq6NEiWFH0NWKaM5ZFsLoJ8y37ABbnpAYUvsLpWLeB43fIDvRX1 zpjUUxcIqYC3qeCX/6O3BK0y6EnH4vqkTk1W2J43kIilQ77Gy9MtPWwZ2Ow/ncHmCwVE T5Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=SwQEk23n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ak11si4708958ejc.352.2021.02.11.12.55.01; Thu, 11 Feb 2021 12:55:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=SwQEk23n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229768AbhBKUye (ORCPT + 99 others); Thu, 11 Feb 2021 15:54:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbhBKUyd (ORCPT ); Thu, 11 Feb 2021 15:54:33 -0500 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D99DC0613D6 for ; Thu, 11 Feb 2021 12:53:53 -0800 (PST) Received: by mail-io1-xd32.google.com with SMTP id e24so7172212ioc.1 for ; Thu, 11 Feb 2021 12:53:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Z6ZG5Dmpcr3dphEuMXhR4ohnjOhh91pyYZOXK8YBBQ8=; b=SwQEk23nQu49/7zGvXpYbPxTTfQhd6o7wAYudESH1lMiZQYROCK9GrzJrOl2Bh84Zl o/RJiF9S+Nv6YIJsJs9mHanLZCn57L0+7WYavg7+z7foM6R7Jd//qEu+5oJIcCnPjXOf xktxquW2pcwEdLVdDtL00ytKmXKh1pNsWBuGs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Z6ZG5Dmpcr3dphEuMXhR4ohnjOhh91pyYZOXK8YBBQ8=; b=T5ts2aiYZtrDlxGtcHRLfK4dkQOOWHP/gGqprvjLUrrhpwL8JPMz75o+rRxXj3cItj pr1BpzJMfHwEfv4pdscp7NZExrGob/lDNWb4dyAWRtJfRVc75wNCop1q5p8tLumHVr4u Fzbpo4+iMRJt6LA7TjyiA2eMRaTE7fcPwy9GGHCpUIM+zEtUM7JC1f9dvs7xEaGsbBQU opjdgNqhtZ9IAw09YpyUL2PlVlSAXkvCr24RGCNraONVX/dPLLytGz0chtL1GJMFnNz6 HEwx/du+UBwgp2TWX0gTQUngnZObq3xB5FmWdtgVZbXxEzC4ryNOsNARfPRuRZcAVhoq Lm8A== X-Gm-Message-State: AOAM531Qyjwu65VHSECLNv6l9Psl9JTJxyHSbWn9KkVcgbJFTWvbEeyK bw+TAoyL2IEI/v4fdeoxLC2rGA== X-Received: by 2002:a5d:9586:: with SMTP id a6mr7220881ioo.83.1613076832081; Thu, 11 Feb 2021 12:53:52 -0800 (PST) Received: from [192.168.1.112] (c-24-9-64-241.hsd1.co.comcast.net. [24.9.64.241]) by smtp.gmail.com with ESMTPSA id h13sm3006905ioe.40.2021.02.11.12.53.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Feb 2021 12:53:51 -0800 (PST) Subject: Re: [PATCH 4/5] ath10k: detect conf_mutex held ath10k_drain_tx() calls To: Kalle Valo Cc: netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, ath10k@lists.infradead.org, kuba@kernel.org, davem@davemloft.net, Shuah Khan References: <87lfbwtjls.fsf@codeaurora.org> <871rdmu9z9.fsf@codeaurora.org> From: Shuah Khan Message-ID: Date: Thu, 11 Feb 2021 13:53:50 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <871rdmu9z9.fsf@codeaurora.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/11/21 4:20 AM, Kalle Valo wrote: > Shuah Khan writes: > >> On 2/10/21 1:25 AM, Kalle Valo wrote: >>> Shuah Khan writes: >>> >>>> ath10k_drain_tx() must not be called with conf_mutex held as workers can >>>> use that also. Add check to detect conf_mutex held calls. >>>> >>>> Signed-off-by: Shuah Khan >>> >>> The commit log does not answer to "Why?". How did you find this? What >>> actual problem are you trying to solve? >>> >> >> I came across the comment block above the ath10k_drain_tx() as I was >> reviewing at conf_mutex holds while I was debugging the conf_mutex >> lock assert in ath10k_debug_fw_stats_request(). >> >> My reasoning is that having this will help detect incorrect usages >> of ath10k_drain_tx() while holding conf_mutex which could lead to >> locking problems when async worker routines try to call this routine. > > Ok, makes sense. I prefer having this background info in the commit log, > for example "found by code review" or something like that. Or just copy > what you wrote above :) > Thanks. I will do that. >>>> --- a/drivers/net/wireless/ath/ath10k/mac.c >>>> +++ b/drivers/net/wireless/ath/ath10k/mac.c >>>> @@ -4566,6 +4566,7 @@ static void >>>> ath10k_mac_op_wake_tx_queue(struct ieee80211_hw *hw, >>>> /* Must not be called with conf_mutex held as workers can use that also. */ >>>> void ath10k_drain_tx(struct ath10k *ar) >>>> { >>>> + WARN_ON(lockdep_is_held(&ar->conf_mutex)); >>> >>> Empty line after WARN_ON(). >>> >> >> Will do. >> >>> Shouldn't this check debug_locks similarly lockdep_assert_held() does? >>> >>> #define lockdep_assert_held(l) do { \ >>> WARN_ON(debug_locks && !lockdep_is_held(l)); \ >>> } while (0) >>> >>> And I suspect you need #ifdef CONFIG_LOCKDEP which should fix the kbuild >>> bot error. >>> >> >> Yes. >> >>> But honestly I would prefer to have lockdep_assert_not_held() in >>> include/linux/lockdep.h, much cleaner that way. Also >>> i915_gem_object_lookup_rcu() could then use the same macro. >>> >> >> Right. This is the right way to go. That was first instinct and >> decided to have the discussion evolve in that direction. Now that >> it has, I will combine this change with >> include/linux/lockdep.h and add lockdep_assert_not_held() >> >> I think we might have other places in the kernel that could use >> lockdep_assert_not_held() in addition to i915_gem_object_lookup_rcu() > I looked at i915_gem_object_lookup_rcu(). The following can be replaced by lockdep_assert_held(). #ifdef CONFIG_LOCKDEP WARN_ON(debug_locks && !lock_is_held(&rcu_lock_map)); #endif > Great, thank you. The only problem is that lockdep.h changes have to go > via some other tree, I just don't know which :) I think it would be > easiest if also the ath10k patch goes via that other tree, I can ack the > ath10k changes. > > Another option is that I'll apply the ath10k patch after the lockdep.h > change has trickled down to my tree, but that usually happens only after > the merge window and means weeks of waiting. Either is fine for me. > I will send the include/linux/lockdep.h and ath10k patch together and we will take it from there. thanks, -- Shuah