Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp485021lqh; Tue, 7 May 2024 05:36:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXTPMvO6d/ZfANVm6Sz6YdjSgp2EMiOHu5yA3HUL5ZOYRcAbM3uUHUAxiEAiLME8Nt64XKQ0LHYBW1ygc5q9fdasr5/QPSzN4qK/6+vjA== X-Google-Smtp-Source: AGHT+IGk/tjhQQ2ZRxHSxy1uoFx6AjihmPp5ZCCz7GZ070YejHZ4V1+ujkSe5bZ3pwK1M3zd5Olb X-Received: by 2002:a05:622a:1aaa:b0:43a:f821:5a8d with SMTP id s42-20020a05622a1aaa00b0043af8215a8dmr16153837qtc.9.1715085411938; Tue, 07 May 2024 05:36:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715085411; cv=pass; d=google.com; s=arc-20160816; b=w5VfsNjiGHwea4mHGetUNTlyU72vRT9wAi33e3W4kcogfgJBzqdKFVEAAyQ4en3T2i +N3bzFtcGRSL1zXQUFga13R+00+fOdwcbYB2gl0m0Yk3B9LFzB8Hrg7GJ9ITJloD31h1 nMN3rhqk8tJTGRSpL7TyAyoIKCVjGEDnn6+jS1is5usz+2/ganQRsiXA6HGRDDYW1FMH e2JFcMXXPC/xiih3Xi+jhN2SyAVRdnW6YkSLGodzsO2TKSAn0Yqs5xUW1jDaKIktBrmg dbosswxvTSd5WovZ1AqNusE/eWn+NIUmQbL5R7/rFEIx8t6cj8jLqluLLJdENZ4N2YOM wdIw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:dkim-signature:date; bh=abD/WEok7ruvAwEFcdpePsY8TlgCTElZkcX9i8JMXQc=; fh=y7aUTm14SNpb9Y5B3hcLxd3axLOc2o1LpgKDVT4nh8Q=; b=nRRnxLehURwin33fQSWouxqw8y52j/PR+QFdAcogmLuhDPbsMS81KAaO6fxrqgEWLW Dh+QMDceo4DwgyAOugJz4B9/BfTHKblhVUfguwx/wtg0vAUIj3fBvCS1jDwMmL1rIF76 2DIPDTB6TVacKTpLFGmjCgzm/wUod+beoV+LKR4dk7nbOYpgBksuLWh+Q7BNeUQ7XMvG xs/OmRmQnGhgFRZUzKYRDaEhKovAOPz7kFZunf0cgFEvBwHzI1UAjnharVvn8JOTo3nH rwn/F/kYZEmIcbmvEF54i9DV5sdolxr4zQFRiXDizamIehkanCuFK5N0DOee2OWASAEW ofPA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0skkp0I5; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-171292-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171292-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u14-20020a05622a14ce00b0043aea523a7asi11968326qtx.103.2024.05.07.05.36.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 05:36:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171292-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0skkp0I5; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-171292-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171292-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8500C1C23CA8 for ; Tue, 7 May 2024 12:36:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F45815B122; Tue, 7 May 2024 12:36:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0skkp0I5"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="/JjfpUyS" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C6C61DA3A; Tue, 7 May 2024 12:36:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715085400; cv=none; b=O9UbCHMhltUXnJC2OcdDXELGa39cwmlM7ihrzF+kf43FZgjTeazt2GqkbTBoDnyC++7dgMvFJAkgwAf4zLlT8bxOo5RQgyMaB8FPTAKHzvjJsgki9t6LxnsOXtO1JdE+gfdta7c/1JuzXYbyTL6vVoBxB1vNO++eqnyeseBY8yQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715085400; c=relaxed/simple; bh=9G2vBiJaAA3BQNwwiCWALPOb9+HbQdLD4X/2fudy6xY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jUTFAluWgoWHLDbLRMP8El7h8dQYQqJaDzgGjC4HuURXAgEHN/AzbXxQAwlLqhLqVxlQEwKVRvdmcwyMHcbHcI0PSmxR9mUqwxnuIwknyVA7nxNKD0+Ut387l+zi8LW2qUPO4geXWDv6UMNBwQ771z78zKjOLGC2wuzUYGyKiQc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=0skkp0I5; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=/JjfpUyS; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Tue, 7 May 2024 14:36:36 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1715085397; 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: in-reply-to:in-reply-to:references:references; bh=abD/WEok7ruvAwEFcdpePsY8TlgCTElZkcX9i8JMXQc=; b=0skkp0I5Wkrm16f4vCYvhDeUv4Xe3PXz+RhPhsojzPdEIO0NiyUDKt6ug+dBNqMYInzZP1 VeI8iSwX5Lyj9kwoUNCSclciGjCfQod+Bmkad4u5QFIx+jwC4dghdQ8PUpVEULXAHKnp0Y kNGRyGfkQjIH48axOYQdikSVAMK9wepxbHz6LOmRn99fKS5OKMD2/CntrvctCKHZc+KayC xXpUvIgSeh+6lqiRb6wNJBicC5X5sN8Tsr+dBwb63BakpsJSNuM3laxdao8djuRHrx+qMF cq62Ae7kKN0Wo4x8L3D6EY66UzW6EBAWUOVE4nWNnT/QlOKgj6GGyUc/jiGFDw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1715085397; 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: in-reply-to:in-reply-to:references:references; bh=abD/WEok7ruvAwEFcdpePsY8TlgCTElZkcX9i8JMXQc=; b=/JjfpUySMWS2t+Eo2IHC62Dpq6h8Q0dExEHVXU13h2qbsd59k6fSl9dOokezH4jZhi8G/q oEqNaLi5OeIV4KCQ== From: Sebastian Andrzej Siewior To: Alexei Starovoitov Cc: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= , LKML , Network Development , "David S. Miller" , Boqun Feng , Daniel Borkmann , Eric Dumazet , Frederic Weisbecker , Ingo Molnar , Jakub Kicinski , Paolo Abeni , Peter Zijlstra , Thomas Gleixner , Waiman Long , Will Deacon , Alexei Starovoitov , Andrii Nakryiko , Eduard Zingerman , Hao Luo , Jesper Dangaard Brouer , Jiri Olsa , John Fastabend , KP Singh , Martin KaFai Lau , Song Liu , Stanislav Fomichev , Yonghong Song , bpf Subject: Re: [PATCH net-next 14/15] net: Reference bpf_redirect_info via task_struct on PREEMPT_RT. Message-ID: <20240507123636.cTnT7TvU@linutronix.de> References: <20240503182957.1042122-1-bigeasy@linutronix.de> <20240503182957.1042122-15-bigeasy@linutronix.de> <87y18mohhp.fsf@toke.dk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On 2024-05-06 16:09:47 [-0700], Alexei Starovoitov wrote: > > > On PREEMPT_RT the pointer to bpf_net_context is saved task's > > > task_struct. On non-PREEMPT_RT builds the pointer saved in a per-CPU > > > variable (which is always NODE-local memory). Using always the > > > bpf_net_context approach has the advantage that there is almost zero > > > differences between PREEMPT_RT and non-PREEMPT_RT builds. > > > > Did you ever manage to get any performance data to see if this has an > > impact? > > > > [...] > > > > > +static inline struct bpf_net_context *bpf_net_ctx_get(void) > > > +{ > > > + struct bpf_net_context *bpf_net_ctx = this_cpu_read(bpf_net_context); > > > + > > > + WARN_ON_ONCE(!bpf_net_ctx); > > > > If we have this WARN... > > > > > +static inline struct bpf_redirect_info *bpf_net_ctx_get_ri(void) > > > +{ > > > + struct bpf_net_context *bpf_net_ctx = bpf_net_ctx_get(); > > > + > > > + if (!bpf_net_ctx) > > > + return NULL; > > > > ... do we really need all the NULL checks? > > Indeed. > Let's drop all NULL checks, since they definitely add overhead. > I'd also remove ifdef CONFIG_PREEMPT_RT and converge on single implementation: > static inline struct bpf_net_context * bpf_net_ctx_get(void) > { > return current->bpf_net_context; > } Okay, let me do that then. Sebastian