Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp496793lqt; Thu, 6 Jun 2024 09:25:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVoEvATrmpIF800gjSytDBz9KDRIt9VPYXTE4HFVdrUfuYhAV1eoyufQ1B52/h/JGGYXqH95r2qZsEXIaQ8RXckFSdpCsQ0zcwErN9yHQ== X-Google-Smtp-Source: AGHT+IGRxqc/5st2pil3iXRUKnaBHIGWID30LzpkohgPY1MKFSvR3zzw5zPfe9gbPgXEnU9CkhaT X-Received: by 2002:a17:903:41cf:b0:1f6:78f7:14da with SMTP id d9443c01a7336-1f6d02e6cfemr1182565ad.24.1717691146184; Thu, 06 Jun 2024 09:25:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717691146; cv=pass; d=google.com; s=arc-20160816; b=zxcnX+gkWR79CwPrAjkgW2GtPZOyeSKfPc/GXEP8S5GmlwvAc/nivaGPGVtOPFUIXE CcF5kxYCyRYCWVVSp4o6KYiTfNYYiP/jM9cNocHkDlm279eWczcwG78pCUP1gYrb+l6/ b3nPstf+oUGOwdk1R9cvbLXRKQKc8K7+k8QgkUcwekEblS+lk80G82KQEsWwZR+Crqho 019VkTTbmSxQ7/8/6GOi0HnZ6HZYmV6nyBIlpm9Nevz2rmK/bJxtknMUQdS6s+2oAYei OsAUazu5u2YnT4CHDgOyQSpiwiQo/Kq1lcGy0+1sJgzYHg2DQ7qwC2/WW7/b8U0DJIML 2KAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=ROVw/MGINueYp77DHAobzSV7irjIeHbZVqgH5HBMjNw=; fh=MVgI8yGMrpfSeQU+FAmuvGazxdeGTFzc/DECwfIweHI=; b=GQyCr3Z+226Shrsg2BsYbM9oFjp0VvWvly3L7eP8jyDDw+7OICgE1XJno71aJExnxj aT5volsVJTGKrzMbIX4Q0ltt4cciopG5nBzMfVt8eLwhIbARvI0URdXil4R+rsQvj8zL wefVALV6TVv4jmt/V0FhkSQWDZnlkrs55eyt3wXUC1ASPN0BhO+VyFW1XSOtnAegRdef vez0s8G/J3+gKXU6sgoID0B7SnvenTZ+Ga8zk/83Q6R/Zy+mKv0V5ITt3wCH/EoS/1ea 2/9xWVXuv7hhLSBQDrBqYD9pbvk8ZTeDJyRhmhoXN+tpRm+dGxn2YYcWU2pz7Qw4VUjw M8aA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=JmSHwzaF; arc=pass (i=1 spf=pass spfdomain=efficios.com dkim=pass dkdomain=efficios.com dmarc=pass fromdomain=efficios.com); spf=pass (google.com: domain of linux-kernel+bounces-204684-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204684-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f6bd7e5072si8497025ad.416.2024.06.06.09.25.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 09:25:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204684-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=JmSHwzaF; arc=pass (i=1 spf=pass spfdomain=efficios.com dkim=pass dkdomain=efficios.com dmarc=pass fromdomain=efficios.com); spf=pass (google.com: domain of linux-kernel+bounces-204684-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204684-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 74D9A284A50 for ; Thu, 6 Jun 2024 16:21:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D1CDA19AA71; Thu, 6 Jun 2024 16:16:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="JmSHwzaF" Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F3FF1991BC; Thu, 6 Jun 2024 16:16:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=167.114.26.122 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690594; cv=none; b=GcJiw5v941bmbErtnrn3ydXWF61mkPSILEXkahgsH5f2xB9kAkUIoXoHweCndtvqmEbGC38lpaiqsoSrJsqzTDXT9C4dIZJiUWwfCebaPw2q6y6Ky9sy8saUc/DXhu3K5TCPzP4HZL+z3MVC/Gw1gLPZc3/K8SgPVsZqMDwaU1k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690594; c=relaxed/simple; bh=RFc53pBgTWIlv5uA9fwIBtYs0TJgbzdzSpuTpFwpyqQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=IZeycAklbQAKFBy+E7vHBEN/AlP3+GFrZNTQCG2NR0D1GeGkQjPDyhkKEE1QsfYd3kRLFLH9c+zW9L0HDDzsPzwqgMio6gNriOi+3fuzgUmC/zhqjLdhPTOIw2bJyr45uqioDk+D4DOzrYLozRbI8h/fkeVmedulQ538EwZTF5Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com; spf=pass smtp.mailfrom=efficios.com; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b=JmSHwzaF; arc=none smtp.client-ip=167.114.26.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=efficios.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1717690591; bh=RFc53pBgTWIlv5uA9fwIBtYs0TJgbzdzSpuTpFwpyqQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=JmSHwzaFzu5SZrgopaWVwEeGeBkdOI8GYilDbZyBQxj1UWZ40zg57BrACmyBRrXS1 RU2+cQVfa+AYKlK5sNsujG3oNh4Mrhu8xSJoLx7Wt9zZNvqNe9ZxMkFJfq6Co2xHa6 mpDOruR1cNxGcxowWufaEBgvB5yrUKcgKxXaFheK0Dpw6wYg+Lrgrqrnr+4TqjuQ8J EcSsSF9cUJ5PzxS/M96hvHYtfgRtTS6VeWEbDm+hCvSRKKYMoIVcq3I0lHY7fA7kgn CIyHFTAjTpY1S5OpF3wpMSnMMGh2QCg+onAL+cwzmDVGZBlvNI/z0CEQdZ2iPV0Nos oELz9YHBotlGA== Received: from [172.16.0.134] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4Vw8bL6v4lz12m8; Thu, 6 Jun 2024 12:16:30 -0400 (EDT) Message-ID: Date: Thu, 6 Jun 2024 12:17:20 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 0/3] Tracepoints and static branch/call in Rust To: Alice Ryhl Cc: Steven Rostedt , Masami Hiramatsu , Peter Zijlstra , Josh Poimboeuf , Jason Baron , Ard Biesheuvel , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , linux-trace-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240606-tracepoint-v1-0-6551627bf51b@google.com> From: Mathieu Desnoyers Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024-06-06 11:46, Alice Ryhl wrote: > On Thu, Jun 6, 2024 at 5:25 PM Mathieu Desnoyers > wrote: >> >> On 2024-06-06 11:05, Alice Ryhl wrote: >>> This implementation implements support for static keys in Rust so that >>> the actual static branch will end up in the Rust object file. However, >>> it would also be possible to just wrap the trace_##name generated by >>> __DECLARE_TRACE in an extern C function and then call that from Rust. >>> This will simplify the Rust code by removing the need for static >>> branches and calls, but it places the static branch behind an external >>> call, which has performance implications. >> >> The tracepoints try very hard to minimize overhead of dormant tracepoints >> so it is not frowned-upon to have them built into production binaries. >> This is needed to make sure distribution vendors keep those tracepoints >> in the kernel binaries that reach end-users. >> >> Adding a function call before evaluation of the static branch goes against >> this major goal. >> >>> >>> A possible middle ground would be to place just the __DO_TRACE body in >>> an extern C function and to implement the Rust wrapper by doing the >>> static branch in Rust, and then calling into C the code that contains >>> __DO_TRACE when the tracepoint is active. However, this would need some >>> changes to include/linux/tracepoint.h to generate and export a function >>> containing the body of __DO_TRACE when the tracepoint should be callable >>> from Rust. >> >> This tradeoff is more acceptable than having a function call before >> evaluation of the static branch, but I wonder what is the upside of >> this tradeoff compared to inlining the whole __DO_TRACE in Rust ? >> >>> So in general, there is a tradeoff between placing parts of the >>> tracepoint (which is perf sensitive) behind an external call, and having >>> code duplicated in both C and Rust (which must be kept in sync when >>> changes are made). This is an important point that I would like feedback >>> on from the C maintainers. >> >> I don't see how the duplication happens there: __DO_TRACE is meant to be >> inlined into each C tracepoint caller site, so the code is already meant >> to be duplicated. Having an explicit function wrapping the tracepoint >> for Rust would just create an extra instance of __DO_TRACE if it happens >> to be also inlined into C code. >> >> Or do you meant you would like to prevent having to duplicate the >> implementation of __DO_TRACE in both C and Rust ? >> >> I'm not sure if you mean to prevent source code duplication between >> C and Rust or duplication of binary code (instructions). > > It's a question of maintenance burden. If you change how __DO_TRACE is > implemented, then those changes must also be reflected in the Rust > version. There's no issue in the binary code. As long as it is only __DO_TRACE that is duplicated between C and Rust, I don't see it as a large burden. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com