From mboxrd@z Thu Jan 1 00:00:00 1970 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 0110CC5478C for ; Tue, 27 Feb 2024 05:32:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jxv4n11XvoqYDg6MihmvaVZaLmlgtVNGRFVjhO7rThI=; b=KpnINi7Z759zNw 8c8852OJ3p1tF2q6mPOo3eAZvM6EM05qFjN3zmYX+XhRmurQWIS+6hMVGx4p3VCcAUCa8FaiZWtJ+ 48kykGX0E4QsMgSOYHOuliUpu/ZQ+0FhEQfXdeO/lXPooAGuJIafm4yrK+zAyrllyaalo6xSL9Sz6 NzHkLHEUq5cuTznJRU3OYYEcn8gMyvqkPw+j8B/+Ynx4w/0VGN7JUR8OgGSZGh6OtX/3LtHUFKm3R R0rXMw8V2V/VbS5ooTyUYj8LtMZMiT/4HI3+iKV6ssouhaPEsDSkyFKUDZgIRTwHrFsBDKFmIXNa2 xa6SHolA5bmNqf52c10w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1req4X-00000003sMQ-0QAZ; Tue, 27 Feb 2024 05:32:09 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1req4U-00000003sLu-0XY5 for linux-arm-kernel@lists.infradead.org; Tue, 27 Feb 2024 05:32:07 +0000 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 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: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240226_213206_305414_52B4A565 X-CRM114-Status: GOOD ( 22.51 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel