Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5864754ioo; Wed, 1 Jun 2022 14:25:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMAQHA8I21d5K2H8ig3j/Ac9MLhysGGnxFCxqo+emEo42ZhhUYDgGRazdLo5kZkYH6+PgA X-Received: by 2002:a17:90b:4b90:b0:1e0:1b0:1a1 with SMTP id lr16-20020a17090b4b9000b001e001b001a1mr36712208pjb.70.1654118706753; Wed, 01 Jun 2022 14:25:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654118706; cv=none; d=google.com; s=arc-20160816; b=tlNzC0qVzGHSBAW3ARnyZ7v2pgBOzS/n1I5m//BlbhpgwvARQTGLAet/Lo8lDdOxbQ T9CWeN1rwWGWwfnY5A9Yk9jgmcQpvnQh/Ee5Q5fkJWyMoqqaIfHx7TJIg0h+GsXOL4Am C/T0W9uTTOP8CSxO2Z67vWqcd8OJyd6ZVkHI/CWhgY2LgQeigkwD4LkSPAJyNlvub6BL +GFjaPvnjctvQfmf7bjH+wunJ1Ey8eeGUuYlRnBbHPYcvj71ygg3jgNhZI0sdovmW2J/ R4SH7iKU07WQO3sX/kszTx5vyg1pbJg2Mfp7pJCpYKapQxhfnAUARIcUm3lfqnZOJ2q5 d7jg== 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=gggQbo5NJjrb3yk8zVJBSg+Moiv4wNE6luuvF26Nva4=; b=sd2i5bjn19iIIK6OQYa/xbPg9CopbaGC81f+HdbCNfr/c642J7pafJ75nkN1+XHVQT 8pHc94VD5IoUR4kk70O+9FvpqdS5T0uWbx7GnZpAhU7wqBlPAreRZf+ibGVqnBrfKuk4 qxk1Z7g558hmZ3EgVqBBaH7my4dzDZLIYEb6kONro3rLT1TFw/WXvvBy1H8XmTZdjdQk FdUXMk9VTNwE0rLpdmI/F2M908DnqOfztbs36zzSXRa0lCt7yPdk9pkCHgg3rRDwHz66 ssD9ny6RbBgPM6DpDs1eu274U9roIkKHBs74BQH/5ZrEbr4KoP77kpwzYoiCVsBOWSHr jtSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TGlMkx+W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id mh16-20020a17090b4ad000b001dca4bd019esi8837919pjb.135.2022.06.01.14.25.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 14:25:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TGlMkx+W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3447330412D; Wed, 1 Jun 2022 13:15:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348941AbiFAJyH (ORCPT + 99 others); Wed, 1 Jun 2022 05:54:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230171AbiFAJyF (ORCPT ); Wed, 1 Jun 2022 05:54:05 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FAD15DE53; Wed, 1 Jun 2022 02:54:04 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id c2so1423798edf.5; Wed, 01 Jun 2022 02:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gggQbo5NJjrb3yk8zVJBSg+Moiv4wNE6luuvF26Nva4=; b=TGlMkx+WG1bgv466kwIPZfg1n0hlEuKZgWDt4a1taruNgqjxK8YALEO8qiTZN8XkB8 TnEN4QHj3/K0uyZOICKdLIcOt8d2OL1OsuR4KRISnuznWznm0XqHZf2T6TUVCGzFnYrQ WQaGG7eXza6vvNOirULo0TASE2rK48ol18dnMt46pu2Z5gxWlj3sqgwQkEu5xEtnJj6M BugXLYzu+DdPYN/ExCS/nllxxb3dh0LLxT+6dYeqibxO3Ckqaf6zsiM46KbEEVD7VM+P rgKQc/02G6L8CLoq+hHHT0qYCnHEEHdbAK5S6UPnUUd9s1m/5Go9TZ2XR6irBoJ5/IJO C2fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gggQbo5NJjrb3yk8zVJBSg+Moiv4wNE6luuvF26Nva4=; b=WV2APRRYYhKmAre/HsrartySmrUXReWYGLg46H0MLXoq1+ITDqF8NChikl3fZVNbR4 6AEJLYSs11ca0zfHejiWj4pQIwyXQs510uzvnhGPmV6FURwGmOIIyb1h7rvsXIqEzutk 0wvpLO+n6sJZ1+ax6J5//tt7OIIVB8DIC4a0hpT61hgfb0uVSGwKz2AEyjXKSiMy4ofI PsVFAtQaB1EPvqu2WMHm4FAcoR9j4H/bF2gpzaRjEGA2wz6LnVL8yNmzGUTPLlQYpgs5 kaWw6nNo11AcMd//CdyFdivqmpPkyfv7Y+/ZoQ0YZFzkBCmRycpSDSfPCwkVr/3PRoqc 6Gpg== X-Gm-Message-State: AOAM531klMLLYFQHTFWlLunnJx6pQz/vjfNiFHj0VIrlsHWnpn0txkSx kqmjGSbznxJFC09sCGVW4zyrBcf8lbbYafmuXo4= X-Received: by 2002:a05:6402:11ca:b0:42b:d282:4932 with SMTP id j10-20020a05640211ca00b0042bd2824932mr35251322edw.421.1654077243089; Wed, 01 Jun 2022 02:54:03 -0700 (PDT) MIME-Version: 1.0 References: <20220601084149.13097-1-zhoufeng.zf@bytedance.com> <20220601084149.13097-3-zhoufeng.zf@bytedance.com> In-Reply-To: <20220601084149.13097-3-zhoufeng.zf@bytedance.com> From: Alexei Starovoitov Date: Wed, 1 Jun 2022 11:53:51 +0200 Message-ID: Subject: Re: [PATCH v4 2/2] selftest/bpf/benchs: Add bpf_map benchmark To: Feng zhou Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Network Development , bpf , LKML , Xiongchun Duan , Muchun Song , Dongdong Wang , Cong Wang , Chengming Zhou Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 1, 2022 at 10:42 AM Feng zhou wrote: > +struct { > + __uint(type, BPF_MAP_TYPE_HASH); > + __type(key, u32); > + __type(value, u64); > + __uint(max_entries, MAX_ENTRIES); > +} hash_map_bench SEC(".maps"); > + > +u64 __attribute__((__aligned__(256))) percpu_time[256]; aligned 256 ? What is the point? > +u64 nr_loops; > + > +static int loop_update_callback(__u32 index, u32 *key) > +{ > + u64 init_val = 1; > + > + bpf_map_update_elem(&hash_map_bench, key, &init_val, BPF_ANY); > + return 0; > +} > + > +SEC("fentry/" SYS_PREFIX "sys_getpgid") > +int benchmark(void *ctx) > +{ > + u32 key = bpf_get_prandom_u32() % MAX_ENTRIES + MAX_ENTRIES; What is the point of random ? just key = MAX_ENTRIES would be the same, no? or key = -1 ? > + u32 cpu = bpf_get_smp_processor_id(); > + u64 start_time = bpf_ktime_get_ns(); > + > + bpf_loop(nr_loops, loop_update_callback, &key, 0); > + percpu_time[cpu & 255] = bpf_ktime_get_ns() - start_time; > + return 0; > +} > -- > 2.20.1 >