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=-2.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 42554C433B4 for ; Thu, 13 May 2021 22:58:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1DA3F61405 for ; Thu, 13 May 2021 22:58:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230204AbhEMXAA (ORCPT ); Thu, 13 May 2021 19:00:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229652AbhEMXAA (ORCPT ); Thu, 13 May 2021 19:00:00 -0400 Received: from mail-yb1-xb32.google.com (mail-yb1-xb32.google.com [IPv6:2607:f8b0:4864:20::b32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34838C061574 for ; Thu, 13 May 2021 15:58:50 -0700 (PDT) Received: by mail-yb1-xb32.google.com with SMTP id c14so5090582ybr.5 for ; Thu, 13 May 2021 15:58:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=j//wuBLQrPeO+0R8nxBy3+Tq8QZ40QULPmh5wfDL8fY=; b=WQmMLHMpom6OpEyA17DDycNMt9yHpgnCHWQ4MMl7iR8Mi2c4MDzn59oppBtLgmlO9Y dFXLupDvyYyepL5tb1B5fMg52jmIkz3vc5wQwtGKuAqmXJbn5HfNo+v4rSaMe1POw7Yt Vtq+sTkc6CVjvNHYzKidIspJdkIhR1rysF6Gvr+wHk8rVni25n1IRtXc5LtfmUO2p6e6 feyxlOiJj7zh2xBOQFefUJ1XpWVFHNis7XVno8+r44+RgTrkJGA8pka1oPQqagrT/sxj vuLf+TvUsjbtfXnqpjpmBskDpUlPe98JLCX0ycLn9vMhoc3z0uvkc4PbjFQea9qmd6ID A0UA== 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; bh=j//wuBLQrPeO+0R8nxBy3+Tq8QZ40QULPmh5wfDL8fY=; b=r+cwxEaZzqVE7oCFkXJr8/eYkQ2YDnwIHyJKWu67b7T9Ob9abgeg0pikrIWl2aAmz5 SsnhoG2glH0BfUNmDNHh/KW14TgKKJW6tLBgUY1yjXVYcAKgTe971DLdJFmNQsCILu54 cuL/zS//ALvJ3M1PdBubc29JR/oagI/8T6rfD6GH5g3AydTOkITuyvJOT5xDI40pXIGu zQEzOxGu7ssiJIRBiWqfN3A/2ipfKHG6a8NkymaTucpKnU2nvtkWxhQFSD7tobcr7Z8l xR/5DtophVc/pmNMcn2x6yAyfAeFvQrFGL3j+2HV5fuslElO5GGFHBc9t6u6eNa263j9 xqTw== X-Gm-Message-State: AOAM533ZjyqVFGvVlwASd4z5pPIEEBQhPoW9jXKsWk1uDH/qXbIXJOZ1 NliI+uW/gcrzT1n9hE/LLmFLHhlGOhWmQuTkVY4= X-Google-Smtp-Source: ABdhPJxQrelg5PlLBbQ7gkkNaCYJ9Kok/kuyGULmmSW8PQA2YL+yD4/PkHqasQYNrdEo5G2TAGvyJxOScTOQSzJIbaI= X-Received: by 2002:a25:ba06:: with SMTP id t6mr57142543ybg.459.1620946729348; Thu, 13 May 2021 15:58:49 -0700 (PDT) MIME-Version: 1.0 References: <20210512213256.31203-1-alexei.starovoitov@gmail.com> <20210512213256.31203-17-alexei.starovoitov@gmail.com> In-Reply-To: From: Andrii Nakryiko Date: Thu, 13 May 2021 15:58:38 -0700 Message-ID: Subject: Re: [PATCH v5 bpf-next 16/21] libbpf: Introduce bpf_map__initial_value(). To: Alexei Starovoitov Cc: Alexei Starovoitov , "David S. Miller" , Daniel Borkmann , Andrii Nakryiko , john fastabend , bpf , Kernel Team Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Thu, May 13, 2021 at 3:22 PM Alexei Starovoitov wrote: > > On 5/13/21 2:16 PM, Andrii Nakryiko wrote: > > On Wed, May 12, 2021 at 2:33 PM Alexei Starovoitov > > wrote: > >> > >> From: Alexei Starovoitov > >> > >> Introduce bpf_map__initial_value() to read initial contents > >> of rodata/bss maps. Note only mmaped maps qualify. > >> Just as bpf_map__set_initial_value() works only for mmaped kconfig. > > > > This sentence is confusing. bpf_map__set_initial_value() rejects > > LIBBPF_MAP_KCONFIG, so it *doesn't* work for kconfig. But your > > implementation will return non-NULL pointer for kconfig (it will be > > all zeroes before load). So did you intend to match > > set_initial_value() semantics or not? > > Good catch. I'll reword. > It was too forward looking and ended up as completely incorrect > sentence. > > The idea was to make getter work for all is_internal and mmaped > maps (including kconfig), so that after __open and before __load > phase can populate them with correct values. > Initially for kconfig I was thinking to do it as part of the loader > program, but the kernel doesn't have in memory kconfig. Unzipping > and string searching didn't feel like the right task for > the loader prog/kernel, so the light skel instead will populate > it from user space during __open. > At that point we can either fail the __open if /proc/config.gz > cannot be open or it doesn't have the fields the prog is looking for > or proceed with default values in kconfig map that libbpf populated > earlier during light skel and loader prog generation. > Depending on that choice the bpf_map__initial_value() should > either return initial value for kconfig or not. > I think returning it for kconfig map doesn't hurt. Yep, I agree.