From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DAA2C433EF for ; Mon, 8 Nov 2021 11:32:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 36F5A60F14 for ; Mon, 8 Nov 2021 11:32:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239262AbhKHLez (ORCPT ); Mon, 8 Nov 2021 06:34:55 -0500 Received: from foss.arm.com ([217.140.110.172]:49284 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237827AbhKHLey (ORCPT ); Mon, 8 Nov 2021 06:34:54 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 571852B; Mon, 8 Nov 2021 03:32:09 -0800 (PST) Received: from [10.1.35.131] (e127744.cambridge.arm.com [10.1.35.131]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1452E3F800; Mon, 8 Nov 2021 03:32:06 -0800 (PST) Subject: Re: [PATCH 1/3] perf arm-spe: Track task context switch for cpu-mode events To: Arnaldo Carvalho de Melo , Leo Yan Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Namhyung Kim , John Garry , Will Deacon , Mathieu Poirier , Mark Rutland , Alexander Shishkin , Jiri Olsa , linux-arm-kernel@lists.infradead.org References: <20211102180739.18049-1-german.gomez@arm.com> <20211102180739.18049-2-german.gomez@arm.com> <20211106032907.GG477387@leoy-ThinkPad-X240s> From: German Gomez Message-ID: <2d6b41a0-2ded-d8c8-630a-d418a0ef285a@arm.com> Date: Mon, 8 Nov 2021 11:32:05 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/11/2021 19:49, Arnaldo Carvalho de Melo wrote: > Em Sat, Nov 06, 2021 at 11:29:07AM +0800, Leo Yan escreveu: >> [...] >> Reviewed-by: Leo Yan >> >> Note for one thing, please keep "Namhyung Kim" as the author for this >> patch, thanks. > This merits a v2 submission, please do so. > > - Arnaldo > Will do, Also will fix the authorship of [2/3]. Thanks, German >> Leo >> >>> --- >>> tools/perf/arch/arm64/util/arm-spe.c | 6 +++++- >>> tools/perf/util/arm-spe.c | 25 +++++++++++++++++++++++++ >>> 2 files changed, 30 insertions(+), 1 deletion(-) >>> >>> diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c >>> index a4420d4df..58ba8d15c 100644 >>> --- a/tools/perf/arch/arm64/util/arm-spe.c >>> +++ b/tools/perf/arch/arm64/util/arm-spe.c >>> @@ -166,8 +166,12 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, >>> tracking_evsel->core.attr.sample_period = 1; >>> >>> /* In per-cpu case, always need the time of mmap events etc */ >>> - if (!perf_cpu_map__empty(cpus)) >>> + if (!perf_cpu_map__empty(cpus)) { >>> evsel__set_sample_bit(tracking_evsel, TIME); >>> + evsel__set_sample_bit(tracking_evsel, CPU); >>> + /* also track task context switch */ >>> + tracking_evsel->core.attr.context_switch = 1; >>> + } >>> >>> return 0; >>> } >>> diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c >>> index 58b7069c5..230bc7ab2 100644 >>> --- a/tools/perf/util/arm-spe.c >>> +++ b/tools/perf/util/arm-spe.c >>> @@ -681,6 +681,25 @@ static int arm_spe_process_timeless_queues(struct arm_spe *spe, pid_t tid, >>> return 0; >>> } >>> >>> +static int arm_spe_context_switch(struct arm_spe *spe, union perf_event *event, >>> + struct perf_sample *sample) >>> +{ >>> + pid_t pid, tid; >>> + int cpu; >>> + >>> + if (!(event->header.misc & PERF_RECORD_MISC_SWITCH_OUT)) >>> + return 0; >>> + >>> + pid = event->context_switch.next_prev_pid; >>> + tid = event->context_switch.next_prev_tid; >>> + cpu = sample->cpu; >>> + >>> + if (tid == -1) >>> + pr_warning("context_switch event has no tid\n"); >>> + >>> + return machine__set_current_tid(spe->machine, cpu, pid, tid); >>> +} >>> + >>> static int arm_spe_process_event(struct perf_session *session, >>> union perf_event *event, >>> struct perf_sample *sample, >>> @@ -718,6 +737,12 @@ static int arm_spe_process_event(struct perf_session *session, >>> } >>> } else if (timestamp) { >>> err = arm_spe_process_queues(spe, timestamp); >>> + if (err) >>> + return err; >>> + >>> + if (event->header.type == PERF_RECORD_SWITCH_CPU_WIDE || >>> + event->header.type == PERF_RECORD_SWITCH) >>> + err = arm_spe_context_switch(spe, event, sample); >>> } >>> >>> return err; >>> -- >>> 2.25.1 >>> From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B478C433F5 for ; Mon, 8 Nov 2021 11:33:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 14E7561288 for ; Mon, 8 Nov 2021 11:33:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 14E7561288 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:Subject:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=fSjjYJfLfutV65P+0s6F8e27Xuys7RahfxHgcmXjS6M=; b=RBodqc2jbw+TXnjtz7EgWFF9Yn wsyMgPqRBJMzyXoSSxomF7lQzwFML/kqrEROiT/pJchJwmYZk5j8FqH9thjhQsOstrEapIEBvd2sV phBgjoLXT/pwo6mYqsXs5xIo/gsunOPre6Do1/TBYSndIJQX1CEsqyzg3mW2WJpxD6UsfMUEnP/J3 /lDNTI3r4vTiHHWSdT1H/XgB+7VBc8qHOgixqayStEbEDNvqbRu7+H4JicRXLWPuJ8oGQn4Fp4upY E4McVJCmrryxogxWu7bRewibJqlqPewFhXdVvv5/MYjsUp39upICf0zk497SmCi4Um5XwvYN0F9xm eQmMT16A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mk2ss-00GISs-EN; Mon, 08 Nov 2021 11:32:18 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mk2so-00GIRe-P6 for linux-arm-kernel@lists.infradead.org; Mon, 08 Nov 2021 11:32:16 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 571852B; Mon, 8 Nov 2021 03:32:09 -0800 (PST) Received: from [10.1.35.131] (e127744.cambridge.arm.com [10.1.35.131]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1452E3F800; Mon, 8 Nov 2021 03:32:06 -0800 (PST) Subject: Re: [PATCH 1/3] perf arm-spe: Track task context switch for cpu-mode events To: Arnaldo Carvalho de Melo , Leo Yan Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Namhyung Kim , John Garry , Will Deacon , Mathieu Poirier , Mark Rutland , Alexander Shishkin , Jiri Olsa , linux-arm-kernel@lists.infradead.org References: <20211102180739.18049-1-german.gomez@arm.com> <20211102180739.18049-2-german.gomez@arm.com> <20211106032907.GG477387@leoy-ThinkPad-X240s> From: German Gomez Message-ID: <2d6b41a0-2ded-d8c8-630a-d418a0ef285a@arm.com> Date: Mon, 8 Nov 2021 11:32:05 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211108_033214_962356_34400CCA X-CRM114-Status: GOOD ( 17.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 06/11/2021 19:49, Arnaldo Carvalho de Melo wrote: > Em Sat, Nov 06, 2021 at 11:29:07AM +0800, Leo Yan escreveu: >> [...] >> Reviewed-by: Leo Yan >> >> Note for one thing, please keep "Namhyung Kim" as the author for this >> patch, thanks. > This merits a v2 submission, please do so. > > - Arnaldo > Will do, Also will fix the authorship of [2/3]. Thanks, German >> Leo >> >>> --- >>> tools/perf/arch/arm64/util/arm-spe.c | 6 +++++- >>> tools/perf/util/arm-spe.c | 25 +++++++++++++++++++++++++ >>> 2 files changed, 30 insertions(+), 1 deletion(-) >>> >>> diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c >>> index a4420d4df..58ba8d15c 100644 >>> --- a/tools/perf/arch/arm64/util/arm-spe.c >>> +++ b/tools/perf/arch/arm64/util/arm-spe.c >>> @@ -166,8 +166,12 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, >>> tracking_evsel->core.attr.sample_period = 1; >>> >>> /* In per-cpu case, always need the time of mmap events etc */ >>> - if (!perf_cpu_map__empty(cpus)) >>> + if (!perf_cpu_map__empty(cpus)) { >>> evsel__set_sample_bit(tracking_evsel, TIME); >>> + evsel__set_sample_bit(tracking_evsel, CPU); >>> + /* also track task context switch */ >>> + tracking_evsel->core.attr.context_switch = 1; >>> + } >>> >>> return 0; >>> } >>> diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c >>> index 58b7069c5..230bc7ab2 100644 >>> --- a/tools/perf/util/arm-spe.c >>> +++ b/tools/perf/util/arm-spe.c >>> @@ -681,6 +681,25 @@ static int arm_spe_process_timeless_queues(struct arm_spe *spe, pid_t tid, >>> return 0; >>> } >>> >>> +static int arm_spe_context_switch(struct arm_spe *spe, union perf_event *event, >>> + struct perf_sample *sample) >>> +{ >>> + pid_t pid, tid; >>> + int cpu; >>> + >>> + if (!(event->header.misc & PERF_RECORD_MISC_SWITCH_OUT)) >>> + return 0; >>> + >>> + pid = event->context_switch.next_prev_pid; >>> + tid = event->context_switch.next_prev_tid; >>> + cpu = sample->cpu; >>> + >>> + if (tid == -1) >>> + pr_warning("context_switch event has no tid\n"); >>> + >>> + return machine__set_current_tid(spe->machine, cpu, pid, tid); >>> +} >>> + >>> static int arm_spe_process_event(struct perf_session *session, >>> union perf_event *event, >>> struct perf_sample *sample, >>> @@ -718,6 +737,12 @@ static int arm_spe_process_event(struct perf_session *session, >>> } >>> } else if (timestamp) { >>> err = arm_spe_process_queues(spe, timestamp); >>> + if (err) >>> + return err; >>> + >>> + if (event->header.type == PERF_RECORD_SWITCH_CPU_WIDE || >>> + event->header.type == PERF_RECORD_SWITCH) >>> + err = arm_spe_context_switch(spe, event, sample); >>> } >>> >>> return err; >>> -- >>> 2.25.1 >>> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel