Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp419857ybf; Fri, 28 Feb 2020 00:20:21 -0800 (PST) X-Google-Smtp-Source: APXvYqzgk5chkNqb+uh5UGVEEV+H9iAHPE0p0R7vxbXsSTMYcC5QFmPX0FGyidhFcmTxte1shlwn X-Received: by 2002:a05:6830:10d7:: with SMTP id z23mr2380112oto.114.1582878021651; Fri, 28 Feb 2020 00:20:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582878021; cv=none; d=google.com; s=arc-20160816; b=vaUtk/iW0gP9W/I2Irmj3cdcIPk/P1QxFnAgXU9ZIcmuwUYS7D6erbxYJEEmCQBE1d oTxcAj40PkuqliwlK7JstgGFjyUc5Gp+eeVrOVBfH/BcOLH6li3NW7rxdZkCSFzYDTDV cfhElQD6GxoOmacMRc2ZWO/StaNTJI5fMBALL7KNs0bT5a76tNPnfsayzXuaef0bGw9c FMM2MD0O/B8TPU5cbMvKKOyRi8l+5KwLBMYNkLsJ6fP7Y/eF+9gkpHYFbASM8IoDHpch jP5FYDTtAwASTfPRl8SzTI5VL+j9wopRx+v2eJidJod3o4tRV4uiL1pT3qKMr8khnGzf 8PTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=82hR3jxtPv4UggNL0wzEkgrjlskYE39vomAxuJiCLBc=; b=sygLdgbC1br66re3f7Nw+Tu28y+/Eb9/hl/znpSUPBAEiSJrF/yk2+pqk6wHqYdWck Li3Gg0gzAy0VEfhXnfZqLF9j/JlFxnR8C1oZa6XAEJNWanvPAT2V5gXiKkFeAsiS2qLQ eaeDMpIsWf6sNZzNJ6OEZYw0IVjSXKCc5AFj0SBhP4lBLShIU5sQgt7jvpHHcexZC3FV eCWxVNizecc+aASWKN2K/ui2SqdIMcYX+Vmv7YqiK+QMqAWfO3murxc0MnCuYzZ0aEEo dRBYDqY+5E2+iLoYTlpLx8ik6/MsiLg55VV82sr3jP30zbdX0l6X7JIJaQz8kE1h/AoB fgQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lF8EzwU6; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j33si1169974ota.21.2020.02.28.00.20.09; Fri, 28 Feb 2020 00:20:21 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=lF8EzwU6; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726359AbgB1ITe (ORCPT + 99 others); Fri, 28 Feb 2020 03:19:34 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34835 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725871AbgB1ITe (ORCPT ); Fri, 28 Feb 2020 03:19:34 -0500 Received: by mail-pf1-f193.google.com with SMTP id i19so1344374pfa.2 for ; Fri, 28 Feb 2020 00:19:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=82hR3jxtPv4UggNL0wzEkgrjlskYE39vomAxuJiCLBc=; b=lF8EzwU6FiMyfYM17VgdfJRlWA1Cngg7w662b4E4QrKszsubmtKTlYbyi5xobHoLQK 3i6p/VlC6tP3jrlL++O+5zrHqkw+7BzZY5YEg9hT+d9iCru4cq++vUG6ZFd9758OuQMD a9X+2PvDkLyvjcKf6zLj6h/twbH9Wb8B+vH9dmkGPEQXqA53hWhTsPv25xz9sAKkSCT7 TVN/jNsx5Q5wQb7mfmdqMiEtEjR6aTmAQDcq+a9WUjLqOmflo7sJbVnbx0yXZ81447nk /j1mmawMVmBu37FXmc0oIfCUnrDW8BmszNpbWdPIyfrTrYtfN5Kh5PvNHWuLrCMY9m+K 21SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=82hR3jxtPv4UggNL0wzEkgrjlskYE39vomAxuJiCLBc=; b=ud7mI9uRj/O1fF7r/WGVtnGvA1w87+EeJ5APiiLhuW6n4dimOkzbOYx6gAMOXr4RtC 2XJutWXx7KXIncMKpDYfHE0WAun8e9d/K0c/D00A8Fq66F8YlvLp+7sdjJ/RAUIU5Gjf Sa0P2ojRXyhxn7mKc/RWPM6uK2pkx6tVgtlQCYQ2B39WYZ9B4PqpXjofA877IuutA4ys yz3Kd3DoanAodB6Z0bCZiVSkeqnD7kpFh/X2D54B67uwwugCj6M2v1jWOULR9xIDdika jTCS8JBGsnggSw3eLafl2jHnJ8T0mRYL5QRuNV19WgnraIat+KMvdljgy4zN459ulnhq Zl7Q== X-Gm-Message-State: APjAAAVbvwatzjtF68L7yj7Yt9bBqyUGzn2Fk2NSg7Em/G1uGondUNtI 7d+j9qP4HafeGN5nYeVh1cI= X-Received: by 2002:a62:e708:: with SMTP id s8mr3377192pfh.122.1582877972863; Fri, 28 Feb 2020 00:19:32 -0800 (PST) Received: from localhost.localdomain ([103.87.56.81]) by smtp.gmail.com with ESMTPSA id w18sm10370516pfq.167.2020.02.28.00.19.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2020 00:19:31 -0800 (PST) From: Amol Grover To: Corey Minyard , Arnd Bergmann , Greg Kroah-Hartman Cc: openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, John Garry , Joel Fernandes , Madhuparna Bhowmik , "Paul E . Mckenney" , Amol Grover Subject: [PATCH] ipmi: Fix RCU list lockdep debugging warnings Date: Fri, 28 Feb 2020 13:47:33 +0530 Message-Id: <20200228081731.18149-1-frextrite@gmail.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is completely safe to traverse ipmi_interfaces and intf->users under SRCU read lock using list_for_each_entry_rcu(). Tell lockdep about it as well else it will show false-positive warnings as the one below. Fixes the following false-positive warning and others that may follow. [ 29.772408] ============================= [ 29.776863] WARNING: suspicious RCU usage [ 29.780915] 5.6.0-rc3-00001-g907305ae6618-dirty #1755 Not tainted [ 29.787046] ----------------------------- [ 29.791100] drivers/char/ipmi/ipmi_msghandler.c:744 RCU-list traversed in non-reader section!! Reported-by: John Garry Suggested-by: Paul E. McKenney Signed-off-by: Amol Grover --- drivers/char/ipmi/ipmi_msghandler.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index cad9563f8f48..d202022c69de 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -741,7 +741,8 @@ int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher) list_add(&watcher->link, &smi_watchers); index = srcu_read_lock(&ipmi_interfaces_srcu); - list_for_each_entry_rcu(intf, &ipmi_interfaces, link) { + list_for_each_entry_rcu(intf, &ipmi_interfaces, link, + srcu_read_lock_held(&ipmi_interfaces_srcu)) { int intf_num = READ_ONCE(intf->intf_num); if (intf_num == -1) @@ -1188,7 +1189,8 @@ int ipmi_create_user(unsigned int if_num, return -ENOMEM; index = srcu_read_lock(&ipmi_interfaces_srcu); - list_for_each_entry_rcu(intf, &ipmi_interfaces, link) { + list_for_each_entry_rcu(intf, &ipmi_interfaces, link, + srcu_read_lock_held(&ipmi_interfaces_srcu)) { if (intf->intf_num == if_num) goto found; } @@ -1241,7 +1243,8 @@ int ipmi_get_smi_info(int if_num, struct ipmi_smi_info *data) struct ipmi_smi *intf; index = srcu_read_lock(&ipmi_interfaces_srcu); - list_for_each_entry_rcu(intf, &ipmi_interfaces, link) { + list_for_each_entry_rcu(intf, &ipmi_interfaces, link, + srcu_read_lock_held(&ipmi_interfaces_srcu)) { if (intf->intf_num == if_num) goto found; } @@ -4098,7 +4101,8 @@ static int handle_read_event_rsp(struct ipmi_smi *intf, * getting events. */ index = srcu_read_lock(&intf->users_srcu); - list_for_each_entry_rcu(user, &intf->users, link) { + list_for_each_entry_rcu(user, &intf->users, link, + srcu_read_lock_held(&intf->users_srcu)) { if (!user->gets_events) continue; @@ -4453,7 +4457,8 @@ static void handle_new_recv_msgs(struct ipmi_smi *intf) int index; index = srcu_read_lock(&intf->users_srcu); - list_for_each_entry_rcu(user, &intf->users, link) { + list_for_each_entry_rcu(user, &intf->users, link, + srcu_read_lock_held(&intf->users_srcu)) { if (user->handler->ipmi_watchdog_pretimeout) user->handler->ipmi_watchdog_pretimeout( user->handler_data); @@ -4746,7 +4751,8 @@ static void ipmi_timeout(struct timer_list *unused) return; index = srcu_read_lock(&ipmi_interfaces_srcu); - list_for_each_entry_rcu(intf, &ipmi_interfaces, link) { + list_for_each_entry_rcu(intf, &ipmi_interfaces, link, + srcu_read_lock_held(&ipmi_interfaces_srcu)) { if (atomic_read(&intf->event_waiters)) { intf->ticks_to_req_ev--; if (intf->ticks_to_req_ev == 0) { -- 2.25.0