Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp636882pxb; Fri, 15 Oct 2021 12:43:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyWL2+LeayC18vRTuDNOWPk36C1DLn0WGxAQLmhSAq+LV3Q/9XjB+x57cY48qn0Ux3A7wc X-Received: by 2002:a63:8c4d:: with SMTP id q13mr10578242pgn.92.1634327039649; Fri, 15 Oct 2021 12:43:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634327039; cv=none; d=google.com; s=arc-20160816; b=bvUC8PzZsBZR7SutZQe0p4iwMdXcSWGCIQil60ddjaN5cMtVkW0r/GP8nLngtsb9p8 i8ykA1Remq3RKtMebSXO6mVlc6lieLO2vapbNSbRBSJKJgvIx6K5kVm40LlwWoC8nKNP Lg35NVKbTu7sHO+kLCk90tvYtKyPaUwHxltiKmMxBM7xVKWKB69s/EgTmucpH5nM8OAb 5gqX/jlyChClo2ZzDoXGmpMIRZ9WldODZtzVbSCprYnNsFu3RkWwcr/mg34hi4TgBPcB Hy1Ezcc40A2mbTSQ3APrCnDOnzQmgVq0ThVKcW8zhUfAe9U3h7AwX3FHdGI4OyDww6tr 9YzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=V+cJjSvq0XoSXqji+O0DNO47WqNt7WusSScjO7880JI=; b=oR+iiaSc4L8hZHOMOQDau7+ngbejy5h9ePCgriNHP/yLxk4JMTtjKOauXmqzPx+Lki 8Li2jfDEMw2Oc5Vo0aKKVG3YhZWRqdKlG3zviWneV3U7Dto14SQdFy9Av++IfPpEReRc Ga1vtW47Aut692XgW8d0R0rBXN0U2YjLOnNsbMeyyBYGttSXJSq1EdWg44oQ0Yg1cBVn uGcpdQ5JPytPXN1WzpRXfJoLNaPY3nD3vMVf+QONERnzUIFzquDoUQ6+Li5fAXDuKmzt EUSLRhD2bqtw6WPrSXvFr14t2K4qUx2uTUA3wxmoqmOC5CK0ClPwKBgodu+TZxvUl0+r L57g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FVGuAdBj; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o13si17513759pji.10.2021.10.15.12.43.47; Fri, 15 Oct 2021 12:43:59 -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=@kernel.org header.s=k20201202 header.b=FVGuAdBj; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238274AbhJOLJA (ORCPT + 99 others); Fri, 15 Oct 2021 07:09:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:37842 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238259AbhJOLI7 (ORCPT ); Fri, 15 Oct 2021 07:08:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BA28A6108E; Fri, 15 Oct 2021 11:06:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634296013; bh=5urlJjG5MT9l7GOh70p04V26dTETlNdlw6d/u8+w/ko=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=FVGuAdBjTlMWVyDLJKPYT4Pxk30LhF2eJ+PesWGxyoE8+JZlg46DBUn3uMnQxfxlq dZtJKD69i1OatanhUQJlZeccpYDqJJQhErfCdX/YoqBUTuaoX9nXGVqFnNKzJfO6+x rNNMcexzNQBML8n9QYK7lqcbnx8D4RFVsTTyOKl3bvCduqUwyP7g7cChw4lKlZla/x 5QfQCtCz+Pw2pZxa0FmNvxIwEdZyw90fZcvJL1XSWPr57CV0NoDgwblGQqFuoMDidW XwZiC0KXhA/3uCcgmF1I2BR4aNvA/tc/PTRayqDioUt9kVUJJgyMMs9oBWgZt4hMAG R4oTa71yf1TIg== Date: Fri, 15 Oct 2021 06:06:50 -0500 From: Bjorn Helgaas To: menglong8.dong@gmail.com Cc: bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Menglong Dong Subject: Re: [PATCH v2] pci: call cond_resched() after pci bus config writing Message-ID: <20211015110650.GA2088919@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211015024025.2916363-1-imagedong@tencent.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 15, 2021 at 10:40:25AM +0800, menglong8.dong@gmail.com wrote: > From: Menglong Dong > > While the system is running in KVM, pci config writing for virtio devices > may cost long time (about 1-2ms), as it causes VM-exit. During > __pci_bus_assign_resources(), pci_setup_bridge(), which can write pci > config up to 10 times, can be called many times without any > cond_resched(). So __pci_bus_assign_resources() can cause 25+ms > scheduling latency with !CONFIG_PREEMPT. > > To solve this problem, call cond_resched() after pci config writing. See https://lore.kernel.org/r/20211013190014.GA1909934@bhelgaas for comments about subject line, s/pci/PCI/, line length, etc. > Signed-off-by: Menglong Dong > --- > v2: > - use cond_resched() instead of _cond_resched() > --- > drivers/pci/access.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/pci/access.c b/drivers/pci/access.c > index 46935695cfb9..4c52a50f2c46 100644 > --- a/drivers/pci/access.c > +++ b/drivers/pci/access.c > @@ -57,6 +57,7 @@ int noinline pci_bus_write_config_##size \ > pci_lock_config(flags); \ > res = bus->ops->write(bus, devfn, pos, len, value); \ > pci_unlock_config(flags); \ > + cond_resched(); \ > return res; \ > } > > -- > 2.27.0 >