Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1839817pxb; Thu, 4 Nov 2021 09:19:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhxp8V+3+qW/wGny+vuy3zlV8oqJ9p/xcp7XtStZQMZVQEHNT65gsIyPkt+8pYs4hUNjED X-Received: by 2002:a17:906:2b82:: with SMTP id m2mr64477243ejg.122.1636042748325; Thu, 04 Nov 2021 09:19:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636042748; cv=none; d=google.com; s=arc-20160816; b=m2nU6LVRt3eL56q2bNxjcXydsVNlRwsFA9My29EjB7rlTcVZDcbJ3mHneb2oEbPUXz rYj6v93H7SfTKzoj+3GtS8cMdcj6nQASjCKIT14wGN0VxTz8pQCz//hFYN2KP4N/LaZA uIGB9Tbbe9aGpcRtNe4aJjvC8uc4tbg7N4c72Odj8wGDaFwoMgPLKqodJQZbQQJKjTTY J7gw0vNw8c6pEyigtUZg9LFL6EKFQv3pWQeXGJIIkJRqSK3ejea1LiXG3ebwCVQxCMEJ U7fbQ7gbHz1sbcQE3/EwPTKmRUXjyaUfJoegLqyjvlHhbvWMj6cksgr9OGlk9Y2aG+Zf sjaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=sGhrNvp6uYs1eENGQtazLcPrJxO2giqX3yn86Q2Rjb0=; b=vmfPNAWfSL7VE6E8Vce9E/A341LNHMzOmLtnFsE+otwEZjCccu8Xj3pUaN3maCBzXU qhg1L5Jh2KmClsa6zJC/qg0JBBipW4JaxEBrtuvQgOR3WbxEwK4vppSK9NJzo6x9vHmx Wls8Yzcl3uTyRIQcYa+fpjcs/VrcWbYvCXbjKMGfIEnJRXrrTeIxDdu5aLlzA0zW+Rpz qD04vpcmyWKR5dAr/ex2E5amgs8jza9usMqdxskU6NH2loitnEAN3Q+TsBhTXzCQ94ms no0HQWte4W4LL7XUH6sT2kzJ7HPSzSWlI+FldIXieWGgGZPDOUTHBSWBobjczuUgVPjQ 9s7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=OzWlf0h4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 2si8142884ejw.30.2021.11.04.09.17.52; Thu, 04 Nov 2021 09:19:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=OzWlf0h4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231642AbhKDQRk (ORCPT + 99 others); Thu, 4 Nov 2021 12:17:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231419AbhKDQRj (ORCPT ); Thu, 4 Nov 2021 12:17:39 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C447C061714; Thu, 4 Nov 2021 09:15:01 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id f8so7978697plo.12; Thu, 04 Nov 2021 09:15:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sGhrNvp6uYs1eENGQtazLcPrJxO2giqX3yn86Q2Rjb0=; b=OzWlf0h4HDva5w8/fjj8qykjVe5BGNoaTXijP4Hro17C7voOuJc2L83UigCX/Ce/Cb oN9HSXKUkDlmO79igfzpN06HaVh8mgRhtICw5Ix+iFqTxY/mHUXFu+Lgs/itfW5uQ7JP /U/7LGPCPa/siFewODGT5aajhljPambkIPQxtS4PXL8uVpH8iv+EZGjlNFZ3QxlCK7o9 JamSxoe3HUtNXrTPUDPNzdTb7qwxLf5FuxoCxowi/RFzgyF4DDITN2cMzVC/FqJnchSa /qyM12DwUyQyENbiGq+bYPQTzCb3MZoQxrJHR0Uy3G+LmnPJSrTNKeUPFC7OD+OINALE UQZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sGhrNvp6uYs1eENGQtazLcPrJxO2giqX3yn86Q2Rjb0=; b=Zd9YynsPhdZV/ALtmGbrtPLi1ZcShOlyEgCNdZJzrzyB2syMMisGPhHUa54mjppRsS GQOV9x7Xd379wExszpqBtcpZylNkHlJ916jQwCdCyKxoCIYPPr27QNz/D+nGC6dQ3ros eqgwpECeeEtp1JFAF5tICsHrx6e74KGcaycvATnZaa1PKJe6zxOps+YHdyhioqKJnS0n Bcpcwn7Fuos5tCNWt0QPhU4YHMMJzM8997jtLrIJ1mGzksOExRn/kvXkwtgkRIO6p5Tv /XxjFiV/xAqHlkyW6g/HyaFfNM5ssfGaaUi946dAmlkWKoppOQhPBQDIjOvYFz4mkAHR DDuA== X-Gm-Message-State: AOAM531QKqy0vkNeOHj2ehKaGwbTOpCFSvIqxxdhhf+xcMHFegdKJaoN bEFk6QbweuOG1qZ87y/rVLBEnRc5+oD4R/bOUGw= X-Received: by 2002:a17:90a:6b0d:: with SMTP id v13mr23239514pjj.138.1636042500356; Thu, 04 Nov 2021 09:15:00 -0700 (PDT) MIME-Version: 1.0 References: <20211102021432.2807760-1-jevburton.kernel@gmail.com> <20211103001245.muyte7exph23tmco@ast-mbp.dhcp.thefacebook.com> <55c95c15-ccad-bb31-be87-ad17db7cb02a@fb.com> In-Reply-To: <55c95c15-ccad-bb31-be87-ad17db7cb02a@fb.com> From: Alexei Starovoitov Date: Thu, 4 Nov 2021 09:14:49 -0700 Message-ID: Subject: Re: [RFC PATCH v3 0/3] Introduce BPF map tracing capability To: Yonghong Song Cc: Joe Burton , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , John Fastabend , KP Singh , LKML , Network Development , bpf , Petar Penkov , Stanislav Fomichev , Joe Burton Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 3, 2021 at 9:23 PM Yonghong Song wrote: > > asm("") indeed helped preserve the call. > > [$ ~/tmp2] cat t.c > int __attribute__((noinline)) foo() { asm(""); return 1; } > int bar() { return foo() + foo(); } > [$ ~/tmp2] clang -O2 -c t.c > [$ ~/tmp2] llvm-objdump -d t.o > > t.o: file format elf64-x86-64 > > Disassembly of section .text: > > 0000000000000000 : > 0: b8 01 00 00 00 movl $1, %eax > 5: c3 retq > 6: 66 2e 0f 1f 84 00 00 00 00 00 nopw %cs:(%rax,%rax) > > 0000000000000010 : > 10: 50 pushq %rax > 11: e8 00 00 00 00 callq 0x16 > 16: e8 00 00 00 00 callq 0x1b > 1b: b8 02 00 00 00 movl $2, %eax > 20: 59 popq %rcx > 21: c3 retq > [$ ~/tmp2] > > Note with asm(""), foo() is called twice, but the compiler optimization > knows foo()'s return value is 1 so it did calculation at compiler time, > assign the 2 to %eax and returns. Missed %eax=2 part... That means that asm("") is not enough. Maybe something like: int __attribute__((noinline)) foo() { int ret = 0; asm volatile("" : "=r"(var) : "0"(var)); return ret; }