Received: by 2002:a05:7412:d024:b0:f9:90c9:de9f with SMTP id bd36csp132644rdb; Wed, 20 Dec 2023 08:05:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IFS9MNRxhYH3VP6NEjvybuCks4yCjOq9qezlPPe4ZUvmHcemKoS3UNisyr01NsxYLL+tbaM X-Received: by 2002:a17:902:eb8a:b0:1d3:da07:5731 with SMTP id q10-20020a170902eb8a00b001d3da075731mr2863687plg.22.1703088323649; Wed, 20 Dec 2023 08:05:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703088323; cv=none; d=google.com; s=arc-20160816; b=OSqW0SnVkqb28DOotmShTGH5mtmwc/9r95GB441OjLpbP85y9GL/WX9BWx96Hmxujs gWh8B234EqBiBJjE3nEXsXKx/UTRdlEQ6Hh5FXhF5yDfK5orXnwljB8sDpLiLgGy6tAY S3Oh9N6xjjzAfkSRgftDMJWKomoufhcaXqvXFlBJKx/jk28lMzwKYQWL7y/i0YyzXPCC wqDZHb8EVn/QWZq28zkoVUJYqree+RpYPTmwJ9mUzrK/L5iFcABFjC7kIsct9PR6RE5W pgp6MunRG24EIiChjfuBq6C9O4vAW/9ENlNkMs2kBKzU0MqXyidQenebu6NixvEIVHWx Z00A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=R5Ix4MFFn7oVw/8yRsDO+4Cq+FuXYvzA2aUl32xt5Fg=; fh=aL+2eEGlqndECjsQkaNn4SZH9S7Qn4FRu3jw1k002I0=; b=Q8uPIABI5bc9uWMUdGrJPh8brxImYgRLlxfoiR5YGswAvR+soS138+dpLvTfJCeWs1 xsh+8wBeo9wiawwhIh9j7IOwIJSQsXJY1146nDyuPLZwgJQtj/zLzkVa19gg7lP4RGC2 3jEv8nJeKEMNReYSkEGguoM/jeJ6N0BjKWdmFYDGNOPWAfSwLVb5KzqhG27znUshCD6u uDrcb3MfKIYWZ+nRJ6aHy9KFx2QKUdzoyW14gK0InsJJzcnzhlQO27p3CFYtmZjPJ33K d7arXFZl099cux5QXV09UcrEHicEmwI0pkIjt3R4DWa02mob8ueicCqViG5rOrnfh60b 5t5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-7224-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7224-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id p9-20020a1709027ec900b001d00ed1187fsi21458794plb.116.2023.12.20.08.05.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 08:05:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7224-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-7224-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7224-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 850DFB228F2 for ; Wed, 20 Dec 2023 16:00:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4BF2646535; Wed, 20 Dec 2023 15:59:07 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4FF6745C09; Wed, 20 Dec 2023 15:59:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 77D261FB; Wed, 20 Dec 2023 07:59:49 -0800 (PST) Received: from [192.168.1.3] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1C9C23F64C; Wed, 20 Dec 2023 07:59:02 -0800 (PST) Message-ID: Date: Wed, 20 Dec 2023 15:59:01 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 From: James Clark Subject: Re: [PATCH RFC V3 4/4] coresight: Have a stab at support for pause / resume To: Adrian Hunter Cc: Ingo Molnar , Mark Rutland , Alexander Shishkin , Heiko Carstens , Thomas Richter , Hendrik Brueckner , Suzuki K Poulose , Mike Leach , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, Yicong Yang , Jonathan Cameron , Will Deacon , Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim , Ian Rogers , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Peter Zijlstra References: <20231208172449.35444-5-adrian.hunter@intel.com> <20231215064242.36251-1-adrian.hunter@intel.com> Content-Language: en-US In-Reply-To: <20231215064242.36251-1-adrian.hunter@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 15/12/2023 06:42, Adrian Hunter wrote: > For discussion only, un-tested... > If anyone wants to test Coresight, the diff below is required to get the most basic use case working. It also probably needs more thought and some edge case handling: diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index 596c01e37624..bd0767356277 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -556,7 +556,8 @@ static void etm_event_stop(struct perf_event *event, int mode) struct etm_event_data *event_data; struct list_head *path; - if (mode & PERF_EF_PAUSE && !READ_ONCE(ctxt->pr_allowed)) + if ((mode & PERF_EF_PAUSE && !READ_ONCE(ctxt->pr_allowed)) || + event->hw.state == PERF_HES_STOPPED) return; WRITE_ONCE(ctxt->pr_allowed, 0); @@ -573,9 +574,6 @@ static void etm_event_stop(struct perf_event *event, int mode) /* Clear the event_data as this ETM is stopping the trace. */ ctxt->event_data = NULL; - if (event->hw.state == PERF_HES_STOPPED) - goto out_pr_allowed; - /* We must have a valid event_data for a running event */ if (WARN_ON(!event_data)) return; @@ -586,7 +584,7 @@ static void etm_event_stop(struct perf_event *event, int mode) * nothing needs to be torn down other than outputting a * zero sized record. */ - if (handle->event && (mode & PERF_EF_UPDATE) && + if (handle->event && (mode & (PERF_EF_UPDATE | PERF_EF_PAUSE)) && !cpumask_test_cpu(cpu, &event_data->mask)) { event->hw.state = PERF_HES_STOPPED; perf_aux_output_end(handle, 0); @@ -616,7 +614,7 @@ static void etm_event_stop(struct perf_event *event, int mode) * handle due to lack of buffer space), we don't * have to do anything here. */ - if (handle->event && (mode & PERF_EF_UPDATE)) { + if (handle->event && (mode & (PERF_EF_UPDATE | PERF_EF_PAUSE))) { if (WARN_ON_ONCE(handle->event != event)) return; @@ -646,7 +644,6 @@ static void etm_event_stop(struct perf_event *event, int mode) /* Disabling the path make its elements available to other sessions */ coresight_disable_path(path); -out_pr_allowed: if (mode & PERF_EF_PAUSE) WRITE_ONCE(ctxt->pr_allowed, 1); } @@ -656,7 +653,7 @@ static int etm_event_add(struct perf_event *event, int mode) int ret = 0; struct hw_perf_event *hwc = &event->hw; - if (mode & PERF_EF_START && !READ_ONCE(event->aux_paused)) { + if (mode & PERF_EF_START) { etm_event_start(event, 0); if (hwc->state & PERF_HES_STOPPED) ret = -EINVAL; -- 2.34.1