Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1094934pxb; Wed, 13 Apr 2022 20:48:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmNjc8cD30umndDjeM4eMTSjTBG8VLQWthil5EelcUtwzZV7wYcFwRklr3p59CLDKOeaAl X-Received: by 2002:a17:90b:4a0f:b0:1cb:b800:b109 with SMTP id kk15-20020a17090b4a0f00b001cbb800b109mr1509592pjb.51.1649908134747; Wed, 13 Apr 2022 20:48:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649908134; cv=none; d=google.com; s=arc-20160816; b=F+bjtLcClILNEKMoOWgBNedh6DWbijmdobgW3oyZmjZfbMW5Hlh6vfA6LE7cT1QfFp qkWb5b4iXgozA79orp5QS9ladJRiuav3CTuibJrn4CvYmNj2eJiSIfl+cL6N2Cf9jAMS dGQ8Eb8ZhP1waUavGZdt2aVVCF9cfZ3ffR8qFdAZfbskOQDtI0Q8sk5CrxvxfCddTNag YbxMPJVPhtkqVfEXrkCPfbwOeOy1lCXIHHD3qk4SGTQD0OLKMBIo7E4lZa+sO7yz1cTX bdU7i6FRdOpajwEs/cIJoZzU82+JYjhZjXCh+U2bnnebncYgaKDzwpDLraIVxY+Leyw8 NtPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=tAfD3NhN7fayTDj+zqA64IJMnx8ZxzqbVRBoMThFMGA=; b=z6OjVfnrDKkvs2oL8wo3WQ4VEX0rj1I/pJ1ffJ9dwJIhuK7jUE7JroPXJTEZXLbCnv HeaXXGSQtgGf+I3TmyDdE3+84nRnsCzmZC8IiBAZkcoc2HfQUfXdQBnaNfMkqQ2jA0Vy n3ZWjzPireDLmKslMjtzI3sKpLtKtT/5JyMCUXyFMRbGkkSfJR2w66M9syfZRlkOMXBa jEAJsknfjcshChOpQ7Yoaiy+nj3n2aNDUrqel787MfpzpFYf0B0PgpZKvPS/NiztOzWX MfWtackfUHeHpfgLhuZ7BuZdCybqwoccmiNT/yc7dAvqf2kmDq94QvBgFxekaOwhilzq NlCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DpXmLyET; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 66-20020a630145000000b003816043f0f8si6809759pgb.749.2022.04.13.20.48.40; Wed, 13 Apr 2022 20:48:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DpXmLyET; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232972AbiDMOFK (ORCPT + 99 others); Wed, 13 Apr 2022 10:05:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231764AbiDMOFI (ORCPT ); Wed, 13 Apr 2022 10:05:08 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 97D4D58813 for ; Wed, 13 Apr 2022 07:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649858566; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tAfD3NhN7fayTDj+zqA64IJMnx8ZxzqbVRBoMThFMGA=; b=DpXmLyETWnY+UTtNVFfLoDQsbCtlVDvmXpz7H/kcYaiRwRjJ9Ea3VLmbhfnHp/Y8VS13W6 IndVnyRCksUN7h7EQIMG3T+xDD4Jb6do5FXlxu1Z1nJ6LAVjNgwun5xpjY+KvgWbBbWvnv qcDScLvmEAZouIRU85eox+y9+OaHULI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-636-xzrjdR4XMWORsqlOI_ibHw-1; Wed, 13 Apr 2022 10:02:44 -0400 X-MC-Unique: xzrjdR4XMWORsqlOI_ibHw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D49A129DD987; Wed, 13 Apr 2022 14:02:35 +0000 (UTC) Received: from [10.18.17.215] (dhcp-17-215.bos.redhat.com [10.18.17.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 569B4C28109; Wed, 13 Apr 2022 14:02:35 +0000 (UTC) Message-ID: <06ed6ba2-00c4-ab38-4fcf-611133865615@redhat.com> Date: Wed, 13 Apr 2022 10:02:35 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v2 00/12] device-core: Enable device_lock() lockdep validation Content-Language: en-US To: Dan Williams , linux-cxl@vger.kernel.org Cc: Ira Weiny , Dave Jiang , Peter Zijlstra , Jonathan Cameron , Vishal Verma , Ben Widawsky , Kevin Tian , Pierre-Louis Bossart , Alison Schofield , Boqun Feng , Ingo Molnar , Greg Kroah-Hartman , Will Deacon , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev References: <164982968798.684294.15817853329823976469.stgit@dwillia2-desk3.amr.corp.intel.com> From: Waiman Long In-Reply-To: <164982968798.684294.15817853329823976469.stgit@dwillia2-desk3.amr.corp.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/13/22 02:01, Dan Williams wrote: > Changes since v1 [1]: > - Improve the clarity of the cover letter and changelogs of the > major patches (Patch2 and Patch12) (Pierre, Kevin, and Dave) > - Fix device_lock_interruptible() false negative deadlock detection > (Kevin) > - Fix off-by-one error in the device_set_lock_class() enable case (Kevin) > - Spelling fixes in Patch2 changelog (Pierre) > - Compilation fixes when both CONFIG_CXL_BUS=n and > CONFIG_LIBNVDIMM=n. (0day robot) > > [1]: https://lore.kernel.org/all/164610292916.2682974.12924748003366352335.stgit@dwillia2-desk3.amr.corp.intel.com/ > > --- > > The device_lock() is why the lockdep_set_novalidate_class() API exists. > The lock is taken in too many disparate contexts, and lockdep by design > assumes that all device_lock() acquisitions are identical. The lack of > lockdep coverage leads to deadlock scenarios landing upstream. To > mitigate that problem the lockdep_mutex was added [2]. > > The lockdep_mutex lets a subsystem mirror device_lock() acquisitions > without lockdep_set_novalidate_class() to gain some limited lockdep > coverage. The mirroring approach is limited to taking the device_lock() > after-the-fact in a subsystem's 'struct bus_type' operations and fails > to cover device_lock() acquisition in the driver-core. It also can only > track the needs of one subsystem at a time so, for example the kernel > needs to be recompiled between CONFIG_PROVE_NVDIMM_LOCKING and > CONFIG_PROVE_CXL_LOCKING depending on which subsystem is being > regression tested. Obviously that also means that intra-subsystem > locking dependencies can not be validated. Instead of using a fake lockdep_mutex, maybe you can just use a unique lockdep key for each subsystem and call lockdep_set_class() in the device_initialize() if such key is present or lockdep_set_novalidate_class() otherwise. The unique key can be passed either as a parameter to device_initialize() or as part of the device structure. It is certainly less cumbersome that having a fake lockdep_mutex array in the device structure. Cheers, Longman