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=-8.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 159DAC433E2 for ; Mon, 7 Sep 2020 17:24:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D858A20658 for ; Mon, 7 Sep 2020 17:24:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KSy7/aim" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729577AbgIGRYv (ORCPT ); Mon, 7 Sep 2020 13:24:51 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:49418 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729624AbgIGNlY (ORCPT ); Mon, 7 Sep 2020 09:41:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599486082; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mx0HitpHOfVEuxavEK5m2SMEcJVCFnXIoy6pEZlAL9w=; b=KSy7/aimN1Tc/FMrvJvulDHfb/MYTVTVaxFXDXhINm+1LuHx2JFBcNjC16//xK6tmc8x9F emhW1VIGiSMoZUzvAxF6t+VgRU+/p37CN9ZJKgyTUlZz7VxjtoQvKI1pnmuGBRtUFyXQcZ nOyobn2GCJktid/9eHZoMs4mn/MlmUw= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-273-CyjkLx4kN5Km9b8_puugSQ-1; Mon, 07 Sep 2020 09:33:00 -0400 X-MC-Unique: CyjkLx4kN5Km9b8_puugSQ-1 Received: by mail-wr1-f70.google.com with SMTP id v12so5718871wrm.9 for ; Mon, 07 Sep 2020 06:33:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=mx0HitpHOfVEuxavEK5m2SMEcJVCFnXIoy6pEZlAL9w=; b=seRA5xWxYU83VdMrVLtHF1Eatqqkw31ga6qcyMBfJd+s3QPgBx6g+m4DYH4pvRRXGR jczirAIlRfV2UI1tHi1gioMFawIR/5VYinHBKhnK4AXeTpyuU8rhwBe+xz6/pGK9D8wF OVVt3jyIMYLV+rSFg49uvYePMuAPwuKt7W5vh8yhCAYWkMXfUeCWtUwHxfMUI7bGWnJm zDmgPrvn0L0TAlDTowtsOSR/h+zCvLygMY0s3/nYIT6RxKJzNr8cJ2MYmX+NcQDAOv48 D9jA179S6jzp+u2ZcH9Fs3WjgXUt/1unPj4CKRcXX8WrmqBdO9kFNhJmnQLF5/h1cNyf p6Cg== X-Gm-Message-State: AOAM532TRjW8Hq17NyrMM8N01/nc4KFVV3h7bqSMdKg4iXO38ArueLi+ oJQeHdU9pXlrOiblyfLuaQY7MTpJ/YhftbQPSy9/Fk6FZYxGPBHVRVGdjFMZf6EGRKN6KqNvq42 nup/tp77YPAbg X-Received: by 2002:adf:a18c:: with SMTP id u12mr22429550wru.90.1599485578833; Mon, 07 Sep 2020 06:32:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTQDEUKyKYpoKhV6e9kqnUpqInxvY6mXvKDlN1WLTG+p30H/JZ2ZVv0WLVSsrs9mojCzV9xg== X-Received: by 2002:adf:a18c:: with SMTP id u12mr22429519wru.90.1599485578415; Mon, 07 Sep 2020 06:32:58 -0700 (PDT) Received: from alrua-x1.borgediget.toke.dk ([2a0c:4d80:42:443::2]) by smtp.gmail.com with ESMTPSA id t22sm20618520wmt.1.2020.09.07.06.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2020 06:32:57 -0700 (PDT) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 64EF1180497; Mon, 7 Sep 2020 15:32:57 +0200 (CEST) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Borna Cafuk , Alexei Starovoitov Cc: bpf@vger.kernel.org, Luka Perkov , kpsingh@google.com Subject: Re: HASH_OF_MAPS inner map allocation from BPF In-Reply-To: References: X-Clacks-Overhead: GNU Terry Pratchett Date: Mon, 07 Sep 2020 15:32:57 +0200 Message-ID: <878sdlpv92.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org Borna Cafuk writes: > On Sat, Sep 5, 2020 at 12:47 AM Alexei Starovoitov > wrote: >> >> On Fri, Sep 4, 2020 at 7:57 AM Borna Cafuk wrote: >> > >> > Hello everyone, >> > >> > Judging by [0], the inner maps in BPF_MAP_TYPE_HASH_OF_MAPS can only be created >> > from the userspace. This seems quite limiting in regard to what can be done >> > with them. >> > >> > Are there any plans to allow for creating the inner maps from BPF programs? >> > >> > [0] https://stackoverflow.com/a/63391528 >> >> Did you ask that question or your use case is different? >> Creating a new map for map_in_map from bpf prog can be implemented. >> bpf_map_update_elem() is doing memory allocation for map elements. >> In such a case calling this helper on map_in_map can, in theory, create a new >> inner map and insert it into the outer map. > > No, it wasn't me who asked that question, but it seemed close enough to > my issue. My use case calls for modifying the syscount example from BCC[1]. > > 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 number 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