Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp6070142ioo; Wed, 1 Jun 2022 20:33:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9vg2k3kpJQjH1i750ojuladY0cc2AFZ09u/9se8KHF32GE8UJWLpIiQdSX5D7C8QxN49V X-Received: by 2002:a63:e603:0:b0:3fb:c191:9b65 with SMTP id g3-20020a63e603000000b003fbc1919b65mr2365668pgh.12.1654140792051; Wed, 01 Jun 2022 20:33:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654140792; cv=none; d=google.com; s=arc-20160816; b=K4zGcoubqTB1cWo58eScs2gsPssA7ZFdnRWeTQXoNSGH2Ozc7BhpbGul70qImC1XFy USa2b8OOqHayZ+JNpSRr16meshZnQDsmgWJeOJBliM2tJas4BCWogkpcSdnvEp31+jrC rqljlqyPvSsCvjfeBOqIPGZODl7a0+Eujym7i+PWKTTwe0g8EgdcFUIK04R6DVra4Z9y nE3Aq4x3pPeIAtyteQBo/ul/NwVd9jlsF3DoPI/QaJVWMYfrVDVXlSyF7fHyjd3lT+bF BWmqez9g4yLAEJwMKdOQjtWY3Q8U96DVbNIWES3Kp/mxrh89q+cNz2gYMMvOq6roSmfz GRHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=d7/X5D/XlWDgxC+lr9ny4gEaWSqGcdWBVlXv9V2nJSc=; b=gWRg2+PsVNMTUlpkYu/pSci5ipXd/BjWLximTS9QSkmLpME9yp3Rpo50XhDL8/4Tre BPSYxZ3dycF4zjhHJNmab/QDWejNBbXSWJZdrI0xgoRW1jYcFUw7DV+xIzedGC5IGbmr SmrdpkrROp8ndUrCOZbIh5XP8o2oHFWx1+yZNwLAeJmLBvNy8BPlc7ScXSjRjg/zzM1+ 374d7EsZusihNhoiYSMG4WAOJOVLLiE7kqLRArbWqK2NvF4hsn1f+dPZq8TFijhVVrYH Ha/12ay5hwBU+NfbLKluH53om76XWJztfpVmpV+FvNL60/f2tmbkVJDRTs8N0AOsvoXE 4+BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="4zgwd/so"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i4-20020a17090acf8400b001df3fb83daesi8267846pju.157.2022.06.01.20.33.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 20:33:12 -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=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="4zgwd/so"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0D9F7268542; Wed, 1 Jun 2022 20:29:35 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233520AbiFBD31 (ORCPT + 99 others); Wed, 1 Jun 2022 23:29:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233573AbiFBD3X (ORCPT ); Wed, 1 Jun 2022 23:29:23 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 574C8267CE2 for ; Wed, 1 Jun 2022 20:29:17 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id u2so3656118pfc.2 for ; Wed, 01 Jun 2022 20:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:to:cc:references :from:in-reply-to:content-transfer-encoding; bh=d7/X5D/XlWDgxC+lr9ny4gEaWSqGcdWBVlXv9V2nJSc=; b=4zgwd/soJ4OlZOpXRWMVKCorWv2P8U3su0NGdknMw1o/lf/a30yo2AcvaHVixK4JcF HEf5qgd8iNm+Iu7TGuu2W1/UAlo7NIcftpk4VWQyeAjUF4m3RkS1x0+QylTvUiPn+dut 0gAvKdf3riJQgRXO4pz/G7rmweSBnWdvYJmsAYhq+wR364cs2wiiVzu7zzRMQYV3G109 HHJiCxvOCctMT0SRMlJaiGxpSd4U8IgIT8sP9fNkHkuXAPdeo3jrj/I2q0IP+EjNieEG b22fM9Zpj5PBalBM5lVDOBwBkL7xz4P42CIx8Q1qgw1Xd2Kker2XfNkgN2SGUIn+IV3W 30rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :to:cc:references:from:in-reply-to:content-transfer-encoding; bh=d7/X5D/XlWDgxC+lr9ny4gEaWSqGcdWBVlXv9V2nJSc=; b=3snCB2Ctmh+nJ3qcnlsemg9yz/XdwYZtS+1JgXogDPSF1h162b6UuIjQX62U0kY9I2 sHyE1q913zP7q7LIGld/H0aXg6w7Zucb3bAlZmNFXp1tya0QHXmhlXX/lQjCZNQ9hTDG bVILamksqux+9Hpa+411t3rsxV7R4GyWiAfrJNc/DVLojJmDrs5mwUjisP4XyzNgviWb x0jDPOqOiKfEYDjoATpYMRY1rbgldy42AEA1GnIY5j23YErFDS7p+RM/KVuL9yawT6Ha 2C4GPO4BQdGUAX1l+0EKorYeJY8jiYIYu8bzrOGQsyl3K9Bl3uMZkwiM+mWwDPxaTNPP 77DQ== X-Gm-Message-State: AOAM531u9FCewlwM7hkBpRQC/4Xq3vA9p/+xhWd/ZrytkRKa8Z7npE8M x1qOmEmvhpNpKkxBDRfQIltKFg== X-Received: by 2002:a05:6a00:889:b0:510:91e6:6463 with SMTP id q9-20020a056a00088900b0051091e66463mr2840480pfj.58.1654140556716; Wed, 01 Jun 2022 20:29:16 -0700 (PDT) Received: from [10.71.57.194] ([139.177.225.241]) by smtp.gmail.com with ESMTPSA id v4-20020a1709028d8400b00163cdf1a200sm2239756plo.38.2022.06.01.20.29.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Jun 2022 20:29:16 -0700 (PDT) Message-ID: <6181d77a-66ed-76ff-35a4-b24134bc67fb@bytedance.com> Date: Thu, 2 Jun 2022 11:29:09 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: Re: Re: [PATCH v4 2/2] selftest/bpf/benchs: Add bpf_map benchmark To: Alexei Starovoitov 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 References: <20220601084149.13097-1-zhoufeng.zf@bytedance.com> <20220601084149.13097-3-zhoufeng.zf@bytedance.com> <041465f0-0fd3-fd39-0dac-8093a1c98c00@bytedance.com> From: Feng Zhou In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 在 2022/6/1 下午7:37, Alexei Starovoitov 写道: > On Wed, Jun 1, 2022 at 1:17 PM Feng Zhou wrote: >> 在 2022/6/1 下午5:53, Alexei Starovoitov 写道: >>> 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? >> I didn't think too much about it here, just referenced it from >> tools/testing/selftests/bpf/progs/bloom_filter_bench.c >> >>>> +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 ? >> If all threads on different cpu trigger sys_getpgid and lookup the same >> key, it will cause >> "ret = htab_lock_bucket(htab, b, hash, &flags);" >> the lock competition here is fierce, and unnecessary overhead is >> introduced, >> and I don't want it to interfere with the test. > I see. > but using random leaves it to chance. > Use cpu+max_entries then? Ok, will do. Thanks.