Re: [PATCH v5 bpf-next 1/6] bpf: enable task local storage for tracing programs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 2/23/21 2:28 PM, Song Liu wrote:
To access per-task data, BPF programs usually creates a hash table with
pid as the key. This is not ideal because:
  1. The user need to estimate the proper size of the hash table, which may
     be inaccurate;
  2. Big hash tables are slow;
  3. To clean up the data properly during task terminations, the user need
     to write extra logic.

Task local storage overcomes these issues and offers a better option for
these per-task data. Task local storage is only available to BPF_LSM. Now
enable it for tracing programs.

Unlike LSM programs, tracing programs can be called in IRQ contexts.
Helpers that access task local storage are updated to use
raw_spin_lock_irqsave() instead of raw_spin_lock_bh().

Tracing programs can attach to functions on the task free path, e.g.
exit_creds(). To avoid allocating task local storage after
bpf_task_storage_free(). bpf_task_storage_get() is updated to not allocate
new storage when the task is not refcounted (task->usage == 0).

Reported-by: kernel test robot <lkp@xxxxxxxxx>

For a patch like this, typically we do not put the above
Reported-by here as it is not really reported by the
kernel test robot. If no revision is required, maybe
maintainer can remove it before applying.

Acked-by: KP Singh <kpsingh@xxxxxxxxxx>
Signed-off-by: Song Liu <songliubraving@xxxxxx>
---
  include/linux/bpf.h            |  7 ++++++
  include/linux/bpf_lsm.h        | 22 -----------------
  include/linux/bpf_types.h      |  2 +-
  include/linux/sched.h          |  5 ++++
  kernel/bpf/Makefile            |  3 +--
  kernel/bpf/bpf_local_storage.c | 28 +++++++++++++---------
  kernel/bpf/bpf_lsm.c           |  4 ----
  kernel/bpf/bpf_task_storage.c  | 43 +++++++++-------------------------
  kernel/fork.c                  |  5 ++++
  kernel/trace/bpf_trace.c       |  4 ++++
  10 files changed, 51 insertions(+), 72 deletions(-)

[...]



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux