netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Wei Wang <weiwan@google.com>
Cc: "Jakub Kicinski" <kuba@kernel.org>,
	"Eric Dumazet" <edumazet@google.com>, 李哲 <sensor1010@163.com>,
	davem@davemloft.net, pabeni@redhat.com, imagedong@tencent.com,
	kuniyu@amazon.com, petrm@nvidia.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] net/dev.c : Remove redundant state settings after waking up
Date: Wed, 11 Jan 2023 08:32:42 +0100	[thread overview]
Message-ID: <Y75mGsoe5XUVtqqa@linutronix.de> (raw)
In-Reply-To: <CAEA6p_AdUL-NgX-C9j0DRNbwnc+nKPnwKRY8dXNCEZ4_pnTOXQ@mail.gmail.com>

On 2023-01-10 16:42:56 [-0800], Wei Wang wrote:
> I was not able to see the entire changelog, but I don't think
> > -               set_current_state(TASK_INTERRUPTIBLE);
> is redundant.
> 
> It makes sure that if the previous if statement:
>     if (test_bit(NAPI_STATE_SCHED_THREADED, &napi->state) || woken)
> is false, this napi thread yields the CPU to other threads waiting to
> be run by calling schedule().

It made sense in the beginning but now the suggested patch is a clean
up. First the `woken' parameter was added in commit
   cb038357937ee ("net: fix race between napi kthread mode and busy poll")

and then the `napi_disable_pending' check was removed in commit
   27f0ad71699de ("net: fix hangup on napi_disable for threaded napi")

which renders the code to:
|         while (!kthread_should_stop()) {
|                 if (test_bit(NAPI_STATE_SCHED_THREADED, &napi->state) || woken) {
|                         WARN_ON(!list_empty(&napi->poll_list));
|                         __set_current_state(TASK_RUNNING);
|                         return 0;
|                 }
| 
|                 schedule();
|                 /* woken being true indicates this thread owns this napi. */
|                 woken = true;
|                 set_current_state(TASK_INTERRUPTIBLE);
|         }
|         __set_current_state(TASK_RUNNING);

so when you get out of schedule() woken is set and even if
NAPI_STATE_SCHED_THREADED is not set, the while() loop is left due to
`woken = true'. So changing state to TASK_INTERRUPTIBLE makes no sense
since it will be set back to TASK_RUNNING cycles later.

Sebastian

  reply	other threads:[~2023-01-11  7:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10  9:14 [PATCH v1] net/dev.c : Remove redundant state settings after waking up 李哲
2023-01-10  9:29 ` Eric Dumazet
2023-01-11  0:30   ` Jakub Kicinski
2023-01-11  0:42     ` Wei Wang
2023-01-11  7:32       ` Sebastian Andrzej Siewior [this message]
2023-01-11 18:20         ` Jakub Kicinski
2023-01-11 19:39           ` Wei Wang
     [not found]             ` <706ea669.7a09.1869dce0851.Coremail.sensor1010@163.com>
2023-03-01 17:07               ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y75mGsoe5XUVtqqa@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=imagedong@tencent.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.com \
    --cc=sensor1010@163.com \
    --cc=weiwan@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).