Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp663783ybl; Thu, 23 Jan 2020 05:38:55 -0800 (PST) X-Google-Smtp-Source: APXvYqyzA7wIAq5Ohv9G0oaNikVdM/4GYQGyZ7wcE4QS/2VnUYnh5KmtF0pz4M7/VroVaMIoiihm X-Received: by 2002:a05:6830:1e2d:: with SMTP id t13mr11750307otr.128.1579786735385; Thu, 23 Jan 2020 05:38:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579786735; cv=none; d=google.com; s=arc-20160816; b=nxSZg8Ctdk0RO1E0BXrfOgDWutF64xg+MQSi5199XUu3NVpQQihvHp+lEvFR7O3epv mjWBiBw6xX0bRd9QPgDDDQmOypBbF3kZVDfiB6yOMNoPtBnfhcAEkm3sLL1RkFWOty2b Rxb5YPOAago8oFJrh7Jnh3zs87vwpn4aEhBWpfwZ2TOpJbrtv0YfRDMLPGhop5cd7+HD Ox/XH4A6pwEjlfABtmVEv7yqOOAkWCOhjM78oq5I6skYSpZ88c01YwIpueeLu+XQeZsD 9CGjd31VSrEQzJUCK01+uCK0ZDDbm63+Y49S7adFWJOVIdqyppGCffq9FfHT84b3Gsk1 L87w== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=D/mKKFH0Pgl6eS/j/YSBbgLp/TGqqZwcT4ZYT6DqoVE=; b=sSzpaPFBcyJDzKjhKoX89bsrE195cpbLyOBKEKzrJThgEOx+ezYTYD4lZpFVEz2lgJ mPqstOT+LD8wRpowITjX8xm1VDnfAW7nDrZB4LU3yhTIQiu+J7N9lMKEoB2RlX+Ocuej tJbl0F+sObfgBSv5zX5JhJEL6nSYlXCOA+cUm6mewNPD9j5ZVutxsZsl6wyIN5zqzUwl X74QKlmt4m4EmsUElcPOjuhIllQouEdLtEsddcvyhZLsti8RYgxCOUypVfw+uvWzldmz XfU6rBaVsn0PElQaj/IHK6JQKrgO4AlCOPDAx0vUIgdUPbllL8iYf0UU1zXvQCyWH71k dLZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ehfZwprk; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u15si806770oie.265.2020.01.23.05.38.42; Thu, 23 Jan 2020 05:38:55 -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=@redhat.com header.s=mimecast20190719 header.b=ehfZwprk; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727453AbgAWNho (ORCPT + 99 others); Thu, 23 Jan 2020 08:37:44 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:59903 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726729AbgAWNhn (ORCPT ); Thu, 23 Jan 2020 08:37:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579786662; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D/mKKFH0Pgl6eS/j/YSBbgLp/TGqqZwcT4ZYT6DqoVE=; b=ehfZwprk0j1lEJz4juilZedVKzN146EAVxRRqQehD2Tfb3OGMGmCjXJr0I+IFQEgHMe5Eg heFKqpzhXGXdwfl9gpIzMK/fGtyRaY5En8B++uub1ZJforNmrPBNbkFzDMEip4/9122x7t UPLbJaxwgdjdw/J1mmOePcAlON23t7g= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-76-RmPa_-kPPlyz1GZ6KM_CTA-1; Thu, 23 Jan 2020 08:37:37 -0500 X-MC-Unique: RmPa_-kPPlyz1GZ6KM_CTA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 96BAE800D48; Thu, 23 Jan 2020 13:37:34 +0000 (UTC) Received: from carbon (ovpn-200-37.brq.redhat.com [10.40.200.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40B737C42C; Thu, 23 Jan 2020 13:37:26 +0000 (UTC) Date: Thu, 23 Jan 2020 14:37:25 +0100 From: Jesper Dangaard Brouer To: Amol Grover Cc: brouer@redhat.com, Alexei Starovoitov , Daniel Borkmann , "David S . Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Joel Fernandes , Madhuparna Bhowmik , "Paul E . McKenney" Subject: Re: [PATCH] bpf: devmap: Pass lockdep expression to RCU lists Message-ID: <20200123143725.036140e7@carbon> In-Reply-To: <20200123120437.26506-1-frextrite@gmail.com> References: <20200123120437.26506-1-frextrite@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 23 Jan 2020 17:34:38 +0530 Amol Grover wrote: > head is traversed using hlist_for_each_entry_rcu outside an > RCU read-side critical section but under the protection > of dtab->index_lock. We do hold the lock in update and delete cases, but not in the lookup cases. Is it then still okay to add the lockdep_is_held() annotation? If it is then it looks fine to me: Acked-by: Jesper Dangaard Brouer > Hence, add corresponding lockdep expression to silence false-positive > lockdep warnings, and harden RCU lists. > > Signed-off-by: Amol Grover > --- > kernel/bpf/devmap.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c > index 3d3d61b5985b..b4b6b77f309c 100644 > --- a/kernel/bpf/devmap.c > +++ b/kernel/bpf/devmap.c > @@ -293,7 +293,8 @@ struct bpf_dtab_netdev *__dev_map_hash_lookup_elem(struct bpf_map *map, u32 key) > struct hlist_head *head = dev_map_index_hash(dtab, key); > struct bpf_dtab_netdev *dev; > > - hlist_for_each_entry_rcu(dev, head, index_hlist) > + hlist_for_each_entry_rcu(dev, head, index_hlist, > + lockdep_is_held(&dtab->index_lock)) > if (dev->idx == key) > return dev; > -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer