From patchwork Wed Nov 9 08:29:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiezhu Yang X-Patchwork-Id: 17396 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp217336wru; Wed, 9 Nov 2022 00:33:21 -0800 (PST) X-Google-Smtp-Source: AMsMyM77Kz31LHzEDJ4nklvDlXilsZsip/vH5/k+4Dqq8fdPckGAj9ALg5mCHf2ApjZN7cX0oVhm X-Received: by 2002:a17:902:ef4c:b0:186:6399:6b48 with SMTP id e12-20020a170902ef4c00b0018663996b48mr61734197plx.128.1667982801309; Wed, 09 Nov 2022 00:33:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667982801; cv=none; d=google.com; s=arc-20160816; b=bppgqyfsNakT5/IqTT/K/2BX//ZbAHPKxXpNdcGmJStVhsypWnYXdKl8kxsXGF6+qh V/1gJJ5KAdEyDKVi1WaneHYY8dOAaVHYdWT/Py/bl33XAgdwwwR9aI8GXbWVRTb6xinl BlBMuGv1iwCRAzcbusG3Ha6Sj3SiiDLRNDwtjmvf+X/75tXn7HJgkvAMRH+u3q1xQbmZ GHlDsZzrbt37vAR41Yd1NeZtHzC7HbZocN8NXkrhmvDZNCeiS6J5bZHgeqLHBn+0LvVg QxSSDofGv4Nr0+9xwmAO8N8a7yDhh/2TqOkw22QIco4oxkYebEQEIRtHmxk0MaOhyz9i Ajow== 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=vo0WqGsHx+/BuDadc+jSAGT8WRaNUGETPC71e+GTIiaqD4t+p5aQbbt5YAtHNfaYz7 kqRz73m4/PvhhA5/08OOHUf39ay0d+56XjMyxcUuq6jr6fEo8SE0QHy5MggvLR4Kkxci IGkHJbXr/aEd4oPL/xGw6K+bGH32ncktBkEWws4fc1vBkAGlOQFb3D7Ox9wNEeQaI4bO GPq4U9LGI2Mqj9lqrZDkj1zAY95SDeMGU9hZmh5uwXczuYw0SDNr60+ClS9fh5bLutOg 3rdKCTlreGzWVSGRZQK2zgpD+wviyBgsdnaNjT+BpIJWRx6OCiSzPv61aXvOOi/ARR3l yuqg== 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 ja18-20020a170902efd200b00186c9d17afbsi15238708plb.293.2022.11.09.00.33.08; Wed, 09 Nov 2022 00:33:21 -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 S229829AbiKIIav (ORCPT + 99 others); Wed, 9 Nov 2022 03:30:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229995AbiKIIaT (ORCPT ); Wed, 9 Nov 2022 03:30:19 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EA37422B04; Wed, 9 Nov 2022 00:29:19 -0800 (PST) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8Dx_7fVZGtjdYEFAA--.16102S3; Wed, 09 Nov 2022 16:29:09 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxtuPTZGtjJnIPAA--.42697S3; Wed, 09 Nov 2022 16:29:08 +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 v4 1/4] tools x86: Keep list sorted by number in unistd_{32,64}.h Date: Wed, 9 Nov 2022 16:29:04 +0800 Message-Id: <1667982547-22331-2-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1667982547-22331-1-git-send-email-yangtiezhu@loongson.cn> References: <1667982547-22331-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8BxtuPTZGtjJnIPAA--.42697S3 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?1749006733582526643?= X-GMAIL-MSGID: =?utf-8?q?1749006733582526643?= 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 Wed Nov 9 08:29: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: 17395 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp217330wru; Wed, 9 Nov 2022 00:33:20 -0800 (PST) X-Google-Smtp-Source: AMsMyM7JH30gM2RSn097VUG2QwhCDMp7T9yPSA+4PRVpgaUmpxvbRmFuxreRzANNMjg3IpMgw5hH X-Received: by 2002:a17:90b:390b:b0:213:d517:f408 with SMTP id ob11-20020a17090b390b00b00213d517f408mr54334781pjb.158.1667982800248; Wed, 09 Nov 2022 00:33:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667982800; cv=none; d=google.com; s=arc-20160816; b=iyZwN89QrINoWPyVuqmIk7Wi0fft91ToP/IcwfCSQEKME3/q9NmAVZi5GvUMEp1isi fbDnbfiDWU1BlsQmdFfb5KixBLEReNPMpkXwK3RGQeSfSVIHCKp/n07mqsQj4RwJyoxk DciIdYHX5yr3Zi1oZsQUR8bWyihJkq49GY1NdGiF1J96W6WooNDcT93ghRhIemgiGLlz n1ywp7y9EPNTF1vkw5ixvD7rqi56gkIUPtkSNGdoew6dvntRpBD2ga+f7vmhJG2mm2/k eW0PE1TJvtBoKcbc6s+477qVGZ6lBKGvrtzIGskIGVgNAJ8H3DyoEyxmJeOCQ0U128Qz 4BjA== 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=yhBG4bnvZxpncN8zvHcyWXPsf2anRVM8SG7CT0pZFA4Wya3sNN5qVUiUZ9F1kSjl5p UKyU643TfCcufzVHneDolwdfwE+Jx9L4X67k4zjLC9yxPdq+NEyDOf58b/HjUDxOVZa3 sOdElFhdbUxcxqgNMuSgjmdtJ1CLNH3Vr2yHVi/Pc3HTY1HBwAfThvuWxo37q+BwsZEY 7MfdiSWNQwrnoIHXIY363yiMcMSxuCe1/g3YmhN9rrCXPaKqQANNb5XIkdYZN81F4loJ 4v9PWgF+seJvbhoUTQGX0kPFWLMcDGi6o98ZfQfI0SLaQ1MW6ceDZ3WzHvrqUM6lGhXW CHYg== 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 2-20020a621902000000b0054ed3047ee2si15579595pfz.22.2022.11.09.00.33.07; Wed, 09 Nov 2022 00:33:20 -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 S230153AbiKIIar (ORCPT + 99 others); Wed, 9 Nov 2022 03:30:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229979AbiKIIaT (ORCPT ); Wed, 9 Nov 2022 03:30:19 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EA53722B09; Wed, 9 Nov 2022 00:29:19 -0800 (PST) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8BxbbbXZGtjf4EFAA--.5988S3; Wed, 09 Nov 2022 16:29:11 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxtuPTZGtjJnIPAA--.42697S4; Wed, 09 Nov 2022 16:29:09 +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 v4 2/4] perf bench syscall: Introduce bench_syscall_common() Date: Wed, 9 Nov 2022 16:29:05 +0800 Message-Id: <1667982547-22331-3-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1667982547-22331-1-git-send-email-yangtiezhu@loongson.cn> References: <1667982547-22331-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8BxtuPTZGtjJnIPAA--.42697S4 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoWxJFWruF1UCr18KF17Zr18Zrb_yoW5Wr43pF 9rAw4kJF4ruaya9r1fXF10gry5Jr97Cr15Kry293s5ZrWxt343tr47KF9IvF17u3yIka45 WFs3ZrWUWa1UXaUanT9S1TB71UUUUj7qnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bSxYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_JF0_JFyl8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1l n4kS14v26r126r1DM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6x ACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q6rW5McIj6I8E 87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc7CjxV Aaw2AFwI0_JF0_Jw1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l4IxY O2xFxVAFwI0_JF0_Jw1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGV WUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_ Xr0_Ar1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rV WUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4U JbIYCTnIWIevJa73UjIFyTuYvjxU4eMKDUUUU 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?1749006732628884367?= X-GMAIL-MSGID: =?utf-8?q?1749006732628884367?= 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 Wed Nov 9 08:29: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: 17408 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp223430wru; Wed, 9 Nov 2022 00:53:21 -0800 (PST) X-Google-Smtp-Source: AMsMyM7wCxpHfRLfnfYQvjLvYZWNkkfPdFi+4P3TBBjBHgTjBuTqX2sQueKZrbp246Mc8RFekbtW X-Received: by 2002:a17:90a:4745:b0:214:100a:65c8 with SMTP id y5-20020a17090a474500b00214100a65c8mr44045168pjg.105.1667984001529; Wed, 09 Nov 2022 00:53:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667984001; cv=none; d=google.com; s=arc-20160816; b=OUfRRiFb9wfvWxpa7pn0oIRfexSIun/FJPlQGrIgaVYY6T+Xjo9FfM16WB2NBM+fYC e4maPMjShyZ2UGmCygqWVLgvvkstEb11PZZcbE4Ojyl7HZ8ahcb+xkBDIIRxGaEl/kEt Hq/5BvlUXWnNXERJXlKqI1Osa7rnB0WZZIotAX/AHcTdnNJyzhv3pvEtyC7sZej74Wz9 +QWWTrFoSVg7FReyELOzaEBT0kdZB7TSIdLz0TZSuGZplARrmuGYYiMdH3dVhcmiA6ls ri+ueS3PrSS2lMjIY6gckKbJ0gMJ/I8M6sL18+xseeqV8BaJlAEERapzC/3+r7/fMjeg 59kg== 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=RJr0wA582tObpLjGkPrV81pbRCL92tNFMlfnw82H+7k=; b=kBPn7+hl92nL48nqyQImo94fbMcd05nLpcHcG+Zix0pfhlOfk8EUBl4QKxszy5JNkC 9gNNCYXXUZD28urwX250STafPyqraqJrmPI74+vgLHlIsC8+YdSh6ig18hd2B1VBPNpk Kv+mEZ9M77Ah6LLuPhfbdcCFvXSBetBVdI0XJqWT+H+9/LvFltEIdWUiK68yNo+dznEF BGR/S1thR/MhW7x2wWthPfwhtiJaZHH+uMNS0MyoSufto8F8g/AAZcsS2Hxed23IVOVI Nk0JONrrHfoTvMw3cPGBziWcT53cIXhZRAEikXx1Hj9Z4zoLa8VOcyF48TkYSe0xc2l8 73+g== 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 h13-20020a63f90d000000b00439ae523fd2si17749078pgi.289.2022.11.09.00.53.05; Wed, 09 Nov 2022 00:53:21 -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 S230161AbiKIIax (ORCPT + 99 others); Wed, 9 Nov 2022 03:30:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230028AbiKIIaT (ORCPT ); Wed, 9 Nov 2022 03:30:19 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 426AD22B10; Wed, 9 Nov 2022 00:29:19 -0800 (PST) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8DxTtvXZGtjgYEFAA--.17858S3; Wed, 09 Nov 2022 16:29:11 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxtuPTZGtjJnIPAA--.42697S5; Wed, 09 Nov 2022 16:29:10 +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 v4 3/4] perf bench syscall: Add getpgrp syscall benchmark Date: Wed, 9 Nov 2022 16:29:06 +0800 Message-Id: <1667982547-22331-4-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1667982547-22331-1-git-send-email-yangtiezhu@loongson.cn> References: <1667982547-22331-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8BxtuPTZGtjJnIPAA--.42697S5 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoWxAF17Zr13ZFWUZF4rury8Zrb_yoW5uw43pF 97Cw48Aw4rWFWYvw1Iqr10gry7AwnrZryrK3Wak3yDZrW2q343tr47KFy3WF17Zw47ta45 uFs7ZrW8X3WrJaUanT9S1TB71UUUUj7qnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj 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?1749007991968540730?= X-GMAIL-MSGID: =?utf-8?q?1749007991968540730?= This commit adds a simple getpgrp 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..2bcf47f 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_getpgrp +#define __NR_getpgrp 65 +#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..5472203 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_getpgrp +#define __NR_getpgrp 111 +#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..7ccc021 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_getpgrp(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..2b89884 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_getpgrp: + getpgrp(); + 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_getpgrp: + name = "getpgrp()"; + 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_getpgrp(int argc, const char **argv) +{ + return bench_syscall_common(argc, argv, __NR_getpgrp); +} diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c index 334ab89..20ca4ac 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 }, + { "getpgrp", "Benchmark for getpgrp(2) calls", bench_syscall_getpgrp }, { "all", "Run all syscall benchmarks", NULL }, { NULL, NULL, NULL }, }; From patchwork Wed Nov 9 08:29: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: 17397 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp220405wru; Wed, 9 Nov 2022 00:43:31 -0800 (PST) X-Google-Smtp-Source: AMsMyM7mfnr9iMtI5nYdi1qO9tCBJhTMOdRtxG6jrQL8tC1kMvsc6mpq6r55rMYObZps7Gx13Q9i X-Received: by 2002:a17:907:3fa7:b0:7ad:e0cf:417d with SMTP id hr39-20020a1709073fa700b007ade0cf417dmr43347718ejc.577.1667983411464; Wed, 09 Nov 2022 00:43:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667983411; cv=none; d=google.com; s=arc-20160816; b=IP+k27Ju6tXwV/Zh7nd8EOtKkaF4LdXOKd0AxcvOv5SkYfp8BflokmZ0QMPiwxCkYS 4C4BosT8XoaRIAj9K25Ix4/WuLfhhpi2BbVFjEsDMEAxS4b7cRJrnLFTeWMihGwt7X6D z8hljAcamhyT5mdz8pRI5M2k7gEHFJSHJri9bkK2KsMS/QoaMpA+arPF6AYed19rBB6Z KfBy3r6ybIqZCjVT2mY9nV7sTa072tkfri/7l9Jlt9+e8WS4AKDxNmgNAQ8mD2TzbR2e QFb6qPFLq9fyOSeVF4iGccG61ehBnIKuD14tkfrR96ipen34in9FkEUz3YpfhuwoCpI1 lluQ== 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=ngiuBnJTn7JJ3jpNlebiCG1Tkwn2UY9+vYCUMYT0wOY=; b=Nmhk6y+WYOlDr0FbwKb2sDKS1N/OeTaaB27NE1kXa+BBMC1tfOx0KSnKQiq/dNhySu szRXl30nYvZqrqQpd+Dt5nPF4dbrgDx8d7GEM78HKbPDpQA+6rN0eUQ2SDmLeKZbbd7D 3YyhSSclS2KgIGr/zM5WLyliE2Zrjo3/R+6qU/+fmUd9I/zKdT7Vc131ah8b+AnZ9l+4 qcp8DNr1YHpLjV7mBPFGX8pg8ONHSE1Ud/clSrZmcdGhOvD7JlVQ9fvPnODS5hb9My0m M6o6airPaxiqlhMemGJbkJzfoY+SwBDcZQxz6xJoEktJELyW6aU3W0fmNJxZkZbCS3vy IuIg== 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 e13-20020a17090658cd00b007ae61d89b4bsi12428997ejs.283.2022.11.09.00.43.06; Wed, 09 Nov 2022 00:43:31 -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 S230164AbiKIIa6 (ORCPT + 99 others); Wed, 9 Nov 2022 03:30:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230032AbiKIIaU (ORCPT ); Wed, 9 Nov 2022 03:30:20 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8CA9122B19; Wed, 9 Nov 2022 00:29:20 -0800 (PST) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8Bx37fYZGtjh4EFAA--.12874S3; Wed, 09 Nov 2022 16:29:12 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxtuPTZGtjJnIPAA--.42697S6; Wed, 09 Nov 2022 16:29:11 +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 v4 4/4] perf bench syscall: Add execve syscall benchmark Date: Wed, 9 Nov 2022 16:29:07 +0800 Message-Id: <1667982547-22331-5-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1667982547-22331-1-git-send-email-yangtiezhu@loongson.cn> References: <1667982547-22331-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8BxtuPTZGtjJnIPAA--.42697S6 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoWxAF13JryxJF1UCw1rAF4ktFb_yoWrCFy3pF s7Ca18Jws5WFWYvr13tr1DKFy3Awn7Zry5Kw17C3yDZr42g343tr42gFy3GF17XwsrK343 uFs7Zry8Wa1rXaUanT9S1TB71UUUUj7qnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bSkYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_JF0_JFyl8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1l84 ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AKxVW8Jr0_Cr1U M2kKe7AKxVWUAVWUtwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zV CFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUtVWrXwAv7VC2 z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxkF7I 0En4kS14v26r126r1DMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMxCI bckI1I0E14v26r126r1DMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_Jr I_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v2 6ryj6F1UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj4 0_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8 JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8Gii3UUUUU== 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?1749007373513049858?= X-GMAIL-MSGID: =?utf-8?q?1749007373513049858?= 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 2bcf47f..d20b43c 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 5472203..80d4d90 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 7ccc021..9d6f692 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_getpgrp(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 2b89884..c71334c 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_getpgrp: getpgrp(); 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_getpgrp: name = "getpgrp()"; break; + case __NR_execve: + name = "execve()"; + break; default: break; } @@ -111,3 +142,8 @@ int bench_syscall_getpgrp(int argc, const char **argv) { return bench_syscall_common(argc, argv, __NR_getpgrp); } + +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 20ca4ac..ace7a2a 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 }, { "getpgrp", "Benchmark for getpgrp(2) calls", bench_syscall_getpgrp }, + { "execve", "Benchmark for execve(2) calls", bench_syscall_execve }, { "all", "Run all syscall benchmarks", NULL }, { NULL, NULL, NULL }, };