Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1272786lqb; Thu, 30 May 2024 05:57:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCURkIeO5Z32L/8C7z2ZVNvLlafYD7s/2LC6ipNyLcdO3/A9DWM7rm68GYgQojPuxCjN/ZEt5e7y4QHOWZ6q9f8pcd5vMJZ7PfbnLJRLCg== X-Google-Smtp-Source: AGHT+IGEgi0La/Y3bI4O6HcJs53mPaLdVyRBH4vt9f7aKLuvJCzWaRgbjIYGN91c8cpMjJplUVr8 X-Received: by 2002:a17:902:e846:b0:1f4:6dca:234b with SMTP id d9443c01a7336-1f61a3dd962mr21708255ad.65.1717073830265; Thu, 30 May 2024 05:57:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717073830; cv=pass; d=google.com; s=arc-20160816; b=PTfEhmaDXu3nIebqxHMZee/IAKN/Lo7y2HHUxUb74L41DN/iTp4TeycIMbiZ6Dybe+ d7TdL6ChtwZIhEmL4m4BauTHEexJGMo4dC2EAP0bfgS+fxiizYRPHvPmNWuGHkCVahZq 5j5mrXRstohKggZ3nOV5mtQwZtKZxPxN6arkug7K+uK8KHeaAxAoaZ+oy5e3qEjl/Dn3 P3mDE1SY9SdIGaC7PW7VAQJKzmOHYgjVps47Mq5zotilpvEY7StW5QvmVFG1VSYaW3n7 12onfkRLnxrNJnGrE8xQHUWuj+WV6aH6HJLLp30mK52HoothcsYKeM9XEW+bU6JS0Nre 4YpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=drBw7k2cQVq8vzHuuQ/qVDMmrPadnDpDnvJd62sLPa0=; fh=6aoYZbf7cwxhWi8yFJjZ8KldiNdE4GzyU7cZ3FjYGWY=; b=0SPlB8gXVw15iXe7BjEXfco9R3PKoArVHjofCzHdKZhVvtAy24Ws+IJln4XOJ8AwVr tZS8eqP2RNtQLaBEQ6Ckc+MRMUFappiLiCoNlOIgyIo5/+fJu5Els1mlZDExd8DEGg3H sBlhmBohQgwScBhxaEHeqvolhEiulM9qyuPPQCOY7v8q9M3wkSeHGYL3EltFiaz5RA9t lZuez76rMlRWGLHAiDHjSKvUGE0S+on2gKMhzV591D5CVLNEbiW10PHFm0fHASW4BPWR En3dxdeq6FtPB0PgSeShFrzN7anBUT4NqWXA20IUV1qUdJHRybmN9JedwMYxq6zO5IHk gm5Q==; dara=google.com 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-195392-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195392-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. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f62ccb3e86si955165ad.538.2024.05.30.05.57.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 05:57:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195392-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-195392-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195392-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 A147FB22B47 for ; Thu, 30 May 2024 12:54:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D64717CA01; Thu, 30 May 2024 12:54:46 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1DA5D17CA06; Thu, 30 May 2024 12:54:42 +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=1717073685; cv=none; b=QLOhCR4ML4o+7IdfqvZVGpHZrMY4ntSxqhLeQ9kzuwkk8RZzghO3FZiat9n41agxbMgfRx4bO65qD6d+A+ZjXH4V8S/5+IRwvD+qeYshfzN6vUQloMkmVhby+AQy9pYYPJs5K0FnCx8ciyHc1zxGJ+8lnTW1bsrI9X5XoPNCVq8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717073685; c=relaxed/simple; bh=bIrMEs5NYdtb9T9UOCr6ZAsNT8glRmdAXyGs2MUvXok=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Yn7zUG00PG7OtiHv0D2vKhWJXKp7Ave/KHcX0agnET7SXG46fOe6iEmOJntD8W31JcMZy6+W+nCocagrB+8Ucf/cSvH21fasfJOnVuHJyVZMYbWB2TItZGWNUWdLQFYGhnSURi54ZFxpFpAQbAzKjn2klh/a/88bIBrJ//nwnPQ= 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 1BD35339; Thu, 30 May 2024 05:55:06 -0700 (PDT) Received: from [192.168.1.100] (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 628EF3F792; Thu, 30 May 2024 05:54:40 -0700 (PDT) Message-ID: <193884e6-0911-4a5f-9676-74e1630f9a28@arm.com> Date: Thu, 30 May 2024 13:54:42 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 4/4] tools/perf: Allow inherit + PERF_SAMPLE_READ when opening events To: Namhyung Kim , Ben Gainey Cc: "alexander.shishkin@linux.intel.com" , "peterz@infradead.org" , "acme@kernel.org" , "mingo@redhat.com" , "adrian.hunter@intel.com" , "irogers@google.com" , "jolsa@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-perf-users@vger.kernel.org" , Mark Rutland References: <20240521133029.83654-1-ben.gainey@arm.com> <20240521133029.83654-5-ben.gainey@arm.com> Content-Language: en-US From: James Clark In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 29/05/2024 20:18, Namhyung Kim wrote: > Hello, > > On Wed, May 29, 2024 at 10:48 AM Ben Gainey wrote: >> >> On Mon, 2024-05-27 at 18:47 +0100, Ben Gainey wrote: >>> On Thu, 2024-05-23 at 18:41 -0700, Namhyung Kim wrote: >>>> On Tue, May 21, 2024 at 6:30 AM Ben Gainey >>>> wrote: >>>>> >>>>> The tool will now default to this new mode if the user specifies >>>>> a >>>>> sampling group when not in system-wide mode, and when --no- >>>>> inherit >>>>> is not specified. >>>>> >>>>> This change updates evsel to allow the combination of inherit >>>>> and PERF_SAMPLE_READ. >>>>> >>>>> A fallback is implemented for kernel versions where this feature >>>>> is >>>>> not >>>>> supported. >>>> >>>> But I'm afraid the test would fail on old kernels. Maybe we need >>>> to >>>> put it in the selftests. >>>> >>> >>> Sorry, not clear what you mean? >>> >>> Is the issue that the fallback on older kernels fails, or that the >>> "perf test" tests fail? >>> >>> Thanks >>> Ben >> >> Just to follow up, I've rechecked the fallback on an unmodified 6.9.1 >> kernel with the following: >> >> perf record -vv -e '{cycles,instructions}:S' ls >> >> With an unpatched version of perf running on an unpatched kernel, the >> cycles event is opened as: >> >> ------------------------------------------------------------ >> perf_event_attr: >> type 0 (PERF_TYPE_HARDWARE) >> size 136 >> config 0 (PERF_COUNT_HW_CPU_CYCLES) >> { sample_period, sample_freq } 4000 >> sample_type IP|TID|TIME|READ|ID|PERIOD >> read_format ID|GROUP|LOST >> disabled 1 >> exclude_kernel 1 >> exclude_hv 1 >> mmap 1 >> comm 1 >> freq 1 >> enable_on_exec 1 >> task 1 >> sample_id_all 1 >> exclude_guest 1 >> mmap2 1 >> comm_exec 1 >> ksymbol 1 >> bpf_event 1 >> ------------------------------------------------------------ >> >> whereas with these patches applied to perf, on an unpatched kernel, the >> output is as follows >> >> ------------------------------------------------------------ >> perf_event_attr: >> type 0 (PERF_TYPE_HARDWARE) >> size 136 >> config 0 (PERF_COUNT_HW_CPU_CYCLES) >> { sample_period, sample_freq } 4000 >> sample_type IP|TID|TIME|READ|ID|PERIOD >> read_format ID|GROUP|LOST >> disabled 1 >> inherit 1 >> exclude_kernel 1 >> exclude_hv 1 >> mmap 1 >> comm 1 >> freq 1 >> enable_on_exec 1 >> task 1 >> sample_id_all 1 >> exclude_guest 1 >> mmap2 1 >> comm_exec 1 >> ksymbol 1 >> bpf_event 1 >> ------------------------------------------------------------ >> sys_perf_event_open: pid 3442954 cpu 0 group_fd -1 flags 0x8 >> sys_perf_event_open failed, error -22 >> Using PERF_SAMPLE_READ / :S modifier is not compatible with >> inherit, falling back to no-inherit. >> ------------------------------------------------------------ >> perf_event_attr: >> type 0 (PERF_TYPE_HARDWARE) >> size 136 >> config 0 (PERF_COUNT_HW_CPU_CYCLES) >> { sample_period, sample_freq } 4000 >> sample_type IP|TID|TIME|READ|ID|PERIOD >> read_format ID|GROUP|LOST >> disabled 1 >> exclude_kernel 1 >> exclude_hv 1 >> mmap 1 >> comm 1 >> freq 1 >> enable_on_exec 1 >> task 1 >> sample_id_all 1 >> exclude_guest 1 >> mmap2 1 >> comm_exec 1 >> ksymbol 1 >> bpf_event 1 >> ------------------------------------------------------------ >> >> The command falls back to the same configuration as was previously >> used. The same is true for the instructions event. >> >> `perf test` fails on an unpatched kernel in "15: Setup struct >> perf_event_attr" for the test "test-record-group-sampling1" but that is >> surely expected for unpatched kernels? >> >> Is there some very-old kernel version where this would be expected to >> succeed by accident? > > I don't think so but I don't want the test to fail depending on the > kernel version. Maybe we can check the allowed combination > first and skip the test if perf_event_open() fails. And then it can > verify if the kernel rejects the unsupported combinations. Not > sure if it's easy to do that in the current attr test framework. > > Thanks, > Namhyung I added the kernel version feature to the attr tests. Seems like you can add two tests, one for before and one for after. Search "kernel_until" in tests/attr