From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C7F239524B for ; Wed, 14 Jan 2026 11:28:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768390106; cv=none; b=sfN6LBXNsvJwfzITqe96eOi4Xb6Sm2Tc4jETUnBm9GZyIAcQx3tEnLFJvPNfsJ09R/epjRw2MmHd4sqnLHiHkY4oYUhI4jEmSNMnGVr7K/llv6yvVuMDSU31yd6R4S3CKNUlW4vzWjn7vqMsP7Pk8kErfkxQ83JVxP+oQldyWpE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768390106; c=relaxed/simple; bh=0fGVhftsc+nGHo+Lm9VKmninWdcz1+QWpalR0QeBDSM=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tfyZ4wgYVXQZTpjgndk7CA8sm2rlUW5SITGJyBiKqWbt+6xF/dAueizsReO4hTQWrLfgw1vxgJhuqLO0LfSj9xAOfXkNC4FpaGxvW/c/pNVIW3s3jKZb2/6APQzxc93CLY81Yp+qJqXvVol8DR03xvT8rYgENr0BJW1H6/wJpqU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XFF35kug; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XFF35kug" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-47d5e021a53so64315305e9.3 for ; Wed, 14 Jan 2026 03:28:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768390098; x=1768994898; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:date:from:from:to :cc:subject:date:message-id:reply-to; bh=IGVDUUpgpDLMWHZgDOLEkAjObayE3q3JK8jeYcF9PIs=; b=XFF35kugUQxnCboeg0kWoGprR6/B0CUuUgWyN8gQOF7GT65jnzwWCBjfvibxdL0vVv 3G87ZVe+M4ar9sHRztusxXCeQ0nZYK5gPrZkMRAz4RuvWegTaypQCDv9xjee2jYLiOpv i0fDhs3/U1sRAD93DiW4r6iB+l0Q3hl1JSJg373CEF2alY5mDV5kVdaoW+njviEX83A3 je3WIF59O7CzephDfNYav3Wz+XivtdBYXWTgbUSSRSbNcCVKC+rgDVrIf+DeEkC0P5za V0q6OMd52b4WKl6+Ub1if/pp58kAiE6lsNI3H6+q6tGzP3M8M5FhN6glRVkqqFSVglYv In6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768390098; x=1768994898; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IGVDUUpgpDLMWHZgDOLEkAjObayE3q3JK8jeYcF9PIs=; b=q8wP5TfPMbZv2OHJjASw/md+sGMZ7zogM+fJ/Pd2KItwtI4DJ6aGETrjdYpqaQZ1jS ODjEM/4fYF2PJRFs86XCfEMlvXIGtgNNF+itPp9ITHZtDDuNg+DAi10KJ+dNtQOZYBnP xZnk3mudtgovLC0KOBh+IReet5Q8bA+j0OdXo0FQi75NbxRCf7lujx9mln7mrSRIinWP HDlQst/UlCwSbUhNvlAhpXV6jbvqpnvDjn45A0zZ/cRV1D7e+ztjbJyTffFJZist39c4 AA8v7WG/LgR4Nl8tmq7Vm2Ai+Q2eFtSpluOkF2bnvz6oMnqBSuxGNWtUpBRH1xBQqZH0 P3tQ== X-Forwarded-Encrypted: i=1; AJvYcCWL9nbEkI+v4dI9wBaDVSG2cOu7mmu3dKBzwhfipcLva7IX3ZAXUKiPORnHx+G7nFXv1yuYjKSbPxDpbhs=@vger.kernel.org X-Gm-Message-State: AOJu0YzDVlrGRDo8fbneR1EkXn2Y3v3rQphcrBBf+UeBbVH62t4jjQyc fyCQAGs3C+RTgHHhslN+24V86uLnDEUWwvaUuSbLEhMaB92AoYMx7qK5 X-Gm-Gg: AY/fxX4eu4R6AL75NuFN3fdPRtOz3BWA8EDYSo3B/EYAlUb79nW/8zZyO2tLK27Cf7Q mwtx2r2g61H548Snmi7s98Z7k++ECzoWR2bkr+LD/5vOUBh/wpN+Uj3Wsl2AjUw2x5rGAvomoK8 sM9t5U9hWxWZNKC9lfN/JYs1akVTv+lhNyaY7MC466ZkBRkCuxGbrmtm1q7zbAD32aqs63xhkIn foKk1NSkC4fszS18or9qGf1kY48ilo/NuvoYxNICb2J3n9IGAv3oK+F6GjlKgVOp5+Zbox6q7a/ Y6rK5qOMGkc6tL6J7W4rT3emM2RUa10XEjEAu3nnJaOHdPD4fm6RKDprNVVyfv4hRc3lbeGQuDO eN9j+C5A2/pbVwB4GNjwF1Tc2rHVn6+1Z7VI+NFnkx25Ypu5z8rJyT5Lj9/eVp8A+8Eyf2+hcdW I= X-Received: by 2002:a05:600c:4f0b:b0:477:9392:8557 with SMTP id 5b1f17b1804b1-47ee4819824mr18444405e9.18.1768390097518; Wed, 14 Jan 2026 03:28:17 -0800 (PST) Received: from krava ([176.74.159.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47ee54b90d5sm23620545e9.2.2026.01.14.03.28.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jan 2026 03:28:17 -0800 (PST) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Wed, 14 Jan 2026 12:28:15 +0100 To: Alexei Starovoitov Cc: Leon Hwang , bpf , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Puranjay Mohan , Xu Kuohai , Catalin Marinas , Will Deacon , "David S . Miller" , David Ahern , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , X86 ML , "H . Peter Anvin" , Andrew Morton , linux-arm-kernel , LKML , Network Development , kernel-patches-bot@fb.com Subject: Re: [PATCH bpf-next 0/4] bpf: tailcall: Eliminate max_entries and bpf_func access at runtime Message-ID: References: <20260102150032.53106-1-leon.hwang@linux.dev> 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 Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Jan 02, 2026 at 04:10:01PM -0800, Alexei Starovoitov wrote: > On Fri, Jan 2, 2026 at 7:01 AM Leon Hwang wrote: > > > > This patch series optimizes BPF tail calls on x86_64 and arm64 by > > eliminating runtime memory accesses for max_entries and 'prog->bpf_func' > > when the prog array map is known at verification time. > > > > Currently, every tail call requires: > > 1. Loading max_entries from the prog array map > > 2. Dereferencing 'prog->bpf_func' to get the target address > > > > This series introduces a mechanism to precompute and cache the tail call > > target addresses (bpf_func + prologue_offset) in the prog array itself: > > array->ptrs[max_entries + index] = prog->bpf_func + prologue_offset > > > > When a program is added to or removed from the prog array, the cached > > target is atomically updated via xchg(). > > > > The verifier now encodes additional information in the tail call > > instruction's imm field: > > - bits 0-7: map index in used_maps[] > > - bits 8-15: dynamic array flag (1 if map pointer is poisoned) > > - bits 16-31: poke table index + 1 for direct tail calls > > > > For static tail calls (map known at verification time): > > - max_entries is embedded as an immediate in the comparison instruction > > - The cached target from array->ptrs[max_entries + index] is used > > directly, avoiding the 'prog->bpf_func' dereference > > > > For dynamic tail calls (map pointer poisoned): > > - Fall back to runtime lookup of max_entries and prog->bpf_func > > > > This reduces cache misses and improves tail call performance for the > > common case where the prog array is statically known. > > Sorry, I don't like this. tail_calls are complex enough and > I'd rather let them be as-is and deprecate their usage altogether > instead of trying to optimize them in certain conditions. > We have indirect jumps now. The next step is indirect calls. > When it lands there will be no need to use tail_calls. > Consider tail_calls to be legacy. No reason to improve them. hi, I'd like to make tail calls available in sleepable programs. I still need to check if there's technical reason we don't have that, but seeing this answer I wonder you'd be against that anyway ? fyi I briefly discussed that with Andrii indicating that it might not be worth the effort at this stage. thanks, jirka