diff mbox series

[net-next] mlx5_en: use read sequence for gettimex64

Message ID 20241014170103.2473580-1-vadfed@meta.com (mailing list archive)
State Accepted
Commit 0452a2d8b8b98a5b1a9139c1a9ed98bccee356cc
Delegated to: Netdev Maintainers
Headers show
Series [net-next] mlx5_en: use read sequence for gettimex64 | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 2 maintainers not CCed: linux-rdma@vger.kernel.org pabeni@redhat.com
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 20 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-10-15--06-00 (tests: 777)

Commit Message

Vadim Fedorenko Oct. 14, 2024, 5:01 p.m. UTC
The gettimex64() doesn't modify values in timecounter, that's why there
is no need to update sequence counter. Reduce the contention on sequence
lock for multi-thread PHC reading use-case.

Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Rahul Rameshbabu Oct. 18, 2024, 4:08 a.m. UTC | #1
On Mon, 14 Oct, 2024 10:01:03 -0700 Vadim Fedorenko <vadfed@meta.com> wrote:
> The gettimex64() doesn't modify values in timecounter, that's why there
> is no need to update sequence counter. Reduce the contention on sequence
> lock for multi-thread PHC reading use-case.
>
> Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
> index b306ae79bf97..4822d01123b4 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
> @@ -402,9 +402,7 @@ static int mlx5_ptp_gettimex(struct ptp_clock_info *ptp, struct timespec64 *ts,
>  			     struct ptp_system_timestamp *sts)
>  {
>  	struct mlx5_clock *clock = container_of(ptp, struct mlx5_clock, ptp_info);
> -	struct mlx5_timer *timer = &clock->timer;
>  	struct mlx5_core_dev *mdev;
> -	unsigned long flags;
>  	u64 cycles, ns;
>  
>  	mdev = container_of(clock, struct mlx5_core_dev, clock);
> @@ -413,10 +411,8 @@ static int mlx5_ptp_gettimex(struct ptp_clock_info *ptp, struct timespec64 *ts,
>  		goto out;
>  	}
>  
> -	write_seqlock_irqsave(&clock->lock, flags);
>  	cycles = mlx5_read_time(mdev, sts, false);
> -	ns = timecounter_cyc2time(&timer->tc, cycles);
> -	write_sequnlock_irqrestore(&clock->lock, flags);
> +	ns = mlx5_timecounter_cyc2time(clock, cycles);
>  	*ts = ns_to_timespec64(ns);
>  out:
>  	return 0;

The patch seems like a good cleanup to me. Like Vadim mentioned, we
should not need to update the timecounter since this simply a read
operation.

Reviewed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Vadim Fedorenko Oct. 30, 2024, 10:17 a.m. UTC | #2
On 18/10/2024 05:08, Rahul Rameshbabu wrote:
> On Mon, 14 Oct, 2024 10:01:03 -0700 Vadim Fedorenko <vadfed@meta.com> wrote:
>> The gettimex64() doesn't modify values in timecounter, that's why there
>> is no need to update sequence counter. Reduce the contention on sequence
>> lock for multi-thread PHC reading use-case.
>>
>> Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
>> ---
>>   drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 6 +-----
>>   1 file changed, 1 insertion(+), 5 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
>> index b306ae79bf97..4822d01123b4 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
>> @@ -402,9 +402,7 @@ static int mlx5_ptp_gettimex(struct ptp_clock_info *ptp, struct timespec64 *ts,
>>   			     struct ptp_system_timestamp *sts)
>>   {
>>   	struct mlx5_clock *clock = container_of(ptp, struct mlx5_clock, ptp_info);
>> -	struct mlx5_timer *timer = &clock->timer;
>>   	struct mlx5_core_dev *mdev;
>> -	unsigned long flags;
>>   	u64 cycles, ns;
>>   
>>   	mdev = container_of(clock, struct mlx5_core_dev, clock);
>> @@ -413,10 +411,8 @@ static int mlx5_ptp_gettimex(struct ptp_clock_info *ptp, struct timespec64 *ts,
>>   		goto out;
>>   	}
>>   
>> -	write_seqlock_irqsave(&clock->lock, flags);
>>   	cycles = mlx5_read_time(mdev, sts, false);
>> -	ns = timecounter_cyc2time(&timer->tc, cycles);
>> -	write_sequnlock_irqrestore(&clock->lock, flags);
>> +	ns = mlx5_timecounter_cyc2time(clock, cycles);
>>   	*ts = ns_to_timespec64(ns);
>>   out:
>>   	return 0;
> 
> The patch seems like a good cleanup to me. Like Vadim mentioned, we
> should not need to update the timecounter since this simply a read
> operation.
> 
> Reviewed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>

Rahul, Tariq,

will you take it through mlx5-next, or should it go directly to
net-next?

Thanks!
Tariq Toukan Nov. 5, 2024, 5:30 p.m. UTC | #3
On 30/10/2024 12:17, Vadim Fedorenko wrote:
> On 18/10/2024 05:08, Rahul Rameshbabu wrote:
>> On Mon, 14 Oct, 2024 10:01:03 -0700 Vadim Fedorenko <vadfed@meta.com> 
>> wrote:
>>> The gettimex64() doesn't modify values in timecounter, that's why there
>>> is no need to update sequence counter. Reduce the contention on sequence
>>> lock for multi-thread PHC reading use-case.
>>>
>>> Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
>>> ---
>>>   drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 6 +-----
>>>   1 file changed, 1 insertion(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/ 
>>> drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
>>> index b306ae79bf97..4822d01123b4 100644
>>> --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
>>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
>>> @@ -402,9 +402,7 @@ static int mlx5_ptp_gettimex(struct 
>>> ptp_clock_info *ptp, struct timespec64 *ts,
>>>                    struct ptp_system_timestamp *sts)
>>>   {
>>>       struct mlx5_clock *clock = container_of(ptp, struct mlx5_clock, 
>>> ptp_info);
>>> -    struct mlx5_timer *timer = &clock->timer;
>>>       struct mlx5_core_dev *mdev;
>>> -    unsigned long flags;
>>>       u64 cycles, ns;
>>>       mdev = container_of(clock, struct mlx5_core_dev, clock);
>>> @@ -413,10 +411,8 @@ static int mlx5_ptp_gettimex(struct 
>>> ptp_clock_info *ptp, struct timespec64 *ts,
>>>           goto out;
>>>       }
>>> -    write_seqlock_irqsave(&clock->lock, flags);
>>>       cycles = mlx5_read_time(mdev, sts, false);
>>> -    ns = timecounter_cyc2time(&timer->tc, cycles);
>>> -    write_sequnlock_irqrestore(&clock->lock, flags);
>>> +    ns = mlx5_timecounter_cyc2time(clock, cycles);
>>>       *ts = ns_to_timespec64(ns);
>>>   out:
>>>       return 0;
>>
>> The patch seems like a good cleanup to me. Like Vadim mentioned, we
>> should not need to update the timecounter since this simply a read
>> operation.
>>
>> Reviewed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
> 
> Rahul, Tariq,
> 
> will you take it through mlx5-next, or should it go directly to
> net-next?
> 
> Thanks!
> 

Hi,

Sorry for the late response, I missed this question previously.

Acked-by: Tariq Toukan <tariqt@nvidia.com>

Should go to net-next.

Regards,
Tariq
patchwork-bot+netdevbpf@kernel.org Nov. 5, 2024, 11:50 p.m. UTC | #4
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 14 Oct 2024 10:01:03 -0700 you wrote:
> The gettimex64() doesn't modify values in timecounter, that's why there
> is no need to update sequence counter. Reduce the contention on sequence
> lock for multi-thread PHC reading use-case.
> 
> Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)

Here is the summary with links:
  - [net-next] mlx5_en: use read sequence for gettimex64
    https://git.kernel.org/netdev/net-next/c/0452a2d8b8b9

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
index b306ae79bf97..4822d01123b4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
@@ -402,9 +402,7 @@  static int mlx5_ptp_gettimex(struct ptp_clock_info *ptp, struct timespec64 *ts,
 			     struct ptp_system_timestamp *sts)
 {
 	struct mlx5_clock *clock = container_of(ptp, struct mlx5_clock, ptp_info);
-	struct mlx5_timer *timer = &clock->timer;
 	struct mlx5_core_dev *mdev;
-	unsigned long flags;
 	u64 cycles, ns;
 
 	mdev = container_of(clock, struct mlx5_core_dev, clock);
@@ -413,10 +411,8 @@  static int mlx5_ptp_gettimex(struct ptp_clock_info *ptp, struct timespec64 *ts,
 		goto out;
 	}
 
-	write_seqlock_irqsave(&clock->lock, flags);
 	cycles = mlx5_read_time(mdev, sts, false);
-	ns = timecounter_cyc2time(&timer->tc, cycles);
-	write_sequnlock_irqrestore(&clock->lock, flags);
+	ns = mlx5_timecounter_cyc2time(clock, cycles);
 	*ts = ns_to_timespec64(ns);
 out:
 	return 0;