From patchwork Wed Feb 28 19:41:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13575868 X-Patchwork-Delegate: bpf@iogearbox.net 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="McIgWXQL" 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: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-Patchwork-Delegate: bpf@iogearbox.net X-Patchwork-State: RFC 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);