Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update info regarding arguments where BTF task struct pointers are required. #84

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions docs/linux/helper-function/bpf_get_task_stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ description: "This page documents the 'bpf_get_task_stack' eBPF helper function,
> Copyright (c) 2015 The Libbpf Authors. All rights reserved.


<!-- [HELPER_FUNC_DEF] -->
Return a user or a kernel stack in bpf program provided buffer. Note: the user stack will only be populated if the _task_ is the current task; all other tasks will return -EOPNOTSUPP. To achieve this, the helper needs _task_, which is a valid pointer to **struct task_struct**. To store the stacktrace, the bpf program provides _buf_ with a nonnegative _size_.

Return a user or a kernel stack in bpf program provided buffer. Note: the user stack will only be populated if the _task_ is the current task; all other tasks will return -EOPNOTSUPP. To achieve this, the helper needs _task_, which is a valid BTF pointer to **struct task_struct**, see [bpf_get_current_task_btf](../helper-function/bpf_get_current_task_btf.md) for more information. To store the stacktrace, the bpf program provides _buf_ with a nonnegative _size_.

The last argument, _flags_, holds the number of stack frames to skip (from 0 to 255), masked with **BPF_F_SKIP_FIELD_MASK**. The next bits can be used to set the following flags:

Expand All @@ -37,7 +37,6 @@ The last argument, _flags_, holds the number of stack frames to skip (from 0 to
The non-negative copied _buf_ length equal to or less than _size_ on success, or a negative error in case of failure.

`#!c static long (* const bpf_get_task_stack)(struct task_struct *task, void *buf, __u32 size, __u64 flags) = (void *) 141;`
<!-- [/HELPER_FUNC_DEF] -->

## Usage

Expand Down
5 changes: 2 additions & 3 deletions docs/linux/helper-function/bpf_task_pt_regs.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ description: "This page documents the 'bpf_task_pt_regs' eBPF helper function, i
> Copyright (c) 2015 The Libbpf Authors. All rights reserved.


<!-- [HELPER_FUNC_DEF] -->
Get the struct pt_regs associated with **task**.
Get the struct pt_regs associated with **task**. Expects a BTF pointer to the "current" task. See [bpf_get_current_task_btf](../helper-function/bpf_get_current_task_btf.md) for more information.

### Returns

A pointer to struct pt_regs.

`#!c static long (* const bpf_task_pt_regs)(struct task_struct *task) = (void *) 175;`
<!-- [/HELPER_FUNC_DEF] -->


## Usage

Expand Down
5 changes: 3 additions & 2 deletions docs/linux/helper-function/bpf_task_storage_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ description: "This page documents the 'bpf_task_storage_delete' eBPF helper func
> Copyright (c) 2015 The Libbpf Authors. All rights reserved.


<!-- [HELPER_FUNC_DEF] -->

Delete a bpf_local_storage from a _task_.
The map must be of **BPF_MAP_TYPE_TASK_STORAGE** type and the second argument a valid BTF pointer to **struct task_struct**.

### Returns

Expand All @@ -23,7 +24,7 @@ Delete a bpf_local_storage from a _task_.
**-ENOENT** if the bpf_local_storage cannot be found.

`#!c static long (* const bpf_task_storage_delete)(void *map, struct task_struct *task) = (void *) 157;`
<!-- [/HELPER_FUNC_DEF] -->


## Usage

Expand Down
8 changes: 4 additions & 4 deletions docs/linux/helper-function/bpf_task_storage_get.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ description: "This page documents the 'bpf_task_storage_get' eBPF helper functio
> Copyright (c) 2015 The Libbpf Authors. All rights reserved.


<!-- [HELPER_FUNC_DEF] -->
Get a bpf_local_storage from the _task_.

Logically, it could be thought of as getting the value from a _map_ with _task_ as the **key**. From this perspective, the usage is not much different from **bpf_map_lookup_elem**(_map_, **&**_task_) except this helper enforces the key must be a task_struct and the map must also be a **BPF_MAP_TYPE_TASK_STORAGE**.
Get a bpf_local_storage from the _task_.

Logically, it could be thought of as getting the value from a _map_ with _task_ as the **key**. From this perspective, the usage is not much different from **bpf_map_lookup_elem**(_map_, **&**_task_) except this helper enforces the key must be a valid BTF pointer to **struct task_struct** (see [bpf_get_current_task_btf](../helper-function/bpf_get_current_task_btf.md) for more information), and the map must also be a **BPF_MAP_TYPE_TASK_STORAGE**.

Underneath, the value is stored locally at _task_ instead of the _map_. The _map_ is used as the bpf-local-storage "type". The bpf-local-storage "type" (i.e. the _map_) is searched against all bpf_local_storage residing at _task_.

Expand All @@ -29,7 +29,7 @@ A bpf_local_storage pointer is returned on success.
**NULL** if not found or there was an error in adding a new bpf_local_storage.

`#!c static void *(* const bpf_task_storage_get)(void *map, struct task_struct *task, void *value, __u64 flags) = (void *) 156;`
<!-- [/HELPER_FUNC_DEF] -->


## Usage

Expand Down
Loading