From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796055851; b=dQljdfle4KSQabigSX5tgJ8jBsDeq4hQhT6Oqm8bInWt/yBJie2m3VgqeFn4P3+HySgQ i8zfOEH3LwLmeVTPsoFnnzXhWj6i8g3mZcBHnGqSqbxeJN3gVfjLD8/6PCC2TbYunIvjS Az/WZbw7VxUsMjWe8L0HAL9X/8xNvG74gH5reBt/3+AbzkI0BMGRjBopZjcs8NlNWs9FI k+fp2LSTZOn++b6tfBic+LehRpOYroN4eMTbmMSnktyJAiX9WKO5k3bV08vXRSrpieuWh eyAb/vjt0Su0u+l8mlAdVcfGa+bvwXVlWFLbITMIpiqxH68s76xaeRmk5ys+iwA/2CQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796055851; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=k2BIlwG9FLueBZYJggCLoGtQcW5Npq7lIrqZW/5khfM=; b=0n5HobWIGIr1DS8ARdkjn/7Zl1GYvYXBkMuUpPRaTV+pJ2uGG8n0/4Ijd12zSpHjoHON bhzIFwWj4cGG1iXONXYl0EUd335agaJI89fbQuCngCYmuBX1rAOuJ+SQF+ZNn1xFrz0n/ 0EiBhhyXUrOuM7JklDIInV48ErVFX3/j6amJiaVGyIt2KLgFUmV71IlvwU4W9DddldzYS Tp2sJppaattY6x23qJzw7SqIAUiTYFEK+bu1Ln0c7dnT/vl+2Tx8RU7geNJ7kLtncrzQ0 xB7E0jy5IsUBenOK0c4pJYsh6eoF8gHWTGDz6fM98e6djbURG43ZS4GAjabxFI+LgqQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=iLr1OQJT; arc=none smtp.remote-ip=209.85.221.53 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9CB6606A327 for ; Mon, 30 Nov 2026 16:24:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E9CB6606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=iLr1OQJT Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-4a358881793so5678534f8f.0 for ; Mon, 30 Nov 2026 08:24:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1796055848; x=1796660648; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=k2BIlwG9FLueBZYJggCLoGtQcW5Npq7lIrqZW/5khfM=; b=iLr1OQJT1xHapNWOXanqaGkWxwaDFqscngA9HvefMse26hNEmwohGmSjMgApFIXUyQ 0R239njLArCNWs78Mw2DnreA6kiHkoTSJnwDaL6st7N4a+s+iwmWkNgW0WfXTZlkyKYf gA2+/+8n0s6MpW8658xDPqOQZqjO5kiaaveOcxMiuwc2yBjA9PW08HOQyjA3sivo++uU 6/sGKz5JfgK+QZCzx3J9kSILb4BRIC6pqOFsngqyndTtiv8sKjg/5THzFSxjxLJd3DGx 0gMbLl0siT/E75Ai90rsAcMcHVEPTdfxPVnE0lH3EFZfPAWJnqIPpKtW2230oeyLAvV1 fdwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796055848; x=1796660648; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=k2BIlwG9FLueBZYJggCLoGtQcW5Npq7lIrqZW/5khfM=; b=BWk++sONPEMVw/2f6w2SvmvS15jyLZAaGmRM7eEQQhRz1Az4cbcb+zJJRWITSQuQq1 /YczwIwhnBKB7+CITPJ661+dCR8H5u+aY4QgkwqECOidAnUGslAbVYeJ3LZKrtEAWFlD eMHfEZEknTF/U7I2+rNJWYy7I5OigoGmQHUQBl79bYqNLQOqKIeC0WoDr/F9WFGjymv6 jnLPuB4wbVdiDINLs6mUgc+a3ykDa8dlhYmsig8ICONAdL+Pt0Xn01cve1GQLkKGYpIr ee2xnjG0kvE61ZHz/wIKA9rNzHuBFFbTQ7zBbwH60X2m/QYmydTdW78rVLLhWzf4ly9T IlHQ== X-Forwarded-Encrypted: i=1; AL+hErGN8seH6oxy5xXTkVJUBytjXxEzExAPycmxJNnzr4C6kgEHjNCuaSq2eGP3FkqOXAim16FpzBNagEi8xXc=@vger.kernel.org X-Gm-Message-State: APuU4Z9Wjf10wbX3tE8c7FNVaimdGmKBLyjbQrJKRQDziKNn58olTy4l CFf9S+xBSWjkT6NwUbRhGpXs3y5yQwcRYjWHCilhneC5e5ZVms0fHL/vrZq64TO71DI= X-Gm-Gg: AZFdTZf/HbKLfZiYWPJUsmD5kRucOtSCrSlGYaC/4U6lMofIa8e0+pvoQVzvVVtetFk xA2dqbroEaWHN52AZFoQm9l40HGramoEhJmXVoLGYhIOR7J4DyerbbolKyW2si71R1gn7FG1w4F IB8D0/6zbh0b+HL8qkAWe5nlhlMhvjTlFwBB7x/PyoejZXW8LV0n+5o6dMNmMEo/R241imdU2Wp zz1dDv+Pr5R0U8jpgXPism4UDHfC5+y0D/lYQd23w8AktxoaPjZHJi84L5MbY1PM5mowTShp/D9 96rDcJOvhqz+wBTgqUo4yNRpxJGa+4meTe5Rl82R+VYftlpCoV5spcFhdPv3OQNkuhgTZIW2dHU rBB5y9PIt8IMK3IxJ/dGXYk4c2aU5rMWpeEd3ciFHfkk2DaH/jgGRILdMM00Lj8TY9hx1SAkQZm TEu4AGQJG9sQUIL8zunM5D600SF9bRa0FZsIAmnV0oymWl/2MzrcyqbQnI4vEyIoKQq+ZBxNKoX TqM2lvvJQMa91FLSYW3FlRatzDiqvnDtV0N61h9ES02JrxCd+U5rgZnUeewPHs00i8MPDotlCtK fzaI5mCJ1PpNKCHD4XMuM8/iq0WpHrcEWw== X-Received: by 2002:a05:6000:470c:b0:4a7:593a:f421 with SMTP id ffacd0b85a97d-4abb73b557amr63192196f8f.47.1796055848201; Mon, 30 Nov 2026 08:24:08 -0800 (PST) Received: from [192.168.1.3] ([37.18.141.193]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6a68048esm68733787f8f.29.2026.11.30.08.24.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Nov 2026 08:24:07 -0800 (PST) Message-ID: <328bd3ef-4fc7-43f8-9a6a-8c68b9055bc8@linaro.org> Date: Mon, 30 Nov 2026 16:24:06 +0000 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/3] perf: arm_spe: Factor HW discard mode out of arm_spe_perf_aux_output_begin() To: Will Deacon Cc: Mark Rutland , Leo Yan , Suzuki Poulose , Al Grant , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260805-james-spe-software-discard-v1-0-0ff0e44c4c92@linaro.org> <20260805-james-spe-software-discard-v1-2-0ff0e44c4c92@linaro.org> <9c5e1aa7-4e0f-4576-b322-b4594cdea5b0@linaro.org> Content-Language: en-US From: James Clark In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 27/11/2026 18:42, Will Deacon wrote: > On Mon, Oct 05, 2026 at 10:31:48AM +0100, James Clark wrote: >> >> >> On 05/10/2026 09:27, Will Deacon wrote: >>> On Wed, Aug 05, 2026 at 04:01:52PM +0100, James Clark wrote: >>>> Discard mode doesn't call perf_aux_output_begin() or emit aux records, >>>> and enabling it never fails. We'll add a second discard mode in the >>>> next commit so it will be cleaner if there is a separate begin function >>>> just for discard mode. >>>> >>>> No functional changes intended. >>> >>> [...] >>> >>>> +static void arm_spe_pmu_begin_discard(struct perf_output_handle *handle, >>>> + struct perf_event *event) >>>> +{ >>>> + u64 limit; >>>> + >>>> + limit = FIELD_PREP(PMBLIMITR_EL1_FM, PMBLIMITR_EL1_FM_DISCARD); >>>> + limit |= PMBLIMITR_EL1_E; >>>> + >>>> + write_sysreg_s(limit, SYS_PMBLIMITR_EL1); >>>> +} >>>> + >>>> static int arm_spe_perf_aux_output_begin(struct perf_output_handle *handle, >>>> struct perf_event *event) >>>> { >>>> u64 base, limit; >>>> struct arm_spe_pmu_buf *buf; >>> >>> Is it worth checking that we have a discard event in begin_discard() and >>> similarly that we don't have a discard event in output_begin()? It looks >>> like quite an error-prone interface for the caller, otherwise. >>> >> >> Makes sense, I can add that. >> >>>> @@ -775,6 +785,12 @@ static irqreturn_t arm_spe_pmu_irq_handler(int irq, void *dev) >>>> arm_spe_pmu_disable_and_drain_local(); >>>> break; >>>> case SPE_PMU_BUF_FAULT_ACT_OK: >>>> + if (arm_spe_discard_mode(event)) { >>>> + arm_spe_pmu_begin_discard(handle, event); >>>> + isb(); >>>> + break; >>>> + } >>> >>> This looks like new behaviour? >>> >>> Will >> >> I just extracted the discard part of arm_spe_perf_aux_output_begin() into >> here and arm_spe_pmu_begin_discard(). The PMBLIMITR_EL1 write and isb() >> should be the same. >> >> Do you mean that now it does arm_spe_pmu_begin_discard() unconditionally >> before checking PERF_AUX_FLAG_TRUNCATED? Truncated would never be set in HW >> discard mode, so it should be equivalent. And the IRQ would never fire >> anyway so we don't get here until SW discard is added, and even if it did, >> handle->event is NULL so the handler would exit on the first line anyway. > > I'm just highlighing that this goes beyond what I would normally expect > when a commit messages says "No functional changes intended." since > you're adding unconditional register writes to the interrupt handler that > weren't there before. If it "should be equivalent" because the truncation > flag isn't set, then put this inside the existing conditional. In fact, > that would make the whole thing more readable anyway. > > Will Yeah that's a bit cleaner, I sent a V2. They share the same isb() now as well. I did have to initialise handle->aux_flags manually which perf_aux_output_begin() normally does, otherwise that condition can read a stale value. But it's next to the manual initialisation of handle->event, so I think it's ok.