From patchwork Thu Sep 29 07:04:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin KaFai Lau X-Patchwork-Id: 12993570 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 261B3C6FA82 for ; Thu, 29 Sep 2022 07:04:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235036AbiI2HEw (ORCPT ); Thu, 29 Sep 2022 03:04:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235034AbiI2HEh (ORCPT ); Thu, 29 Sep 2022 03:04:37 -0400 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87806A98DC; Thu, 29 Sep 2022 00:04:24 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1664435061; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=JFdunjvLsFhOdctZk0L2M1ZTEvP3hRf2QZ8TjxsFZJc=; b=pPdvdLJHXSOORExVWP6Mxpv2k3VmGElV9TlGZWN6ssMstGLjnDZeAqIIN6eglfSFIF3hi8 DY57OvjWXh/VOM3M00Zs9ibSEWe52eUi+BfRNOKUgqGoFhda88b0YpUEgsMB8hLBxPV0gl BfKOVklNcuNQF4yeg0qI8Ss+xLDSPNU= From: Martin KaFai Lau To: ' ' , ' ' Cc: 'Alexei Starovoitov ' , 'Andrii Nakryiko ' , 'Daniel Borkmann ' , 'David Miller ' , 'Jakub Kicinski ' , 'Eric Dumazet ' , 'Paolo Abeni ' , ' ' Subject: [PATCH v3 bpf-next 0/5] bpf: Remove recursion check for struct_ops prog Date: Thu, 29 Sep 2022 00:04:02 -0700 Message-Id: <20220929070407.965581-1-martin.lau@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net From: Martin KaFai Lau The struct_ops is sharing the tracing-trampoline's enter/exit function which tracks prog->active to avoid recursion. It turns out the struct_ops bpf prog will hit this prog->active and unnecessarily skipped running the struct_ops prog. eg. The '.ssthresh' may run in_task() and then interrupted by softirq that runs the same '.ssthresh'. The kernel does not call the tcp-cc's ops in a recursive way, so this set is to remove the recursion check for struct_ops prog. v3: - Clear the bpf_chg_cc_inprogress from the newly cloned tcp_sock in tcp_create_openreq_child() because the listen sk can be cloned without lock being held. (Eric Dumazet) v2: - v1 [0] turned into a long discussion on a few cases and also whether it needs to follow the bpf_run_ctx chain if there is tracing bpf_run_ctx (kprobe/trace/trampoline) running in between. It is a good signal that it is not obvious enough to reason about it and needs a tradeoff for a more straight forward approach. This revision uses one bit out of an existing 1 byte hole in the tcp_sock. It is in Patch 4. [0]: https://lore.kernel.org/bpf/20220922225616.3054840-1-kafai@fb.com/T/#md98d40ac5ec295fdadef476c227a3401b2b6b911 Martin KaFai Lau (5): bpf: Add __bpf_prog_{enter,exit}_struct_ops for struct_ops trampoline bpf: Move the "cdg" tcp-cc check to the common sol_tcp_sockopt() bpf: Refactor bpf_setsockopt(TCP_CONGESTION) handling into another function bpf: tcp: Stop bpf_setsockopt(TCP_CONGESTION) in init ops to recur itself selftests/bpf: Check -EBUSY for the recurred bpf_setsockopt(TCP_CONGESTION) arch/x86/net/bpf_jit_comp.c | 3 + include/linux/bpf.h | 4 ++ include/linux/tcp.h | 6 ++ kernel/bpf/trampoline.c | 23 ++++++ net/core/filter.c | 70 ++++++++++++++----- net/ipv4/tcp_minisocks.c | 1 + .../selftests/bpf/prog_tests/bpf_tcp_ca.c | 4 ++ tools/testing/selftests/bpf/progs/bpf_dctcp.c | 25 ++++--- 8 files changed, 112 insertions(+), 24 deletions(-)