diff mbox series

[net-next] r8169: improve handling task scheduling

Message ID c65873a3-7394-4107-99a7-83f20030779c@gmail.com (mailing list archive)
State Accepted
Commit 127532cd0f060ebc3c4cbca81b6438728ad5896e
Delegated to: Netdev Maintainers
Headers show
Series [net-next] r8169: improve handling task scheduling | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/codegen success Generated files up to date
netdev/tree_selection success Clearly marked for net-next
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: 1115 this patch: 1115
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 1142 this patch: 1142
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: 1142 this patch: 1142
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 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

Commit Message

Heiner Kallweit Nov. 27, 2023, 5:20 p.m. UTC
If we know that the task is going to be a no-op, don't even schedule it.
And remove the check for netif_running() in the worker function, the
check for flag RTL_FLAG_TASK_ENABLED is sufficient. Note that we can't
remove the check for flag RTL_FLAG_TASK_ENABLED in the worker function
because we have no guarantee when it will be executed.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/ethernet/realtek/r8169_main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Przemek Kitszel Nov. 28, 2023, 11:53 a.m. UTC | #1
On 11/27/23 18:20, Heiner Kallweit wrote:
> If we know that the task is going to be a no-op, don't even schedule it.
> And remove the check for netif_running() in the worker function, the
> check for flag RTL_FLAG_TASK_ENABLED is sufficient. Note that we can't
> remove the check for flag RTL_FLAG_TASK_ENABLED in the worker function
> because we have no guarantee when it will be executed.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>   drivers/net/ethernet/realtek/r8169_main.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> index b74d7cc50..91d9dc5a7 100644
> --- a/drivers/net/ethernet/realtek/r8169_main.c
> +++ b/drivers/net/ethernet/realtek/r8169_main.c
> @@ -2228,6 +2228,9 @@ u16 rtl8168h_2_get_adc_bias_ioffset(struct rtl8169_private *tp)
>   
>   static void rtl_schedule_task(struct rtl8169_private *tp, enum rtl_flag flag)
>   {
> +	if (!test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags))
> +		return;
> +
>   	set_bit(flag, tp->wk.flags);
>   	schedule_work(&tp->wk.work);
>   }
> @@ -4468,8 +4471,7 @@ static void rtl_task(struct work_struct *work)
>   
>   	rtnl_lock();
>   
> -	if (!netif_running(tp->dev) ||
> -	    !test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags))
> +	if (!test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags))
>   		goto out_unlock;
>   
>   	if (test_and_clear_bit(RTL_FLAG_TASK_TX_TIMEOUT, tp->wk.flags)) {

sounds plausible and likely to run better,

Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
patchwork-bot+netdevbpf@kernel.org Nov. 30, 2023, 3:50 a.m. UTC | #2
Hello:

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

On Mon, 27 Nov 2023 18:20:11 +0100 you wrote:
> If we know that the task is going to be a no-op, don't even schedule it.
> And remove the check for netif_running() in the worker function, the
> check for flag RTL_FLAG_TASK_ENABLED is sufficient. Note that we can't
> remove the check for flag RTL_FLAG_TASK_ENABLED in the worker function
> because we have no guarantee when it will be executed.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> 
> [...]

Here is the summary with links:
  - [net-next] r8169: improve handling task scheduling
    https://git.kernel.org/netdev/net-next/c/127532cd0f06

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index b74d7cc50..91d9dc5a7 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -2228,6 +2228,9 @@  u16 rtl8168h_2_get_adc_bias_ioffset(struct rtl8169_private *tp)
 
 static void rtl_schedule_task(struct rtl8169_private *tp, enum rtl_flag flag)
 {
+	if (!test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags))
+		return;
+
 	set_bit(flag, tp->wk.flags);
 	schedule_work(&tp->wk.work);
 }
@@ -4468,8 +4471,7 @@  static void rtl_task(struct work_struct *work)
 
 	rtnl_lock();
 
-	if (!netif_running(tp->dev) ||
-	    !test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags))
+	if (!test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags))
 		goto out_unlock;
 
 	if (test_and_clear_bit(RTL_FLAG_TASK_TX_TIMEOUT, tp->wk.flags)) {