From nobody Mon Feb 9 20:30:09 2026 Received: from mail-yw1-f196.google.com (mail-yw1-f196.google.com [209.85.128.196]) (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 467AF1DFFD for ; Thu, 8 Jan 2026 02:25:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767839139; cv=none; b=mVHs2rcocEkAFAaO4SHOIeuqre+kDaMBy5j08GdSs+YbW5vOJdKAQ4BaAADaiYvHSJOFhLcjNzNBXSQqJa4gvd//tqikbUDBXHBMx6DY8115Phce8cyl5W8oa0ExxPhwG72Po8+XZYueD8sqtjdR7JWCF+c0YMBB47r6bg7VUXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767839139; c=relaxed/simple; bh=z1FXtwKIRsZptJAyDyFFIRDl2UKWJMd6LDExUnxO6es=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sPaafOBumsDoBgGTydjqtNlq1hDptI4w3j+C2tKMA3rQrEK7VLsf6xQNc91HTMEYSIy4PQ/oLUeTL8Zzml96cGZ9v3LykNyOEecZU92Ipyk7jAdFLW2iTINak5f4gAoGuPPl0Ur1DSkuGEDZmF7Ju6+4bBjO9v06cQn/U6vS/s4= 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=BBl9hz2R; arc=none smtp.client-ip=209.85.128.196 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="BBl9hz2R" Received: by mail-yw1-f196.google.com with SMTP id 00721157ae682-78fb6c7874cso31684137b3.0 for ; Wed, 07 Jan 2026 18:25:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767839137; x=1768443937; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dfGdp4s1hudLP6FKv2EKIaTufWaeCLX1APZrG5rR5Yg=; b=BBl9hz2R3dHe/KwrBzwBptXyvRr7B7d6UlZPXiG1aY8zi3zIRx6W4XbdyydO1yM7IE VK9c7RILUHxUwl/PeRCpajdngDjXhQODU0CnbMu6IfLfoJJ4NUseE1AOmxG/bLNo7fPE RrlMFssmfwXpPI137cWfvqkPI1gmukSCe6oWmI0ZLsaCxZ+bPqW9D7z6ekgO8tX25FNH 1PylSM6vvYqsLNl22QBUBiRVTFIZXnc5/oJDGTsjjW3tWcaG0RYngUYgdEB5qS4fHI8m jPyQJqAwSEX1NRcsslZSWJNgJhxYHGQr1fOYSYS4nTPSAODMQ7kCoRdQE+Et8PA6FWq9 +XOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767839137; x=1768443937; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=dfGdp4s1hudLP6FKv2EKIaTufWaeCLX1APZrG5rR5Yg=; b=GtnBZRi0MpBNhhyGmG2c1iK+RY41aF22FR+7z5UICByxVOOAvcaqnPH8Rr29BEYAci eIHtD1GFmXoNjfWuPz3LHJW5LvF5gUKWnPhN2D2PIssvIgW4AQfxGXDG4DHLTq6XNBol x3q+HYwBO0TbpE8PKnYPq3ldtPFrxdYyS2ldr1Rb2oRGu7WvinsU9F9BUDzkNYD61nlU pbtDVyYeG393B9bRVTRv3jXgS1Ir37Lz3Iu76g/mOKaNyENS1+YTm65qsk0xoAxjwyM1 CjWBAkgrL8m4f5MAIfP+XbGVHfLWUVN5CMGEXhczMyBEC9n5Czf+NphOqS3nQ2l51wZW cj+w== X-Forwarded-Encrypted: i=1; AJvYcCX4+EdU+Ax4SD6KVJPZfxhHDrhRjVdjcviRN9iDCdAxJvQIWnLJfKMtaDTJ+E33A6ZFESD56l0352xIzJU=@vger.kernel.org X-Gm-Message-State: AOJu0Yzfce0Xt2MQqlQWF6ItBaW4UFS6JlXbQPRy4zjQFFpEHlMop/V6 /Uw9yIfokK6tPTR8e1UNGh1vPYUWZfs0bumCx4ERnUd/Lex8aehvkJdc X-Gm-Gg: AY/fxX5GR4GvMbUty/ucr62f+wAV8xnYB/Ff97fieHzs6bVW39uUAOZKz5Ar7pZaWna X0ZTFmEr6RyAHWi6kwbHAPR00jcdiRRkrvXTJJ+J+HKu5lqLcxldOUzJsOeQGDBBXXu0dX/7uao kIihwbb/QO2PKDHC6LqnWJD2AmUMXnBkfbjRCU8brFEZ8Jtk2NBLgZHLXmyueVhOuKBaLvK/tBJ ABIEFIQmCHnL+b9sElsx7DrUBz5aK0cUP2av2QYs+IFvWH6TRazI+a56utHBtl3qlgPyB698rgP cW/TIPAUAyXl7nAfu0uGcibiNuUle9MRFDfvbcXruIF+LACyR5er3B36jNVU1WJfVAbYnGUeY9a cLqIElWx6VnXZamg1qoXD+l+0/BGz/TpUn9mFb3cREY9fhoqaEtYotfFEc4kPKVO+88icD0DtmG vWHelRwlc= X-Google-Smtp-Source: AGHT+IHqYMLoVCf2X8X0QJMoLJQnWHLCXx3Yuc6YM1wrrAj6dJa9o4RR5eXnLSarByUc9ac/HaBOTw== X-Received: by 2002:a05:690c:6012:b0:78d:1136:4e6f with SMTP id 00721157ae682-790b55d3489mr50675527b3.15.1767839137335; Wed, 07 Jan 2026 18:25:37 -0800 (PST) Received: from 7940hx ([23.94.188.235]) by smtp.gmail.com with ESMTPSA id 00721157ae682-790aa57deacsm24855027b3.20.2026.01.07.18.25.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jan 2026 18:25:37 -0800 (PST) From: Menglong Dong X-Google-Original-From: Menglong Dong To: ast@kernel.org, andrii@kernel.org Cc: daniel@iogearbox.net, martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com, jolsa@kernel.org, davem@davemloft.net, dsahern@kernel.org, tglx@linutronix.de, mingo@redhat.com, jiang.biao@linux.dev, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v8 03/11] bpf: change prototype of bpf_session_{cookie,is_return} Date: Thu, 8 Jan 2026 10:24:42 +0800 Message-ID: <20260108022450.88086-4-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260108022450.88086-1-dongml2@chinatelecom.cn> References: <20260108022450.88086-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add the function argument of "void *ctx" to bpf_session_cookie() and bpf_session_is_return(), which is a preparation of the next patch. The two kfunc is seldom used now, so it will not introduce much effect to change their function prototype. Signed-off-by: Menglong Dong --- kernel/trace/bpf_trace.c | 4 ++-- tools/testing/selftests/bpf/bpf_kfuncs.h | 4 ++-- .../bpf/progs/kprobe_multi_session_cookie.c | 12 ++++++------ .../selftests/bpf/progs/uprobe_multi_session.c | 4 ++-- .../bpf/progs/uprobe_multi_session_cookie.c | 12 ++++++------ .../bpf/progs/uprobe_multi_session_recursive.c | 8 ++++---- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 5f621f0403f8..297dcafb2c55 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -3316,7 +3316,7 @@ static u64 bpf_uprobe_multi_entry_ip(struct bpf_run_c= tx *ctx) =20 __bpf_kfunc_start_defs(); =20 -__bpf_kfunc bool bpf_session_is_return(void) +__bpf_kfunc bool bpf_session_is_return(void *ctx) { struct bpf_session_run_ctx *session_ctx; =20 @@ -3324,7 +3324,7 @@ __bpf_kfunc bool bpf_session_is_return(void) return session_ctx->is_return; } =20 -__bpf_kfunc __u64 *bpf_session_cookie(void) +__bpf_kfunc __u64 *bpf_session_cookie(void *ctx) { struct bpf_session_run_ctx *session_ctx; =20 diff --git a/tools/testing/selftests/bpf/bpf_kfuncs.h b/tools/testing/selft= ests/bpf/bpf_kfuncs.h index e0189254bb6e..dc495cb4c22e 100644 --- a/tools/testing/selftests/bpf/bpf_kfuncs.h +++ b/tools/testing/selftests/bpf/bpf_kfuncs.h @@ -79,8 +79,8 @@ extern int bpf_verify_pkcs7_signature(struct bpf_dynptr *= data_ptr, struct bpf_dynptr *sig_ptr, struct bpf_key *trusted_keyring) __ksym; =20 -extern bool bpf_session_is_return(void) __ksym __weak; -extern __u64 *bpf_session_cookie(void) __ksym __weak; +extern bool bpf_session_is_return(void *ctx) __ksym __weak; +extern __u64 *bpf_session_cookie(void *ctx) __ksym __weak; =20 struct dentry; /* Description diff --git a/tools/testing/selftests/bpf/progs/kprobe_multi_session_cookie.= c b/tools/testing/selftests/bpf/progs/kprobe_multi_session_cookie.c index 0835b5edf685..4981d29e3907 100644 --- a/tools/testing/selftests/bpf/progs/kprobe_multi_session_cookie.c +++ b/tools/testing/selftests/bpf/progs/kprobe_multi_session_cookie.c @@ -23,16 +23,16 @@ int BPF_PROG(trigger) return 0; } =20 -static int check_cookie(__u64 val, __u64 *result) +static int check_cookie(struct pt_regs *ctx, __u64 val, __u64 *result) { __u64 *cookie; =20 if (bpf_get_current_pid_tgid() >> 32 !=3D pid) return 1; =20 - cookie =3D bpf_session_cookie(); + cookie =3D bpf_session_cookie(ctx); =20 - if (bpf_session_is_return()) + if (bpf_session_is_return(ctx)) *result =3D *cookie =3D=3D val ? val : 0; else *cookie =3D val; @@ -42,17 +42,17 @@ static int check_cookie(__u64 val, __u64 *result) SEC("kprobe.session/bpf_fentry_test1") int test_kprobe_1(struct pt_regs *ctx) { - return check_cookie(1, &test_kprobe_1_result); + return check_cookie(ctx, 1, &test_kprobe_1_result); } =20 SEC("kprobe.session/bpf_fentry_test1") int test_kprobe_2(struct pt_regs *ctx) { - return check_cookie(2, &test_kprobe_2_result); + return check_cookie(ctx, 2, &test_kprobe_2_result); } =20 SEC("kprobe.session/bpf_fentry_test1") int test_kprobe_3(struct pt_regs *ctx) { - return check_cookie(3, &test_kprobe_3_result); + return check_cookie(ctx, 3, &test_kprobe_3_result); } diff --git a/tools/testing/selftests/bpf/progs/uprobe_multi_session.c b/too= ls/testing/selftests/bpf/progs/uprobe_multi_session.c index 30bff90b68dc..a06c2d7ec022 100644 --- a/tools/testing/selftests/bpf/progs/uprobe_multi_session.c +++ b/tools/testing/selftests/bpf/progs/uprobe_multi_session.c @@ -51,7 +51,7 @@ static int uprobe_multi_check(void *ctx, bool is_return) SEC("uprobe.session//proc/self/exe:uprobe_multi_func_*") int uprobe(struct pt_regs *ctx) { - return uprobe_multi_check(ctx, bpf_session_is_return()); + return uprobe_multi_check(ctx, bpf_session_is_return(ctx)); } =20 static __always_inline bool verify_sleepable_user_copy(void) @@ -67,5 +67,5 @@ int uprobe_sleepable(struct pt_regs *ctx) { if (verify_sleepable_user_copy()) uprobe_multi_sleep_result++; - return uprobe_multi_check(ctx, bpf_session_is_return()); + return uprobe_multi_check(ctx, bpf_session_is_return(ctx)); } diff --git a/tools/testing/selftests/bpf/progs/uprobe_multi_session_cookie.= c b/tools/testing/selftests/bpf/progs/uprobe_multi_session_cookie.c index 5befdf944dc6..d916d5017233 100644 --- a/tools/testing/selftests/bpf/progs/uprobe_multi_session_cookie.c +++ b/tools/testing/selftests/bpf/progs/uprobe_multi_session_cookie.c @@ -13,16 +13,16 @@ __u64 test_uprobe_1_result =3D 0; __u64 test_uprobe_2_result =3D 0; __u64 test_uprobe_3_result =3D 0; =20 -static int check_cookie(__u64 val, __u64 *result) +static int check_cookie(struct pt_regs *ctx, __u64 val, __u64 *result) { __u64 *cookie; =20 if (bpf_get_current_pid_tgid() >> 32 !=3D pid) return 1; =20 - cookie =3D bpf_session_cookie(); + cookie =3D bpf_session_cookie(ctx); =20 - if (bpf_session_is_return()) + if (bpf_session_is_return(ctx)) *result =3D *cookie =3D=3D val ? val : 0; else *cookie =3D val; @@ -32,17 +32,17 @@ static int check_cookie(__u64 val, __u64 *result) SEC("uprobe.session//proc/self/exe:uprobe_multi_func_1") int uprobe_1(struct pt_regs *ctx) { - return check_cookie(1, &test_uprobe_1_result); + return check_cookie(ctx, 1, &test_uprobe_1_result); } =20 SEC("uprobe.session//proc/self/exe:uprobe_multi_func_2") int uprobe_2(struct pt_regs *ctx) { - return check_cookie(2, &test_uprobe_2_result); + return check_cookie(ctx, 2, &test_uprobe_2_result); } =20 SEC("uprobe.session//proc/self/exe:uprobe_multi_func_3") int uprobe_3(struct pt_regs *ctx) { - return check_cookie(3, &test_uprobe_3_result); + return check_cookie(ctx, 3, &test_uprobe_3_result); } diff --git a/tools/testing/selftests/bpf/progs/uprobe_multi_session_recursi= ve.c b/tools/testing/selftests/bpf/progs/uprobe_multi_session_recursive.c index 8fbcd69fae22..d3d682512b69 100644 --- a/tools/testing/selftests/bpf/progs/uprobe_multi_session_recursive.c +++ b/tools/testing/selftests/bpf/progs/uprobe_multi_session_recursive.c @@ -16,11 +16,11 @@ int idx_return =3D 0; __u64 test_uprobe_cookie_entry[6]; __u64 test_uprobe_cookie_return[3]; =20 -static int check_cookie(void) +static int check_cookie(struct pt_regs *ctx) { - __u64 *cookie =3D bpf_session_cookie(); + __u64 *cookie =3D bpf_session_cookie(ctx); =20 - if (bpf_session_is_return()) { + if (bpf_session_is_return(ctx)) { if (idx_return >=3D ARRAY_SIZE(test_uprobe_cookie_return)) return 1; test_uprobe_cookie_return[idx_return++] =3D *cookie; @@ -40,5 +40,5 @@ int uprobe_recursive(struct pt_regs *ctx) if (bpf_get_current_pid_tgid() >> 32 !=3D pid) return 1; =20 - return check_cookie(); + return check_cookie(ctx); } --=20 2.52.0