Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2283546iof; Wed, 8 Jun 2022 01:23:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPo429nIU6O2tqTuzXMtfpO0cFSu+T2ianXRoeezrpKVicGXqoB0t3XJe/5ZQZCKNT5Qp6 X-Received: by 2002:a63:409:0:b0:3fd:77f0:9a75 with SMTP id 9-20020a630409000000b003fd77f09a75mr17475159pge.149.1654676585919; Wed, 08 Jun 2022 01:23:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654676585; cv=none; d=google.com; s=arc-20160816; b=TKhLh2oepqvCvk46TmCyMk1J84cJnW+Te0oxHhj1YmqC+/PV1Ku5+YxD3REpIyvrzW SoXcCfv5mkY/9Dryn7fdf7ZlDDzKNMaRXJ25DYDYOMj94g+Giv8UIFh6Okt9ff8FpVbh jdV5HzIsLlexNVLlzqWGjhMnyFG/s0B2Al7BNVsYk8H9eqp2mTxrS4u+iWGoWvQRDFv3 1hLOHRXMELSLGHBCBZ9Px/vkfNkI3TnARfpZFcdNFU3wXLVpJQDRczoLg0QqwKQaE0lP o/xAt/MXTpDYQQbaD0PtLFck/WbbwlOp3RaVR6UiIWgQeWwzYNiSZf1/ZNM3adBtQR7y DxSQ== 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=TIpn0h2PVrPJC3SI/KH0xb5zHLGy1ws/TaSSWL1fafE=; b=JwJ22qX6MH07QUYtJXrr2Kxjass9w+rOInmf+CGKmPY4UIHZNO4Ez7cYcueTV5OXCC 91cbsD4OspT9Kkya4mSdW99SCInspAW92f9cLUI1rvINjq1v36ehD7X9pEAr1BG+Yzzw /0UqDi5vF+ib7uQs4eCSoUzzUj/RyKU+mDOFdtmbs4sBqTgA/1PyFYLfeCr9nu4MkODW +A0WDWS0r6f3IirjyuEM7AI4ba9SMNE42aWQh36e17i9a6qOTLkW+RO+dfPhlW2VJCnR 943RVPOVWpUYuBgMBFZb+PiKl+Vp9cx3waIccXCqc62RQI6v7CLpO4KiHlIADmzK7pnD VWqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZRJirNsP; 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 q131-20020a632a89000000b003fcd2455908si2666668pgq.309.2022.06.08.01.23.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:23:05 -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=ZRJirNsP; 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 BC849156B5D; Wed, 8 Jun 2022 00:53:33 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233489AbiFHFfv (ORCPT + 99 others); Wed, 8 Jun 2022 01:35:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234199AbiFHFe6 (ORCPT ); Wed, 8 Jun 2022 01:34:58 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E08102200A7; Tue, 7 Jun 2022 20:39:24 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id s12so31665549ejx.3; Tue, 07 Jun 2022 20:39:24 -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=TIpn0h2PVrPJC3SI/KH0xb5zHLGy1ws/TaSSWL1fafE=; b=ZRJirNsPmCJEJ8/xnwMXrjipNEdCoSO+YJlycAp6wr+Y+VIu9Qm0TsQ/xbl2UkI0+L 4WtwcGHsG9iVn4/DIpsadFXw37zZd/kzciybUhbJUVdirBgGDXwswi20O0rYsy33imxk WOdvvDtoGHSR0AT1DeC5aC/zJU4qRzE9WDGZg4+yARXJ4aPFocpV1utF703vXaxXkcF8 2o99mSaoPk3pMZ0VXE1okpFArQCfwpN58epmZHq+KhOyf3XnBNjkKH9pB+rduYl6A+t1 6st4ECCjKlV3uSgIlbdKMgdHUbMOP4lsjNhBQm4/ewYKQUkQuwVd/k1SLR7fewMpO+g/ gsiw== 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=TIpn0h2PVrPJC3SI/KH0xb5zHLGy1ws/TaSSWL1fafE=; b=EEEXA3RYaiJi6o0uvuZoJi3ZUozJV1nktXisLztxtfl4J3UKIeQZQPyrxLDjGu/BRm SEkaS2Z31MvSOChcwrQQFFLtjdNy9agZp9QPQB4SOYDOkV1svyG6iu3BTBbupWb5zR5G JHlkuxUahnweg6NRS8gkjVBhTvaDs2zd0zzHiXSREsrNkjYlwZAJ5jfD48yI6U03ocQP Oq9iFL3lYQ6MVODW2InpIPtHSnB9Y9KICqKmP+P1l0Nl73oY9iU+I/k9dBXAYk76MS9a lyUu32tofN+hfGQoCxXRtfrzYqm1AdEaoqhERp9pDBCv8xcZ/czh4qivvQjcEfZRjBGK hCQA== X-Gm-Message-State: AOAM532HIDNVwRxM7GaE8zyyj0JfjcSUDrVbUHbw/rSaA2IKaCK5n1Y1 OKevs7yVBKmK4NNp4CGt1fI4IE6GWtugg89TvxXpD/LT X-Received: by 2002:a17:906:c156:b0:6ff:2415:fc18 with SMTP id dp22-20020a170906c15600b006ff2415fc18mr29466294ejc.94.1654659563312; Tue, 07 Jun 2022 20:39:23 -0700 (PDT) MIME-Version: 1.0 References: <20220608021050.47279-1-zhoufeng.zf@bytedance.com> <20220608021050.47279-2-zhoufeng.zf@bytedance.com> In-Reply-To: <20220608021050.47279-2-zhoufeng.zf@bytedance.com> From: Alexei Starovoitov Date: Tue, 7 Jun 2022 20:39:11 -0700 Message-ID: Subject: Re: [PATCH v5 1/2] bpf: avoid grabbing spin_locks of all cpus when no free elems 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 Tue, Jun 7, 2022 at 7:11 PM Feng zhou wrote: > > From: Feng Zhou > > This patch use head->first in pcpu_freelist_head to check freelist > having free or not. If having, grab spin_lock, or check next cpu's > freelist. > > Before patch: hash_map performance > ./map_perf_test 1 > 0:hash_map_perf pre-alloc 975345 events per sec > 4:hash_map_perf pre-alloc 855367 events per sec > 12:hash_map_perf pre-alloc 860862 events per sec > 8:hash_map_perf pre-alloc 849561 events per sec > 3:hash_map_perf pre-alloc 849074 events per sec > 6:hash_map_perf pre-alloc 847120 events per sec > 10:hash_map_perf pre-alloc 845047 events per sec > 5:hash_map_perf pre-alloc 841266 events per sec > 14:hash_map_perf pre-alloc 849740 events per sec > 2:hash_map_perf pre-alloc 839598 events per sec > 9:hash_map_perf pre-alloc 838695 events per sec > 11:hash_map_perf pre-alloc 845390 events per sec > 7:hash_map_perf pre-alloc 834865 events per sec > 13:hash_map_perf pre-alloc 842619 events per sec > 1:hash_map_perf pre-alloc 804231 events per sec > 15:hash_map_perf pre-alloc 795314 events per sec > > hash_map the worst: no free > ./map_perf_test 2048 The commit log talks about some private patch you've made to map_perf_test. Please use numbers from the bench added in the 2nd patch. Also trim commit log to only relevant parts. ftrace dumps and numbers from all cpus are too verbose for commit log.