From patchwork Wed Jun 9 10:33:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= X-Patchwork-Id: 12309581 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=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 5E79EC48BCD for ; Wed, 9 Jun 2021 10:38:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2C016608FE for ; Wed, 9 Jun 2021 10:38:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C016608FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tBftBEyU9Pj/ih6QPK8BC9RVMn7oWYh22l1taewJfqs=; b=ZZyo4CsHr6s1FO VKJnRvaGFXEqPeN46yIsztK0i9wfZQYz1/0jYRgUuYOkZBEYtbd/BX+AQTV+vpFePvKWn61F5z/sR iIHzSUecG0Lmu+XPiXk2xx/o8FBWlHWqrYdVVjZGfbaYJVhtsO1Y1xSNMRPaY7Cj81eqFrvmEuaw0 wy/TIVDyWNytp+2A648EqohOCui1eWzj3N6lgnijRk34J0ipBsxOAY+tm0XtNLY6orPEk19Z+57nk dCAWOiM6gg/Yp8Xt7ePhDYKPLoUPyhoqQSxwPweEZ/wpkxi0J1og/Tu6gtGvMJJ+Zp+hpTRKHvPdg lW2yQFx0nET2f0oHgSXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqvZP-00D2oR-GP; Wed, 09 Jun 2021 10:36:24 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqvWn-00D1eK-4b for linux-arm-kernel@lists.infradead.org; Wed, 09 Jun 2021 10:33:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623234818; 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=VOVdIjFGkWIiDQLhZ4O8JX1OgtVYddfMXm2FFCs+0ZU=; b=LAnJttbNrUiWR2jOVwxyBmNgve0PIw+ucCws4rRMGvf31AVFRO1TM6uDXlfrXH1Ob96LHh zHKw8fp8lhVhaBBCsVQClWmHcl/vbJf+YzytHjji1pl0xZr0C7wYih/4h8FP0rswXbnu4D 3xzy7Nj5RcPssF6QUZA/r1AMCsWxrEo= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-574-LkNt_keGMCKBVD2jYXEi-A-1; Wed, 09 Jun 2021 06:33:37 -0400 X-MC-Unique: LkNt_keGMCKBVD2jYXEi-A-1 Received: by mail-ed1-f70.google.com with SMTP id u21-20020aa7d5550000b02903937d876df1so5430239edr.20 for ; Wed, 09 Jun 2021 03:33:37 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=VOVdIjFGkWIiDQLhZ4O8JX1OgtVYddfMXm2FFCs+0ZU=; b=Y8+b3LsXh0ahpp8jHvugTOoWFZVBnMdJhdX6SvxOtp/+9p69A0g3Zi/51wkhT/OA7V QEiak3hqY6wfdLrcT5GP0/dhZhuo4z3u89aGnlUtbZ8R1KkGO1bPSt0WaULVeS34WJ2Z L/jArRMSEua5D4rxQ6KBxF7CSbcwiH5XS5VmasfJovkjeqYIqey6tg98eHgimectP4KN UWFSNf2pJbapo6FQA5CkRNUGfkKi3v6gmYDESDUDn+c+0r/N3qI5UlD5SUnMayZY/my8 kQWtWwkLKIZ5g5xP8totTmfDfX3ehdv7gs+pxyT8IW5wT29eKEpxDv7fkCwzqZ2yLmRI 5rAA== X-Gm-Message-State: AOAM532fUq72lNelHe8QhwEfdJOzaaihr5v6CKWLIuoi1uDEl3FDVEW8 X+qKCF51A1GAEbLKPXE/xz2VudYZWo8j3GbOCGLliJPLUKyWl5CtJwZOsHFiFfjkAYLpIwbUcXw gQQ0FpnnjJbL5LDEhhNyCCPMktWm5KDkKNbQ= X-Received: by 2002:aa7:c547:: with SMTP id s7mr29599537edr.239.1623234816147; Wed, 09 Jun 2021 03:33:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJsMQfvKo7/nhkmRlLMchZWxJh31qEpOl87eLrNsvu1Nhy2NQKMbTQafLxov+eQh4WGHJZIQ== X-Received: by 2002:aa7:c547:: with SMTP id s7mr29599525edr.239.1623234816007; Wed, 09 Jun 2021 03:33:36 -0700 (PDT) Received: from alrua-x1.borgediget.toke.dk ([45.145.92.2]) by smtp.gmail.com with ESMTPSA id c6sm916307eje.9.2021.06.09.03.33.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 03:33:32 -0700 (PDT) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 95EA618072B; Wed, 9 Jun 2021 12:33:30 +0200 (CEST) From: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= To: bpf@vger.kernel.org, netdev@vger.kernel.org Cc: Martin KaFai Lau , Hangbin Liu , Jesper Dangaard Brouer , Magnus Karlsson , "Paul E . McKenney" , =?utf-8?q?Toke_H=C3=B8iland-J?= =?utf-8?q?=C3=B8rgensen?= , Sunil Goutham , linux-arm-kernel@lists.infradead.org Subject: [PATCH bpf-next 07/17] thunderx: remove rcu_read_lock() around XDP program invocation Date: Wed, 9 Jun 2021 12:33:16 +0200 Message-Id: <20210609103326.278782-8-toke@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210609103326.278782-1-toke@redhat.com> References: <20210609103326.278782-1-toke@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=toke@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210609_033341_311308_1F7A0900 X-CRM114-Status: GOOD ( 13.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The thunderx driver has rcu_read_lock()/rcu_read_unlock() pairs around XDP program invocations. However, the actual lifetime of the objects referred by the XDP program invocation is longer, all the way through to the call to xdp_do_flush(), making the scope of the rcu_read_lock() too small. This turns out to be harmless because it all happens in a single NAPI poll cycle (and thus under local_bh_disable()), but it makes the rcu_read_lock() misleading. Rather than extend the scope of the rcu_read_lock(), just get rid of it entirely. With the addition of RCU annotations to the XDP_REDIRECT map types that take bh execution into account, lockdep even understands this to be safe, so there's really no reason to keep it around. Cc: Sunil Goutham Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Toke Høiland-Jørgensen --- drivers/net/ethernet/cavium/thunder/nicvf_main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c index c33b4e837515..e2b290135fd9 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c @@ -555,9 +555,7 @@ static inline bool nicvf_xdp_rx(struct nicvf *nic, struct bpf_prog *prog, xdp_prepare_buff(&xdp, hard_start, data - hard_start, len, false); orig_data = xdp.data; - rcu_read_lock(); action = bpf_prog_run_xdp(prog, &xdp); - rcu_read_unlock(); len = xdp.data_end - xdp.data; /* Check if XDP program has changed headers */