Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1723539rbb; Mon, 26 Feb 2024 21:32:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVpAmaK9Xjw+CHJxVdsXnrmM+PLehl4ZIdDob3kyVDR9OmjcX6EeD5/WW1qGXGK08xVgcC+jZhLnz1eWD2CXA5oav6PtRkmVkM7wrjf7w== X-Google-Smtp-Source: AGHT+IGHkwOoujRJ1iGChzuSPl/KE89xr0asA0qQErxMldHc0iRuF6IUCIr2oEW3+S403lPN+epP X-Received: by 2002:a05:6808:210a:b0:3c1:3322:157d with SMTP id r10-20020a056808210a00b003c13322157dmr1462834oiw.44.1709011929127; Mon, 26 Feb 2024 21:32:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709011929; cv=pass; d=google.com; s=arc-20160816; b=C7ANtHs8aVaYfVufqroWvikIohOXQdlUIpq+KjAN44YHrfsG5VbGprzq6azy74DUNF aI7xzusIKnQ6bgpK21xRbz8uNNClWBOoUNGq/96FEBJ4juROa+n83VG3KtQG0/0qJ0dt QAEuAul5Qqfl8EAuosM8WiZGu6yu6COAMlWtEb/vmuPAHqvnWVsQwmqXKnGkiOjh0s8p LJ5AkbICixeDkJuKqKPGtLq0AvxIwyJPK8mqx6SDyPETB3OHfuO3JWJjOideqhD6V7Ob +gO5xKj28+4kQnJt+3/FR2KALgMvoSVW/UaIQbGgoxFXhz8orNEZd5t16OcOhhT4EALZ wz9Q== 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:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=nLtZMwtUFu7zPqyN91CKQbQW//DzeSDi94Z4hRd+Z68=; fh=QvWXZQPFX3KP1gLsTZT1hAhZCMfsLsq/9MOLJpKuW7M=; b=RsYeQH8PYaZCtSwZDnhChPoYqES0kSOCK+sVQrTbVh/GG4Fsmelb4LG+dj4WofTD10 YiHipUuOSz/MMFX8SS9VNSzdTfxCtaS7kpu6F0/4slkEQ5njUQhPaeEt7cmdaFV7yuk9 oQiLb7yv8tNFizXwGi7m/QmP7Zj1hPW08CjxVRVLyXHQYxbGXDO4hnk9Vzb+MErkvGaZ 3l8+ArB/3n16cKalbpoe/uZ25JmTvP3NClSAQABPe+yUpSMDsv6iswNLLZ9GNuh7HOMA YT4KjcCJyvnp8M4vAhKB5RO7BZWLGtv9oxR3LMgWfBStdi9Qlh0rzJ6blJJk4/4fQdDp AIsw==; 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-82721-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82721-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z19-20020aa785d3000000b006e4c85a8129si4845778pfn.130.2024.02.26.21.32.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 21:32:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82721-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; 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-82721-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82721-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CA61E2849AB for ; Tue, 27 Feb 2024 05:32:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7A06552F92; Tue, 27 Feb 2024 05:32:02 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ADF221AACE for ; Tue, 27 Feb 2024 05:31:59 +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=1709011922; cv=none; b=EB9PbfyWibspAOOUOjnlygZgTfSAa2mO8m0dy93NLK+yMIlV2LsJQQnYva5SlROg5IboOZSCMjwa8NZLZD/Hhqm/0Ha1G+Yxs0Mh7Ms4i3N54ABRZK8EZAWOdRgLGWwNZPtd29qy3/Zk5WQgi9zQOTh77BQlbYKYzAYcvWLph1g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709011922; c=relaxed/simple; bh=MULxpeaD/ViV6fujeZYHcokbWGSluuQ/LDYbbkn2tfQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=QZKETCqB8Aud91QPdhfvldZHkqWUxW5Y6BWZM1QYpUbsULEpF//cRANVAHXO/a7uBOp/JnsBYEp89sDnJSXyOnw/jQ5ono+D/OAznPb92ZepWcxCM3Icop1WoOSGnrRN19MS22L2/Z71EbHAoNen24wCHI5uNjAHe/7ERlm0oDM= 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 D8DD2DA7; Mon, 26 Feb 2024 21:32:36 -0800 (PST) Received: from [10.163.48.107] (unknown [10.163.48.107]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8D06B3F6C4; Mon, 26 Feb 2024 21:31:56 -0800 (PST) Message-ID: Date: Tue, 27 Feb 2024 11:01:54 +0530 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] arm64/hw_breakpoint: Determine lengths from generic perf breakpoint macros Content-Language: en-US To: Mark Rutland Cc: Will Deacon , linux-arm-kernel@lists.infradead.org, broonie@kernel.org, Catalin Marinas , linux-kernel@vger.kernel.org References: <20240223113102.4027779-1-anshuman.khandual@arm.com> <20240223125224.GC10641@willie-the-truck> <1901fadb-1d71-4374-be8c-00935bb27854@arm.com> From: Anshuman Khandual In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/26/24 16:34, Mark Rutland wrote: > On Mon, Feb 26, 2024 at 08:19:39AM +0530, Anshuman Khandual wrote: >> On 2/23/24 18:22, Will Deacon wrote: >>> On Fri, Feb 23, 2024 at 05:01:02PM +0530, Anshuman Khandual wrote: >>>> Both platform i.e ARM_BREAKPOINT_LEN_X and generic i.e HW_BREAKPOINT_LEN_X >>>> macros are used interchangeably to convert event->attr.bp_len and platform >>>> breakpoint control arch_hw_breakpoint_ctrl->len. Let's be consistent while >>>> deriving one from the other. This does not cause any functional changes. >>>> >>>> Cc: Will Deacon >>>> Cc: Mark Rutland >>>> Cc: Catalin Marinas >>>> Cc: linux-arm-kernel@lists.infradead.org >>>> Cc: linux-kernel@vger.kernel.org >>>> Signed-off-by: Anshuman Khandual >>>> --- >>>> This applies on v6.8-rc5 >>>> >>>> arch/arm64/kernel/hw_breakpoint.c | 16 ++++++++-------- >>>> 1 file changed, 8 insertions(+), 8 deletions(-) >>>> >>>> diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c >>>> index 35225632d70a..1ab9fc865ddd 100644 >>>> --- a/arch/arm64/kernel/hw_breakpoint.c >>>> +++ b/arch/arm64/kernel/hw_breakpoint.c >>>> @@ -301,28 +301,28 @@ static int get_hbp_len(u8 hbp_len) >>>> >>>> switch (hbp_len) { >>>> case ARM_BREAKPOINT_LEN_1: >>>> - len_in_bytes = 1; >>>> + len_in_bytes = HW_BREAKPOINT_LEN_1; >>> >>> I don't think we should do this. The HW_BREAKPOINT_LEN_* definitions are >>> part of the user ABI and, although they correspond to the length in bytes, >>> that's not necessarily something we should rely on. >> >> Why should not we rely on the user ABI macros if these byte lengths were >> initially derived from them. > > Why should we change the clear: > > len_in_bytes = 1; > > ... to the longer, and less clear: > > len_in_bytes = HW_BREAKPOINT_LEN_1; > > ... ? > >> But also there are similar conversions in arch_bp_generic_fields(). > > Those are specifically for converting from the rch_hw_breakpoint_ctrl encodings > to the perf_event_attr encodings. There we don't care about the specific value > of the byte, just that we're using the correct encoding. > >> These hard coded raw byte length numbers seems cryptic, where as in reality >> these are just inter converted from generic HW breakpoints lengths. > > There are three distinct concepts here: > > 1. The length in bytes, as returned above by get_hbp_len() > > 2. The length as encoded in the ARM_BREAKPOINT_LEN_* encoding > > 3. The length as encoded in the HW_BREAKPOINT_LEN_* encoding. > > I think you're arguing that since 1 and 3 happen to have the values we should > treat them as the same thing. I think that Will and I believe that they should > be kept distinct because they are distinct concepts. > > I don't think this needs to change, and can be left as-is. Fair enough, but just wondering how about deriving len_in_bytes from hweight_long(ARM_BREAKPOINT_LEN_*) instead ? This also drops the hard coding using the platform macros itself, without going to user ABI.