Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1677358lqe; Mon, 8 Apr 2024 17:20:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVKdRdg6dfbAiG7RG+3b++h3/OQlYhZvQufmfrLid4jxGKmnBmhQstaZ7BAerlxj4DRF5iQLEswfWCJaHZinPyTMYJc7qbM7+tlLIuZxA== X-Google-Smtp-Source: AGHT+IHUC9L3VkJLfXKcdgCl/FdxnXyO9VLcWg++7Vc0wCaNDXj24IsS3GZzQMWxrfDmO1zt4mLk X-Received: by 2002:a17:902:ea01:b0:1e0:c3b5:196 with SMTP id s1-20020a170902ea0100b001e0c3b50196mr1587844plg.20.1712622016780; Mon, 08 Apr 2024 17:20:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712622016; cv=pass; d=google.com; s=arc-20160816; b=M6tPoNecDei1F4RVs6E2QPPPxkBYOwKyIV3Lb1x8UBeMO5vkzT1L3vm1jHCdpmmIr8 oi3NuZ0aGJdnAcn0uqXtQ+Uxg2bQ94Ksksdn+x60EBAEoudnP0u5gnFjdsUO8xeSMG3m /ZLxcO/e/exvT8D1UFqi1dv/nopHWNE/863B18qoAYbgBXYKoVWGoYXutmCZPNanRpXw 4KiGxeNrW7LOBtNvjFJWVVEYl9FegDU4n/YANDPYANfWCFiVsgRt5YEGL7T1TM8Qj61/ 8N6426l1GZCuQoeIsKvPDOuypPFs9FtuWal6gHwSh6Sp1ymiTkwyKwhqvtmpoJFS2BEX BneA== 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:dkim-signature; bh=jJJm0YinR6Fz1JQTj6m9HJC7BJLubttssqp1IhI/OVY=; fh=7jLpIOZhffTyKQiulfBZtq/wXyM0ylo9lIwdc4sMy/Y=; b=vfB2g2XN2ZLM+MkncyBfWR4R+M7yR+JW72b4vb4BGIVW/vVctBrocDTI1SPpNlRYl9 YyDlZ6J1uyAKiyz75krKXhhp9w7WRvmUddne3cX5LzhOl8sV+G1cl92hmNr8sctzIvfE kmmi52cEl/pxtPMZ5MDJPgBUITgf4g9LtfdUvy9O9SJk4DJiqnkvIOcKZ+q4R4XENTr/ XeaN/+qHpWt2+xL3WJYB5anjPCH/T4XyRgTtjtXQ3KePK8oLPglGDQebeFu1+vqiNWgc t6DuwJq/jUA9VLhFxpJPmvThtmjM8h5jVqay0fuxRLTNtR+JS9LLM6/1smv6jhurdsCF hW5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=t6hfHAYV; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-136039-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136039-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id a2-20020a170902ecc200b001e2a5cb536asi5613990plh.496.2024.04.08.17.20.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 17:20:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136039-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; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=t6hfHAYV; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-136039-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136039-linux.lists.archive=gmail.com@vger.kernel.org" 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 71A642839D4 for ; Tue, 9 Apr 2024 00:20:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D419B10F2; Tue, 9 Apr 2024 00:20:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="t6hfHAYV" Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D755376 for ; Tue, 9 Apr 2024 00:20:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712622006; cv=none; b=quUFW3n2JXqGqpXPZKwDSrxHCkzHz1Ns1PG3pB72n2ZWs/mtHta94p4Oou9EhZdgtu5Cnm8rI+sjSHrAgQS1YVWyW68G5+wZ9GWAKJvm1Qa4bj+p+roiFC5Et3Il5427K4qoylTVWhRlOVD59mLPST+cghcb3TlU+kzdHRiFIp0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712622006; c=relaxed/simple; bh=7AyJE+Ynxw1W3Oop+jkW2MDTcjqw7F9xUTd+5z52JAI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=RHbILyShwhS01pyWDdAjAQSqsvyLyyoCTVK+m861DXhhXzzt8Jm9S08B7YTjdjfnsKUxixlF1+PWg7QUVp+tkftw52+T3GV+T2pUNjr/s3blFRNB0wKQ1007Jr1CryfyCtbtrBAYtHgfP1wUk6jdU6hLsFPlOPTh3QIEo1iIdRw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=t6hfHAYV; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6ecf8ebff50so3027321b3a.1 for ; Mon, 08 Apr 2024 17:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1712622004; x=1713226804; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=jJJm0YinR6Fz1JQTj6m9HJC7BJLubttssqp1IhI/OVY=; b=t6hfHAYVV0N2oSkEDZTbLXE68ltwkqsRbF7GAF95khFXygtm43m8BFcjGXWk1yuu10 ZR+uIUr7QBbsBf4gEygKbUPVpPnhQcwLG/H/C585ERn04Qcbl+TRkzWbhKqkR+eoCTF/ 6ou9tIWstBJV1owuQiHpeagkUg80/AkGpYk5ykYBXjwdFAtbfxjcLYvUJ3YUxzUHoTP/ uXpH8PVu9lvkvdXm1b3rrf3sU49LhgECiergtHayLB0OLA8HcE1fQdLeOe7QRKChgfv3 J9VnGBkYhmYmcDUNrh7W19e3uV1y02QgFVBvm2CGvqUrm5JnKZzmzZmUWVGBijeUVYRt hGnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712622004; x=1713226804; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jJJm0YinR6Fz1JQTj6m9HJC7BJLubttssqp1IhI/OVY=; b=C84+IGYXs5/pPBhwyiSVQR6k2sXmomSV17cqgBDU2gpTxBxbECB+aSpq/qfqq7l+EU OHvtlLyfrvVDc9Zwgd9ji/ps/lE+LSH0MzmpSsDG51vVV1/xJNz4xYUtKKsXoaVW/lOI ThWO2YQGxqW0a+4d/oz2l5rGiZf8t6khPAJFWbAiFYpacoNW3UXy1y8bUq7KLK2xntia wS1+n3gMxcjGmDbNSmd7uXw5idWxO93ADM9It0vkLFDqZaZusKLyXo9w/oFBCCrHslxa UDxXfIFES7qVAaXvGNubfabxKVn4DscZRRIKFj+yOl7osxRWI6KJGhIw/x/j305jbJKa i/xQ== X-Gm-Message-State: AOJu0Yx1I32uxI+N0HI60I/W657r9WQT67uiQRBOlsoMLrQKy1CQ+zyn Gb6AACDyV4wLSlkqx8j0qNuNTFcTBrHflRNJW7ctcQfuFmsaPnsqvjHopCPqhjo= X-Received: by 2002:a05:6a21:199:b0:1a7:9e84:dc51 with SMTP id le25-20020a056a21019900b001a79e84dc51mr1952924pzb.7.1712622003695; Mon, 08 Apr 2024 17:20:03 -0700 (PDT) Received: from ?IPV6:2601:647:4180:9630::e8c1? ([2601:647:4180:9630::e8c1]) by smtp.gmail.com with ESMTPSA id y22-20020a056a00181600b006ed0b798f1fsm5677375pfa.119.2024.04.08.17.20.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Apr 2024 17:20:02 -0700 (PDT) Message-ID: Date: Mon, 8 Apr 2024 17:20:01 -0700 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 v5 04/22] drivers/perf: riscv: Use BIT macro for shifting operations Content-Language: en-US To: Andrew Jones Cc: linux-kernel@vger.kernel.org, Ajay Kaher , Alexandre Ghiti , Alexey Makhalov , Anup Patel , Conor Dooley , Juergen Gross , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Paolo Bonzini , Paul Walmsley , Shuah Khan , virtualization@lists.linux.dev, VMware PV-Drivers Reviewers , Will Deacon , x86@kernel.org References: <20240403080452.1007601-1-atishp@rivosinc.com> <20240403080452.1007601-5-atishp@rivosinc.com> <20240404-9a84f2090d00f6b994e1de7c@orel> From: Atish Patra In-Reply-To: <20240404-9a84f2090d00f6b994e1de7c@orel> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/4/24 04:08, Andrew Jones wrote: > On Wed, Apr 03, 2024 at 01:04:33AM -0700, Atish Patra wrote: >> It is a good practice to use BIT() instead of (1UL << x). > > (1UL << x) isn't generally a problem. The problem is with (1 << x). > Yes. That's why, the commit message said it's good to have :) I improved the commit message to specify about 1 << x as well. >> Replace the current usages with BIT(). >> >> Signed-off-by: Atish Patra >> --- >> arch/riscv/include/asm/sbi.h | 20 ++++++++++---------- >> drivers/perf/riscv_pmu_sbi.c | 2 +- >> 2 files changed, 11 insertions(+), 11 deletions(-) >> >> diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h >> index ef8311dafb91..4afa2cd01bae 100644 >> --- a/arch/riscv/include/asm/sbi.h >> +++ b/arch/riscv/include/asm/sbi.h >> @@ -233,20 +233,20 @@ enum sbi_pmu_ctr_type { >> #define SBI_PMU_EVENT_IDX_INVALID 0xFFFFFFFF >> >> /* Flags defined for config matching function */ >> -#define SBI_PMU_CFG_FLAG_SKIP_MATCH (1 << 0) >> -#define SBI_PMU_CFG_FLAG_CLEAR_VALUE (1 << 1) >> -#define SBI_PMU_CFG_FLAG_AUTO_START (1 << 2) >> -#define SBI_PMU_CFG_FLAG_SET_VUINH (1 << 3) >> -#define SBI_PMU_CFG_FLAG_SET_VSINH (1 << 4) >> -#define SBI_PMU_CFG_FLAG_SET_UINH (1 << 5) >> -#define SBI_PMU_CFG_FLAG_SET_SINH (1 << 6) >> -#define SBI_PMU_CFG_FLAG_SET_MINH (1 << 7) >> +#define SBI_PMU_CFG_FLAG_SKIP_MATCH BIT(0) >> +#define SBI_PMU_CFG_FLAG_CLEAR_VALUE BIT(1) >> +#define SBI_PMU_CFG_FLAG_AUTO_START BIT(2) >> +#define SBI_PMU_CFG_FLAG_SET_VUINH BIT(3) >> +#define SBI_PMU_CFG_FLAG_SET_VSINH BIT(4) >> +#define SBI_PMU_CFG_FLAG_SET_UINH BIT(5) >> +#define SBI_PMU_CFG_FLAG_SET_SINH BIT(6) >> +#define SBI_PMU_CFG_FLAG_SET_MINH BIT(7) >> >> /* Flags defined for counter start function */ >> -#define SBI_PMU_START_FLAG_SET_INIT_VALUE (1 << 0) >> +#define SBI_PMU_START_FLAG_SET_INIT_VALUE BIT(0) >> >> /* Flags defined for counter stop function */ >> -#define SBI_PMU_STOP_FLAG_RESET (1 << 0) >> +#define SBI_PMU_STOP_FLAG_RESET BIT(0) >> >> enum sbi_ext_dbcn_fid { >> SBI_EXT_DBCN_CONSOLE_WRITE = 0, >> diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c >> index babf1b9a4dbe..a83ae82301e3 100644 >> --- a/drivers/perf/riscv_pmu_sbi.c >> +++ b/drivers/perf/riscv_pmu_sbi.c >> @@ -386,7 +386,7 @@ static int pmu_sbi_ctr_get_idx(struct perf_event *event) >> cmask = 1; >> } else if (event->attr.config == PERF_COUNT_HW_INSTRUCTIONS) { >> cflags |= SBI_PMU_CFG_FLAG_SKIP_MATCH; >> - cmask = 1UL << (CSR_INSTRET - CSR_CYCLE); >> + cmask = BIT(CSR_INSTRET - CSR_CYCLE); >> } >> } >> >> -- >> 2.34.1 >> > > Other than the commit message, > > Reviewed-by: Andrew Jones > > Thanks, > drew