linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Jiang Biao <benbjiang@gmail.com>
Cc: bhelgaas@google.com, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org, Jiang Biao <benbjiang@tencent.com>,
	Bin Lai <robinlai@tencent.com>
Subject: Re: [PATCH] driver/pci: reduce the single block time in pci_read_config
Date: Thu, 17 Sep 2020 12:32:28 -0500	[thread overview]
Message-ID: <20200917173228.GA1713970@bjorn-Precision-5520> (raw)
In-Reply-To: <20200824052025.48362-1-benbjiang@tencent.com>

On Mon, Aug 24, 2020 at 01:20:25PM +0800, Jiang Biao wrote:
> From: Jiang Biao <benbjiang@tencent.com>
> 
> pci_read_config() could block several ms in kernel space, mainly
> caused by the while loop to call pci_user_read_config_dword().
> Singel pci_user_read_config_dword() loop could consume 130us+,
>               |    pci_user_read_config_dword() {
>               |      _raw_spin_lock_irq() {
> ! 136.698 us  |        native_queued_spin_lock_slowpath();
> ! 137.582 us  |      }
>               |      pci_read() {
>               |        raw_pci_read() {
>               |          pci_conf1_read() {
>   0.230 us    |            _raw_spin_lock_irqsave();
>   0.035 us    |            _raw_spin_unlock_irqrestore();
>   8.476 us    |          }
>   8.790 us    |        }
>   9.091 us    |      }
> ! 147.263 us  |    }
> and dozens of the loop could consume ms+.
> 
> If we execute some lspci commands concurrently, ms+ scheduling
> latency could be detected.
> 
> Add scheduling chance in the loop to improve the latency.
> 
> Reported-by: Bin Lai <robinlai@tencent.com>
> Signed-off-by: Jiang Biao <benbjiang@tencent.com>

Applied to pci/enumeration for v5.10, thanks!

> ---
>  drivers/pci/pci-sysfs.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index 6d78df9..3b9f63d 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -708,6 +708,7 @@ static ssize_t pci_read_config(struct file *filp, struct kobject *kobj,
>  		data[off - init_off + 3] = (val >> 24) & 0xff;
>  		off += 4;
>  		size -= 4;
> +		cond_resched();
>  	}
>  
>  	if (size >= 2) {
> -- 
> 1.8.3.1
> 

      parent reply	other threads:[~2020-09-17 17:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-24  5:20 [PATCH] driver/pci: reduce the single block time in pci_read_config Jiang Biao
2020-08-27  9:49 ` Jiang Biao
2020-09-10  1:25 ` Bjorn Helgaas
2020-09-10  1:54   ` Jiang Biao
2020-09-10  1:59     ` Bjorn Helgaas
2020-09-10  2:18       ` Jiang Biao
2020-09-13  4:27       ` Jiang Biao
2020-09-16 16:56         ` Bjorn Helgaas
2020-09-17  0:22           ` Jiang Biao
2020-09-17 17:32 ` Bjorn Helgaas [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=20200917173228.GA1713970@bjorn-Precision-5520 \
    --to=helgaas@kernel.org \
    --cc=benbjiang@gmail.com \
    --cc=benbjiang@tencent.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=robinlai@tencent.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).