Received: by 10.223.185.116 with SMTP id b49csp7576734wrg; Thu, 1 Mar 2018 07:41:11 -0800 (PST) X-Google-Smtp-Source: AG47ELvQ7ik4qc18fx9xm0SDDEaiQ7MPTWaJz5xNesYjEanOoXx+PrS11CQAWAeSrShvypAR0dDK X-Received: by 10.99.125.92 with SMTP id m28mr1906811pgn.257.1519918871008; Thu, 01 Mar 2018 07:41:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519918870; cv=none; d=google.com; s=arc-20160816; b=ADx9RGfvb73CmyuUy0JNtW7EMpKL8mZPSddnCf/nycKiHEt1U2wRpf47vQa0mFqVTF 62n1WM6VmLYF2I8ZV3z1DRLnJtNrzgCDX1OpuGViCNYMFHOp/Xxup2HVS05hY7cMbord BMYu43QQw24O9Qa0FxEcIXU5muf0qUS7VpgADtDmKh90aFEuWZxuV2tK71p0aVqszl/7 POJBI7sU5wJ9v4QUeU/OBhB8ITAeC5xAUjK+5NoMj++BkYD/h8zRIUKs6nSANlPSprQJ mnwjqCHBrIHm+3PMb/bzJRc34+hbkOmwd6LmPslp3RJe4CHRJm/GVoDqiZLlYXmc5fAR DYmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:mime-version:user-agent:date:message-id :organization:cc:to:subject:from:arc-authentication-results; bh=Wjp5JcXCeRRQi+HTrB+b50wNGEa/TvN8HX/NNDe8yOg=; b=FEAz+eL4pSLOctS8dNet3T5MxspULa0mXQaDys1/6Xm1H/vEIR6JbsD3xgXR+Z4O+J 7IUqdGPEfEw7/Tudm6K9zPBDpWDZP+i5jNYY6qUV4QXO2RaViQPhbeXI+cjI6ThZSbLh 85xX/sCyhZJyVebg7GQwLx8KvyTGqDM3ZMZFdoAyHV9JWlUdK+H7lDH/6cbIGcsFzn8Z EuynEI1CDKvDLVGesc49GwE2uB/WgrZgkvlJA9YP7JwcR9jT8pFZsG8K3aBA9C8jSSDs 35901jhDox55Ztdaiu7N8E5QKPOZzd/oFOjvdVmZN5MtR6Tqa+/QsjOJUAmpdAtaD44y FhxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t25si2555304pge.714.2018.03.01.07.40.55; Thu, 01 Mar 2018 07:41:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032659AbeCAPkP (ORCPT + 99 others); Thu, 1 Mar 2018 10:40:15 -0500 Received: from mga14.intel.com ([192.55.52.115]:18846 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032646AbeCAPkK (ORCPT ); Thu, 1 Mar 2018 10:40:10 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Mar 2018 07:40:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,408,1515484800"; d="scan'208";a="208109396" Received: from linux.intel.com ([10.54.29.200]) by fmsmga006.fm.intel.com with ESMTP; 01 Mar 2018 07:40:10 -0800 Received: from [10.249.228.87] (abudanko-mobl3.ccr.corp.intel.com [10.249.228.87]) by linux.intel.com (Postfix) with ESMTP id 11CA05802A9; Thu, 1 Mar 2018 07:40:06 -0800 (PST) From: Alexey Budankov Subject: [RFC PATCH] perf/core: exposing type of context-switch-out event To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo Cc: Alexander Shishkin , Jiri Olsa , Namhyung Kim , Andi Kleen , linux-kernel , Dmitri Prokhorov Organization: Intel Corp. Message-ID: <06006a92-3745-0785-cb11-ddbf70e84ded@linux.intel.com> Date: Thu, 1 Mar 2018 18:40:04 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, This patch prototypes exposing the type of context-switch-out event using PERF_RECORD_MISC_EXT_RESERVED bit for PERF_RECORD_SWITCH[_CPU_WIDE] records. Types of context-switch-out events introduced by the patch meant to be a) preempted (task->state == TASK_RUNNING) or b) yielded == !preempted; The changes have been manually tested on Fedora 27 with the patched kernel: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf/core Signed-off-by: Alexey Budankov --- kernel/events/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 57898102847f..e3ca597f4e2b 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -7216,6 +7216,8 @@ static void perf_event_switch(struct task_struct *task, struct task_struct *next_prev, bool sched_in) { struct perf_switch_event switch_event; + __u16 switch_type = sched_in ? 0 : PERF_RECORD_MISC_SWITCH_OUT | + (task->state == TASK_RUNNING ? 0 : PERF_RECORD_MISC_EXT_RESERVED); /* N.B. caller checks nr_switch_events != 0 */ @@ -7225,7 +7227,7 @@ static void perf_event_switch(struct task_struct *task, .event_id = { .header = { /* .type */ - .misc = sched_in ? 0 : PERF_RECORD_MISC_SWITCH_OUT, + .misc = switch_type, /* .size */ }, /* .next_prev_pid */