Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2226394rdd; Fri, 12 Jan 2024 03:24:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdKyvMVqMY9W6jBk1v7G1dFQPkrJ2NdTwnxTLm5sTcUHfGp0DtkMR0Dwu3IDyb0fbPAlzm X-Received: by 2002:a05:622a:11:b0:429:94f2:60f9 with SMTP id x17-20020a05622a001100b0042994f260f9mr1451638qtw.18.1705058654506; Fri, 12 Jan 2024 03:24:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705058654; cv=none; d=google.com; s=arc-20160816; b=uSyusja8mkHnW4XT3TTjR9KclpN1kBa0gexGCTms1CJXrhg2RCTQIjbCtwuE261cas 24QKNSO7Qi/7z/8SGWY9XW8/rh96pRm4ryCY5vt5z9grcbKdVaEcWoGVrrpkbyOlAGOJ 9mtiFoJFAARCsVmB8n7d5iPDgiz4s0C7WeHGIJmujaxf/VCm2lrBHSNqXtFWhI8Da5BL VYLwcAGptdhL5UR2/z0zY9B2Ryw7a/wI12HMENPkoG7upOWDtMZN5F88hdHGOKdz7IBK pljZcg6IguF/rHwf/L1t5O+1hhAKF5gCkFcyDAF19DP6FOGS7DVUI1YM0P2ZRxI+3ADD 6HJw== ARC-Message-Signature: i=1; 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=ipRmzQ27dl1DxnG+lFoUSErLcW1ZeSdEpT87MdBHov8=; fh=CLabnkgTNYoQTGPjb66Sin0yLJyNHfnYAqbeRu6rF10=; b=XHyyglA5e8XQ/+S4xHhn/olEwsQy0QYYB1XtLrPcUvPxyqAyqoUtuXaB8QL43sPTuZ hfLItYJo7PJM9eBkaRf3IAm4asKd814iUJ2FHdgXmnFlAcuXeDTF5nkkArfdBhzJVecB 6XeTfZjoYLwq3c1EaSXOAMrNaM2cgLNworoe9Kf813HFAAVxZ7FsxE7FdRZRs6xCOK0T CnzJtyGs8UChRCqYU6y2b8zoapc8BkG3zjb/yeEe6D+Sbu3uOqNQp4LrksAw4Ch8jo7Y k3WfGoVAfgfgd9w1aalk9WcoYvR1okA0eRtXXpSlJ0Q7OQ7bZ8XSxPQJCDLlljCvosSq arSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=OWbqIxGY; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-24614-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24614-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 r8-20020ac85c88000000b00429cff475ccsi643408qta.657.2024.01.12.03.24.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 03:24:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24614-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=OWbqIxGY; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-24614-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24614-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 E284C1C23A8D for ; Fri, 12 Jan 2024 11:24:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 992DF67E73; Fri, 12 Jan 2024 11:24:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="OWbqIxGY"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="JdeACgwt" 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 693B064CFF; Fri, 12 Jan 2024 11:23:59 +0000 (UTC) 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: Fri, 12 Jan 2024 12:23:55 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1705058637; 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=ipRmzQ27dl1DxnG+lFoUSErLcW1ZeSdEpT87MdBHov8=; b=OWbqIxGYriukbUuN3UMPklkgruSimjDJSDUOwZ5gBcO0O0DDs0Yz/NMj3gNm5LDTT+M10q uWTbxGDIWi2mAwtPP8Rxr0hIaAQTbwiDYy/T94L1MypdJ5dREUmbTKW+4L0BqzdmcYkBUg QBzw0257rqdWGTtxj5YAP21j5ip+5sjCiEKNr/fAodeDFbtmOgJVYwwyo+vPanLrcJPztN g/CmxWfcvyJ0qMlvxEzcxL+lH3sTMivUUcaQ1lf2ZHmAWRCg84u4Mts42BUPxCUk4eA+a9 zIuUvov5uKxL9FTkij35cgRyPKvGOkEMjZlFdTnvdDwIldEwv/nieuZJaMYJQw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1705058637; 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=ipRmzQ27dl1DxnG+lFoUSErLcW1ZeSdEpT87MdBHov8=; b=JdeACgwtioEI2COU5SpvVfU1cwQPg/wWwhEkVp+hhJLmUw8TlVFHJ6c4tXwbBnjcQkd74r GDlENmh/5R6pSSCw== From: Sebastian Andrzej Siewior To: Paolo Abeni Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, "David S. Miller" , Boqun Feng , Daniel Borkmann , Eric Dumazet , Frederic Weisbecker , Ingo Molnar , Jakub Kicinski , Peter Zijlstra , Thomas Gleixner , Waiman Long , Will Deacon , Alexei Starovoitov , Andrii Nakryiko , David Ahern , Hao Luo , Jiri Olsa , John Fastabend , KP Singh , Martin KaFai Lau , Song Liu , Stanislav Fomichev , Yonghong Song , bpf@vger.kernel.org Subject: Re: [PATCH net-next 12/24] seg6: Use nested-BH locking for seg6_bpf_srh_states. Message-ID: <20240112112355.k1vpvtth@linutronix.de> References: <20231215171020.687342-1-bigeasy@linutronix.de> <20231215171020.687342-13-bigeasy@linutronix.de> 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 2023-12-18 09:33:39 [+0100], Paolo Abeni wrote: > > --- a/net/ipv6/seg6_local.c > > +++ b/net/ipv6/seg6_local.c > > @@ -1420,41 +1422,44 @@ static int input_action_end_bpf(struct sk_buff *skb, > > } > > advance_nextseg(srh, &ipv6_hdr(skb)->daddr); > > > > - /* preempt_disable is needed to protect the per-CPU buffer srh_state, > > - * which is also accessed by the bpf_lwt_seg6_* helpers > > + /* The access to the per-CPU buffer srh_state is protected by running > > + * always in softirq context (with disabled BH). On PREEMPT_RT the > > + * required locking is provided by the following local_lock_nested_bh() > > + * statement. It is also accessed by the bpf_lwt_seg6_* helpers via > > + * bpf_prog_run_save_cb(). > > */ > > - preempt_disable(); > > - srh_state->srh = srh; > > - srh_state->hdrlen = srh->hdrlen << 3; > > - srh_state->valid = true; > > + scoped_guard(local_lock_nested_bh, &seg6_bpf_srh_states.bh_lock) { > > + srh_state = this_cpu_ptr(&seg6_bpf_srh_states); > > + srh_state->srh = srh; > > + srh_state->hdrlen = srh->hdrlen << 3; > > + srh_state->valid = true; > > Here the 'scoped_guard' usage adds a lot of noise to the patch, due to > the added indentation. What about using directly > local_lock_nested_bh()/local_unlock_nested_bh() ? If this is preferred, sure. > Cheers, > > Paolo Sebastian