From patchwork Thu Nov 10 03:50:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiezhu Yang X-Patchwork-Id: 17944 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp710595wru; Wed, 9 Nov 2022 19:56:43 -0800 (PST) X-Google-Smtp-Source: AMsMyM5s4STffeoSWFMI/4f27bYneo7inULj48w8nbJh+34AgPXrHjRjhhAWfcESIeAiGe97wQ5T X-Received: by 2002:aa7:80d9:0:b0:56c:3a1e:35a6 with SMTP id a25-20020aa780d9000000b0056c3a1e35a6mr1737718pfn.57.1668052603627; Wed, 09 Nov 2022 19:56:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668052603; cv=none; d=google.com; s=arc-20160816; b=E4VfcbiFRuOBUPZgUUSBCxwYls3zba7ppxwIBLxZ5kFBtg2PUC08Kwyfrvh37VLijU YtYuMdeOXz1vBZhuQLzXSrf+vudnLzRyjcjH9VpiJKpm8d7K744yT5643RCHrTTlBdU6 28XKMxF5WWHZJSeFuQBZSw0rRI+q2hvJ7Mo/UyLvoDu5u0hdOKxhjKq0BKAXhDsRn+Eu e8z07E1P2WepH/VTBSIel+ie1Oubn0MGuOMjYC+q9FEEaymCxK8oqifB/cv7y68yKJ0j enRGpMv7enyObybNqQV8uzuSz2+uWLW/h1Uuy8ZgA6mu2tlE6GY31H720fPZfjI0QEId Ko7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=rqjVWU//AmRZk3aGOcA5+uLiloJLcwnf4lhKaAGbhNE=; b=jspyWllLT5pBczhnJ95UKpHxICOrsXqcw3c6LPkPYQPu4obZfWenCgaQ/VE023/BSj SOtgXZPb3fa4qOII2VQ1YBsCvJ3nfVdmZKG1qEvVwtvZ/qlUajq7ZcZM3Techi3y61Vq bs/WxQB9NT2sMcidJqgLh8H9TE4gDGfurziVbcKMZ5v5qSbSNZHnuID5+XtRcgqcOHYL +52VG9Rv0ft7iKOa9rxEtwVU+ALTkSKQTX9ALl10AD9YDoCb5gevAg9IzbQCSSdC+G2a ReIDHgDi7vrkLcNoSPSYw+RrBLiT6LserYQD1/XfijAIxJ0KFDnAyqQMPaK4xAH19K0W Z48g== ARC-Authentication-Results: i=1; mx.google.com; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e2-20020a637442000000b0042b807728e3si18665970pgn.762.2022.11.09.19.56.27; Wed, 09 Nov 2022 19:56:43 -0800 (PST) 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; 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 S232736AbiKJDuV (ORCPT + 99 others); Wed, 9 Nov 2022 22:50:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232318AbiKJDuT (ORCPT ); Wed, 9 Nov 2022 22:50:19 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 408FB2EF77; Wed, 9 Nov 2022 19:50:17 -0800 (PST) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8DxOdj3dGxjhbAFAA--.16415S3; Thu, 10 Nov 2022 11:50:15 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Dx9Vb1dGxjO_4PAA--.25722S3; Thu, 10 Nov 2022 11:50:15 +0800 (CST) From: Tiezhu Yang To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo Cc: Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH v5 1/4] tools x86: Keep list sorted by number in unistd_{32,64}.h Date: Thu, 10 Nov 2022 11:50:05 +0800 Message-Id: <1668052208-14047-2-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1668052208-14047-1-git-send-email-yangtiezhu@loongson.cn> References: <1668052208-14047-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8Dx9Vb1dGxjO_4PAA--.25722S3 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoW7AFyxurWrZw4Utr1rXw1kZrb_yoW8uF4fpF ykCrWDta15KFWag34SyF18Gw17CFZ7ZrW8KFy5W3s5ZFySqw1xXr1xursxCryUXw4vya4U Xa1xZw47WasrXw7anT9S1TB71UUUUj7qnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bSxYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jrv_JF1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1l n4kS14v26r126r1DM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6x ACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q6rW5McIj6I8E 87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc7CjxV Aaw2AFwI0_JF0_Jw1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l4IxY O2xFxVAFwI0_JF0_Jw1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGV WUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_ Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rV WUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4U JbIYCTnIWIevJa73UjIFyTuYvjxU4Xo7DUUUU X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749079927069563059?= X-GMAIL-MSGID: =?utf-8?q?1749079927069563059?= It is better to keep list sorted by number in unistd_{32,64}.h, so that we can add more syscall number to a proper position. This is preparation for later patch, no functionality change. Signed-off-by: Tiezhu Yang --- tools/arch/x86/include/uapi/asm/unistd_32.h | 16 ++++++++-------- tools/arch/x86/include/uapi/asm/unistd_64.h | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/arch/x86/include/uapi/asm/unistd_32.h b/tools/arch/x86/include/uapi/asm/unistd_32.h index 60a89db..e1cc62d 100644 --- a/tools/arch/x86/include/uapi/asm/unistd_32.h +++ b/tools/arch/x86/include/uapi/asm/unistd_32.h @@ -1,16 +1,16 @@ /* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __NR_perf_event_open -# define __NR_perf_event_open 336 +#ifndef __NR_gettid +#define __NR_gettid 224 #endif #ifndef __NR_futex -# define __NR_futex 240 -#endif -#ifndef __NR_gettid -# define __NR_gettid 224 +#define __NR_futex 240 #endif #ifndef __NR_getcpu -# define __NR_getcpu 318 +#define __NR_getcpu 318 +#endif +#ifndef __NR_perf_event_open +#define __NR_perf_event_open 336 #endif #ifndef __NR_setns -# define __NR_setns 346 +#define __NR_setns 346 #endif diff --git a/tools/arch/x86/include/uapi/asm/unistd_64.h b/tools/arch/x86/include/uapi/asm/unistd_64.h index cb52a3a..ce8b7ab 100644 --- a/tools/arch/x86/include/uapi/asm/unistd_64.h +++ b/tools/arch/x86/include/uapi/asm/unistd_64.h @@ -1,16 +1,16 @@ /* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __NR_perf_event_open -# define __NR_perf_event_open 298 +#ifndef __NR_gettid +#define __NR_gettid 186 #endif #ifndef __NR_futex -# define __NR_futex 202 -#endif -#ifndef __NR_gettid -# define __NR_gettid 186 +#define __NR_futex 202 #endif -#ifndef __NR_getcpu -# define __NR_getcpu 309 +#ifndef __NR_perf_event_open +#define __NR_perf_event_open 298 #endif #ifndef __NR_setns #define __NR_setns 308 #endif +#ifndef __NR_getcpu +#define __NR_getcpu 309 +#endif From patchwork Thu Nov 10 03:50:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiezhu Yang X-Patchwork-Id: 17942 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp710358wru; Wed, 9 Nov 2022 19:55:49 -0800 (PST) X-Google-Smtp-Source: AMsMyM55aALVGnJPbsgqpugJ7s5PqEBP9eVruYfmNyruKZnluKKtr7GaYGNAfnAeAHMTTPnR/l0a X-Received: by 2002:a50:c90b:0:b0:461:82d9:ef76 with SMTP id o11-20020a50c90b000000b0046182d9ef76mr1504764edh.70.1668052549532; Wed, 09 Nov 2022 19:55:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668052549; cv=none; d=google.com; s=arc-20160816; b=VmvROCPrAnzfhxqcKdRbZ27l6XD5flqxraAJtlFEu6R9FgJYnbgtC1FDyVJwK3vYa2 pRMzl/Vc3foaUoF1QeqA834liWf3bSlU9UG3tNLD6n34HBf8dpfi39JYA6fBlxCQbijp vLXOl1mPfY98UJZQvFJf8YX50oHeyDoSESGUQgkBEKedtLPmqe3xjqO+2Bq6zrGtMSCs t9Io4XGGfAvSfwVt2QpveYbqbNQt+BYZlJbUZmIU/oL0vb1D3yZjigVq/NdQesEOyumJ GdGTH1O7M1K/4MYsxVrCvqvuaiQA3U5MXFx82NmgG0qQpaAKCcG+8vmGtMy0L0L9FFeo ZJ8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=tnspbfSCt3bbz9Nooj/uvygb2itudy8rtV62RTKRztE=; b=nKrRh27peQLTUE2hJRkoyB17HeyvXHJuG/XJFTDdNQ2Sf3jR8tt/xxPBM/Wl+U1nNq N7Ck02l3FSfeFvHESmJeF7pfucgDKFxl2FkFwnRCYG4z5avi7tZKpBH8dTNxtbzAxroo uLD31WBy4gQHlrxS5eqanh3pcOLXJNMV8+6GlHZvSpSx2/IIvlMQ4FuSTCipnt+WA9Nr 0lmn6K5CvVi21cw10qSscZWwdC4KUptFheBeKvXOjZJzgPwN1ap4UaxvvynPOsKFmFqV I2kkAxz+LlkHpKrntuGOTBLIBJJG/542JLf1WOAT4qXpYZore1RQQNcOKXaaGmUjvo9T lkfA== ARC-Authentication-Results: i=1; mx.google.com; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h7-20020a05640250c700b00463c30d3f54si18291517edb.340.2022.11.09.19.55.26; Wed, 09 Nov 2022 19:55:49 -0800 (PST) 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; 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 S232752AbiKJDuY (ORCPT + 99 others); Wed, 9 Nov 2022 22:50:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232724AbiKJDuU (ORCPT ); Wed, 9 Nov 2022 22:50:20 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F011AC77E; Wed, 9 Nov 2022 19:50:17 -0800 (PST) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8BxXbf4dGxji7AFAA--.8877S3; Thu, 10 Nov 2022 11:50:16 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Dx9Vb1dGxjO_4PAA--.25722S4; Thu, 10 Nov 2022 11:50:15 +0800 (CST) From: Tiezhu Yang To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo Cc: Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH v5 2/4] perf bench syscall: Introduce bench_syscall_common() Date: Thu, 10 Nov 2022 11:50:06 +0800 Message-Id: <1668052208-14047-3-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1668052208-14047-1-git-send-email-yangtiezhu@loongson.cn> References: <1668052208-14047-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8Dx9Vb1dGxjO_4PAA--.25722S4 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoWxJFWruF1UCr18KF17Zr18Zrb_yoW5Wr43pF 9rAw4kJF4ruaya9r1fXF10gry5Jr97Cr15Kry293s5ZrWxt343tr47KF9IvF17u3yIka45 WFs3ZrWUWa1UXaUanT9S1TB71UUUUj7qnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bSxYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jrv_JF1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1l n4kS14v26r126r1DM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6x ACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q6rW5McIj6I8E 87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc7CjxV Aaw2AFwI0_JF0_Jw1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l4IxY O2xFxVAFwI0_JF0_Jw1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGV WUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_ Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rV WUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4U JbIYCTnIWIevJa73UjIFyTuYvjxU4Xo7DUUUU X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749079870049356144?= X-GMAIL-MSGID: =?utf-8?q?1749079870049356144?= In the current code, there is only a basic syscall benchmark via getppid, this is not enough. Introduce bench_syscall_common() so that we can add more syscalls to benchmark. This is preparation for later patch, no functionality change. Signed-off-by: Tiezhu Yang --- tools/arch/x86/include/uapi/asm/unistd_32.h | 3 +++ tools/arch/x86/include/uapi/asm/unistd_64.h | 3 +++ tools/perf/bench/syscall.c | 29 +++++++++++++++++++++++++---- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/tools/arch/x86/include/uapi/asm/unistd_32.h b/tools/arch/x86/include/uapi/asm/unistd_32.h index e1cc62d..4d8873a 100644 --- a/tools/arch/x86/include/uapi/asm/unistd_32.h +++ b/tools/arch/x86/include/uapi/asm/unistd_32.h @@ -1,4 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __NR_getppid +#define __NR_getppid 64 +#endif #ifndef __NR_gettid #define __NR_gettid 224 #endif diff --git a/tools/arch/x86/include/uapi/asm/unistd_64.h b/tools/arch/x86/include/uapi/asm/unistd_64.h index ce8b7ab..e29038a 100644 --- a/tools/arch/x86/include/uapi/asm/unistd_64.h +++ b/tools/arch/x86/include/uapi/asm/unistd_64.h @@ -1,4 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __NR_getppid +#define __NR_getppid 110 +#endif #ifndef __NR_gettid #define __NR_gettid 186 #endif diff --git a/tools/perf/bench/syscall.c b/tools/perf/bench/syscall.c index 9b75101..746fd71 100644 --- a/tools/perf/bench/syscall.c +++ b/tools/perf/bench/syscall.c @@ -30,25 +30,41 @@ static const char * const bench_syscall_usage[] = { NULL }; -int bench_syscall_basic(int argc, const char **argv) +static int bench_syscall_common(int argc, const char **argv, int syscall) { struct timeval start, stop, diff; unsigned long long result_usec = 0; + const char *name = NULL; int i; argc = parse_options(argc, argv, options, bench_syscall_usage, 0); gettimeofday(&start, NULL); - for (i = 0; i < loops; i++) - getppid(); + for (i = 0; i < loops; i++) { + switch (syscall) { + case __NR_getppid: + getppid(); + break; + default: + break; + } + } gettimeofday(&stop, NULL); timersub(&stop, &start, &diff); + switch (syscall) { + case __NR_getppid: + name = "getppid()"; + break; + default: + break; + } + switch (bench_format) { case BENCH_FORMAT_DEFAULT: - printf("# Executed %'d getppid() calls\n", loops); + printf("# Executed %'d %s calls\n", loops, name); result_usec = diff.tv_sec * 1000000; result_usec += diff.tv_usec; @@ -79,3 +95,8 @@ int bench_syscall_basic(int argc, const char **argv) return 0; } + +int bench_syscall_basic(int argc, const char **argv) +{ + return bench_syscall_common(argc, argv, __NR_getppid); +} From patchwork Thu Nov 10 03:50:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiezhu Yang X-Patchwork-Id: 17943 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp710557wru; Wed, 9 Nov 2022 19:56:36 -0800 (PST) X-Google-Smtp-Source: AMsMyM4tEAdydjA5zV+3s00pRk9w5Nu8JB0t1XEMOMecSaGKef+ptIOCMXQ4GxpGj+SrJmTYGswM X-Received: by 2002:a17:90a:c201:b0:216:ab2c:25b with SMTP id e1-20020a17090ac20100b00216ab2c025bmr34033491pjt.45.1668052596407; Wed, 09 Nov 2022 19:56:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668052596; cv=none; d=google.com; s=arc-20160816; b=tBYoyqeMouLjiwl4NZiDI42KsKxzmh9yrE+QzJNVnesOKPXzAXMiqOTbJZDY51Lss4 60Kfjtjj8Oqcx62oWHfGC5BMHG32rIRbHXE3xQnfA7IBlMipjrqwFwwl+DCustTv29lC K+49i3dz+z7VyJLYWSS6BQL4/IYkd8pPIUoZvyLI7Tya4QPvMrDEVOs2LS6PTff6Lvsp MGh9HZkoDVUSjpID5CEws2l2RmyF4btn4v8pFFvDSBnQuDG9j1TRXFMyVsOg5cpfnGhC U9Gx2iI0inOaCUu/xKlnQVWNQJ3gB5xdGSesHJ7MwAjbD3cIXy+sKulrpOe9KrqTwxab vOJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=tUJoiav9sf/qqGZb3A3Rd1s7yVqIZjcx/EG8MCh6REg=; b=tVCaJq6RE6O7jNveQRsRDFZ7I3CuY9qyqgT65/MwVZij1wA02Nqs3QXqB+mUHy82lf 75VsNdFsPyN/8/UFqWM3jbKNZAKnhemkQY/Oiwim0iPyCqaj08foGZtDKM+5mnKpzIli FqH71jmZr62KbVZ5/sUBV3oE9MPQTmxWtV58zHysuSOtCcxjV6OMWm+gqls7oBVMGkww jJ5ZQdm5/S/r1BZbEwLlpuPkJWKtmahBL0fY7GP+68/chgxKr9QgG8liRHzVt0NEFPHX lguuypfoBTfrbIWI6yqCE2h26a2Asou3UBN+YJXeOEKUqiTcBBmf8J3HH3FECmJ508QJ Jcog== ARC-Authentication-Results: i=1; mx.google.com; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 32-20020a631360000000b0045e00b905cbsi20365110pgt.73.2022.11.09.19.56.13; Wed, 09 Nov 2022 19:56:36 -0800 (PST) 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; 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 S232783AbiKJDud (ORCPT + 99 others); Wed, 9 Nov 2022 22:50:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232728AbiKJDuU (ORCPT ); Wed, 9 Nov 2022 22:50:20 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3808620BE4; Wed, 9 Nov 2022 19:50:18 -0800 (PST) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8Cx7Nj5dGxjkbAFAA--.18150S3; Thu, 10 Nov 2022 11:50:17 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Dx9Vb1dGxjO_4PAA--.25722S5; Thu, 10 Nov 2022 11:50:16 +0800 (CST) From: Tiezhu Yang To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo Cc: Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH v5 3/4] perf bench syscall: Add getpgid syscall benchmark Date: Thu, 10 Nov 2022 11:50:07 +0800 Message-Id: <1668052208-14047-4-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1668052208-14047-1-git-send-email-yangtiezhu@loongson.cn> References: <1668052208-14047-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8Dx9Vb1dGxjO_4PAA--.25722S5 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoWxAF1rKw1xJFy5JF15JFyDAwb_yoW5uw4DpF 9rCw48Aw4rWFWYvw1IqF1vgry7AwnrZry5K3Z0k3yDZrW2q343tr4xKF9IgF17Xw47ta45 uF4kZr4UXa1rJaUanT9S1TB71UUUUj7qnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bSxYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jrv_JF1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1l n4kS14v26r126r1DM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6x ACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q6rW5McIj6I8E 87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc7CjxV Aaw2AFwI0_JF0_Jw1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l4IxY O2xFxVAFwI0_JF0_Jw1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGV WUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_ Xr0_Ar1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rV WUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4U JbIYCTnIWIevJa73UjIFyTuYvjxU4Xo7DUUUU X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749079919572458908?= X-GMAIL-MSGID: =?utf-8?q?1749079919572458908?= This commit adds a simple getpgid syscall benchmark, more syscall benchmarks can be added in the future. Signed-off-by: Tiezhu Yang --- tools/arch/x86/include/uapi/asm/unistd_32.h | 3 +++ tools/arch/x86/include/uapi/asm/unistd_64.h | 3 +++ tools/perf/bench/bench.h | 1 + tools/perf/bench/syscall.c | 11 +++++++++++ tools/perf/builtin-bench.c | 1 + 5 files changed, 19 insertions(+) diff --git a/tools/arch/x86/include/uapi/asm/unistd_32.h b/tools/arch/x86/include/uapi/asm/unistd_32.h index 4d8873a..053122c 100644 --- a/tools/arch/x86/include/uapi/asm/unistd_32.h +++ b/tools/arch/x86/include/uapi/asm/unistd_32.h @@ -2,6 +2,9 @@ #ifndef __NR_getppid #define __NR_getppid 64 #endif +#ifndef __NR_getpgid +#define __NR_getpgid 132 +#endif #ifndef __NR_gettid #define __NR_gettid 224 #endif diff --git a/tools/arch/x86/include/uapi/asm/unistd_64.h b/tools/arch/x86/include/uapi/asm/unistd_64.h index e29038a..54a6c4d 100644 --- a/tools/arch/x86/include/uapi/asm/unistd_64.h +++ b/tools/arch/x86/include/uapi/asm/unistd_64.h @@ -2,6 +2,9 @@ #ifndef __NR_getppid #define __NR_getppid 110 #endif +#ifndef __NR_getpgid +#define __NR_getpgid 121 +#endif #ifndef __NR_gettid #define __NR_gettid 186 #endif diff --git a/tools/perf/bench/bench.h b/tools/perf/bench/bench.h index 6cefb43..0c03f12 100644 --- a/tools/perf/bench/bench.h +++ b/tools/perf/bench/bench.h @@ -34,6 +34,7 @@ int bench_numa(int argc, const char **argv); int bench_sched_messaging(int argc, const char **argv); int bench_sched_pipe(int argc, const char **argv); int bench_syscall_basic(int argc, const char **argv); +int bench_syscall_getpgid(int argc, const char **argv); int bench_mem_memcpy(int argc, const char **argv); int bench_mem_memset(int argc, const char **argv); int bench_mem_find_bit(int argc, const char **argv); diff --git a/tools/perf/bench/syscall.c b/tools/perf/bench/syscall.c index 746fd71..6411b14 100644 --- a/tools/perf/bench/syscall.c +++ b/tools/perf/bench/syscall.c @@ -46,6 +46,9 @@ static int bench_syscall_common(int argc, const char **argv, int syscall) case __NR_getppid: getppid(); break; + case __NR_getpgid: + getpgid(0); + break; default: break; } @@ -58,6 +61,9 @@ static int bench_syscall_common(int argc, const char **argv, int syscall) case __NR_getppid: name = "getppid()"; break; + case __NR_getpgid: + name = "getpgid()"; + break; default: break; } @@ -100,3 +106,8 @@ int bench_syscall_basic(int argc, const char **argv) { return bench_syscall_common(argc, argv, __NR_getppid); } + +int bench_syscall_getpgid(int argc, const char **argv) +{ + return bench_syscall_common(argc, argv, __NR_getpgid); +} diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c index 334ab89..c9a02ac 100644 --- a/tools/perf/builtin-bench.c +++ b/tools/perf/builtin-bench.c @@ -52,6 +52,7 @@ static struct bench sched_benchmarks[] = { static struct bench syscall_benchmarks[] = { { "basic", "Benchmark for basic getppid(2) calls", bench_syscall_basic }, + { "getpgid", "Benchmark for getpgid(2) calls", bench_syscall_getpgid }, { "all", "Run all syscall benchmarks", NULL }, { NULL, NULL, NULL }, }; From patchwork Thu Nov 10 03:50:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiezhu Yang X-Patchwork-Id: 17945 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp710606wru; Wed, 9 Nov 2022 19:56:46 -0800 (PST) X-Google-Smtp-Source: AMsMyM7AIUi6qbCzJt52lO5wj3ZSVWPqj/of3lA5fS5eE8eaNo2GJOb/rAMM0of9cE/a7/0Z/3Sf X-Received: by 2002:a17:907:a64a:b0:78d:554f:fb16 with SMTP id vu10-20020a170907a64a00b0078d554ffb16mr2161644ejc.151.1668052605992; Wed, 09 Nov 2022 19:56:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668052605; cv=none; d=google.com; s=arc-20160816; b=04k2qYNtqG32QtrJEAO19weaF6+M137rrD/w+dMGRN8C7qu6BCbRnq/3NKOoiihEbu 5ZMyp/c8UD1NXTHc7Fw2RnFpeSAIwTjVeUCdNMGeUO/TKQCt4yh0VqKRB2Cqj2fSTTaT yHkvMyNHMoiYgxquN72ImzwsgNn8VGXjgMYBKON/eTm1G+xDCQB4VjKlGfe7F0Oc0uLt ECZJNs1uYVyJx27J0i3MUGXTkEg1dY5jsxfhe9qyAyT0YpU0gB0H5EmwaUbAIQp6qZIT gyX9fykddjWS/2n1VEH3FXAGcnT2J8Ct/at2orLJy2L3lpNosvTHOQ9LNv7JzXh1uSE5 gEnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=XTQqawxD9EaZ2Fa9j18f+Xz4l55OusaPdd+73NTlayw=; b=eJR02vvUhZ36NDdTJSDDrQbZXCsg+odfIpLH/Ov9xwZCpksDK68s2G7qHWO3LS1Fmx gHiT+WZJ7IU45UnHFsLKA+atCK8XcE463HZS8crPbnVH+d6GxyU6G5JzwSa1wnxF+CzM PIcby6Z6IiK2xALv699pZK9hTkw56Ypcph5IybBuro2tWmnhmzKUtVLds/p3eSzaQ1bH sXVWFpQBP1FD2PPVsRdoHSCZPqMaKnEvgDOhfzMzAfjOc9seehrKiDlV9xUUmmbyokUs JPnD2dwgVoLqR5Nt/QO4KVweZM3mWur0sKqBzGinyiVSgBCEFj7hXLxq3EjgJWDM+nHl UphA== ARC-Authentication-Results: i=1; mx.google.com; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp41-20020a1709073e2900b0078333d9f17bsi16902358ejc.819.2022.11.09.19.55.58; Wed, 09 Nov 2022 19:56:45 -0800 (PST) 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; 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 S232755AbiKJDua (ORCPT + 99 others); Wed, 9 Nov 2022 22:50:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232732AbiKJDuU (ORCPT ); Wed, 9 Nov 2022 22:50:20 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C4DCA2F3B6; Wed, 9 Nov 2022 19:50:18 -0800 (PST) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8BxGdj5dGxjl7AFAA--.16544S3; Thu, 10 Nov 2022 11:50:17 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Dx9Vb1dGxjO_4PAA--.25722S6; Thu, 10 Nov 2022 11:50:17 +0800 (CST) From: Tiezhu Yang To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo Cc: Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH v5 4/4] perf bench syscall: Add execve syscall benchmark Date: Thu, 10 Nov 2022 11:50:08 +0800 Message-Id: <1668052208-14047-5-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1668052208-14047-1-git-send-email-yangtiezhu@loongson.cn> References: <1668052208-14047-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8Dx9Vb1dGxjO_4PAA--.25722S6 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoWxAF1rKw1xJF17Jw4DZr43Wrg_yoWrCFyfpF s7Ca18Jw4ruFWYvr1aqr1DKFy3Awn7Zry5Kw12kw4DZr42g343tr4IgF9xWF17XwsrKa43 uF4kZry8Wa1rXaUanT9S1TB71UUUUj7qnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bSkYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jrv_JF1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1l84 ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AKxVW8Jr0_Cr1U M2kKe7AKxVWUAVWUtwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zV CFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUtVWrXwAv7VC2 z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxkF7I 0En4kS14v26r126r1DMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMxCI bckI1I0E14v26r126r1DMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_Jr I_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v2 6ryj6F1UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj4 0_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8 JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8_gA5UUUUU== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749079929632848822?= X-GMAIL-MSGID: =?utf-8?q?1749079929632848822?= This commit adds the execve syscall benchmark, more syscall benchmarks can be added in the future. Signed-off-by: Tiezhu Yang --- tools/arch/x86/include/uapi/asm/unistd_32.h | 3 +++ tools/arch/x86/include/uapi/asm/unistd_64.h | 3 +++ tools/perf/bench/bench.h | 1 + tools/perf/bench/syscall.c | 36 +++++++++++++++++++++++++++++ tools/perf/builtin-bench.c | 1 + 5 files changed, 44 insertions(+) diff --git a/tools/arch/x86/include/uapi/asm/unistd_32.h b/tools/arch/x86/include/uapi/asm/unistd_32.h index 053122c..2712d5e 100644 --- a/tools/arch/x86/include/uapi/asm/unistd_32.h +++ b/tools/arch/x86/include/uapi/asm/unistd_32.h @@ -1,4 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __NR_execve +#define __NR_execve 11 +#endif #ifndef __NR_getppid #define __NR_getppid 64 #endif diff --git a/tools/arch/x86/include/uapi/asm/unistd_64.h b/tools/arch/x86/include/uapi/asm/unistd_64.h index 54a6c4d..a6f7fe8 100644 --- a/tools/arch/x86/include/uapi/asm/unistd_64.h +++ b/tools/arch/x86/include/uapi/asm/unistd_64.h @@ -1,4 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __NR_execve +#define __NR_execve 59 +#endif #ifndef __NR_getppid #define __NR_getppid 110 #endif diff --git a/tools/perf/bench/bench.h b/tools/perf/bench/bench.h index 0c03f12..4588d3a 100644 --- a/tools/perf/bench/bench.h +++ b/tools/perf/bench/bench.h @@ -35,6 +35,7 @@ int bench_sched_messaging(int argc, const char **argv); int bench_sched_pipe(int argc, const char **argv); int bench_syscall_basic(int argc, const char **argv); int bench_syscall_getpgid(int argc, const char **argv); +int bench_syscall_execve(int argc, const char **argv); int bench_mem_memcpy(int argc, const char **argv); int bench_mem_memset(int argc, const char **argv); int bench_mem_find_bit(int argc, const char **argv); diff --git a/tools/perf/bench/syscall.c b/tools/perf/bench/syscall.c index 6411b14..fe79f7f 100644 --- a/tools/perf/bench/syscall.c +++ b/tools/perf/bench/syscall.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -30,6 +31,27 @@ static const char * const bench_syscall_usage[] = { NULL }; +static void test_execve(void) +{ + const char *pathname = "/bin/true"; + char *const argv[] = { (char *)pathname, NULL }; + pid_t pid = fork(); + + if (pid < 0) { + fprintf(stderr, "fork failed\n"); + exit(1); + } else if (pid == 0) { + execve(pathname, argv, NULL); + fprintf(stderr, "execve /bin/true failed\n"); + exit(1); + } else { + if (waitpid(pid, NULL, 0) < 0) { + fprintf(stderr, "waitpid failed\n"); + exit(1); + } + } +} + static int bench_syscall_common(int argc, const char **argv, int syscall) { struct timeval start, stop, diff; @@ -49,6 +71,12 @@ static int bench_syscall_common(int argc, const char **argv, int syscall) case __NR_getpgid: getpgid(0); break; + case __NR_execve: + test_execve(); + /* Only loop 10000 times to save time */ + if (i == 10000) + loops = 10000; + break; default: break; } @@ -64,6 +92,9 @@ static int bench_syscall_common(int argc, const char **argv, int syscall) case __NR_getpgid: name = "getpgid()"; break; + case __NR_execve: + name = "execve()"; + break; default: break; } @@ -111,3 +142,8 @@ int bench_syscall_getpgid(int argc, const char **argv) { return bench_syscall_common(argc, argv, __NR_getpgid); } + +int bench_syscall_execve(int argc, const char **argv) +{ + return bench_syscall_common(argc, argv, __NR_execve); +} diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c index c9a02ac..35f9df8 100644 --- a/tools/perf/builtin-bench.c +++ b/tools/perf/builtin-bench.c @@ -53,6 +53,7 @@ static struct bench sched_benchmarks[] = { static struct bench syscall_benchmarks[] = { { "basic", "Benchmark for basic getppid(2) calls", bench_syscall_basic }, { "getpgid", "Benchmark for getpgid(2) calls", bench_syscall_getpgid }, + { "execve", "Benchmark for execve(2) calls", bench_syscall_execve }, { "all", "Run all syscall benchmarks", NULL }, { NULL, NULL, NULL }, };