Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp293426ybi; Mon, 15 Jul 2019 21:03:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLe7Eg2W8zYZUZe2as09OBX899rEODv0WSg6uY0a6qmDbgAlWHGB+x9ya+lTxpP++QRNr7 X-Received: by 2002:a63:130f:: with SMTP id i15mr30169035pgl.158.1563249821556; Mon, 15 Jul 2019 21:03:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563249821; cv=none; d=google.com; s=arc-20160816; b=U8MD+BToaGwCwweoqPqUaKwYfaIdSWckTXVfgabrJ7a5hVsNqhT7ZM7O5geWAZEX9v Rvvca7WPfBZ2DwWqjXVTdfCyot/kzIhdQseBXoOubJcfzkrF+Yoa4LfGMxWHqpcvzBit H1vsGZmx2Q1CMISV0LO/bzoQXbHYrqykXzlD6RI7JH9fVARwEpw9ePFiO8+sabLxn2u4 VIzqtsx0vVt0VtGfw+vmCQKhF0LJXw0uVz5O+F8z1UqsT3akoC5kCDDvHYHO0DJIwoAl z1vqKsNEFdCawbzjm7FCDkgnSBb122eKRvW2Zm2euA9nVJMROG7E6JtPdkdSfpAmqKir 2Dew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=emWs4O8hlB2TIuNtkX4TCZFbfAkCg1SZuUU8yDd2sEA=; b=Y9BRjyBwtn1pEf7k3DvM84Vm1Z3AeJfwFAAEPSz1IC2T+sFXVI/JVZrRAGbHAXhtWk AJ4YdXrJKhAIgZB05XiRJdbs//1Js311HoDjuadwJkvfXYIRJC3ur1Sat1d8cqcx9AzX M0shSYBv1Zha8rUyNMZsPIgQiNZKi4rAQ8OjEDe9CL/+kdcJgWcnvrr14P0tV8cCj4ld 24RAGPPwpp3SlzxU+nz5wlTlEf1k48j+c7Y9lhh6PNvQXjLbKN8sxoicmCf+4Av1QCBR 0lr58w8PeefavbgOI3zmpQroakFzRzdUlr99bznsbaKVVtu0E9X30rY7Gwu+OHK8UMTO EeLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=EUayzWAA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o33si17298433plb.408.2019.07.15.21.03.25; Mon, 15 Jul 2019 21:03:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=EUayzWAA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726528AbfGPEDI (ORCPT + 99 others); Tue, 16 Jul 2019 00:03:08 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:39804 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726443AbfGPEDH (ORCPT ); Tue, 16 Jul 2019 00:03:07 -0400 Received: by mail-pg1-f195.google.com with SMTP id u17so8734745pgi.6 for ; Mon, 15 Jul 2019 21:03:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=emWs4O8hlB2TIuNtkX4TCZFbfAkCg1SZuUU8yDd2sEA=; b=EUayzWAAPKzWkqzvEU0EkCIPVbFaXgTPLnhPDPXNEGqZowkwVyB0fuRja+ukvx2jRx /JsAJvv2ngG4+HyMb/ksTKGTTuCNw6tiK8jigG3DyiGHLTshKdgdlpd3cg/yvXQ34IXh LxYQ1MLKK8X//mQ7Xm/s6D4lgquYO/nzn6BMw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=emWs4O8hlB2TIuNtkX4TCZFbfAkCg1SZuUU8yDd2sEA=; b=jmmRdHlqlWame8i5AaIAmL1toJCI0vG8wSPGYg0wwvomYHqLt6NlHYU6lxH3JeCd5M qgVDUXEj2lmKd4CdCossHbzNqIxJa00f5QlnAslyihxSJq0kjaBOCDvJtDd6h51irOkh dhtbzx/qeUd0rhpdr+yTiMiz1zaxo6cGjTqA9RdomM4F/FahIvdzBHYdj9x4v+Jk+X9t ZYhpl4vj7xzHWCK+L3OOvcdNUjtSVBjx3c1S0IBf/Qa3a1ydoVhXNbELrvQ7dmtl1SEz DPceD7GRUf2iZa8+0jiE0opxGrKH+8srCkv1CEsPdO/RwG6mQ3+rO7TbQEArThK/O1XP lVvg== X-Gm-Message-State: APjAAAXFQwH/pOMEyEcIL+TlVIKDitfK2ms187CK1YXx9KLq+DOfmARN kpHGpXxYY7ZPoIyeHtuL8t4= X-Received: by 2002:a17:90a:374a:: with SMTP id u68mr33288835pjb.4.1563249786384; Mon, 15 Jul 2019 21:03:06 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id y133sm21032895pfb.28.2019.07.15.21.03.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 21:03:05 -0700 (PDT) Date: Tue, 16 Jul 2019 00:03:03 -0400 From: Joel Fernandes To: Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, Alexey Kuznetsov , Borislav Petkov , c0d1n61at3@gmail.com, "David S. Miller" , edumazet@google.com, Greg Kroah-Hartman , Hideaki YOSHIFUJI , "H. Peter Anvin" , Ingo Molnar , Jonathan Corbet , Josh Triplett , keescook@chromium.org, kernel-hardening@lists.openwall.com, kernel-team@android.com, Lai Jiangshan , Len Brown , linux-acpi@vger.kernel.org, linux-doc@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Mathieu Desnoyers , neilb@suse.com, netdev@vger.kernel.org, Oleg Nesterov , "Paul E. McKenney" , Pavel Machek , peterz@infradead.org, "Rafael J. Wysocki" , Rasmus Villemoes , rcu@vger.kernel.org, Steven Rostedt , Tejun Heo , Thomas Gleixner , will@kernel.org, "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Subject: Re: [PATCH 7/9] x86/pci: Pass lockdep condition to pcm_mmcfg_list iterator (v1) Message-ID: <20190716040303.GA73383@google.com> References: <20190715143705.117908-1-joel@joelfernandes.org> <20190715143705.117908-8-joel@joelfernandes.org> <20190715200235.GG46935@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190715200235.GG46935@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 15, 2019 at 03:02:35PM -0500, Bjorn Helgaas wrote: > On Mon, Jul 15, 2019 at 10:37:03AM -0400, Joel Fernandes (Google) wrote: > > The pcm_mmcfg_list is traversed with list_for_each_entry_rcu without a > > reader-lock held, because the pci_mmcfg_lock is already held. Make this > > known to the list macro so that it fixes new lockdep warnings that > > trigger due to lockdep checks added to list_for_each_entry_rcu(). > > > > Signed-off-by: Joel Fernandes (Google) > > Ingo takes care of most patches to this file, but FWIW, > > Acked-by: Bjorn Helgaas Thanks. > I would personally prefer if you capitalized the subject to match the > "x86/PCI:" convention that's used fairly consistently in > arch/x86/pci/. > > Also, I didn't apply this to be sure, but it looks like this might > make a line or two wider than 80 columns, which I would rewrap if I > were applying this. Updated below is the patch with the nits corrected: ---8<----------------------- From 73fab09d7e33ca2110c24215f8ed428c12625dbe Mon Sep 17 00:00:00 2001 From: "Joel Fernandes (Google)" Date: Sat, 1 Jun 2019 15:05:49 -0400 Subject: [PATCH] x86/PCI: Pass lockdep condition to pcm_mmcfg_list iterator (v1) The pcm_mmcfg_list is traversed with list_for_each_entry_rcu without a reader-lock held, because the pci_mmcfg_lock is already held. Make this known to the list macro so that it fixes new lockdep warnings that trigger due to lockdep checks added to list_for_each_entry_rcu(). Acked-by: Bjorn Helgaas Signed-off-by: Joel Fernandes (Google) --- arch/x86/pci/mmconfig-shared.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c index 7389db538c30..9e3250ec5a37 100644 --- a/arch/x86/pci/mmconfig-shared.c +++ b/arch/x86/pci/mmconfig-shared.c @@ -29,6 +29,7 @@ static bool pci_mmcfg_running_state; static bool pci_mmcfg_arch_init_failed; static DEFINE_MUTEX(pci_mmcfg_lock); +#define pci_mmcfg_lock_held() lock_is_held(&(pci_mmcfg_lock).dep_map) LIST_HEAD(pci_mmcfg_list); @@ -54,7 +55,8 @@ static void list_add_sorted(struct pci_mmcfg_region *new) struct pci_mmcfg_region *cfg; /* keep list sorted by segment and starting bus number */ - list_for_each_entry_rcu(cfg, &pci_mmcfg_list, list) { + list_for_each_entry_rcu(cfg, &pci_mmcfg_list, list, + pci_mmcfg_lock_held()) { if (cfg->segment > new->segment || (cfg->segment == new->segment && cfg->start_bus >= new->start_bus)) { @@ -118,7 +120,8 @@ struct pci_mmcfg_region *pci_mmconfig_lookup(int segment, int bus) { struct pci_mmcfg_region *cfg; - list_for_each_entry_rcu(cfg, &pci_mmcfg_list, list) + list_for_each_entry_rcu(cfg, &pci_mmcfg_list, list + pci_mmcfg_lock_held()) if (cfg->segment == segment && cfg->start_bus <= bus && bus <= cfg->end_bus) return cfg; -- 2.22.0.510.g264f2c817a-goog