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 06EEEC64EC4 for ; Sun, 12 Feb 2023 03:13:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229554AbjBLDKc (ORCPT ); Sat, 11 Feb 2023 22:10:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbjBLDKa (ORCPT ); Sat, 11 Feb 2023 22:10:30 -0500 Received: from out-166.mta1.migadu.com (out-166.mta1.migadu.com [95.215.58.166]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 416931556C for ; Sat, 11 Feb 2023 19:10:29 -0800 (PST) Date: Sat, 11 Feb 2023 22:10:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1676171427; 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: in-reply-to:in-reply-to:references:references; bh=jf1H3d/In5/77lbYnmu+P0Ph1nV7stwLY9WuFch+4JA=; b=xfPf/5bYKSccJHE8x9RrnX3GkjgbEsam3IwYmOxSSNgx9Htaqi60HYx0YggXCGTJe4Bm+Y R9wM02p+U29iuRlH8UEDDEviYT+i+qP1B0SXoEK9nxQZmhYocLhdlvh99OJCYa2bsRw6Rh DiayDhtxKt36HOxAKuZuR8/cTXHzb9I= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Alan Stern Cc: Kent Overstreet , Linus Torvalds , Coly Li , Tetsuo Handa , syzkaller , Dmitry Vyukov , Greg Kroah-Hartman , "Rafael J. Wysocki" , Peter Zijlstra , Ingo Molnar , Boqun Feng , LKML , USB list , Hillf Danton Subject: Re: [PATCH RFC] drivers/core: Replace lockdep_set_novalidate_class() with unique class keys Message-ID: References: <52c7d509-ba9e-a121-60c9-138d7ff3f667@I-love.SAKURA.ne.jp> <109c3cc0-2c13-7452-4548-d0155c1aba10@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 11, 2023 at 10:03:11PM -0500, Alan Stern wrote: > On Sat, Feb 11, 2023 at 09:46:42PM -0500, Kent Overstreet wrote: > > On Sat, Feb 11, 2023 at 09:40:58PM -0500, Alan Stern wrote: > > > Or maybe you're referring to what this patch does? It does indeed > > > create a bunch of dynamic classes -- one for each struct device. The > > > ordering rules derived by lockdep will be somewhat arbitrary, as you > > > say. But some of them certainly will be related to the structure of the > > > source code. > > > > I could be :) I haven't been able to find the patch in question - have a > > link? > > It was earlier in this email thread. Here's a link: > > https://lore.kernel.org/r/Y+gLd78vChQERZ6A@rowland.harvard.edu/ > > > If you're talking about making lock_class_key dynamic, I think I stand > > by what I said though - OTOH, if all you're doing is lifting that to the > > caller of the device object init function, so it'll still be a static > > object in the driver, that would be totally fine. > > The patch does the first, not the second. Feel free to object some > more... :-) So IMO the more correct way to do this would be to change device_initialize() to __device_initialize(), have it take a lock_class_key as a parameter, and then use __mutex_init() instead of mutex_init(). But let's think about this more. Will there ever be situations where lock ordering is dependent on what hardware is plugged into what, or what hardware is plugged in first?