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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8CE7C433EF for ; Fri, 20 May 2022 03:02:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238056AbiETDCm (ORCPT ); Thu, 19 May 2022 23:02:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344969AbiETDCh (ORCPT ); Thu, 19 May 2022 23:02:37 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6D60B227D for ; Thu, 19 May 2022 20:02:34 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id 10so2881598plj.0 for ; Thu, 19 May 2022 20:02:34 -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=T49autrwazSVPbqM6JLQ0qnBuicehxkova35EuZCJaU=; b=YAQzupJhJUp7xZHECAP6liV1GLyneKC7ORPbdztHF98+Q7076sqC9DSsyMYsCmP6cA oWwweI2rAbNR1XW76OAHHX4lpS3lIfOkzqlEwwScfdtl/YFj4oxt/7O2AA+TtnDWZAu3 0/8tnXWRPpE/h6SoJ+lwC43FRUQPlDADpf0y0r99L9hq/jeXx3sg1Lw9uJenlEYTz3ce X0kJzXObUKCU7TOOJ30K4XEuS8xNv1TIaxRHNg9Qf0/aDLsQIdKLa/l0wrOuRfha3dgu 2/KpF94tfXYOkEX/1t6Lf1IuRtSmd9XMFw8WvsUvYNNQY2Aq791p0vpJ09dUsT0RNHIi hgEA== 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=T49autrwazSVPbqM6JLQ0qnBuicehxkova35EuZCJaU=; b=x622zvbF+QYsvuJzl5iboEWiK39b3mIMRSK+BycdGHYsyX9l2n76qQOKJLsaq6cZ7Y F04ClIrHebAPMD6qHMz0WXn5saX8+UxUQMAjjSpd1lhr/SJi4Q5hz7MvGHUWxujopwCF zT2YDXuIbkc3ZQAxYsuKQh5lep6iphcim14whPDeTVi2Tuw5hEvOUk8BFHPeRFSJKO+6 eXpb03/SkmaAONjncXY3XyMofEMWnQ0Z91X039TYJtJuLcwzCrb2SlEgfBTVXd8bwSaL BETBRCUB9f6FJrz2ygmBwyGCdiMWWpVHGSM0kcBKWAH2AlD+XqylrQpFvPe183ncv4tR j8oQ== X-Gm-Message-State: AOAM532XRWJgnANvjzMlqNdMjbMrByptlfDwJTOrUBVduxCLLpTjPm0k EDASNVH5gQjUwxQlqBPdFd8O9Q== X-Google-Smtp-Source: ABdhPJwOjHkRwZ7scwMzECt6n/SIMuW/O/aZf3GaVbzT7jr3FkELxpScQ0hys0wR4wtFxD+F+4Ucpg== X-Received: by 2002:a17:903:1c7:b0:161:9d6f:376a with SMTP id e7-20020a17090301c700b001619d6f376amr7770822plh.147.1653015754279; Thu, 19 May 2022 20:02:34 -0700 (PDT) Received: from [10.71.57.194] ([139.177.225.225]) by smtp.gmail.com with ESMTPSA id n1-20020a170902e54100b0015e8d4eb219sm4574667plf.99.2022.05.19.20.02.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 May 2022 20:02:33 -0700 (PDT) Message-ID: <344e2064-62f8-845e-7d1d-2afcaeb0e524@bytedance.com> Date: Fri, 20 May 2022 11:02:24 +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: [External] Re: [PATCH] bpf: avoid grabbing spin_locks of all cpus when no free elems To: Alexei Starovoitov Cc: Yonghong Song , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , John Fastabend , KP Singh , Network Development , bpf , LKML , Xiongchun Duan , Muchun Song , Dongdong Wang , Cong Wang , Chengming Zhou References: <20220518062715.27809-1-zhoufeng.zf@bytedance.com> <6ae715b3-96b1-2b42-4d1a-5267444d586b@bytedance.com> <9c0c3e0b-33bc-51a7-7916-7278f14f308e@fb.com> <380fa11e-f15d-da1a-51f7-70e14ed58ffc@bytedance.com> From: Feng Zhou In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2022/5/20 上午12:12, Alexei Starovoitov 写道: > On Wed, May 18, 2022 at 8:12 PM Feng Zhou wrote: >> 在 2022/5/19 上午4:39, Yonghong Song 写道: >>> >>> On 5/17/22 11:57 PM, Feng Zhou wrote: >>>> 在 2022/5/18 下午2:32, Alexei Starovoitov 写道: >>>>> On Tue, May 17, 2022 at 11:27 PM Feng zhou >>>>> wrote: >>>>>> From: Feng Zhou >>>>>> >>>>>> We encountered bad case on big system with 96 CPUs that >>>>>> alloc_htab_elem() would last for 1ms. The reason is that after the >>>>>> prealloc hashtab has no free elems, when trying to update, it will >>>>>> still >>>>>> grab spin_locks of all cpus. If there are multiple update users, the >>>>>> competition is very serious. >>>>>> >>>>>> So this patch add is_empty 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 >>> could you explain what parameter '1' means here? >> This code is here: >> samples/bpf/map_perf_test_user.c >> samples/bpf/map_perf_test_kern.c >> parameter '1' means testcase flag, test hash_map's performance >> parameter '2048' means test hash_map's performance when free=0. >> testcase flag '2048' is added by myself to reproduce the problem phenomenon. > Please convert it to selftests/bpf/bench, > so that everyone can reproduce the issue you're seeing > and can assess whether it's a real issue or a corner case. > > Also please avoid adding indent in the patch. > Instead of > if (!s->extralist.is_empty) { > .. churn > > do > > if (s->extralist.is_empty) Ok, will do. Thanks.