From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CB2EC43461 for ; Wed, 9 Sep 2020 10:36:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 47A5F21D7B for ; Wed, 9 Sep 2020 10:36:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="jbL2tg7P" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726440AbgIIKgS (ORCPT ); Wed, 9 Sep 2020 06:36:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726293AbgIIKgQ (ORCPT ); Wed, 9 Sep 2020 06:36:16 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7076EC061573 for ; Wed, 9 Sep 2020 03:36:15 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id z22so2783083ejl.7 for ; Wed, 09 Sep 2020 03:36:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=tzhpphIZPNY5HcPVpD2+EfgrB7S3JPj/42APLIASAH8=; b=jbL2tg7Ps/+widMQTGjlh0P2t7g/AY83MSiTvWlda0Suk4Zs0XiCaCgCo7ZrRM1fJH aCQuHi/l75xxIN6eccqZHwvA+L3saYTUv5iqL0CwMtxow/MWJP04b10ZgscVIeB+ayuo 94VnsPRY+gAz615jxaA7UVtzORyMijNcrg0ULj1MFsT/RrPU/MXrHC9iqk0p86G2Ofoj WEXfNND7JUCLZAlmIe4/MGXVguk5NWV/iXqu77dRRy5R/r3tW2YP7YmYojCpAwh1QFU9 7t0vq8KHesHiJe+gEtUs+qneCaUqjDRNWpCVSVHHy71ptruv+1IuahLvSJYHifKkyZk6 HPew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=tzhpphIZPNY5HcPVpD2+EfgrB7S3JPj/42APLIASAH8=; b=ax6qXVBNeSkTUB93Y1J2+t2DabfynUXIHloHQB/CzItBzRbzNkchE/8kZYFZnqejgW Vb1SGGlXGvM5M0dyTZGp/GBOqHs2YjLt7CqoClySrOyvpJ1MILyH4+AGQCdRh7LVMQqO /5/e2GhQCcWyUCMWFv3Zf38pFbTlRs+GhTQ6CZ9hRVPt9cr/k8msF/o4bLEVxFHlC6z8 +1ai9HhdTsgxoBbpWeeBe9/4vp/pOGQ4ZXa/qtnkLM5UL1faxd1RO/0XjmCzNyb1jQTx f+PQii2ACORaKp4Ss/IMoC79+oUvisdfJ41BtFcWm0RqUYTKmwcSwxaE3K0Arh5aUOA4 9jaQ== X-Gm-Message-State: AOAM531WoViz4vIOFcL2gsPs9jl2I5Ih+hfArGTuzrFtitqokdRSIJiO 2yFI2KDL73hh+lv0JhcqvLVnwTc9ZeM9btFgwj1L X-Google-Smtp-Source: ABdhPJwCl6eteNuBgQu+3r8s4PSaBxXmmWl+i7CK6YgF79FSaKs8vVqQPWfmNGMWq1RmR7haK8g7X9zKrK5IkZbrX0s= X-Received: by 2002:a17:906:7809:: with SMTP id u9mr2793628ejm.511.1599647773878; Wed, 09 Sep 2020 03:36:13 -0700 (PDT) MIME-Version: 1.0 References: <878sdlpv92.fsf@toke.dk> <87mu1znt7q.fsf@toke.dk> In-Reply-To: <87mu1znt7q.fsf@toke.dk> From: KP Singh Date: Wed, 9 Sep 2020 12:35:57 +0200 Message-ID: Subject: Re: HASH_OF_MAPS inner map allocation from BPF To: =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= Cc: Borna Cafuk , Alexei Starovoitov , bpf , Luka Perkov Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Wed, Sep 9, 2020 at 12:24 PM Toke H=C3=B8iland-J=C3=B8rgensen wrote: > > Borna Cafuk writes: > > > On Mon, Sep 7, 2020 at 3:33 PM Toke H=C3=B8iland-J=C3=B8rgensen wrote: > >> > >> Borna Cafuk writes: > >> > >> > On Sat, Sep 5, 2020 at 12:47 AM Alexei Starovoitov > >> > wrote: [...] > >> > > >> > The idea is to have an outer map where the keys are PIDs, and inner = maps where > >> > the keys are system call numbers. This would enable tracking the num= ber of > >> > syscalls made by each process and the makeup of those calls for all = processes > >> > simultaneously. > >> > > >> > [1] https://github.com/iovisor/bcc/blob/master/libbpf-tools/syscount= .bpf.c > >> > >> Well, if you just want to count, map-in-map seems a bit overkill? You > >> could just do: > >> > >> struct { > >> u32 pid; > >> u32 syscall; > >> } map_key; > >> > >> and use that? > >> > >> -Toke > >> > > > > I have considered that, but maps in maps seem better for when I need to= get the > > data about a single process's syscalls: It requires reading only one of= the > > inner maps in its entirety. If I have a composite key like that, I don'= t see > > any way, other than: > > * either iterating through all the possible keys for a process > > (i.e. over all syscalls) and looking them up in the map, or > > * iterating over all entries in the map and filtering them. > > > > Looking at it again, the first option does not seem _that_ bad, > > You could even use BPF_MAP_LOOKUP_BATCH to do this in one operation, I > suppose... > > > but just iterating over one (inner) map would be easier to fit into > > our use-case. > > ...but yeah, I see what you mean. Well, maybe BPF local storage per > process would also be a nice fit here? Yes, task local storage does seem like a good fit and is the next one I was thinking of implementing. - KP > > -Toke >