Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp1118274rdb; Fri, 19 Jan 2024 08:40:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjtkOsE6RTNJJm95Q7yOGovpgzXm96rFor+ilK1yPBIgWt8dqexOAPfSdCqsYrQqTWH2kH X-Received: by 2002:a05:620a:f94:b0:783:32f4:1f1a with SMTP id b20-20020a05620a0f9400b0078332f41f1amr108632qkn.136.1705682452905; Fri, 19 Jan 2024 08:40:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705682452; cv=pass; d=google.com; s=arc-20160816; b=UDdGiswFvJF8C4bToS/W39zqMA+9JzPw751w3/aT5+kqIPtkAw1+bAY+Jz+Flqjxd+ i7ye1cAr5kFz3yx4nirMkh5lynyVfQZJIPy9YMfonV6RzXQhMsGt63NvEFTEawdeHfG9 Qi2E1IF/s2sc8Udjtzik+tMV0GMRAkU3WPhn8JbNdyl6EQLXw6AvMFS6UwzE4M4IziXV prpvbT6snBqh3VryydBxjMKmmGhqiCVZ9CQC6gmhnSfwR77EHer16P15Nedgo8zkXJyM W/32J+1FV+9FxZwFw/7XBHcMxa3B1Y9z8UZGuB4fYrf/xnZj9wajGOYFNmsdTZyGoA6e 1yxQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=kqGvfXDLakOEb2Dz85eCJnVf7vhXUSvdTkHhNoRUn5M=; fh=G91xSwRmDhPqekiiQQapZLC6wvNZ0cm3WTKASgdYN18=; b=LNMb+aZFxZW1z3xhLcZuILc4JWma0mAEY1Dl9DxvJK/S9KAKtbtEd+o6h6QPQKSSio m7tmPJ4Nh0jMgiSK7Ndc5K51cdgqD5mea7nwTi2MFxbE2IhyPL0HYKc9FqdMKPtyzMqI Txi+8fmc4OI9LSw+4pSDeliwU3qqq2BBTL0cylDgiaqi8XELCUTUa+HyFrM61G4bv3Vk E8x//Bur7bek8FYkZHlxRYAPwSG/ko59SQeY7C+hS/F7snoupPwZihQPQBgVHkpRAebB j6zTvd6njf5nQB7iw5rd2g2c0zhWRK+pdTEEmDgC15R1gs3vyaH8iU9gXDVV7S5jZdlg +rmA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-31371-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31371-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z37-20020a05620a262500b007836dd67b63si7697718qko.231.2024.01.19.08.40.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 08:40:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31371-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-31371-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31371-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 80ECF1C249D7 for ; Fri, 19 Jan 2024 16:40:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 450E255C29; Fri, 19 Jan 2024 16:39:57 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E85155785; Fri, 19 Jan 2024 16:39:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705682396; cv=none; b=t99A5ywsr6Qo/P8SEzzI1znxozmMDmdOVMAAXB6TDRAMfveTtY7FlAKdmKbBXGVWocnZTKwNUftCMSCZ274RpDHy4UqLYc1U7akrryEFcVAGle6fD5wKTDawzCoR9NYq8VEJOCoyMn14YyiErPdyut07G9pRYdC/yB+3IXxeol0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705682396; c=relaxed/simple; bh=lBmSUPtkwtCMjZIkdsZPZkuixbOXHdWTZ6M2mQb6yPM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JH2oJFuXL4kzx1N/HOuYXjF4+9hA34plqLH2p8aoElIB2z/nJZKeGtVkD1EFrdzTep//iaRwn8EXSQWyIlZqKsAMLhoeZGMKCrg9PG1sOyfJTstBVl/hbmSABhPx3yu9O6yZZdPB8q6znOkybrT/m2XauFy1JIa9WXZimleW2OM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 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 CC8D311FB; Fri, 19 Jan 2024 08:40:38 -0800 (PST) Received: from e126817.. (e126817.cambridge.arm.com [10.2.3.5]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 168413F73F; Fri, 19 Jan 2024 08:39:49 -0800 (PST) From: Ben Gainey To: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com, james.clark@arm.com, Ben Gainey Subject: [PATCH 1/1] perf: Support PERF_SAMPLE_READ with inherit_stat Date: Fri, 19 Jan 2024 16:39:24 +0000 Message-ID: <20240119163924.2801678-2-ben.gainey@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240119163924.2801678-1-ben.gainey@arm.com> References: <20240119163924.2801678-1-ben.gainey@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This change allows events to use PERF_SAMPLE READ with inherit so long as both inherit_stat and PERF_SAMPLE_TID are set. In this configuration, and event will be inherited into any child processes / threads, allowing convenient profiling of a multi-process or multi-threaded application, whilst allowing profiling tools to collect per-thread samples, in particular of groups of counters. Signed-off-by: Ben Gainey --- kernel/events/core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 9efd0d7775e7c..4b603463d888f 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -11988,10 +11988,13 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu, local64_set(&hwc->period_left, hwc->sample_period); /* - * We currently do not support PERF_SAMPLE_READ on inherited events. + * We do not support PERF_SAMPLE_READ on inherited events unless + * inherit_stat and PERF_SAMPLE_TID are also selected, which allows + * inherited events to collect per-thread samples. * See perf_output_read(). */ - if (attr->inherit && (attr->sample_type & PERF_SAMPLE_READ)) + if (attr->inherit && (attr->sample_type & PERF_SAMPLE_READ) + && !(attr->inherit_stat && (attr->sample_type & PERF_SAMPLE_TID))) goto err_ns; if (!has_branch_stack(event)) -- 2.43.0