From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98D47C2D0A8 for ; Thu, 10 Sep 2020 02:47:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58F1B21D6C for ; Thu, 10 Sep 2020 02:47:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599706062; bh=eQSHJfWZ3DxC0HJ+ibhPFp1Bf0FdR9SvFxiYcGxWF6I=; h=Date:From:To:Cc:Subject:In-Reply-To:List-ID:From; b=w9mtgimqDtLA9f5bcNftxjRVSW7i/6QjKSS2Ww+KGJdikGkixtbYEQjTeskqs8NmO OypJPviCQEWkzmqpfE/U61OTQ6NZQ2GHgkt9j0kegK0qpZq1n5BCeYJDfnU1nFU/kl BvkYy3YJaImVwoQVWEXBoyUqOHD+QtoMvIQEK2qM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730446AbgIJCri (ORCPT ); Wed, 9 Sep 2020 22:47:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:40150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730375AbgIJB7z (ORCPT ); Wed, 9 Sep 2020 21:59:55 -0400 Received: from localhost (52.sub-72-107-123.myvzw.com [72.107.123.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6B32F206DB; Thu, 10 Sep 2020 01:59:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599703191; bh=eQSHJfWZ3DxC0HJ+ibhPFp1Bf0FdR9SvFxiYcGxWF6I=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=AiZwJ0if6N9KXZ/+Y+yitBZHqIPrOj2JaQFG2eR1JW5GdcWOilKF7bRxXxdA6zYqu IIjUQmmxmmyOswztPrNUh2211cq4RAa9C7t3OgRrGeWTXaCjNhSsMN+dvqK0eoK/24 y2s2RIpdENaFgkeNuM2/3HNLfxDLV70I53U6QsVs= Date: Wed, 9 Sep 2020 20:59:50 -0500 From: Bjorn Helgaas To: Jiang Biao Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel , Jiang Biao , Bin Lai Subject: Re: [PATCH] driver/pci: reduce the single block time in pci_read_config Message-ID: <20200910015950.GA748330@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 10, 2020 at 09:54:02AM +0800, Jiang Biao wrote: > Hi, > > On Thu, 10 Sep 2020 at 09:25, Bjorn Helgaas wrote: > > > > On Mon, Aug 24, 2020 at 01:20:25PM +0800, Jiang Biao wrote: > > > From: Jiang Biao > > > > > > 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. > > > > Thanks for the patch, this makes a lot of sense. > > > > Shouldn't we do the same in pci_write_config()? > Yes, IMHO, that could be helpful too. If it's feasible, it would be nice to actually verify that it makes a difference. I know config writes should be faster than reads, but they're certainly not as fast as a CPU can pump out data, so there must be *some* mechanism that slows the CPU down. Bjorn