Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5027629rwb; Wed, 17 Aug 2022 09:46:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Pm19wBsoVkGsVj7/wfPv0zlwWWff+RC48D3D20zb7D8IfPBZsjICVR/qg8VQ+6NNuktlt X-Received: by 2002:a17:907:2ceb:b0:730:e0ce:34f1 with SMTP id hz11-20020a1709072ceb00b00730e0ce34f1mr1535092ejc.293.1660754814655; Wed, 17 Aug 2022 09:46:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660754814; cv=none; d=google.com; s=arc-20160816; b=HTtCgAPlour7AYdPXpRgVN7dUgyn8det3PrvDCA57UR2Z2tVRUkf0blT4YpscIkOEn kGGEgwxvztk4j5l0czQ9d3v/l35dKj+hw0iAdrpQbNOOND/OPrmATzmVQA52j00fnsCd ijXiRhJakslim1G/kq3PkW5HP0vflEF1K7LoJCUlEmVWmwhv4kv+rt2AWguwfmC1kGdX n8gB23kKMBHiQ3EcMkV4v7zpfnPryD4uTmv1ihQQ5tWNYtt4heyFzfat1EWwXTVaDoni jeyhdWHPjCEub5hU0BLU7SBSjlNcQolM8sbQ0Jf25F0IN11rvmRWmHRnQudXpNcKz/HL gNMQ== 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=rNsoClh34rx/3eWm5W2OOBZPW56iIjZI3iAQYDBsTWs=; b=NNBvTPV1bIvEzdzj/hA8nYIGAWBiOBiewHeQMbQ3f2lEKKkOii9xpychmONxuqYDAX 9RlcXG8/CXswLeio4YQk9wQ6YqoK37bJGlebh7EA0HIbRtXEKcOlsa4AJYfIuc6nPS0+ YP12ub7FgQIyyi+36hFK2y4NFcNO3vdEjQZwEaej3WcGaYajLyKiq/BoDBeeaNRMGAAu tZ0fIjfjScbKdh0yQmpbHPSsxR/xDDk76KcN5okYuoA2t8YCnTgx+jBgOIZ0BPYzez1S CIIpsxbeB8Ar26pJKMaTK+L/R16a9SE1F7H66yVUHEd/JO/7G1kWIygCjWuHjTd76IXH 8QYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Fg3kShD9; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l11-20020a170906794b00b00730f07ead67si14401947ejo.929.2022.08.17.09.46.29; Wed, 17 Aug 2022 09:46: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=@gmail.com header.s=20210112 header.b=Fg3kShD9; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240170AbiHQQld (ORCPT + 99 others); Wed, 17 Aug 2022 12:41:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237637AbiHQQl3 (ORCPT ); Wed, 17 Aug 2022 12:41:29 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56AF27CB74; Wed, 17 Aug 2022 09:41:27 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id w19so25531284ejc.7; Wed, 17 Aug 2022 09:41:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=rNsoClh34rx/3eWm5W2OOBZPW56iIjZI3iAQYDBsTWs=; b=Fg3kShD9pR4kNxNRr0RRAEzvtaGoROTzXzWXbRQ/N91CLXomIxAXPrtyY9wuzmGqxt PpAYP747oAMly9tDUBssvT0/SzL0sMfmiyUdREi922bQ+79YLQQh1pD6d84hz+NVO508 9eI6xz4JeRRTVVy2vTIOHEVSTX1twHcchbMm7OD4WsfQwMDDi2fNvWJoVX7QnbvLpdqi K+ITvj0cIT6GIVMiK0Kn4nQarHEVisyChJxGc+GMvVWIpSF43p42fqPGKNKq/RrzjFF1 IWhRFrx/jpg6YSPFWsM7+q7EJDZoAGFAa+Or96qn+6wzCA1l1AM5xc21ELT8S9RRMv6K xzKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=rNsoClh34rx/3eWm5W2OOBZPW56iIjZI3iAQYDBsTWs=; b=b2IuYNFZEhGoB8/fNjckgCq+tF45fSQg76Al8QWK3ScQTmuXNMjkT7R/3LSV96okcA WjhUaJ83p2lYS8XxpWwTYpvOrC3Wi74nEHmpleZlFSsuNghzHZ8DT+QSbxeEW2+IBofX gafVrkwo2j4UcrIDYA5IMvfpeUdzsXECcW0Qi8qYG6Cn5IP6L6FtCpJUIKNRcJ8ROzn+ PnUNgLvKTOEymcwBiWpLkWEGxcS/LeXyX3ASTbIL61Mw13XLwYuhr1ejZevq9ZcwVOto B/FQG+tvar9V+SGuR33X/BHCLPNLNhMZseLVuTm6qFv3SBna3CMbxsQ/bhIK6mH6dVf3 TNpg== X-Gm-Message-State: ACgBeo2liMBzcOneKNdw+K3nyH5AIDr+NYJ6vPGhiSqr5dWTPgGNKckj yS/UhH2tpt4t5clnpmA6LnatmFxWxQHFP1+y3fvka7W9 X-Received: by 2002:a17:907:e8d:b0:730:a4e8:27ed with SMTP id ho13-20020a1709070e8d00b00730a4e827edmr16635182ejc.58.1660754485835; Wed, 17 Aug 2022 09:41:25 -0700 (PDT) MIME-Version: 1.0 References: <20220817130807.68279-1-punit.agrawal@bytedance.com> In-Reply-To: <20220817130807.68279-1-punit.agrawal@bytedance.com> From: Alexei Starovoitov Date: Wed, 17 Aug 2022 09:41:14 -0700 Message-ID: Subject: Re: [PATCH] bpf: Simplify code by using for_each_cpu_wrap() To: Punit Agrawal Cc: Alexei Starovoitov , bpf , LKML , Feng Zhou , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Jiri Olsa Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, 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 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!