From patchwork Wed Jun 23 11:07:17 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: 12339595 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.1 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 46AFAC4743C for ; Wed, 23 Jun 2021 11:10:02 +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 0E04C6102A for ; Wed, 23 Jun 2021 11:10:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E04C6102A 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=tpGMN/UnIZKBI9BpIsZVlKUnGSxRbo0HBfrkWJ1dMsM=; b=DR3gLrc+WT3qKk yIE2IpPK7Hm7LwxA6HbKedAW0M+U+WCjrMFlvXGbgiakeS6JEfg3vcBVIkLSWpwS7fN5YhefYls/l 3/tZnPZ1szXzDQv+XgpSSx2angIb7wUAE3RMsMZWWQDPEqeDFTDgwej8MO40DGmvHO8PXd7jKnV+x yeg36zMzof2JEFTofxHkF8TAqum1FtSAZDEDgxFjy8hFfnD1T32WEdhR38C+cp5kkhEZKpmb94pm4 F4r8bEKwxUoT0U2E7f1CheIQpuxc3JyHuYY0Xh9t9eAR51wZ66ANFaIwf7TpGil7CSWhqgiUhKcWj eLpketHtDZTZAMQdJI8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lw0je-00AOcX-8a; Wed, 23 Jun 2021 11:07:58 +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 1lw0jS-00AOYi-1I for linux-arm-kernel@lists.infradead.org; Wed, 23 Jun 2021 11:07:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624446461; 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=2arA4F9H8piXSu2BaYZfrwo91oZXpALZLKMt5odcOCY=; b=hoTptrQ1oNZF6tVlP4yTZbJxhrLrXfX1w4jccoy9OpyUkixBBW0+0RhwHMsagLFacQtb/3 Ghv0rEgjP5jTjfOaI5q0ebPLrDTUPH9/NFudSH6pneZ0Yji1zPO/h65ycwcOZzyHP7VI4e QXvh9IWlUWX/IRzrAfGnsM1J1AkB1zQ= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-132-ugI1W5GzPWCXtBe8RtN29g-1; Wed, 23 Jun 2021 07:07:38 -0400 X-MC-Unique: ugI1W5GzPWCXtBe8RtN29g-1 Received: by mail-ed1-f72.google.com with SMTP id dy23-20020a05640231f7b0290394996f1452so1093159edb.18 for ; Wed, 23 Jun 2021 04:07:38 -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=2arA4F9H8piXSu2BaYZfrwo91oZXpALZLKMt5odcOCY=; b=pKk45jdCxLLKEUEFlj5YTHixtEjj1RNuescE8OvsDT2xmwQvDtqgbWb6ZP6E9zBzFP nmhWjZ9A5dka9jO0EAXDio/jacTT4tf2nc90HUpINzYw3mUblkjiKvlTCXcjaRRu3jeE TgyZfqePR1G6t0M1d5csk69VcpkaAHgpy3xz02X9ADDruRM0ywPCedFJQYkstAVPPHim NBfFZCBLhhUb+s6X3jRfAee6SX0AI6zpmasjOiMBRNMk51VDZ0a6ctpFP4b58a9tAzkk mgom1g8GaYogpRJgYjlGC+WJv8ZK/Km4vCCR/txt1olzQ4e0PXXs4V1AS3rx3hD0/wQE v+zw== X-Gm-Message-State: AOAM530d/GfoutOi3bBROWzsrpyhruMF2uT3G1A48shCa7jc5NnODK5v /X2/DKy6k7yU06wYS6UcXZrFJNpm7SCJRH0G9HN0WhAG+p5+0fnhDcSh3Z7LmbY6Fm/dXjGtDFx 0SH+m2ftush5i+QvBapM+x/PMDTIWq8pxMA8= X-Received: by 2002:a17:906:190c:: with SMTP id a12mr9070043eje.491.1624446457193; Wed, 23 Jun 2021 04:07:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfYOxCXGNl6WwCkAT61NO9Jw5DYitkekz8LmF8VlrNsuA0TOsWQBt9kYvTmODjjA976dI+eg== X-Received: by 2002:a17:906:190c:: with SMTP id a12mr9070029eje.491.1624446457054; Wed, 23 Jun 2021 04:07:37 -0700 (PDT) Received: from alrua-x1.borgediget.toke.dk ([45.145.92.2]) by smtp.gmail.com with ESMTPSA id jl21sm5514474ejc.42.2021.06.23.04.07.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 04:07:35 -0700 (PDT) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 32D22180739; Wed, 23 Jun 2021 13:07:28 +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" , Jakub Kicinski , =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= , Sunil Goutham , linux-arm-kernel@lists.infradead.org Subject: [PATCH bpf-next v4 09/19] thunderx: remove rcu_read_lock() around XDP program invocation Date: Wed, 23 Jun 2021 13:07:17 +0200 Message-Id: <20210623110727.221922-10-toke@redhat.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210623110727.221922-1-toke@redhat.com> References: <20210623110727.221922-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-20210623_040746_248149_A5E66DB0 X-CRM114-Status: GOOD ( 13.56 ) 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 */