Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1342487rwe; Thu, 1 Sep 2022 17:17:17 -0700 (PDT) X-Google-Smtp-Source: AA6agR5iBrQv1yTwJlARDvirhcIw3wsVa3Am6NZJ1wYBNNhAwix5awU5PEISsBQ1zKUh1xr890wL X-Received: by 2002:a05:6a00:26e0:b0:537:e561:baba with SMTP id p32-20020a056a0026e000b00537e561babamr29259452pfw.34.1662077837199; Thu, 01 Sep 2022 17:17:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662077837; cv=none; d=google.com; s=arc-20160816; b=yf0xhKposgouEEhK+TWFCRxwh9LPe6Fnydn9eFQ6i9gMPy1OI86liS5IceJ1R/ETcO CFgmq6+NCLb34V1UKSUbT88+fPt+JtM0Fi32HscW2Oh8GJGTeY0vUszbcPowPADfQWtB +Hjt21kLPyzKGRS4wixb5lyuwe1N4CD9owkAwQgdO2/hfd96mhBSysv2230jJiG3DuT7 4PNlV1IuVXqCkpPIVHkN65Y5+6uk1QU+wC0Xu/DFbjg1tR9JMom1ksvdZPpRC3IcCyOd scGHbuSYljq64gHIQR7J3nqQ0VIV6IlBkHBceduuR2Ioop3oMPcqcYrauu8OBkObAtj8 chdg== 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=eoNn1fjSkg2leg33L0We1zkgyS0MAxvnNbd+Sflw0Ak=; b=ql5oq0WF/bTaBOlkEU/JB94moeI8ocfcVIEVs/6jYWC6nTNbjBgDI6en41NC1rD6ZJ tcYTZPGYbUZh6ibu7GPdqBwipTYEtyIGRBYkDVkoH3+Gkh+cqhKaWWRHpFKaSdtoJdR6 ZS0yHv/yWnaFahMq4iwgQ7sIbNcK1YghN9NPwLTpLqYirTUI7bAOr0GPP93Vzyzcs/bm 6bRuj6KkohEKWImvbYKC1JtORPIk4srha7HKyaCHys97Ntdk9+mnRrMMdcHlKAYfwJ6c Lem8hJr1MSsw8Va1GFJLm1jTGB+s5MNwTPIr/5VphLcckQ4asysQ05yZKnGIa5nbQ10b M+vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pSTqy+ua; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 23-20020a631557000000b0042ac5388ff4si311780pgv.508.2022.09.01.17.17.03; Thu, 01 Sep 2022 17:17:17 -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=@kernel.org header.s=k20201202 header.b=pSTqy+ua; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234630AbiIAXzx (ORCPT + 99 others); Thu, 1 Sep 2022 19:55:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233404AbiIAXzv (ORCPT ); Thu, 1 Sep 2022 19:55:51 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6D8F60521; Thu, 1 Sep 2022 16:55:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AAD78B82897; Thu, 1 Sep 2022 23:55:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0D4AC433D6; Thu, 1 Sep 2022 23:55:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662076546; bh=hlKF/c1q2pYEpxcRsPclintcggkXHRGlNMmrn+1h++4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pSTqy+uaYNWeoqqQuKaodnQ2nvpxHo84JildhRBzQ1WtyxTXJrUfcfwFVysWv0bLp jhNCW2nmNueqjNtQzh8KfSfyjJlZL7PHtPk900cnn0u5RNPD1R5c4Bq9DLvEFq6RIX ce77kjY7wg6dKxPg3JHJGMjSgBW+NdFkGFAv+kq9sqeWjvAIwAUogG3tlUq1wcZLy8 4tjDAR1aUkkNR6MmO39DJfM8mKGzO4JnYCKqfwgLVzz6leRAB1DIbivs8T/EAvWaXq JPhYV/LWKFMmi3SQP7DZX2E/XzA47PMZp1JbWvyUp+yDYZcq3hhRoabnk8BGSb4j4i WYF1/YVm/v96Q== Date: Fri, 2 Sep 2022 02:55:40 +0300 From: Jarkko Sakkinen To: Dave Hansen Cc: linux-sgx@vger.kernel.org, Haitao Huang , Vijay Dhanraj , Reinette Chatre , Dave Hansen , Shuah Khan , open list , "open list:KERNEL SELFTEST FRAMEWORK" Subject: Re: [PATCH 6/6] selftests/sgx: Add a bpftrace script for tracking allocation errors Message-ID: References: <20220830031206.13449-1-jarkko@kernel.org> <20220830031206.13449-7-jarkko@kernel.org> <85d6c3ed-665f-879e-0889-efbddba3c000@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <85d6c3ed-665f-879e-0889-efbddba3c000@intel.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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, Sep 01, 2022 at 03:34:49PM -0700, Dave Hansen wrote: > On 9/1/22 15:20, Jarkko Sakkinen wrote: > >>> +kr:sgx_alloc_epc_page /(uint64)retval >= (uint64)(-4095)/ { > >>> + printf("sgx_alloc_epc_page: retval=%d\n", (int64)retval); > >>> +} > >>> + > >>> +kr:sgx_encl_page_alloc /(uint64)retval >= (uint64)(-4095)/ { > >>> + printf("sgx_encl_page_alloc: retval=%d\n", (int64)retval); > >>> +} > >> I guess this doesn't _hurt_, but it's also not exactly the easiest way > >> to get this done. You need a whole bpf toolchain. You could also just do: > >> > >> perf probe 'sgx_encl_page_alloc%return $retval' > >> > >> Even *that* can be replicated in a few scant lines of shell code echoing > >> into /sys/kernel/debug/tracing. > > Thanks, I have not used perf that much. What if I replace > > this with a shell script using perf? How do you use that > > for two kretprobes? > > The manpage is pretty good. > > But, I'd proably be doing something along these lines: > > perf probe 'sgx_encl_page_alloc%return ret=$retval' > perf record -e probe:sgx_encl_page_alloc -aR \ > --filter='ret >= 0xwhatever' sleep 1 > perf script > > There are probably shorter ways to do it, but I'm pretty sure that works. Thanks, will give it a shot. BR, Jarkko