Skip to content

Commit

Permalink
bpf, docs: Change underline in btf to match style guide
Browse files Browse the repository at this point in the history
This changes the type of underline used to follow the guidelines in
Documentation/doc-guide/sphinx.rst which also ensures that the headings
are rendered at the correct level in the HTML sidebar

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/981b27485cc294206480df36fca46817e2553e39.1636749493.git.dave@dtucker.co.uk
  • Loading branch information
Dave Tucker authored and Daniel Borkmann committed Nov 17, 2021
1 parent db813d7 commit 3ff36bf
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions Documentation/bpf/btf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ BPF Type Format (BTF)
=====================

1. Introduction
***************
===============

BTF (BPF Type Format) is the metadata format which encodes the debug info
related to BPF program/map. The name BTF was used initially to describe data
Expand All @@ -30,7 +30,7 @@ sections are discussed in details in :ref:`BTF_Type_String`.
.. _BTF_Type_String:

2. BTF Type and String Encoding
*******************************
===============================

The file ``include/uapi/linux/btf.h`` provides high-level definition of how
types/strings are encoded.
Expand All @@ -57,13 +57,13 @@ little-endian target. The ``btf_header`` is designed to be extensible with
generated.

2.1 String Encoding
===================
-------------------

The first string in the string section must be a null string. The rest of
string table is a concatenation of other null-terminated strings.

2.2 Type Encoding
=================
-----------------

The type id ``0`` is reserved for ``void`` type. The type section is parsed
sequentially and type id is assigned to each recognized type starting from id
Expand Down Expand Up @@ -504,7 +504,7 @@ valid index (starting from 0) pointing to a member or an argument.
* ``type``: the type with ``btf_type_tag`` attribute

3. BTF Kernel API
*****************
=================

The following bpf syscall command involves BTF:
* BPF_BTF_LOAD: load a blob of BTF data into kernel
Expand Down Expand Up @@ -547,14 +547,14 @@ The workflow typically looks like:


3.1 BPF_BTF_LOAD
================
----------------

Load a blob of BTF data into kernel. A blob of data, described in
:ref:`BTF_Type_String`, can be directly loaded into the kernel. A ``btf_fd``
is returned to a userspace.

3.2 BPF_MAP_CREATE
==================
------------------

A map can be created with ``btf_fd`` and specified key/value type id.::

Expand All @@ -581,7 +581,7 @@ automatically.
.. _BPF_Prog_Load:

3.3 BPF_PROG_LOAD
=================
-----------------

During prog_load, func_info and line_info can be passed to kernel with proper
values for the following attributes:
Expand Down Expand Up @@ -631,7 +631,7 @@ For line_info, the line number and column number are defined as below:
#define BPF_LINE_INFO_LINE_COL(line_col) ((line_col) & 0x3ff)

3.4 BPF_{PROG,MAP}_GET_NEXT_ID
==============================
------------------------------

In kernel, every loaded program, map or btf has a unique id. The id won't
change during the lifetime of a program, map, or btf.
Expand All @@ -641,13 +641,13 @@ each command, to user space, for bpf program or maps, respectively, so an
inspection tool can inspect all programs and maps.

3.5 BPF_{PROG,MAP}_GET_FD_BY_ID
===============================
-------------------------------

An introspection tool cannot use id to get details about program or maps.
A file descriptor needs to be obtained first for reference-counting purpose.

3.6 BPF_OBJ_GET_INFO_BY_FD
==========================
--------------------------

Once a program/map fd is acquired, an introspection tool can get the detailed
information from kernel about this fd, some of which are BTF-related. For
Expand All @@ -656,7 +656,7 @@ example, ``bpf_map_info`` returns ``btf_id`` and key/value type ids.
bpf byte codes, and jited_line_info.

3.7 BPF_BTF_GET_FD_BY_ID
========================
------------------------

With ``btf_id`` obtained in ``bpf_map_info`` and ``bpf_prog_info``, bpf
syscall command BPF_BTF_GET_FD_BY_ID can retrieve a btf fd. Then, with
Expand All @@ -668,18 +668,18 @@ tool has full btf knowledge and is able to pretty print map key/values, dump
func signatures and line info, along with byte/jit codes.

4. ELF File Format Interface
****************************
============================

4.1 .BTF section
================
----------------

The .BTF section contains type and string data. The format of this section is
same as the one describe in :ref:`BTF_Type_String`.

.. _BTF_Ext_Section:

4.2 .BTF.ext section
====================
--------------------

The .BTF.ext section encodes func_info and line_info which needs loader
manipulation before loading into the kernel.
Expand Down Expand Up @@ -743,7 +743,7 @@ bpf_insn``. For ELF API, the ``insn_off`` is the byte offset from the
beginning of section (``btf_ext_info_sec->sec_name_off``).

4.2 .BTF_ids section
====================
--------------------

The .BTF_ids section encodes BTF ID values that are used within the kernel.

Expand Down Expand Up @@ -804,10 +804,10 @@ All the BTF ID lists and sets are compiled in the .BTF_ids section and
resolved during the linking phase of kernel build by ``resolve_btfids`` tool.

5. Using BTF
************
============

5.1 bpftool map pretty print
============================
----------------------------

With BTF, the map key/value can be printed based on fields rather than simply
raw bytes. This is especially valuable for large structure or if your data
Expand Down Expand Up @@ -849,7 +849,7 @@ bpftool is able to pretty print like below:
]

5.2 bpftool prog dump
=====================
---------------------

The following is an example showing how func_info and line_info can help prog
dump with better kernel symbol names, function prototypes and line
Expand Down Expand Up @@ -883,7 +883,7 @@ information.::
[...]

5.3 Verifier Log
================
----------------

The following is an example of how line_info can help debugging verification
failure.::
Expand All @@ -909,7 +909,7 @@ failure.::
R2 offset is outside of the packet

6. BTF Generation
*****************
=================

You need latest pahole

Expand Down Expand Up @@ -1016,6 +1016,6 @@ format.::
.long 8206 # Line 8 Col 14

7. Testing
**********
==========

Kernel bpf selftest `test_btf.c` provides extensive set of BTF-related tests.

0 comments on commit 3ff36bf

Please sign in to comment.