Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp5509lqh; Fri, 3 May 2024 11:30:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVOp23z8h4FUumUkdAbzTE5UzmgyJVtB5BPJ7rzYDJBLXREDN5gW4DRbJJYJYfp7S5DzZPlu2WciamYjBYryETD851/OlsXpuqpw/w6Dw== X-Google-Smtp-Source: AGHT+IGxk1ARYm1jg52v7K3Z9D7qhU0OO4h4FPJRo/s6+8gAue5bLPDhHxXMjl0d26n61VVB4GiP X-Received: by 2002:a17:902:bb95:b0:1e2:688e:597d with SMTP id m21-20020a170902bb9500b001e2688e597dmr3270468pls.21.1714761026083; Fri, 03 May 2024 11:30:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714761026; cv=pass; d=google.com; s=arc-20160816; b=bLOdxMK3IYonwSIp2YIFLJteY7drxz+gr2AKh5+K5EUk+5Psg1uttgUMsAHKvW9CW2 j+wPvMh2SjmybHxwPUudnYMnHE4M//AXrv/5Vj1rEAw07UeqRpvTrfW5ioem0Vsf5ok+ SuAZkE4kZPlyIoaWYcPp9Y9lL6kmjSmQlfa3K8XL03C0G6oX91xKJaylMxUkxA8KZOZd CjCQ7Wkg8grmDggTTiLqteB9GtTW3YCcvaeoGQisHSaScpLCIUHvMjIjMS2tPLz99fx6 9uVM7BuFHUk5vZXXGNw9qBiuq+ShI3KCFgov2XPR72OVdhD0VK+5JPvqMW53Zvp1UE46 GUng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :dkim-signature:dkim-signature:from; bh=+L2OHtZGBVAI0AzBMGBr/lDGosDbMk0Ei6sq1IBWuVc=; fh=isut5FXJ3IMDA31kBhawKjpOqYjZ97Ca69pMNjk4IR4=; b=qR2hApph6p4v5llggLtX10kD+jMvzmZJ7MJr53XSbp2Ngx0PU2AjdSW6U3yf+FyQb3 4lbC8S+j1asEAb5Une1NXSSEIIu/v81TMAIVafTBX43T/6pP1qNQgLJ+F+pVb9VQj9+e dEs25vHvqXNSH2cCtX2H4bX1gKgNxRUfnz49k6rze+b47QMzVkUqdQLDyikUDaEnx+S5 h+VtLzn3N3TK8kX9IZrf9jAUSF9ndVnbeNMHbloT/8+jpLYOkH1C2k67lmJu5xpLh0Ry h2iGqiZ4G86JpiQcA50WHZeCMVSymOJ8c/jIradk9YmhNEHC/LhWPa0eUz8dnZt0BGsT VJwg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Ppu7nfIu; 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-168053-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168053-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d1-20020a170902e14100b001e9219222b3si3230612pla.271.2024.05.03.11.30.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 11:30:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168053-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Ppu7nfIu; 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-168053-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168053-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B645028311E for ; Fri, 3 May 2024 18:30:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DBA3B158A2B; Fri, 3 May 2024 18:30:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Ppu7nfIu"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="7wdPy5A+" 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 8E019139D19; Fri, 3 May 2024 18:30:07 +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=1714761009; cv=none; b=uMrDA2RwUJjZwFKYdbRuQR3gSRMP/Rq8nh7MG8Qs+s2cgD2AiM/rjBfEi4dWPACgwUtwQy3Tp1194uLQM2zA19crG308+ff5hCmO47HvBcuEsjX5dI3IDgcCz75fRQmwww4hJHPyFDL9T1cEe9IpZKCnpdGI8G6kbVzmk8/8+CU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714761009; c=relaxed/simple; bh=74/0AKsnF9vBQRTv+86J/6a3kei1SXSM/rCzTC9ygsM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=XaKTO6F7DpTUYHIzz/8x2e4xgO2y9ty4cr3B3xgti59wbZzUqzqA8swqAwQLimcQ8fDfuO/5Dl740SipJu6+36iyF6Sa0Ud3+0KzTJmKVSfnSgcpDgFqslkPw2C7fUh8LgnS9ROp10OECPJJ/Kmr1w/52RyryK4rbJc1sjwGFaU= 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=Ppu7nfIu; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=7wdPy5A+; 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 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1714761005; 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; bh=+L2OHtZGBVAI0AzBMGBr/lDGosDbMk0Ei6sq1IBWuVc=; b=Ppu7nfIusKN+1NEBP9Cj+ylvfFl2Rr2yfx6sxiesPdeDuTzk2ge/+lzj8delQEA83Y9WPb 2GUeBYsZd2VD4hp4h0lsUlo6IYtBxI9nMCyKW0z46IJg0wjqOXuJPPebbKoa1q7k1+4eOK dByO+YeuD1daiokAvKf2cZ/zvPRJkcLIp+QBQt5fr8FTTOsXAlmQyCCW1ZKsr5e5kgOlLh lL77tEPZD0Mtuzp8JXI6LnK+q3Re7/LhVEgqOWojN8ULEPXwobn6S6/qG+9PNE2K/6PUzO nlAD+PBmSiO3igZAFknGs0fwxL81P0CWYHDfPhWPGGY8O7wLtnla2rCtCA1laA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1714761005; 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; bh=+L2OHtZGBVAI0AzBMGBr/lDGosDbMk0Ei6sq1IBWuVc=; b=7wdPy5A+jZsO+4HaU3i8bJJIZjAXBJH0k7XSH/fFPG85io9JfzgW6FEV+YtX7UgQDwjRcC JBXUYRUDC0SP6vCA== To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: "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 Subject: [PATCH v2 net-next 00/15] locking: Introduce nested-BH locking. Date: Fri, 3 May 2024 20:25:04 +0200 Message-ID: <20240503182957.1042122-1-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-Transfer-Encoding: quoted-printable Disabling bottoms halves acts as per-CPU BKL. On PREEMPT_RT code within local_bh_disable() section remains preemtible. As a result high prior tasks (or threaded interrupts) will be blocked by lower-prio task (or threaded interrupts) which are long running which includes softirq sections. The proposed way out is to introduce explicit per-CPU locks for resources which are protected by local_bh_disable() and use those only on PREEMPT_RT so there is no additional overhead for !PREEMPT_RT builds. The series introduces the infrastructure and converts large parts of networking which is largest stake holder here. Once this done the per-CPU lock from local_bh_disable() on PREEMPT_RT can be lifted. v1=E2=80=A6v2 https://lore.kernel.org/all/20231215171020.687342-1-bigeasy@l= inutronix.de/: - Jakub complained about touching networking drivers to make the additional locking work. Alexei complained about the additional locking within the XDP/eBFP case. This led to a change in how the per-CPU variables are accessed for the XDP/eBPF case. On PREEMPT_RT the variables are now stored on stack and the task pointer to the structure is saved in the task_struct while keeping every for !RT unchanged. This was proposed as a RFC in v1: https://lore.kernel.org/all/20240213145923.2552753-1-bigeasy@linutro= nix.de/ and then updated v2: https://lore.kernel.org/all/20240229183109.646865-1-bigeasy@lin= utronix.de/ - Renamed the container struct from xdp_storage to bpf_net_context. Suggested by Toke H=C3=B8iland-J=C3=B8rgensen. - Use the container struct also on !PREEMPT_RT builds. Store the pointer to the on-stack struct in a per-CPU variable. Suggested by Toke H=C3=B8iland-J=C3=B8rgensen. This reduces the initial queue from 24 to 15 patches. - There were complains about the scoped_guard() which shifts the whole block and makes it harder to review because the whole gets removed and added again. The usage has been replaced with local_lock_nested_bh()+ its unlock counterpart. Sebastian