Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp50539rbe; Wed, 28 Feb 2024 11:42:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVWWl9876ycEYCJICFNvELSf43TFK/5uycdDW+T+i+gnurnxnAI5JVTsRLNNfaFg0jFzcdC6H85UGIbrW4kQEfTL2u60SWpymXOxBa9+w== X-Google-Smtp-Source: AGHT+IH6lfqHfAizwEZSySQeDu2NByGkgiedAjtau3hGlLXR1eQcb2iqn1o5Y/8IcxDT8Tr8usKn X-Received: by 2002:a05:6402:1497:b0:564:5764:a5d8 with SMTP id e23-20020a056402149700b005645764a5d8mr248341edv.25.1709149335015; Wed, 28 Feb 2024 11:42:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709149335; cv=pass; d=google.com; s=arc-20160816; b=mypwATAnNGh/XYlXxQDqGqGKcPC3CboB+5ITb4Haa6HughZGGLaFVgH9WlNv/74LGL JtIzKITgHdKt3iaSwyxBu9wt2oPWauWQ9n3KiS7b6yaCRRTFvBpmwXEVWUtlsUgSNA4u R9Y0hU2dHbtaJ0P8m5EFhGB2+4JX+jOzFiD719TkU1AE0jgfiGtUJ90mR3ZM7eM4Rc53 QjhabNPh7dkVmtg5e+Ugfjj6tEYCHCvCoxinq7iT9/3aQ92JAMASofN/nJmCNOq2kWWp 2boZInYQMjbEEP7c0WoNfQMSu8ZzQXffLcFsJJiUzibD0MLeDhUxnxOPMzvZ11gHqfwT I6DA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=edAxYiRzkHEr8ycXzQDJGjQQP1hsBAtoGZUN5sWpFIE=; fh=EgQyjI5hPhQUsqVdgef2wZq+c6968G8aiPNSI/un1hQ=; b=DagbzbfZ55I0EZAS513Hc5+nd5rBkso8/FUaBhi7YfHiP2zIrd6luCoiyVcFj1tWbJ eidqtTX9zccIHkl+8bYvFC2GpTIf5SgFvXjKC4ruh4dIwOqSJm85GxUlrOawTRwvgnK9 nJaJSBIVC+uy1c8hHUJDtQ+W8fKeuKoQy9dmSaIVfXVblL2EtbDSWPkXm2lKvaaqtqUh yT/fJhWqASkWPFIzenfB2ivFhPLblDgC8LqViCsFm+RXo/8Y8XnB5+j7zvlp8Yrlch8G f1LTEZpfaG4BMINuCkruAWefWYMeF+FCj/OGdyPMdlwiz8LDlcYOd6GC6gluxjsCdpHb Uqpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=McIgWXQL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85632-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85632-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b11-20020a509f0b000000b0056491a3421dsi2006622edf.643.2024.02.28.11.42.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 11:42:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85632-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=McIgWXQL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85632-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85632-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id CFC371F223A1 for ; Wed, 28 Feb 2024 19:42:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 259185E062; Wed, 28 Feb 2024 19:41:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="McIgWXQL" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 477125E064; Wed, 28 Feb 2024 19:41:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709149295; cv=none; b=NDUFzgGmiIiyqWxPHRvBgamFjbNFvSHPcgwrd5UscNUiWqLGh9QHeY5J4Uh2OaS4X9V2J5XXbzNdEbI8nBGp8uSMPPH9kiOdxSuez+os6JZzifu7qW0ocZ8u4Rl4fCzu6A8anIFxbG+2N3FyvOPwQqHh8MPSjqvmtNrslZvC1go= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709149295; c=relaxed/simple; bh=NPzyxwGeYXka5gn3GSClv08yHw0AIL3RUtkhYEIB4Wg=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=gs/pc4xCcVuSWZSy+VAzpk8k3s+Yt0xEW8CDR8kRDn4i1SBzN41mMfQXIlEfhHq4UCC741lObyfvGVLSY6VVpT0H3fd2HdY4C7zEoxq+uAbVoyJeC11ygpLBd55c9UJ8n1VJ9xDsYj/GSdkYkbqUSH5tgXMkQ3/3JJGv/PnARpM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=McIgWXQL; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8832C433F1; Wed, 28 Feb 2024 19:41:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709149294; bh=NPzyxwGeYXka5gn3GSClv08yHw0AIL3RUtkhYEIB4Wg=; h=Date:From:To:Cc:Subject:Reply-To:From; b=McIgWXQLxWsmvp/4CoIA6FzhNKEtocy6+giqblpmPudKRUvdS3pDFPbKvAAp603Ga 6vaPUQEPp6nxYA+EU3/lHnVCjf/l8xH/Wwgqd643QXjBWhTvCMk9i6siY+tcWW8ma0 t1C3usPFza3lVr5yPx4aHmAzfYjxN+SCVx0mTcAjccFHcNlQNpVQVvKyI/x73LdauJ 0dUFejxdx73g8UdrMStTk2mOa7Gk7Rp6rYYSjHIddwrhNsf+kC/CISd3M7AXaDvkNW FA8Y0SszP/UA1eGxveBLhGq0EQ0s4N86CCFvqlYyZAvteRVCC40hWCIV0Ra0tgjcva 0b9KWq/TNqznw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 38A90CE03F3; Wed, 28 Feb 2024 11:41:29 -0800 (PST) Date: Wed, 28 Feb 2024 11:41:29 -0800 From: "Paul E. McKenney" To: bpf@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Ankur Arora , Thomas Gleixner , kernel-team@meta.com Subject: [PATCH RFC bpf] Chose RCU Tasks based on TASKS_RCU rather than PREEMPTION Message-ID: <847ac98b-886d-4f91-b961-2bb452555af0@paulmck-laptop> Reply-To: paulmck@kernel.org 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=us-ascii Content-Disposition: inline The advent of CONFIG_PREEMPT_AUTO, AKA lazy preemption, will mean that even kernels built with CONFIG_PREEMPT_NONE or CONFIG_PREEMPT_VOLUNTARY might see the occasional preemption, and that this preemption just might happen within a trampoline. Therefore, update bpf_tramp_image_put() to choose call_rcu_tasks() based on CONFIG_TASKS_RCU instead of CONFIG_PREEMPTION. This change might enable further simplifications, but the goal of this effort is to make the code safe, not necessarily optimal. Only build tested. Signed-off-by: Paul E. McKenney Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: John Fastabend Cc: Andrii Nakryiko Cc: Martin KaFai Lau Cc: Song Liu Cc: Yonghong Song Cc: KP Singh Cc: Stanislav Fomichev Cc: Hao Luo Cc: Jiri Olsa Cc: Ankur Arora Cc: Thomas Gleixner Cc: diff --git a/kernel/bpf/trampoline.c b/kernel/bpf/trampoline.c index d382f5ebe06c8..5085f66b33890 100644 --- a/kernel/bpf/trampoline.c +++ b/kernel/bpf/trampoline.c @@ -333,7 +333,7 @@ static void bpf_tramp_image_put(struct bpf_tramp_image *im) int err = bpf_arch_text_poke(im->ip_after_call, BPF_MOD_JUMP, NULL, im->ip_epilogue); WARN_ON(err); - if (IS_ENABLED(CONFIG_PREEMPTION)) + if (IS_ENABLED(CONFIG_TASKS_RCU)) call_rcu_tasks(&im->rcu, __bpf_tramp_image_put_rcu_tasks); else percpu_ref_kill(&im->pcref);