public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v3] ice: use proper macro for testing bit
@ 2024-06-18 11:11 Petr Oros
  2024-06-18 13:43 ` Jiri Pirko
  2024-06-24  6:47 ` [Intel-wired-lan] " Pucha, HimasekharX Reddy
  0 siblings, 2 replies; 3+ messages in thread
From: Petr Oros @ 2024-06-18 11:11 UTC (permalink / raw)
  To: netdev
  Cc: ivecera, przemyslaw.kitszel, horms, Petr Oros, Alexander Lobakin,
	Jesse Brandeburg, Tony Nguyen, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Eric Joyner, Marcin Domagala,
	moderated list:INTEL ETHERNET DRIVERS, open list

Do not use _test_bit() macro for testing bit. The proper macro for this
is one without underline.

_test_bit() is what test_bit() was prior to const-optimization. It
directly calls arch_test_bit(), i.e. the arch-specific implementation
(or the generic one). It's strictly _internal_ and shouldn't be used
anywhere outside the actual test_bit() macro.

test_bit() is a wrapper which checks whether the bitmap and the bit
number are compile-time constants and if so, it calls the optimized
function which evaluates this call to a compile-time constant as well.
If either of them is not a compile-time constant, it just calls _test_bit().
test_bit() is the actual function to use anywhere in the kernel.

IOW, calling _test_bit() avoids potential compile-time optimizations.

The sensors is not a compile-time constant, thus most probably there
are no object code changes before and after the patch.
But anyway, we shouldn't call internal wrappers instead of
the actual API.

Fixes: 4da71a77fc3b ("ice: read internal temperature sensor")
Acked-by: Ivan Vecera <ivecera@redhat.com>
Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Signed-off-by: Petr Oros <poros@redhat.com>
---
 drivers/net/ethernet/intel/ice/ice_hwmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_hwmon.c b/drivers/net/ethernet/intel/ice/ice_hwmon.c
index e4c2c1bff6c086..b7aa6812510a4f 100644
--- a/drivers/net/ethernet/intel/ice/ice_hwmon.c
+++ b/drivers/net/ethernet/intel/ice/ice_hwmon.c
@@ -96,7 +96,7 @@ static bool ice_is_internal_reading_supported(struct ice_pf *pf)
 
 	unsigned long sensors = pf->hw.dev_caps.supported_sensors;
 
-	return _test_bit(ICE_SENSOR_SUPPORT_E810_INT_TEMP_BIT, &sensors);
+	return test_bit(ICE_SENSOR_SUPPORT_E810_INT_TEMP_BIT, &sensors);
 };
 
 void ice_hwmon_init(struct ice_pf *pf)
-- 
2.44.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net v3] ice: use proper macro for testing bit
  2024-06-18 11:11 [PATCH net v3] ice: use proper macro for testing bit Petr Oros
@ 2024-06-18 13:43 ` Jiri Pirko
  2024-06-24  6:47 ` [Intel-wired-lan] " Pucha, HimasekharX Reddy
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Pirko @ 2024-06-18 13:43 UTC (permalink / raw)
  To: Petr Oros
  Cc: netdev, ivecera, przemyslaw.kitszel, horms, Alexander Lobakin,
	Jesse Brandeburg, Tony Nguyen, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Eric Joyner, Marcin Domagala,
	moderated list:INTEL ETHERNET DRIVERS, open list

Tue, Jun 18, 2024 at 01:11:19PM CEST, poros@redhat.com wrote:
>Do not use _test_bit() macro for testing bit. The proper macro for this
>is one without underline.
>
>_test_bit() is what test_bit() was prior to const-optimization. It
>directly calls arch_test_bit(), i.e. the arch-specific implementation
>(or the generic one). It's strictly _internal_ and shouldn't be used
>anywhere outside the actual test_bit() macro.
>
>test_bit() is a wrapper which checks whether the bitmap and the bit
>number are compile-time constants and if so, it calls the optimized
>function which evaluates this call to a compile-time constant as well.
>If either of them is not a compile-time constant, it just calls _test_bit().
>test_bit() is the actual function to use anywhere in the kernel.
>
>IOW, calling _test_bit() avoids potential compile-time optimizations.
>
>The sensors is not a compile-time constant, thus most probably there
>are no object code changes before and after the patch.
>But anyway, we shouldn't call internal wrappers instead of
>the actual API.
>
>Fixes: 4da71a77fc3b ("ice: read internal temperature sensor")
>Acked-by: Ivan Vecera <ivecera@redhat.com>
>Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
>Signed-off-by: Petr Oros <poros@redhat.com>

Reviewed-by: Jiri Pirko <jiri@nvidia.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [Intel-wired-lan] [PATCH net v3] ice: use proper macro for testing bit
  2024-06-18 11:11 [PATCH net v3] ice: use proper macro for testing bit Petr Oros
  2024-06-18 13:43 ` Jiri Pirko
@ 2024-06-24  6:47 ` Pucha, HimasekharX Reddy
  1 sibling, 0 replies; 3+ messages in thread
From: Pucha, HimasekharX Reddy @ 2024-06-24  6:47 UTC (permalink / raw)
  To: poros, netdev@vger.kernel.org
  Cc: ivecera, Eric Dumazet, Kitszel, Przemyslaw, open list,
	Joyner, Eric, Lobakin, Aleksander, Nguyen, Anthony L,
	horms@kernel.org, Marcin Domagala, Jakub Kicinski, Paolo Abeni,
	David S. Miller, moderated list:INTEL ETHERNET DRIVERS

> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Petr Oros
> Sent: Tuesday, June 18, 2024 4:41 PM
> To: netdev@vger.kernel.org
> Cc: ivecera <ivecera@redhat.com>; Eric Dumazet <edumazet@google.com>; Kitszel, Przemyslaw <przemyslaw.kitszel@intel.com>; open list <linux-kernel@vger.kernel.org>; Joyner, Eric <eric.joyner@intel.com>; Lobakin, Aleksander <aleksander.lobakin@intel.com>; Nguyen, Anthony L <anthony.l.nguyen@intel.com>; horms@kernel.org; Marcin Domagala <marcinx.domagala@intel.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; David S. Miller <davem@davemloft.net>; moderated list:INTEL ETHERNET DRIVERS <intel-wired-lan@lists.osuosl.org>
> Subject: [Intel-wired-lan] [PATCH net v3] ice: use proper macro for testing bit
>
> Do not use _test_bit() macro for testing bit. The proper macro for this is one without underline.
>
> _test_bit() is what test_bit() was prior to const-optimization. It directly calls arch_test_bit(), i.e. the arch-specific implementation (or the generic one). It's strictly _internal_ and shouldn't be used anywhere outside the actual test_bit() macro.
> 
> test_bit() is a wrapper which checks whether the bitmap and the bit number are compile-time constants and if so, it calls the optimized function which evaluates this call to a compile-time constant as well.
> If either of them is not a compile-time constant, it just calls _test_bit().
> test_bit() is the actual function to use anywhere in the kernel.
>
> IOW, calling _test_bit() avoids potential compile-time optimizations.
>
> The sensors is not a compile-time constant, thus most probably there are no object code changes before and after the patch.
> But anyway, we shouldn't call internal wrappers instead of the actual API.
>
> Fixes: 4da71a77fc3b ("ice: read internal temperature sensor")
> Acked-by: Ivan Vecera <ivecera@redhat.com>
> Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
> Signed-off-by: Petr Oros <poros@redhat.com>
> ---
>  drivers/net/ethernet/intel/ice/ice_hwmon.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-24  6:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-18 11:11 [PATCH net v3] ice: use proper macro for testing bit Petr Oros
2024-06-18 13:43 ` Jiri Pirko
2024-06-24  6:47 ` [Intel-wired-lan] " Pucha, HimasekharX Reddy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox