From patchwork Fri Jul 12 10:20:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13731590 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 5C45DC2BD09 for ; Fri, 12 Jul 2024 10:26:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RmiqFINbf2RIIt2/HIb6pHgQita750CuprYaFJouhH8=; b=r06DH176+z5YRmgT/aMhJpKaA0 6IR75xVCZ9eYnTABZrzjEMxmpgp2yJ5JqgxB85N57Brg43cfe4olGUj1iadTEnNfXUJsrS4QFIjcB 7TKPanGg/ztNtOOGXEIccyzVi2+YTQG0ufXbWQ0Tk3X2q22nAcZivHBfZcJHx6Y5H8ZbKzCANiNdd B6PimoS+Ob54BuVb9jOYTwtVUuosAE3Zo01oBcITy03FGTouxszjsD9vyQe2JsyEw/zH/Pyt3ssRy 0DorUzcqtZ0Rslk20wi9H97yppClWgNmSIy/I1WRmRArFqpQAyR6VP2SSJNS6yfWkn3Et159H9oH1 4fBAotyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSDTl-0000000HInm-0c0M; Fri, 12 Jul 2024 10:26:17 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSDQj-0000000HHOg-3hwY for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 10:23:11 +0000 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-3678aa359b7so1831095f8f.1 for ; Fri, 12 Jul 2024 03:23:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720779788; x=1721384588; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RmiqFINbf2RIIt2/HIb6pHgQita750CuprYaFJouhH8=; b=kJ9LP6tQhiXO/VZIzXUjCIcL6/yKXBgUXdsZXjE9tuGxw/bb9QspOh3V26ZZLSnPWr DdSB5C49b5ARDxHvkIK5c8GDNYSKYnEcvVaJzcWKIEhOatP8X5qMsKSzSGGwU+aVsGhf iLFm8yVWsPhSrIPNRtOXaoAchC4YhKfm1AR66fhaVHxvLoeZ8aFcJmp1Oe5IOP87CynY A8EsQ6jcAwMp3iDcPzcjJ1pkhn/RXBdMHnCQWsuT8IPiXjvXxOjPpSNnKJkgUxAvL0O3 5MXCUJA0ajh2AhkOi64PDW+CJ16Ktj3zLViYKN/J+6G8oOSH6X9F0UXo2mTVcb/P3WLO qNqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720779788; x=1721384588; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RmiqFINbf2RIIt2/HIb6pHgQita750CuprYaFJouhH8=; b=C5tv3VxBaGD82X0tkWsGt3FBvOQ/IjMa5GT+EQoojp762paPKqG/B+WoMTiMOZf3ib yBZKqAnx1oIwKAOSTRMcW0HCAlJe4VEAYiU50w0vjPcY//WbYBTc0OiZ7coTGe61/zFu EePqf3BSiZbgHDB/hyKPEM03vQF2d4E3biyeC45dVcjVGMNj/cGo/DQIMjEXjP+30FnT LgwFAiqZ+223CNj3FgcO7CGhxSCeHPJbzwkwjjbxtMwkbUXbUFvbFGKFRzMdn+klgTBm S4K6fMwqgDrd1oMdM7+RFXKhZr9/FNNFoAa2U8VY043vDRjhqtoFqi1iMK5yn9QzANTm +IOw== X-Forwarded-Encrypted: i=1; AJvYcCWWIGLxxH1TZZBNNeVbmic5j/+i7vgRvLaIdoyQKIlr1JlqVdG/8RIpcQabujRu/ox7txqNvx09Wy+9JOoYjDJUWM0CwS1SLl1mpMpUOd2h+wUo1sg= X-Gm-Message-State: AOJu0Yx2LlgPwl9e6Kou6BtVHjJIVgds0k0iuBpQZJ9hN6fHhn4CrVt6 IvYCpQIy+H3mdM//QzcNpjDwauPFzvVbamcuxaM+PGJZCKAxYczd3CN911CXEJY= X-Google-Smtp-Source: AGHT+IFKnifONx2hAygp5d6pDLaQbUSgl5BqBFN0FJ2vM12b1+fRzec1gBmGmiVevI48O36kPXQXfg== X-Received: by 2002:a05:6000:1f84:b0:367:9268:bfca with SMTP id ffacd0b85a97d-367ff705355mr1998840f8f.22.1720779788576; Fri, 12 Jul 2024 03:23:08 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367cde89164sm9911058f8f.63.2024.07.12.03.23.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 03:23:08 -0700 (PDT) From: James Clark To: coresight@lists.linaro.org, suzuki.poulose@arm.com, gankulkarni@os.amperecomputing.com, mike.leach@linaro.org, leo.yan@linux.dev, anshuman.khandual@arm.com Cc: James Clark , James Clark , Alexander Shishkin , Maxime Coquelin , Alexandre Torgue , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-perf-users@vger.kernel.org Subject: [PATCH v5 13/17] coresight: Make CPU id map a property of a trace ID map Date: Fri, 12 Jul 2024 11:20:22 +0100 Message-Id: <20240712102029.3697965-14-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240712102029.3697965-1-james.clark@linaro.org> References: <20240712102029.3697965-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_032310_030604_BB719CC1 X-CRM114-Status: GOOD ( 18.59 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Clark The global CPU ID mappings won't work for per-sink ID maps so move it to the ID map struct. coresight_trace_id_release_all_pending() is hard coded to operate on the default map, but once Perf sessions use their own maps the pending release mechanism will be deleted. So it doesn't need to be extended to accept a trace ID map argument at this point. Signed-off-by: James Clark Signed-off-by: James Clark Reviewed-by: Mike Leach --- drivers/hwtracing/coresight/coresight-trace-id.c | 16 +++++++++------- include/linux/coresight.h | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-trace-id.c b/drivers/hwtracing/coresight/coresight-trace-id.c index 5561989a03fa..8a777c0af6ea 100644 --- a/drivers/hwtracing/coresight/coresight-trace-id.c +++ b/drivers/hwtracing/coresight/coresight-trace-id.c @@ -13,10 +13,12 @@ #include "coresight-trace-id.h" /* Default trace ID map. Used in sysfs mode and for system sources */ -static struct coresight_trace_id_map id_map_default; +static DEFINE_PER_CPU(atomic_t, id_map_default_cpu_ids) = ATOMIC_INIT(0); +static struct coresight_trace_id_map id_map_default = { + .cpu_map = &id_map_default_cpu_ids +}; -/* maintain a record of the mapping of IDs and pending releases per cpu */ -static DEFINE_PER_CPU(atomic_t, cpu_id) = ATOMIC_INIT(0); +/* maintain a record of the pending releases per cpu */ static cpumask_t cpu_id_release_pending; /* perf session active counter */ @@ -49,7 +51,7 @@ static void coresight_trace_id_dump_table(struct coresight_trace_id_map *id_map, /* unlocked read of current trace ID value for given CPU */ static int _coresight_trace_id_read_cpu_id(int cpu, struct coresight_trace_id_map *id_map) { - return atomic_read(&per_cpu(cpu_id, cpu)); + return atomic_read(per_cpu_ptr(id_map->cpu_map, cpu)); } /* look for next available odd ID, return 0 if none found */ @@ -145,7 +147,7 @@ static void coresight_trace_id_release_all_pending(void) clear_bit(bit, id_map->pend_rel_ids); } for_each_cpu(cpu, &cpu_id_release_pending) { - atomic_set(&per_cpu(cpu_id, cpu), 0); + atomic_set(per_cpu_ptr(id_map_default.cpu_map, cpu), 0); cpumask_clear_cpu(cpu, &cpu_id_release_pending); } spin_unlock_irqrestore(&id_map_lock, flags); @@ -181,7 +183,7 @@ static int _coresight_trace_id_get_cpu_id(int cpu, struct coresight_trace_id_map goto get_cpu_id_out_unlock; /* allocate the new id to the cpu */ - atomic_set(&per_cpu(cpu_id, cpu), id); + atomic_set(per_cpu_ptr(id_map->cpu_map, cpu), id); get_cpu_id_clr_pend: /* we are (re)using this ID - so ensure it is not marked for release */ @@ -215,7 +217,7 @@ static void _coresight_trace_id_put_cpu_id(int cpu, struct coresight_trace_id_ma } else { /* otherwise clear id */ coresight_trace_id_free(id, id_map); - atomic_set(&per_cpu(cpu_id, cpu), 0); + atomic_set(per_cpu_ptr(id_map->cpu_map, cpu), 0); } spin_unlock_irqrestore(&id_map_lock, flags); diff --git a/include/linux/coresight.h b/include/linux/coresight.h index c16c61a8411d..7d62b88bfb5c 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -234,6 +234,7 @@ struct coresight_sysfs_link { struct coresight_trace_id_map { DECLARE_BITMAP(used_ids, CORESIGHT_TRACE_IDS_MAX); DECLARE_BITMAP(pend_rel_ids, CORESIGHT_TRACE_IDS_MAX); + atomic_t __percpu *cpu_map; }; /**