Skip to content

[doc] Proposal doc for extensible maps#4566

Draft
saxena-anurag wants to merge 9 commits intomicrosoft:mainfrom
saxena-anurag:user/anusa/custom_maps_proposal
Draft

[doc] Proposal doc for extensible maps#4566
saxena-anurag wants to merge 9 commits intomicrosoft:mainfrom
saxena-anurag:user/anusa/custom_maps_proposal

Conversation

@saxena-anurag
Copy link
Copy Markdown
Contributor

@saxena-anurag saxena-anurag commented Aug 12, 2025

Description

This PR adds proposal for implementing extensible maps (#4375), and what areas will need to be touched to add this support.

Testing

NA

Documentation

This is doc only PR

Installation

No

@saxena-anurag saxena-anurag changed the title add proposal doc [doc] Proposal doc for extensible maps Aug 12, 2025
@saxena-anurag saxena-anurag marked this pull request as ready for review August 12, 2025 18:52
Comment thread docs/ExtensibleMaps.md Outdated
Comment thread docs/ExtensibleMaps.md Outdated
Comment thread docs/ExtensibleMaps.md Outdated
@@ -0,0 +1,79 @@
# Introduction

Extensible maps are program type specific maps that will be implemented by the extension that is implementing the program type (program info provider). This document contains the proposal for implementing support for extensible / program type specific maps in eBPF-for-Windows. The below sections describe all the scenarios / areas that will need to be updated or tested for this new map type.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend splitting into shorter source lines.

Comment thread docs/ExtensibleMaps.md Outdated
Global maps get an ID for their map types from a global namespace. There are two possible options for how we can allocate IDs for map types for extensible maps.

**Option 1: Global Map IDs**
- The map type IDs are allocated from a global namespace. This will be disjoint from the namespace for global maps. Global maps will use IDs from 1 to 4095. Extensible maps will use IDs 4096 onwards.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elaborate... I don't follow why you need a separate ID range instead of just using normal IDs.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answer: this is about map type IDs (which makes sense) not map IDs per se. Please update all uses of the term :)

Comment thread docs/ExtensibleMaps.md Outdated
## Map lifecycle
Even though the extensible map will be created by and reside in the extension, ebpfcore will also create a corresponding map entry, as it does for the global maps. The difference being, in case of extensible maps, the map CRUD APIs will be supplied by the extension, and map entry in ebpfcore will contain these function pointers provided by the extension.

Map lifetime will also be maintained by eBPFcore, and it will invoke extension's map delete API when the map needs to be finally deleted.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Map lifetime will also be maintained by eBPFcore, and it will invoke extension's map delete API when the map needs to be finally deleted.
Map lifetime will also be maintained by eBPFcore, and it will invoke the extension's map delete API when the map needs to be finally deleted.

Comment thread docs/ExtensibleMaps.md Outdated
- Once it finds the program info provider, it makes a (new) ioctl call to create the extensible map, and also pass the program type.
- eBPFcore will first attach (NMR) to this provider, and check if the actual provider supports this map type. If yes, proceed to create map in the extension.

Implicit map creation flow will also be similar. ebpf runtime will have similar flow for map creation, automatic map pinning, and map reuse.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Implicit map creation flow will also be similar. ebpf runtime will have similar flow for map creation, automatic map pinning, and map reuse.
Implicit map creation flow will also be similar. The ebpf runtime will have a similar flow for map creation, automatic map pinning, and map reuse.

Also by "ebpf runtime" do you mean ebpfcore?

Comment thread docs/ExtensibleMaps.md Outdated

Extensible maps are program type specific maps that will be implemented by the extension that is implementing the program type (program info provider). This document contains the proposal for implementing support for extensible / program type specific maps in eBPF-for-Windows. The below sections describe all the scenarios / areas that will need to be updated or tested for this new map type.

## Map Id partitioning
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update text and replace "Map ID" by "map type enum"

Comment thread docs/ExtensibleMaps.md Outdated
Map lifetime will also be maintained by eBPFcore, and it will invoke extension's map delete API when the map needs to be finally deleted.
Similarly, map pinning will also be handled by eBPFcore as that impacts map lifetime.

Another thing to note is that once an extensible map is created, the corresponding extension **cannot be allowed to unload / restart**, as that will delete the map and its entries. This will be a limitation / restriction for the extension that is implementing extensible maps, and may impact their servicing flow.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explore if the map memory can come from ebpfcore so that it survives extension restart.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting aside the extension behavior, what happens on Linux if an XSK map contains an entry for an XSK and:

  1. The XSK file handle is closed?
  2. The process that created the XSK terminates? [Can an XSK map be pinned such that it persists across process lifetime?]

I vaguely recall reading somewhere that the XSK map may have entries automatically removed - let me try to find that old context.

Copy link
Copy Markdown
Contributor

@mtfriesen mtfriesen Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this blurb on the man page, but it refers to user mode automatically cleaning up the XSK entry, and not a kernel implementation:

When libxdp deletes an XSK it also removes the associated socket entry from the XSKMAP.

As long as our observable behavior matches Linux (e.g., if adding an XSK to a map keeps the entry around indefinitely) then I agree the simplest extension model is best. If the Linux kernel does support implicit XSK entry deletion, then I'd lean towards having the map itself also be implicitly deleted by the extension if it initiates NMR teardown.

@Alan-Jowett Alan-Jowett requested a review from Copilot August 26, 2025 19:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a proposal document for implementing extensible maps in eBPF-for-Windows, which would allow program type specific maps to be implemented by extensions rather than being limited to global maps. The proposal outlines the technical design considerations and implementation areas that need to be addressed.

Key changes:

  • Adds comprehensive proposal document covering map ID partitioning strategies
  • Defines NMR interface extensions and eBPF store modifications needed
  • Outlines map lifecycle management and API design considerations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread docs/ExtensibleMaps.md Outdated

**Option 1: Global Map IDs**
- The map type IDs are allocated from a global namespace. This will be disjoint from the namespace for global maps. Global maps will use IDs from 1 to 4095. Extensible maps will use IDs 4096 onwards.
- Each program info provider that implements a extensible map will need to register / reserve the MAP ID / enum in the eBPF repo by creating a PR.
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a grammatical error: 'a extensible' should be 'an extensible'.

Suggested change
- Each program info provider that implements a extensible map will need to register / reserve the MAP ID / enum in the eBPF repo by creating a PR.
- Each program info provider that implements an extensible map will need to register / reserve the MAP ID / enum in the eBPF repo by creating a PR.

Copilot uses AI. Check for mistakes.
Comment thread docs/ExtensibleMaps.md Outdated
Use option 1 as it allows keeping the user mode API for map creation same as on Linux, only adding a one-time step for extension developers to reserve the map ID in the global namespace (by creating a PR in eBPF repo).

## NMR interface for extensions
The NMR interface for program info provider will extended (non-breaking) and extensions will provide below information:
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a grammatical error: 'will extended' should be 'will be extended'.

Suggested change
The NMR interface for program info provider will extended (non-breaking) and extensions will provide below information:
The NMR interface for program info provider will be extended (non-breaking) and extensions will provide below information:

Copilot uses AI. Check for mistakes.
Comment thread docs/ExtensibleMaps.md Outdated
Comment on lines +32 to +33
## Verfication
- No impact on verfication (online or offline), as the verifier only cares about the actual map definitions.
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a spelling error: 'Verfication' should be 'Verification'.

Suggested change
## Verfication
- No impact on verfication (online or offline), as the verifier only cares about the actual map definitions.
## Verification
- No impact on verification (online or offline), as the verifier only cares about the actual map definitions.

Copilot uses AI. Check for mistakes.
Comment thread docs/ExtensibleMaps.md Outdated
Comment on lines +32 to +33
## Verfication
- No impact on verfication (online or offline), as the verifier only cares about the actual map definitions.
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a spelling error: 'verfication' should be 'verification'.

Suggested change
## Verfication
- No impact on verfication (online or offline), as the verifier only cares about the actual map definitions.
## Verification
- No impact on verification (online or offline), as the verifier only cares about the actual map definitions.

Copilot uses AI. Check for mistakes.
Comment thread docs/ExtensibleMaps.md Outdated

**Export RCU APIs via NMR interface**
- Probably adds more complexity to ebpfcore.
- Does not require new release from extensions wheenver there is a bugfix in RCU logic.
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a spelling error: 'wheenver' should be 'whenever'.

Suggested change
- Does not require new release from extensions wheenver there is a bugfix in RCU logic.
- Does not require new release from extensions whenever there is a bugfix in RCU logic.

Copilot uses AI. Check for mistakes.
Comment thread docs/ExtensibleMaps.md Outdated
Proposal here is to export RCU as lib.

## Perf Consideration
Since map APIs for extensible maps will have logner path length, we should measure perf for extensible map operations.
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a spelling error: 'logner' should be 'longer'.

Suggested change
Since map APIs for extensible maps will have logner path length, we should measure perf for extensible map operations.
Since map APIs for extensible maps will have longer path length, we should measure perf for extensible map operations.

Copilot uses AI. Check for mistakes.
@dthaler dthaler added the documentation Improvements or additions to documentation label Sep 22, 2025
Comment thread docs/ExtensibleMaps.md Outdated
@@ -0,0 +1,79 @@
# Introduction

Extensible maps are program type specific maps that will be implemented by the extension that is implementing the program type (program info provider). This document contains the proposal for implementing support for extensible / program type specific maps in eBPF-for-Windows. The below sections describe all the scenarios / areas that will need to be updated or tested for this new map type.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all maps extensible maps? Or specific map types? If BPF_MAP_TYPE_XSKMAP is an example of one, say so and point to https://docs.kernel.org/bpf/map_xskmap.html

@saxena-anurag saxena-anurag marked this pull request as draft September 24, 2025 21:30
Comment thread docs/ExtensibleMaps.md
@@ -0,0 +1,149 @@
# Introduction

Extensible maps are custom map types that can be implemented by eBPF extensions (e.g. BPF_MAP_TYPE_XSKMAP) through a new
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then the name is a misnomer. Something that is "extensible" is something that can itself be extended, not something that is an extension to something else. Either describe how an eBPF extension can extend a map type it didn't define, or else change the name. Examples: "extension-specific map type", "custom map type", "extension map type", "program type specific map type", etc. Or even "extension-implemented custom map types" as line 54 uses, but that's even longer. Any of those are more correct than "extensible map" if I understand this definition.

Comment thread docs/ExtensibleMaps.md
- **Global Maps (1-4095)**: Reserved for core eBPF runtime map types (hash, array, etc.)
- **Extensible Maps (4096+)**: Available for extension-implemented custom map types

Extensions *can* reserve unique map type IDs by submitting PRs to update the enum in the eBPF repository.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is "can"highlighted? Just say "must". But I don't understand any benefit to partitioning the space. Please elaborate on what the benefit is. (I don't think allowing collisions is a benefit or a good thing, and requiring a PR is the only way you've defined in this document to avoid it.)

Comment thread docs/ExtensibleMaps.md
- `delete_batch()` - Batch delete operations
- `lookup_and_delete_batch()` - Atomic lookup and delete operations

## Memory Management and RCU Semantics
Copy link
Copy Markdown
Collaborator

@dthaler dthaler Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RCU is an undefined acronym. Please define / expand on first use. For example, if it's Read/Create/Update then why is Delete not supported? (and CRUD would be the usual acronym for that)

@dthaler
Copy link
Copy Markdown
Collaborator

dthaler commented Mar 23, 2026

@saxena-anurag is this PR obsoleted by PR #4882?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants