Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5054878rwb; Wed, 17 Aug 2022 10:12:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR4yVTC5ztK9uzc3KNvcBJ84DxwC6/i4tieYAabtilTeRmf+2RFkowL4vUFe+2DU8rWS0ak9 X-Received: by 2002:a17:907:72d5:b0:731:6512:ad with SMTP id du21-20020a17090772d500b00731651200admr16837452ejc.739.1660756374753; Wed, 17 Aug 2022 10:12:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660756374; cv=none; d=google.com; s=arc-20160816; b=wfBoWUbLMc+CiAbnws7xLGcBz43B9MeJPw4QL3r7mad3YUpfhhHxB0Bk4Yjz0M5Qz6 gl98VAkg5SrWxJu1q34hQWidGCEWmdkIS4Otwptn3p2Zp4cKoTkIowobuC/IkTundfz8 njj+XZYrhUSPhH3knpgBcKHh/3MaqMFm/a1XrVPTb+MeABmACDaoxs1pU2JCDpn3VwyO t/vt2aEtAnsBoME1DloBgc1k+jt7afOhdAqbbcZEVvTcRySTxZQoBSiFe4YRazNM9sej 7rnwwknyzEN9ZG/kE/tH9OR/3tdEloA+V4AhhqjRt/cUf+3Qky2nviDjttKoyGcHCf0i /FHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=BxNAR+uUWZbpzMnoZ6xLNT20e9pYEmaXKXCcI9Q/EoM=; b=XIjfo27Ws/5xeJ8xhJCDNPlDooe4ywv+zL0A4pKRp5jh0NlWnI5WJxaSoxTWySvuGL Z0YB29AQuR3hRor0nXwV7kfa2506jLjaInG6w5BThwl6QAe9tZ2JDHkfXxxT6rOo8mOa Pyxp2n2dGsrlC8OO1LtX++KZD2deXIyFDcwj9Prh33CvD1AmH9jqgY++9CVkn3P74LZ6 hOS9BXibwPb6xwYYQwdqAPPlMwzcXaRBmZZHs4Lwjw3ky8/8Xkkz+rh4Aeyy5lGytWKr 7GmghUPg7VU171rvuUDbMF1rXd70JT7oxV5pmGYMvrTq8EGSRFTYwNUDreRXMg5FuP02 8j7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=OvdQe09o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h15-20020a17090634cf00b00730bcbd396dsi10479882ejb.406.2022.08.17.10.12.26; Wed, 17 Aug 2022 10:12:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=OvdQe09o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237983AbiHQQ5h (ORCPT + 99 others); Wed, 17 Aug 2022 12:57:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236230AbiHQQ5g (ORCPT ); Wed, 17 Aug 2022 12:57:36 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B860396741 for ; Wed, 17 Aug 2022 09:57:34 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id bu15so8404485wrb.7 for ; Wed, 17 Aug 2022 09:57:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc; bh=BxNAR+uUWZbpzMnoZ6xLNT20e9pYEmaXKXCcI9Q/EoM=; b=OvdQe09oW8ZLRSDrSRK1/5ENMDWUmiPXIBtNeLitIXG1Kbo6KKzRs2TyhzIBGbRmIQ 4Rzsqa9Z0lJ/XpJr7er9AiCQnuGTkwUZjAMQabOauEQgN3SZr5waY5Sz/tJ2HSGJ1ol5 546uiJAvhYEBmqQiDlmGvizNVJo8ggddhh1t193EZLxkd7vuS4HzF0HDasB6FIhT6vwV 7ugmDNT7R6heDZWsAQgYp3yVpXfrZw7/QdSEqS8a1P2CTOQaifq/AXfmNAEnqCvkBeg1 VpYkLJCsKjjfjncNdW/VFOj2mprJzJWoB5qY5gIzI2+a/h32aPFA0UgqIyZpMda6pfeV OXqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc; bh=BxNAR+uUWZbpzMnoZ6xLNT20e9pYEmaXKXCcI9Q/EoM=; b=EyZMuIFyW6rQt37fKGxN7P4EPmubsLiVtNO8YNIMA9oRAEbILDBm7By95wB8rrE3NY YvcpwBNabFFERluujEJnKBmXNWFtoKnqSLYX6KwK4HKN2LTVA+3J5HuT6CGXxK3UnTZW 2TUjmUsLAvCiWpeGQvH1DeKF5reiW5oyCx3VAGayigE7DzRfAE/C2piPyL8+5/jwvxLU lTLfRzoTsZUlBJQ3jsjCjJGkrpqWyvGMgFLpJY9kmwb9TuO/q91NzDb+clrF9FmJVmB5 kV/7Uu3P9CXUaAPSNJpcgMJbl2Uds6NS9OzeiMl06zFXlIiTBuTspsFAXblzeiBGq8+Z N3xg== X-Gm-Message-State: ACgBeo3KW3WzXwc5AStCVGFjPd7pKBvzh2R277jYI1sNbj90axc6w7xQ NRF6ypTa7VYbBA6TBOk274SHDg== X-Received: by 2002:adf:ea91:0:b0:225:2106:f765 with SMTP id s17-20020adfea91000000b002252106f765mr3148651wrm.159.1660755453307; Wed, 17 Aug 2022 09:57:33 -0700 (PDT) Received: from localhost ([109.180.234.208]) by smtp.gmail.com with ESMTPSA id m17-20020a05600c3b1100b003a319b67f64sm9533681wms.0.2022.08.17.09.57.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 09:57:31 -0700 (PDT) From: Punit Agrawal To: Alexei Starovoitov Cc: Punit Agrawal , Alexei Starovoitov , bpf , LKML , Feng Zhou , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Jiri Olsa Subject: Re: Re: [PATCH] bpf: Simplify code by using for_each_cpu_wrap() References: <20220817130807.68279-1-punit.agrawal@bytedance.com> Date: Wed, 17 Aug 2022 17:57:29 +0100 In-Reply-To: (Alexei Starovoitov's message of "Wed, 17 Aug 2022 09:41:14 -0700") Message-ID: <87o7wierk6.fsf_-_@stealth> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 Hi Alexei, Alexei Starovoitov writes: > On Wed, Aug 17, 2022 at 6:08 AM Punit Agrawal > wrote: >> >> No functional change intended. > > ? > >> - orig_cpu = cpu = raw_smp_processor_id(); >> - while (1) { >> + for_each_cpu_wrap(cpu, cpu_possible_mask, raw_smp_processor_id()) { >> struct pcpu_freelist_head *head; >> >> head = per_cpu_ptr(s->freelist, cpu); >> @@ -68,15 +67,10 @@ static inline void ___pcpu_freelist_push_nmi(struct pcpu_freelist *s, >> raw_spin_unlock(&head->lock); >> return; >> } >> - cpu = cpumask_next(cpu, cpu_possible_mask); >> - if (cpu >= nr_cpu_ids) >> - cpu = 0; >> - >> - /* cannot lock any per cpu lock, try extralist */ >> - if (cpu == orig_cpu && >> - pcpu_freelist_try_push_extra(s, node)) >> - return; >> } >> + >> + /* cannot lock any per cpu lock, try extralist */ >> + pcpu_freelist_try_push_extra(s, node); > > This is obviously not equivalent! Thanks for taking a look. You're right - I missed the fact that it's an infinite loop until the node gets pushed to one of the lists. I'll send an update with that fixed up.