From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAF08C48BDF for ; Thu, 10 Jun 2021 18:39:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4801613DF for ; Thu, 10 Jun 2021 18:39:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231266AbhFJSlG (ORCPT ); Thu, 10 Jun 2021 14:41:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231293AbhFJSlF (ORCPT ); Thu, 10 Jun 2021 14:41:05 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 585AEC0617A8; Thu, 10 Jun 2021 11:39:08 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id a1so4707955lfr.12; Thu, 10 Jun 2021 11:39:08 -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:content-transfer-encoding; bh=nE5V0361lJGgCdwlFos44U3eitBmblPsO6nM+FoDnC8=; b=USIhsgIapgtE4uiwFOmNcEABgHo/lqw4uiqARcpo2NCn4Xki2YfXyOzg2SS6yaRuLD qDTpS2jb88LuPHe0UoRIs0iWrmcq8jjorzlHhe2swD7lHGpaWeOnZMHYXiyozj4+cOXY ySEMFBdFGBu9kKz5ppCUuWRsYkp9VIe4/SEVy5aiGQjYa3RLOYYDQYO83cTWZHgFkDrT OXxR5EYjRdsITS3o6m6QS4ixg8DHwu4lpQclIx7kWmKQjWpZku0v7t7cRFvcwGnzT1PC cX5gKpmQBVb6iwLKq2mOOBxO7qixVD7BetJua5t7WITZy4qGuFISiq7lLEmtv9e4Jah+ Th1w== 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:content-transfer-encoding; bh=nE5V0361lJGgCdwlFos44U3eitBmblPsO6nM+FoDnC8=; b=phR325uc0A/ZQr4R483jYy0g9A3osCmxZ186eHDsdkgrSCuM92lddL8OU9PQ53YIdk 85fjcUHF2xWenDDfspkJU6s07qb1djI1e3KAtt3UZGJoRDu1Owuh8IZ01O93ClAJ7F2a eTq8HirKRCV/sdSmB3s4RbMMILb7nape6l5SXQilkGNX0PEKd2eP62TkulpnTSmX/N4k raLAIQ8jdT+n9xDJ/kuItKNumzxpHzlRSS3/fAA2k6RLLp7x5aN+0ICwyZaoVABxqSCJ Gk30j5vB5Y+zaIG1xvJbIPyOoqCTVQ8vrNlBkiVDNhYBCm4T1OeRYXzhHXTcbROc+eAf G+SA== X-Gm-Message-State: AOAM5331+LIJzillCBrYSPfTj3lde4b6ocIPKUnDBNgly9qiEBhhh04W 82YcAm7EsmJKwUJjoqbGFXF5Zk7XCBi/UDiIFok= X-Google-Smtp-Source: ABdhPJzx0sLcryTM/UgXpz0Bq1YgTXvSzvpPqDE9jLakOHemD8iucRorJiHPQAsAG3o092yxlpdfJs6G+OcKPmxuX6c= X-Received: by 2002:ac2:5551:: with SMTP id l17mr132123lfk.534.1623350346588; Thu, 10 Jun 2021 11:39:06 -0700 (PDT) MIME-Version: 1.0 References: <20210609103326.278782-1-toke@redhat.com> <20210609103326.278782-3-toke@redhat.com> In-Reply-To: <20210609103326.278782-3-toke@redhat.com> From: Alexei Starovoitov Date: Thu, 10 Jun 2021 11:38:55 -0700 Message-ID: Subject: Re: [PATCH bpf-next 02/17] bpf: allow RCU-protected lookups to happen from bh context To: =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= Cc: bpf , Network Development , Martin KaFai Lau , Hangbin Liu , Jesper Dangaard Brouer , Magnus Karlsson , "Paul E . McKenney" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Wed, Jun 9, 2021 at 7:24 AM Toke H=C3=B8iland-J=C3=B8rgensen wrote: > > XDP programs are called from a NAPI poll context, which means the RCU > reference liveness is ensured by local_bh_disable(). Add > rcu_read_lock_bh_held() as a condition to the RCU checks for map lookups = so > lockdep understands that the dereferences are safe from inside *either* a= n > rcu_read_lock() section *or* a local_bh_disable() section. This is done i= n > preparation for removing the redundant rcu_read_lock()s from the drivers. > > Signed-off-by: Toke H=C3=B8iland-J=C3=B8rgensen > --- > kernel/bpf/hashtab.c | 21 ++++++++++++++------- > kernel/bpf/helpers.c | 6 +++--- > kernel/bpf/lpm_trie.c | 6 ++++-- > 3 files changed, 21 insertions(+), 12 deletions(-) > > diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c > index 6f6681b07364..72c58cc516a3 100644 > --- a/kernel/bpf/hashtab.c > +++ b/kernel/bpf/hashtab.c > @@ -596,7 +596,8 @@ static void *__htab_map_lookup_elem(struct bpf_map *m= ap, void *key) > struct htab_elem *l; > u32 hash, key_size; > > - WARN_ON_ONCE(!rcu_read_lock_held() && !rcu_read_lock_trace_held()= ); > + WARN_ON_ONCE(!rcu_read_lock_held() && !rcu_read_lock_trace_held()= && > + !rcu_read_lock_bh_held()); It's not clear to me whether rcu_read_lock_held() is still needed. All comments sound like rcu_read_lock_bh_held() is a superset of rcu that includes bh. But reading rcu source code it looks like RCU_BH is its own rcu flavor... which is confusing.