netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Siewior <bigeasy@linutronix.de>
To: Tejun Heo <tj@kernel.org>, Sherry Yang <sherry.yang@oracle.com>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-rt-users@vger.kernel.org,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Jack Vogel <jack.vogel@oracle.com>,
	Tariq Toukan <tariqt@nvidia.com>
Subject: Re: 10% regression in qperf tcp latency after introducing commit "4a61bf7f9b18 random: defer fast pool mixing to worker"
Date: Wed, 28 Sep 2022 13:23:46 +0200	[thread overview]
Message-ID: <YzQuwlc3CIlGWa4u@linutronix.de> (raw)
In-Reply-To: <YyukQ/oU/jkp0OXA@slm.duckdns.org>

On 2022-09-21 13:54:43 [-1000], Tejun Heo wrote:
> Hello,
Hi,

> On Thu, Sep 22, 2022 at 12:32:49AM +0200, Jason A. Donenfeld wrote:
> > What are our options? Investigate queue_work_on() bottlenecks? Move back
> > to the original pattern, but use raw spinlocks? Some thing else?
> 
> I doubt it's queue_work_on() itself if it's called at very high frequency as
> the duplicate calls would just fail to claim the PENDING bit and return but
> if it's being called at a high frequency, it'd be waking up a kthread over
> and over again, which can get pretty expensive. Maybe that ends competing
> with softirqd which is handling net rx or sth?

There is this (simplified):
|         if (new_count & MIX_INFLIGHT)
|                 return;
| 
|         if (new_count < 1024 && !time_is_before_jiffies(fast_pool->last + HZ))
|                 return;
| 
|         fast_pool->count |= MIX_INFLIGHT;
|         queue_work_on(raw_smp_processor_id(), system_highpri_wq, &fast_pool->mix);

at least 1k interrupts are needed and a second must pass before a worker
will be scheduled. Oh wait. We need only one of both. So how many
interrupts do we get per second?
Is the regression coming from more than 1k interrupts in less then a
second or a context switch each second? Because if it is a context
switch every second then I am surprised to see a 10% performance drop in
this case since should happen for other reasons, too unless the CPU is
isolated.

[ There isn't a massive claims of the PENDING bit or wakeups because
fast_pool is per-CPU and due to the MIX_INFLIGHT bit. ]

> So, yeah, I'd try something which doesn't always involve scheduling and a
> context switch whether that's softirq, tasklet, or irq work. I probably am
> mistaken but I thought RT kernel pushes irq handling to threads so that
> these things can be handled sanely. Is this some special case?

As Jason explained this part is invoked in the non-threaded part.

> Thanks.

Sebastian

      parent reply	other threads:[~2022-09-28 11:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <B1BC4DB8-8F40-4975-B8E7-9ED9BFF1D50E@oracle.com>
     [not found] ` <CAHmME9rUn0b5FKNFYkxyrn5cLiuW_nOxUZi3mRpPaBkUo9JWEQ@mail.gmail.com>
     [not found]   ` <04044E39-B150-4147-A090-3D942AF643DF@oracle.com>
     [not found]     ` <CAHmME9oKcqceoFpKkooCp5wriLLptpN=+WrrG0KcDWjBahM0bQ@mail.gmail.com>
     [not found]       ` <BD03BFF6-C369-4D34-A38B-49653F1CBC53@oracle.com>
2022-09-21 22:32         ` 10% regression in qperf tcp latency after introducing commit "4a61bf7f9b18 random: defer fast pool mixing to worker" Jason A. Donenfeld
2022-09-21 23:35           ` Jason A. Donenfeld
2022-09-21 23:54           ` Tejun Heo
2022-09-22 16:45             ` Jason A. Donenfeld
2022-09-22 16:55               ` [PATCH] random: use tasklet rather than workqueue for mixing fast pool Jason A. Donenfeld
2022-09-26 22:04                 ` [PATCH v2] random: use immediate per-cpu timer " Jason A. Donenfeld
2022-09-27  7:41                   ` David Laight
2022-09-27  8:23                     ` Jason A. Donenfeld
2022-09-27 10:42                       ` [PATCH v3] random: use expired per-cpu timer rather than wq " Jason A. Donenfeld
2022-09-28 12:06                         ` Sebastian Andrzej Siewior
2022-09-28 16:15                           ` Jason A. Donenfeld
2022-09-29 14:18                             ` Sebastian Andrzej Siewior
2022-09-28 11:23             ` Sebastian Siewior [this message]

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=YzQuwlc3CIlGWa4u@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=Jason@zx2c4.com \
    --cc=jack.vogel@oracle.com \
    --cc=jiangshanlai@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sherry.yang@oracle.com \
    --cc=tariqt@nvidia.com \
    --cc=tj@kernel.org \
    /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).