Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp935612pxu; Wed, 2 Dec 2020 07:07:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDxdVZkn+bHdEPz4grx72N3jDgHuDuomHlT2RndlZ2K75FNgkx9D3Fti/GG+T4iBSNXvDe X-Received: by 2002:a50:da84:: with SMTP id q4mr268468edj.377.1606921620228; Wed, 02 Dec 2020 07:07:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606921620; cv=none; d=google.com; s=arc-20160816; b=Vo0JDD9dmmvfQFG79au0SgAEBBOpKBSUkTWj0W1qLLTvhsdZA3uPnnV6cSbSNc5qqk ZdmdMrj3s7mM4dwGg5Txl9hEQ5q40pTc3y4oFt+zUKwte/1hm04BV3qSB1SpRRh5Hzfg XVeFl9YfSYvtDrKKnraKay/qQtOBj7oMttfA42AgzuTbC2ZsQiq6D5h4x+2UIl9vnpLL ojRCLrPm4oI1m6t9ZJQzGt+64zr1fegebgy534L/lod4FR/Dt6ChUuXy7oVAB5r1WFOI ZNK9iPFzeZVOx09kViOEgoV+pm2scbeoDE8Ae1TYeF0oH0XdfxdOgdjbvBQXitD4yyNQ 8etA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=TCNWVU3OO9+0a2PLnvLJqeJ15b3W1+9HfAOGKsoXdvY=; b=y71jiwBr8snSNpGsTYjGy8ZnuRDt6JAUbOJLEavhE0NFC/CNqujrARoYOw3836Zx5f Qoqcx4u9r8JOe9A/mV8PgDi3uvpsEnaD6nYrMZL0EOY0j2nQ3ksFr1oK+CCdrxFt7wIf D21GpjqoDUFus2Q/S1ovOTGi1xbIH2rqHZEfAyU016rienKqKLhOEdBHlP/ts/imBnUJ 4yyblIOeQOjBs021qazAWRdFFcbk8HLBhPbXwPYvOgAF0zB/K6i4uOHQEp9ud7vqdx6N frugEuM0GmZFaSWXNGiCH16l8YAjlRIZc0/wClouQyr4mzvK1VQwQDfLNmcZsd2JokoG SCjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R2w5VlCq; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l13si133574edj.64.2020.12.02.07.06.35; Wed, 02 Dec 2020 07:07:00 -0800 (PST) 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=20161025 header.b=R2w5VlCq; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730392AbgLBPDD (ORCPT + 99 others); Wed, 2 Dec 2020 10:03:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727753AbgLBPDC (ORCPT ); Wed, 2 Dec 2020 10:03:02 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1AAEC061A04 for ; Wed, 2 Dec 2020 07:02:22 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id f17so1231372pge.6 for ; Wed, 02 Dec 2020 07:02:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TCNWVU3OO9+0a2PLnvLJqeJ15b3W1+9HfAOGKsoXdvY=; b=R2w5VlCqnUAKCmplTH05qDd0jfpG8yXufUohoN6vsOA/O3G3StNShI30DdZ2mc3Lo1 GpWuCAKq0Pj3ou8NZ3TcZZVSquPyOW98vOQh6SBb9qZG+UUajzNBVonxtX3FI461+yPt SswTzNe5G7TBFSg3H+PQmGWCNoajJ2hqBtC/M2XiRnm40zzKZHPnu2IJ9s3Tp1X818rH LfYqqkl1qVu0uMhUf5R57BUk1RusnOjjwvaTefze6dyDAFkRQZap9vuXyDzUy/Nabidc p9dVHdeTy58Pyg4fzwBw8yXeodoQU401GDzUhB8BMO3bsD52vmjW3+PAQyO7dDlaDpxy 2BWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=TCNWVU3OO9+0a2PLnvLJqeJ15b3W1+9HfAOGKsoXdvY=; b=eK4zO5q+w1KzsZTY8oFQWVmThWeywGZHCK/hd0w0nmJNyqF5V3G8cvO7TNURPsGGBV oShLvsie3ApkxGHB3kHsmBJetu9QalJFZTVdDzKRWRHNfo0sqaeHgATX5LG0PLshwz3n L4yaBFeWjXBhTU4ij0hdTLcDuwN4l4px8QEpVfdtyOwuVz02tp3zTDYNSZsAbxF8NhRj P32p7+j+SChzl7jRYv/pU+RdGSpI2kDPRshLpA4L4nLEurN2ru8OUxEBAtx9f9JnxLrH aWJglZNOjH3+W43+Y3imbUv+QcO0xWG2eggGiiszlw1C5xgSHJTUB8zTZCh+El0GGcZ9 amGw== X-Gm-Message-State: AOAM532XnqVBSFOiYqbPyplxpKBar72SZCHhSX4anwUrZw4zPgM/bwAE otP//wsqj7FcxAUEJm9T/zw= X-Received: by 2002:aa7:9501:0:b029:155:3b11:d5c4 with SMTP id b1-20020aa795010000b02901553b11d5c4mr2896375pfp.76.1606921342353; Wed, 02 Dec 2020 07:02:22 -0800 (PST) Received: from balhae.roam.corp.google.com ([101.235.31.111]) by smtp.gmail.com with ESMTPSA id gz2sm82773pjb.2.2020.12.02.07.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 07:02:21 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa , Ingo Molnar , Peter Zijlstra Cc: Mark Rutland , Alexander Shishkin , LKML , Stephane Eranian , Ian Rogers , Andi Kleen Subject: [RFC 2/2] perf tools: Add 'cgroup-switches' software event Date: Thu, 3 Dec 2020 00:02:05 +0900 Message-Id: <20201202150205.35750-2-namhyung@kernel.org> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog In-Reply-To: <20201202150205.35750-1-namhyung@kernel.org> References: <20201202150205.35750-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It counts how often cgroups are changed actually during the context switches. # perf stat -a -e context-switches,cgroup-switches -a sleep 1 Performance counter stats for 'system wide': 11,267 context-switches 10,950 cgroup-switches 1.015634369 seconds time elapsed Signed-off-by: Namhyung Kim --- tools/include/uapi/linux/perf_event.h | 1 + tools/perf/util/parse-events.c | 4 ++++ tools/perf/util/parse-events.l | 1 + 3 files changed, 6 insertions(+) diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h index b95d3c485d27..16559703c49c 100644 --- a/tools/include/uapi/linux/perf_event.h +++ b/tools/include/uapi/linux/perf_event.h @@ -112,6 +112,7 @@ enum perf_sw_ids { PERF_COUNT_SW_EMULATION_FAULTS = 8, PERF_COUNT_SW_DUMMY = 9, PERF_COUNT_SW_BPF_OUTPUT = 10, + PERF_COUNT_SW_CGROUP_SWITCHES = 11, PERF_COUNT_SW_MAX, /* non-ABI */ }; diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 3b273580fb84..f6a5a099e143 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -145,6 +145,10 @@ struct event_symbol event_symbols_sw[PERF_COUNT_SW_MAX] = { .symbol = "bpf-output", .alias = "", }, + [PERF_COUNT_SW_CGROUP_SWITCHES] = { + .symbol = "cgroup-switches", + .alias = "", + }, }; #define __PERF_EVENT_FIELD(config, name) \ diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l index 9db5097317f4..88f203bb6fab 100644 --- a/tools/perf/util/parse-events.l +++ b/tools/perf/util/parse-events.l @@ -347,6 +347,7 @@ emulation-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_EM dummy { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_DUMMY); } duration_time { return tool(yyscanner, PERF_TOOL_DURATION_TIME); } bpf-output { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_BPF_OUTPUT); } +cgroup-switches { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CGROUP_SWITCHES); } /* * We have to handle the kernel PMU event cycles-ct/cycles-t/mem-loads/mem-stores separately. -- 2.29.2.454.gaff20da3a2-goog