Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2155214pxb; Mon, 11 Jan 2021 02:20:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJx2ziBLwe7c9UDchlGXs9MVX0PoAdhu91lFPkbzg11OHEOo80kpISVC1z70OU6XPzt12z+b X-Received: by 2002:a05:6402:797:: with SMTP id d23mr13522070edy.302.1610360442368; Mon, 11 Jan 2021 02:20:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610360442; cv=none; d=google.com; s=arc-20160816; b=WrGCW67yqE6TwIXTaTYYyai3q1bo2pHK0M5X84hjr9V55NNyvmBU1jDfchuPkpDffc oIRwQ2ozttlxOpphSCd00xo7NK1vmbA4BgkJeRmgZ2VUux3crc2pcpl1hfQ69ZhZp+qI PdChhXi0H6UYOHk+OMwH0VOa82Crlw81HvIZc2w9fWlRNgYLmYQFqDLL4sdHOY46nB+Y xaFTAk9fyDkddvhtzsxk45jtQoow8PcghMlcCT7NXkquJv6DHhVY3W7+2iV7gs9s2Kb4 kniWYfcwbayk/tFcGSq4ckIpmQbyHMapfclIfK3E3skaxP8vgjLJHUcDbIaUiDGnnGjt 6JPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=IwllBRuyl3npIVz8CQNy4WV/J6wuNc2gOL8Jwj6ZFnA=; b=fOd6OnPyc255rAM3R8HDZWYz0Zb72WKqAdNf/JecvYWEm5VHHuPkvbTmervVLcu4dm EurI6DwtMXPVm6e3trYNbrIkaT1DaOt0vcyxuxLW2Pj/27E3wFRmsa/eDPTZ6awF7nxN 9Fytr0XVLMLtfRV9+pypk9Ydtsk5xgecmKtj0EZmzmA7hJC1Q5UsLvVgTaWn+JgYwlTZ N4ig5Dx0NyWxxYdjlr5RrvbxGaB7MlJFDEEu8CMJxdw2raToUKsp1viFlFgMPOtwUAgi Bst1BbHFkLyOmx/wOLWpYXudHaLZB9k8mqfYsAbRmsmqEA/7Pmt+dbbxxgqCrcmTzmq4 q7jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=E+xGVIMk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y13si6493141ejw.564.2021.01.11.02.20.18; Mon, 11 Jan 2021 02:20:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=E+xGVIMk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729094AbhAKKSg (ORCPT + 99 others); Mon, 11 Jan 2021 05:18:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:46292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728918AbhAKKSg (ORCPT ); Mon, 11 Jan 2021 05:18:36 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2367722CB2 for ; Mon, 11 Jan 2021 10:17:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610360275; bh=jWFDugK4pflbSyLGsa3mIPsmVN/Rix2+PjepD852jR4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=E+xGVIMkOIJq28Y1lONrG1CNnYXc7k5RGQnw9EDxHH6upy9B1TP35BAykPba+znGO nPc8cQKTH53Te5RXez4p20/0DMcPuYVKPFEXDNeoIgSDyBEfPiRDpVFp2YuTQmOvGI X0Mutem5HFhu64JF5t/t2RpL6OJ668hEaJyrmno8alOeNdPJ+kbYKaC0s4JBSZKBFX 6uppxhgqmZ5RNGWtJTEqVdXSZvlIvAP9Gc/uI/6tDXA+1/skcp4+D3rdJq8Bzme6Tn hc+QGlj9aeU2+H0AFeX6JX4VgSPMbWzZZxhj7RT63r6n635BPQ4QU6RnkJ3Gll7eXZ muOlXY2mQDq7g== Received: by mail-lf1-f44.google.com with SMTP id o19so36995376lfo.1 for ; Mon, 11 Jan 2021 02:17:55 -0800 (PST) X-Gm-Message-State: AOAM5318mgSMrRt18zId3Trt5riCYTl+jYfGaxot8EmCYd9bwVtaC6o5 LC4x08SFDAav3lqVVSYAYVZcOUXvXDD8d3k7bIQtog== X-Received: by 2002:a19:cbd8:: with SMTP id b207mr6689822lfg.550.1610360273029; Mon, 11 Jan 2021 02:17:53 -0800 (PST) MIME-Version: 1.0 References: <20210108231950.3844417-1-songliubraving@fb.com> <20210108231950.3844417-2-songliubraving@fb.com> <733ebec6-e4b0-0913-0483-c79338d03798@fb.com> In-Reply-To: <733ebec6-e4b0-0913-0483-c79338d03798@fb.com> From: KP Singh Date: Mon, 11 Jan 2021 11:17:42 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next 1/4] bpf: enable task local storage for tracing programs To: Yonghong Song Cc: Song Liu , bpf , Networking , open list , mingo@redhat.com, Peter Zijlstra , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , John Fastabend , Kernel Team , Hao Luo , kernel test robot Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 11, 2021 at 7:27 AM Yonghong Song wrote: > > > > On 1/8/21 3:19 PM, Song Liu wrote: > > To access per-task data, BPF program typically creates a hash table with > > pid as the key. This is not ideal because: > > 1. The use need to estimate requires size of the hash table, with may be > > inaccurate; > > 2. Big hash tables are slow; > > 3. To clean up the data properly during task terminations, the user need > > to write code. > > > > Task local storage overcomes these issues and becomes a better option for > > these per-task data. Task local storage is only available to BPF_LSM. Now > > enable it for tracing programs. > > > > Reported-by: kernel test robot > > Signed-off-by: Song Liu > > --- [...] > > struct cfs_rq; > > struct fs_struct; > > @@ -1348,6 +1349,10 @@ struct task_struct { > > /* Used by LSM modules for access restriction: */ > > void *security; > > #endif > > +#ifdef CONFIG_BPF_SYSCALL > > + /* Used by BPF task local storage */ > > + struct bpf_local_storage *bpf_storage; > > +#endif > > I remembered there is a discussion where KP initially wanted to put > bpf_local_storage in task_struct, but later on changed to > use in lsm as his use case mostly for lsm. Did anybody > remember the details of the discussion? Just want to be > sure what is the concern people has with putting bpf_local_storage > in task_struct and whether the use case presented by > Song will justify it. > If I recall correctly, the discussion was about inode local storage and it was decided to use the security blob since the use-case was only LSM programs. Since we now plan to use it in tracing, detangling the dependency from CONFIG_BPF_LSM sounds logical to me. > > > > #ifdef CONFIG_GCC_PLUGIN_STACKLEAK > > unsigned long lowest_stack; > > diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile > > index d1249340fd6ba..ca995fdfa45e7 100644 > > --- a/kernel/bpf/Makefile > > +++ b/kernel/bpf/Makefile > > @@ -8,9 +8,8 @@ CFLAGS_core.o += $(call cc-disable-warning, override-init) $(cflags-nogcse-yy) > > > > obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o inode.o helpers.o tnum.o bpf_iter.o map_iter.o task_iter.o prog_iter.o > > obj-$(CONFIG_BPF_SYSCALL) += hashtab.o arraymap.o percpu_freelist.o bpf_lru_list.o lpm_trie.o map_in_map.o > > -obj-$(CONFIG_BPF_SYSCALL) += local_storage.o queue_stack_maps.o ringbuf.o > > +obj-$(CONFIG_BPF_SYSCALL) += local_storage.o queue_stack_maps.o ringbuf.o bpf_task_storage.o > > obj-${CONFIG_BPF_LSM} += bpf_inode_storage.o > > -obj-${CONFIG_BPF_LSM} += bpf_task_storage.o > > obj-$(CONFIG_BPF_SYSCALL) += disasm.o > > obj-$(CONFIG_BPF_JIT) += trampoline.o > > obj-$(CONFIG_BPF_SYSCALL) += btf.o > [...]