From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (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 F25E53815D8 for ; Thu, 21 May 2026 04:08:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779336514; cv=none; b=UJBUwap0Niyh5KnQoctqbUQKhUYlkmnlx7ICNrD3L0TjDi48qtf9i5XVMUxtiPBL6nt5Jkw9PTRKyZyrL79f4MWjiepawbXdulEYah8d882uKLGRhPNPMvu/S3iG9s9/PhQOIPJvmHHIF32LgpVQQOysDh2YziIAzkjy9OXFBM0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779336514; c=relaxed/simple; bh=cXsEv7M8s8B+fW56IioKkoVTP6yPw0hwmUPpqeXjWu0=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=taeKNmFvOR1LumPAsSp2sD8JuL9WEJspMq16Zgg9szyLGEmOfti7K348YD0zUgKH8GixAdrDQyRz/9nHyfHShJNceLuvXUyMUIklA04cM1D2Y5WWNoMabnfLawM7XJSHYjovqbP6MICOaoSLVvLAUVNtshhcp697eZkGmrrGRC0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com; spf=pass smtp.mailfrom=etsalapatis.com; dkim=pass (2048-bit key) header.d=etsalapatis-com.20251104.gappssmtp.com header.i=@etsalapatis-com.20251104.gappssmtp.com header.b=cY3UYIPG; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=etsalapatis-com.20251104.gappssmtp.com header.i=@etsalapatis-com.20251104.gappssmtp.com header.b="cY3UYIPG" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-8413ac3d82fso1038696b3a.0 for ; Wed, 20 May 2026 21:08:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=etsalapatis-com.20251104.gappssmtp.com; s=20251104; t=1779336512; x=1779941312; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ynBnbM/NLUcVxU1YYBO1La/PNj07zsMaWyq2DVRegqU=; b=cY3UYIPG2erHrgu9yemSWFmSt00sDwaerMFopcaBp/FJ1kD3ZN3mBZCI+Ht4wdlH2x meTJgDtkoK+cUjLvORxi6xwpgzokb945EFL2JjH+y96hLpMd/meb9Sv2zI6dgyU+qla9 oExywKIB5g8HUXyGzUDeh9XRofd+LIC/aKCRruPs24eRKOVorIMy3Tm2NVVrvNN1guGx KfztrGd1w4DYiLXpv5yyIXMMgEr7dWsiQLleOpUKs31f/mOo0JUcw5sFbzVhft+K7eDS ng7NALqCPTlRv+qPfOJACUDMb3c78pxoQnum007hT8VZHHYwKjqjYR1qrZWNXyUtaRN7 C3Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779336512; x=1779941312; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ynBnbM/NLUcVxU1YYBO1La/PNj07zsMaWyq2DVRegqU=; b=LP0cx56xwYc7TgRf89FOycGhYZ3xr47f6Zyg8+LgDWdte3o+uQQAk5GDIaNRbtGW7N Zv7Psp/xS/QvjjKmoenOIg/VDPUSyk67zF1nE6G3WEplt37ZpyXUPClxTyCGa45Dpxdj 6N66AC+GImkwy6QZcixSlaVkp/tD+oR6JLyQtd4Je8jaj67HTinwXJF7krVavUBRypeN cpmxAWI7P0bB/dCvJ5ZBWCFSxJ3R71IBfVS8KGShbbFgjFfshHvTe+9d7QV+0uKCKET8 oI3ORGl2R3x0xDHaIu2x7ZxV13q8NxDBcWVoOix7TQ957Qo+HW06goVsjN1PZk2ZGG/4 hFOA== X-Forwarded-Encrypted: i=1; AFNElJ8z3nku3Kbr8YGZ5WPVcAAOnp0zwjtfFCnPRJorjOLDSGGR6koSeBlxWNQm59EeopyYApkw0M9e6tHi+oo=@vger.kernel.org X-Gm-Message-State: AOJu0Yy0YKgpU2N/6XoYgZdpxLqsNgNmnsVYBamvvepm4S+82ixSmj/F 3iaeQGsXyq4AcWoRdxd78O+j/RVA3kTB1h1jlSpZD0NBDJwBlQ6uF216FAi4+NNSqX0= X-Gm-Gg: Acq92OGbz8XJQeaZGIJH6ZP2A9XHDbhW1RPoh257DdgJWQT8YnLqjD8nSrVKOz4UBaD 5Nu/RjKXeITLAiJxCo99PM1i7AP1i/DExlt6F4/ZX/XneoVFPoPwKZKSREXTOOmFs26avzfBLXq X4MIF0ho/1gwMFJySaD+FuX73TVTFm6aWtDsRKU2Vgnbx+lP6ejeClHqHQZdxIMOqyC/n8Re5y8 sfwxpSoFonv9Qn8K+Bd6cbXnCLQU5ZZi4cgd9Q/SIN2cNe+2rHwV3H9Q9H65asyEmGaek+Sgg9h oJrw/1AUyMxX2/cf6hM6UmHTMws5M2NdKTwVv8w71ccbAyz0OLWTRiXZt1IWyaMlupdaNCfybLk Nc5mhjeRpONhPvqAuv4L+ar0NxGFWyWDc5B8OH9cHHyWJ2rs6qPmcLW1Z7LRYw16mi94nNlMPo9 lPcp8O7BbIW5YWoR3mJQMrZgc+ X-Received: by 2002:aa7:88c1:0:b0:82f:7b98:e499 with SMTP id d2e1a72fcca58-8414adf532amr1336929b3a.31.1779336511925; Wed, 20 May 2026 21:08:31 -0700 (PDT) Received: from localhost ([2001:569:58a0:da00:a5c8:c4ce:f7c1:40c1]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8413ac7b2b2sm3505781b3a.14.2026.05.20.21.08.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 May 2026 21:08:31 -0700 (PDT) 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 Date: Thu, 21 May 2026 00:08:30 -0400 Message-Id: Cc: "Peter Zijlstra" , "Catalin Marinas" , "Will Deacon" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , "Andrew Morton" , "David Hildenbrand" , "Mike Rapoport" , "Emil Tsalapatis" , , , , , , Subject: Re: [PATCH 5/8] bpf/arena: Add bpf_arena_map_kern_vm_start() and bpf_prog_arena() From: "Emil Tsalapatis" To: "Tejun Heo" , "David Vernet" , "Andrea Righi" , "Changwoo Min" , "Alexei Starovoitov" , "Andrii Nakryiko" , "Daniel Borkmann" , "Martin KaFai Lau" , "Kumar Kartikeya Dwivedi" X-Mailer: aerc 0.21.0-0-g5549850facc2 References: <20260520235052.4180316-1-tj@kernel.org> <20260520235052.4180316-6-tj@kernel.org> In-Reply-To: <20260520235052.4180316-6-tj@kernel.org> On Wed May 20, 2026 at 7:50 PM EDT, Tejun Heo wrote: > struct bpf_arena is opaque to callers outside arena.c. Add two helpers > for struct_ops subsystems that need to reach into an arena: > > bpf_arena_map_kern_vm_start(struct bpf_map *map) > returns @map's kern_vm_start. A sched_ext follow-up needs this > to translate kern_va <-> uaddr. > > bpf_prog_arena(struct bpf_prog *prog) > returns the bpf_map of the arena referenced by @prog (NULL if > @prog references no arena). The verifier enforces at most one > arena per program. Used by struct_ops callers that auto-discover > an arena from a member prog and need to take a map reference. > > Suggested-by: Kumar Kartikeya Dwivedi > Signed-off-by: Tejun Heo Reviewed-by: Emil Tsalapatis > --- > include/linux/bpf.h | 2 ++ > kernel/bpf/arena.c | 26 ++++++++++++++++++++++++++ > 2 files changed, 28 insertions(+) > > diff --git a/include/linux/bpf.h b/include/linux/bpf.h > index 5b99d786e98c..e1ba57c10aaa 100644 > --- a/include/linux/bpf.h > +++ b/include/linux/bpf.h > @@ -618,6 +618,8 @@ void bpf_rb_root_free(const struct btf_field *field, = void *rb_root, > struct bpf_spin_lock *spin_lock); > u64 bpf_arena_get_kern_vm_start(struct bpf_arena *arena); > u64 bpf_arena_get_user_vm_start(struct bpf_arena *arena); > +u64 bpf_arena_map_kern_vm_start(struct bpf_map *map); > +struct bpf_map *bpf_prog_arena(struct bpf_prog *prog); > int bpf_obj_name_cpy(char *dst, const char *src, unsigned int size); > =20 > struct bpf_offload_dev; > diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c > index a811cf6170fa..51b9ae36feb6 100644 > --- a/kernel/bpf/arena.c > +++ b/kernel/bpf/arena.c > @@ -84,6 +84,32 @@ u64 bpf_arena_get_user_vm_start(struct bpf_arena *aren= a) > return arena ? arena->user_vm_start : 0; > } > =20 > +/** > + * bpf_arena_map_kern_vm_start - kern_vm_start lookup by struct bpf_map = * > + * @map: a BPF_MAP_TYPE_ARENA map > + * > + * Return @map's kern_vm_start. > + */ > +u64 bpf_arena_map_kern_vm_start(struct bpf_map *map) > +{ > + return bpf_arena_get_kern_vm_start(container_of(map, struct bpf_arena, = map)); > +} > + > +/** > + * bpf_prog_arena - return the bpf_map of the arena referenced by @prog > + * @prog: a loaded BPF program > + * > + * The verifier enforces at most one arena per program and stores it in > + * prog->aux->arena. Return that arena's underlying bpf_map, or NULL if > + * @prog does not reference an arena. > + */ > +struct bpf_map *bpf_prog_arena(struct bpf_prog *prog) > +{ > + struct bpf_arena *arena =3D prog->aux->arena; > + > + return arena ? &arena->map : NULL; > +} > + > static long arena_map_peek_elem(struct bpf_map *map, void *value) > { > return -EOPNOTSUPP;