Received: by 2002:ac8:156:0:b0:3e0:cd10:60c8 with SMTP id f22csp523367qtg; Wed, 5 Apr 2023 13:35:55 -0700 (PDT) X-Google-Smtp-Source: AKy350YZMuHAxgbe7osY8F1avISI3KrhtqniGch1JK934fcPHFFup2NDJ5B997fKcYnchmUz68R/ X-Received: by 2002:a17:906:144d:b0:93f:2256:fc05 with SMTP id q13-20020a170906144d00b0093f2256fc05mr4213471ejc.55.1680726955318; Wed, 05 Apr 2023 13:35:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680726955; cv=none; d=google.com; s=arc-20160816; b=Qva09Ust8KUlPyyZ4Oj05fA60g2IgAYhae9QD+29ZbfrEuZ8kRvu/4cHoz7ws97v9a ytYyqWYjWSc8h35RXOI4HAcy9i9O0IDhxUteWY2z+1hKHekTdY7JD1QEodLHhNVjj85S g0ez3jKN2UU8Y3qjunaz/QTMVtx9RGKIFtKtX3qghrMIOVQ0dgrbqnmMOD36O/uZVE6n zl/RHBVz7lvVKtYrw0DfIyCZM/jPmRPR+UkmioQRBYq6Y/r8N1JzBK5fdpfuKoojtGfC 1CQXDUeKlmER2euOnvYCxFrmPTdiJpL/Okc6o5ksFFsvnHdE7hfriyO/OKes6amKdYxh ZttQ== 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=oOCkov9BBGgT0peCYkNt57Um4DYzrscVavulIOjTDe0=; b=ct15jfozeikKTPQhxiDvsKF6ZKMT49lt34dDw3ulJfAOl9NwVCSl4SMQC7Wg/MCGfM /yOt5nW5cw0plR+eVOsg3/qW8IgKRPttXpyGQby742t4bDoVD40quesGFUPbUyKXvZUR TiiwgyTgH/X2Dusva1d8UomLtGRcjEW2i+aLuyyig/Zh7LNVkelmKsZZ+6X9xqcW/DaL tAWyR5dio3vkiZB9lZr5NDw1ATcszrl/dYXbKn+GIJUh2Q2vu1DCKGNnLtwMx+lP0uqA QQBjWfujmsFBO+XhGpeNC/WqE+YzlaHgUTfZdF7FejTBw5SCj4Zw8kSGJcb8q+gZXY2l LJnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="jsq3/pJl"; 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 y2-20020a17090668c200b009324eea0cedsi3969453ejr.72.2023.04.05.13.35.30; Wed, 05 Apr 2023 13:35:55 -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="jsq3/pJl"; 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 S234597AbjDEUbS (ORCPT + 99 others); Wed, 5 Apr 2023 16:31:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233945AbjDEUbE (ORCPT ); Wed, 5 Apr 2023 16:31:04 -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 F074783E8; Wed, 5 Apr 2023 13:29:48 -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=oOCkov9BBGgT0peCYkNt57Um4DYzrscVavulIOjTDe0=; b=jsq3/pJlrzmJtVq66zSmL3bpa0 rve9SDRkNsNFrM/IjstPSfL26MF5Vf3c3U7OvL8FOiL0Wj7uagJYhcqP8pdG2TAsZhddQaTFZLJ/i wq39MLjDbEWQbghmH0QKHHTpSFs7G1el7eKSaACevYTVDYYFaf9XTVq/JTepUUasiecUUMgI9rNEh NLADemk/us365yrUJBqktfz1coQh4MYNOI+o0zdSvXNCr5fx11Ayi6wLKPUGhJEfsEBppQcjPBFvm qq7y9wW+WV5MG4j0axHwHLxdFac1Ws97hyqlOW35Wv8oe4qN0HXwRAD/fOppsEnD+HtaAjkMhTu6l 9z4D2Eog==; 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 1pk9l6-00A4xd-38; Wed, 05 Apr 2023 20:29:33 +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)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 5DA0030036C; Wed, 5 Apr 2023 22:29:32 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 44FA926A19DB5; Wed, 5 Apr 2023 22:29:32 +0200 (CEST) Date: Wed, 5 Apr 2023 22:29:32 +0200 From: Peter Zijlstra To: Wedson Almeida Filho Cc: Greg KH , rust-for-linux@vger.kernel.org, Miguel Ojeda , Alex Gaynor , Boqun Feng , 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 v2 03/13] rust: lock: introduce `Mutex` Message-ID: <20230405202932.GG365912@hirez.programming.kicks-ass.net> References: <20230405175111.5974-1-wedsonaf@gmail.com> <20230405175111.5974-3-wedsonaf@gmail.com> <2023040554-promoter-chevron-10b2@gregkh> <2023040509-tamer-clinic-c14c@gregkh> <20230405191826.GA365912@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 Wed, Apr 05, 2023 at 05:21:44PM -0300, Wedson Almeida Filho wrote: > On Wed, Apr 05, 2023 at 09:18:26PM +0200, Peter Zijlstra wrote: > > On Wed, Apr 05, 2023 at 08:04:22PM +0200, Greg KH wrote: > > > On Wed, Apr 05, 2023 at 08:03:11PM +0200, Greg KH wrote: > > > > On Wed, Apr 05, 2023 at 02:51:01PM -0300, Wedson Almeida Filho wrote: > > > > > +void rust_helper_mutex_lock(struct mutex *lock) > > > > > +{ > > > > > + mutex_lock(lock); > > > > > +} > > > > > +EXPORT_SYMBOL_GPL(rust_helper_mutex_lock); > > > > > + > > > > > > > > No need to ever unlock a mutex? > > > > > > Oh nevermind, mutex_lock() is a macro, mutex_unlock() is not... > > > > Yeah, so I despise all these stupid helpers... but I suppose it's the > > best they could come up with to interface the languages :/ > > > > The only hope is that the thing can do cross-language LTO or something > > to re-inline stuff. > > One thing we could to do improve the situation is to convert some of the > existing macros into inline functions on the header files. > > We can't do it for all cases (e.g., cases like mutex_init that declare a new > static variable when lockdep is enabled) but mutex_lock is just a function > when lockdep is disabled, and just calls mutex_lock_nested() when it is enabled. > > How do you feel about this? > > -#define mutex_lock(lock) mutex_lock_nested(lock, 0) > +static inline void mutex_lock(struct mutex *lock) > +{ > + mutex_lock_nested(lock, 0); > +} Can rust actually parse C headers and inline C functions ? I thought the whole problem was that it can only call C ABI symbols (which inline functions are not).