Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp1283992lfc; Wed, 1 Jun 2022 14:11:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyx3VStIMR/9RDBdnZ2jlAGc57HQeqkpojx+iUCge+VnoDWd64nR4FnYtSEYaeTBEb2PvWE X-Received: by 2002:a17:90b:1a8a:b0:1e0:3630:19f0 with SMTP id ng10-20020a17090b1a8a00b001e0363019f0mr35998315pjb.89.1654117914288; Wed, 01 Jun 2022 14:11:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654117914; cv=none; d=google.com; s=arc-20160816; b=dIBQh3cIHMLemz/Itv71TtzPBZXiUKCykCRarbR0j7+uifX0OQa7tSlCej90vc7WsE H/zr16b5QXB/nU4okn5TALddmx/GGCVXx6KnhPpC5e2yZ8U2Iiq81qYaaIXRbV7BgsXP lpA/NljDbrIcLccI1sV2BRRdnS28Mb3llofovWd5c9m0nu94peoHKetRbDAwyO87O1+M Tmg6MgcKeBkCFNwieDkf53qxhqIuPgJvGdOLb6tPuXOLaX8sVOgOh8uZuWf68aPw8ulc fcVddtsGldDx3lDH7XR0v822Nx8upTYs5NFl4+e4GPc5iBCwY+XsXAzk0VvytDX2ZjHx B2EA== 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=Zr1dEqY8ItmKj6ohcCJC2RtP4ZcxWkAs3yQd+Txnzkw=; b=BRbsyRILUZ0YKlmlSqTFbECitY+AUkyRPelzJ2upxGH3PbHUcLZp8in1OmKyarD1IJ Ul0Jd7cG7VG3bjjLf+qvOtCrBNo+XAIQpNRQ2T4QqLfdujRAZRIho096NkpbyPoYUz8j f5GSY8mqgalBPKcbIAbcym0879qNMMxGNSF6ydpeF7ClrRKp3aVWiceQyvAy3PJZyrn+ ugpODfVXgGTYRDm+s8+z05+gH5d3F7OxCaKB0rKoPe2h/YcwpeMLIJMMx0TevPRFeJrR /m8KnA/mvqyHv6sNeJZ3LfJXJUIM75eySfyXtpP+F5EKDs6Ere+ZLGzKLgBaoZQ0d/k7 oQuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NbSD0Fzf; 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 y19-20020aa79af3000000b00518c3e572e3si3137190pfp.295.2022.06.01.14.11.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 14:11:54 -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=NbSD0Fzf; 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 AF151187C1E; Wed, 1 Jun 2022 13:03:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346095AbiFAJus (ORCPT + 99 others); Wed, 1 Jun 2022 05:50:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349979AbiFAJui (ORCPT ); Wed, 1 Jun 2022 05:50:38 -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 7D34E3120E; Wed, 1 Jun 2022 02:50:37 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id q21so2637351ejm.1; Wed, 01 Jun 2022 02:50:37 -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=Zr1dEqY8ItmKj6ohcCJC2RtP4ZcxWkAs3yQd+Txnzkw=; b=NbSD0Fzfdi4WUSxPtr2kR4w0l3Nd3CxV5KtHEJzuaEdXGauwqzKScfMeas0qdMZvB0 jBZ82G0LIjI6b3dLgUUOvRksGXMmo96wF0pcA2aMvkUiF0hWzA0lmcF+y8ILvJpuykS6 o9yIZP+mjEWpO7AhrMkLK0vcSjZHKbrOas1oeQPSgLDJeWuB6fEVRz3qZfw/YBU5acwf NJarW5fNLvmAH10mcrTMFsnXZRT8+MTcZVXIafmBt2wVkFjuJv53msqKyFu5JMiHFA/n CV4DSW//5ARJi3YFrDUu7Le39KtAa1eYZBmYsoirkhKWR10Mx9/CZ5xKLn/nxz2NRzt1 S3GA== 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=Zr1dEqY8ItmKj6ohcCJC2RtP4ZcxWkAs3yQd+Txnzkw=; b=Ik2IrMJqCfKboZXD1t5USQ/5xra3NABsBfdGnlGa7x/c82PaQtGrTyG8u+Tuarm4tf 0nLXff8U/Xnw3iIKIF6Ci9tyH/jqUUbW/gQyLA2ZJpYS458UlR4RfwW5RY4keAF74fUB 3kvTQC2p7IvoI3RSz8I1hq0iFhUHPvm/yyUfVvyPrF0KiHtYmlRsiAnyh5CMO9Du8Bnw eRTeOuN+ientUkcRlZRlk39ZpUFWfEQqROs5eqDmZX7cWlXkArD5nng94FXBGHQrbtKj 7/7k1s02N271sfgnO41KweRE+hfDUOy/7nOj7MiWUkDBy1iDxTKaFu5vH9p3P9HZlURs vLiQ== X-Gm-Message-State: AOAM533FGMtZ3p86KbRhjvvmlO4sLOG0uSYEDuZZc7Bcs2UglT8nNn5g p3t5jA4CSufl/sShVEpWqGbDDPVAmFX5atISNSg= X-Received: by 2002:a17:907:3da1:b0:6fe:ae46:997d with SMTP id he33-20020a1709073da100b006feae46997dmr49788697ejc.633.1654077035904; Wed, 01 Jun 2022 02:50:35 -0700 (PDT) MIME-Version: 1.0 References: <20220601084149.13097-1-zhoufeng.zf@bytedance.com> <20220601084149.13097-2-zhoufeng.zf@bytedance.com> In-Reply-To: <20220601084149.13097-2-zhoufeng.zf@bytedance.com> From: Alexei Starovoitov Date: Wed, 1 Jun 2022 11:50:23 +0200 Message-ID: Subject: Re: [PATCH v4 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 Wed, Jun 1, 2022 at 10:42 AM Feng zhou wrote: > > static inline void ___pcpu_freelist_push(struct pcpu_freelist_head *head, > @@ -130,14 +134,19 @@ static struct pcpu_freelist_node *___pcpu_freelist_pop(struct pcpu_freelist *s) > orig_cpu = cpu = raw_smp_processor_id(); > while (1) { > head = per_cpu_ptr(s->freelist, cpu); > + if (READ_ONCE(head->is_empty)) > + goto next_cpu; > raw_spin_lock(&head->lock); > node = head->first; > if (node) { extra bool is unnecessary. just READ_ONCE(head->first)