Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp758836pxk; Wed, 9 Sep 2020 19:22:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+aK5JLyhBwt12k/VZnbnDGvC1h/rHBFwwn0JLqWcREaFDfIky6wY9PhuG6iXie6iONZ0n X-Received: by 2002:a17:907:4037:: with SMTP id nk7mr6448112ejb.84.1599704528373; Wed, 09 Sep 2020 19:22:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599704528; cv=none; d=google.com; s=arc-20160816; b=D2366/eGlEGHlVgbKzcNtNjQphW29EEWNeZfjh9ciCNCWwfgzxiUXoZir5FrPtrdwP aNxo7k0D6sXGv0F1LBiGzJpdjySpsPhwZ7NFpC7jApeNOeS4ViuZvsVcjwwnkmhmW4kB 9m/ZxBWBzcd36SF1j5EZp93Yc3FRXa8Tphb0BAP5ORN6W2DLXENzFhnrKoe3azCf9KNL GhI7dmQFFkw5F+NM7ZmGmk4sKwvtJ0557FvjyYKveTktVKDZgUdDE2LpJzmw82GbBKSy lmaAVrVSst6G4R0FR3gh9jYKGcBQ/O0SKFmYFREJy+q5dgs8r6PZDblhDUagJNNotubD n05Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=oOk59Y9agev+P1pRd+FxE/mXDXASrAFWiJH4a1Tl+Zw=; b=V/HrUQ6t/IFF3+65ay8dT0xTfdFPJ8UYzbDp7skY5P7aKiq8WjrjzQvW/iXNpggLUI hnvWZ9ug6g4QDHGTKWhf0jXiloUfMvOi8K6YYbj01JHQ/uBw6V1Xz3UgHGPDUXi+3L6w cM1xPlCxNHYS84jukCqxVjmCDKK3mSDFVUAloSeU3ERkocYq/1DN4sSFl/U5fvAz2Dka xBjKQ88Cdpgq8McmT/rMrwmO/gE8f55K0kFkQrzznOjKfjOIAaDdX6tZefKXiThW4cR5 arRMFQObN7xyO8udjdKWttgLlocqpp6iVxBfp3cyr85+4hs+NE0BsqUbnFehTnw6hld2 pCWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AZyRw62Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a19si2752153edx.553.2020.09.09.19.21.46; Wed, 09 Sep 2020 19:22:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AZyRw62Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730581AbgIJCVL (ORCPT + 99 others); Wed, 9 Sep 2020 22:21:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730521AbgIJCSv (ORCPT ); Wed, 9 Sep 2020 22:18:51 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 339CDC06179B; Wed, 9 Sep 2020 19:18:34 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id n2so4493637oij.1; Wed, 09 Sep 2020 19:18:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oOk59Y9agev+P1pRd+FxE/mXDXASrAFWiJH4a1Tl+Zw=; b=AZyRw62QIBBWqODqgus8QIlDN9ibQ7DqITmcyT1IhPcNEonrlcxsqhKKDp8Ak7WyJj rB/O10IRiA8Hu2uF7zkMR/gTloOBd3ArSRLEnZWOxbM5HvZKROv281KCgRRCK8E1U8+/ EnH4Ltms45F4lU3oeU3utrA763/BcUK7OM4BsZ0/6i/ra3vl2MTrh/c2zcL8HraOgp8+ AkKRju51Kr/fWnIRVPtDkLhI9RFc6JnO6fembZvQH8X9Xqs8AZgnj2F6vYzH42q9+IAD EIqb+H6j2VTi181/k82+ylN0/UuwaBCLoEMDhT8nqpNkiLTe13hE7lIadoIQG75RsgyB d1fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oOk59Y9agev+P1pRd+FxE/mXDXASrAFWiJH4a1Tl+Zw=; b=n0PakEsG9HQ2u9vaMxhzCFsFY5g6p6mpX7jPnY9r8V+j2ti7FRm09v6VxLFh1jN58Y vEFYWI9+GAllZ78UtUW/VpoujOsW0uQRmWqlM5U7jRlLo70ad+QZ+WSlsqBarbEQEJrU xNFXE+C8U9DdOl9y6JG1Xxkt9bCf/y0S3us3AVcLkYPE1e1hW5cob4mPJSoPSDta4FUv 9l+tPQRDeFo8nZPrtOgGzw+X2Vru1W9q8qoUqRHs7iHjtWTxTVA6kV8fO1zrElYVaaWd 2RMHrSvoWHvhd8wX5nSwTr/YwWKyPqWkgMFU6HRPrldsKkQ9pJwVHEcHaGIytz4wIh7t fmSg== X-Gm-Message-State: AOAM533jdegbRjy5i/QMYbMGp/WS8oP2vnjgY4jYQE1nMz+V9F2nK5Gh aWlpvI9t1gm/TEjWLT8gwfg0AREqrlbxitMepuP11f01 X-Received: by 2002:a05:6808:3d6:: with SMTP id o22mr2296687oie.150.1599704313667; Wed, 09 Sep 2020 19:18:33 -0700 (PDT) MIME-Version: 1.0 References: <20200910015950.GA748330@bjorn-Precision-5520> In-Reply-To: <20200910015950.GA748330@bjorn-Precision-5520> From: Jiang Biao Date: Thu, 10 Sep 2020 10:18:22 +0800 Message-ID: Subject: Re: [PATCH] driver/pci: reduce the single block time in pci_read_config To: Bjorn Helgaas Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel , Jiang Biao , Bin Lai Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Thu, 10 Sep 2020 at 09:59, Bjorn Helgaas wrote: > > 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. We did catch 5ms+ latency caused by pci_read_config() triggered by concurrent lspcis, and latency disappeared after this patch. For pci_write_config path, we have not met the case actually.:) I'll have some tries to verify that, and would send another patch if verified. Thx. Regards, Jiang