Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4214002rwl; Mon, 3 Apr 2023 01:23:12 -0700 (PDT) X-Google-Smtp-Source: AKy350ZfN6EYXF7AC3iOAtuLYM4mzd3n0bzg8Tz1PMQ7EtdXJTCW3JlQprDCOPS32ubxCO/QEvPl X-Received: by 2002:a17:907:960f:b0:93b:5d19:52e1 with SMTP id gb15-20020a170907960f00b0093b5d1952e1mr46885701ejc.50.1680510192083; Mon, 03 Apr 2023 01:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680510192; cv=none; d=google.com; s=arc-20160816; b=rmxSSrc2e6jb81shoGIKatud4Yh7uQbhiXuEAhXSIuHyRN2jUAq7scu1kn40NS8WVr EE3WCrjFz5yWcNWthsd2d/FeCcl6GFKSvmKkPHRF+3UWrm9VE+hH3T3XFg7Hju2nUorE 2sfKvcmlRdNyupitu8jDyz/hYM/2QTZ5jF7IHVXU90NR68GLlzA8nsU/stO8Q1htJdOw SjrmEk0RMcrddUdBwYE6G9HI2kt83eyIeDTDwDhT9sVW193y1bgfAkiUq2fTFJ3itC4B v+pIHcoBe2jm769OUGsrD5h/I+btbIVXuCZPIAloo9g7FudV2NjadCRl/35e+oDhx4eO FVhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ru1UgQqnTK+cQyfSkbKek3qx1F4WSiaJst22Mg2vr8w=; b=qiV6aRFw4RhA9/ME/TuIZGzaPMefP/PsgECr7kRtzMtHc+uiWq57/sf50XfYtq7Dxd y5TWL8J2NTKhfViZJYanheVg6X3QxLbmaMjp00erK63SsbyFRH9kVrThBTxMzyKpnyHi ZDjLRbV+/msu17IiRAipiTXAsqReB1bhls03o4+JpCQIX2EBzlId5eDriytn+vk/1R2u q5TVtuz7vhpapyhx7V+2Xo6zpcIbLXaksAg6HEfJwFyp37QIW+opVJWfKjPCK6CgWc/W cQ0zzTJuuNJgurX7j7qUkOzFZSWqdWya3gJp2Er9JJRqFaUqYuoSCho50MOYLH2sTm10 D0Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=N1y7Mh1C; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q19-20020a17090676d300b00935086a660csi5974890ejn.17.2023.04.03.01.22.47; Mon, 03 Apr 2023 01:23:12 -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=@infradead.org header.s=desiato.20200630 header.b=N1y7Mh1C; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231638AbjDCIV1 (ORCPT + 99 others); Mon, 3 Apr 2023 04:21:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231611AbjDCIVZ (ORCPT ); Mon, 3 Apr 2023 04:21:25 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 117ABCDE2; Mon, 3 Apr 2023 01:21:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ru1UgQqnTK+cQyfSkbKek3qx1F4WSiaJst22Mg2vr8w=; b=N1y7Mh1CxXBC4aH0v11HS9q7is 36O/d/KpyFhL5QqxzCUDy/0bghg1IX+jcMrHB77HlLY3QS5DT5BKX5tBeLeZ8mP6M+4BDHRW+uu6w Q5ILrJNnXVVYJRb+cyoZE09OuUmowZed1UCtWurTXdgy4YET+aLkZ4GJfgQlz9JM+xNejg/rSPrT5 BukT1JUwKKAi9Iav4GUf29edXzj/LG4P6SwOgPoyHmNF8XTxj4FKcYQS+ZFQJ8XC9hbgisq36Ahh5 wCMtl6AbQErnc1Y9DcISxL8TzOl9M8cTvTRZyXSsvL5KWfeWhOgN/hDWM/xtpn9uwTzeTj1EVSBgP Sfh1rLvQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1pjFQs-008nSZ-1v; Mon, 03 Apr 2023 08:20:54 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 5C03A300202; Mon, 3 Apr 2023 10:20:52 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 14C812421CE74; Mon, 3 Apr 2023 10:20:52 +0200 (CEST) Date: Mon, 3 Apr 2023 10:20:52 +0200 From: Peter Zijlstra To: Boqun Feng Cc: Wedson Almeida Filho , rust-for-linux@vger.kernel.org, Miguel Ojeda , Alex Gaynor , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , linux-kernel@vger.kernel.org, Wedson Almeida Filho , Ingo Molnar , Will Deacon , Waiman Long Subject: Re: [PATCH 03/13] rust: lock: introduce `Mutex` Message-ID: <20230403082052.GR4253@hirez.programming.kicks-ass.net> References: <20230330043954.562237-1-wedsonaf@gmail.com> <20230330043954.562237-3-wedsonaf@gmail.com> <20230330130108.GE124812@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 Thu, Mar 30, 2023 at 11:47:12AM -0700, Boqun Feng wrote: > On Thu, Mar 30, 2023 at 03:01:08PM +0200, Peter Zijlstra wrote: > > On Thu, Mar 30, 2023 at 01:39:44AM -0300, Wedson Almeida Filho wrote: > > > From: Wedson Almeida Filho > > > > > > This is the `struct mutex` lock backend and allows Rust code to use the > > > kernel mutex idiomatically. > > > > What, if anything, are the plans to support the various lockdep > > annotations? Idem for the spinlock thing in the other patch I suppose. > > FWIW: > > * At the init stage, SpinLock and Mutex in Rust use initializers > that are aware of the lockdep, so everything (lockdep_map and > lock_class) is all set up. > > * At acquire or release time, Rust locks just use ffi to call C > functions that have lockdep annotations in them, so lockdep > should just work. > ffi is what the C++ world calls RAII ? But yes, I got that far, but I wondered about things like spin_lock_nested(&foo, SINGLE_DEPTH_NESTING) and other such 'advanced' annotations. Surely we're going to be needing them at some point. I suppose you can do the single depth nesting one with a special guard type (or whatever you call that in the rust world) ?