Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6700800iob; Wed, 11 May 2022 03:33:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFYH0Nwb2977uBw6yfxX5mY6ldppyM2Z/pDiFkRY/pGqNm+ZonXnsGQDDbTDUN9GfV4BRT X-Received: by 2002:a17:90b:4ac1:b0:1dc:20c4:6363 with SMTP id mh1-20020a17090b4ac100b001dc20c46363mr4652642pjb.79.1652265184064; Wed, 11 May 2022 03:33:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652265184; cv=none; d=google.com; s=arc-20160816; b=Xx20xMWuPZc3XzfGaqXJzvgYfE3b0H8arEg0DUBKjrc+lCCbc7yqRHBBYgnKBYS76u aMFrxMxeIT1meeFreNcX9FvcTPT6LQ6jv5KVE9N0HECGKT8UUvXO69OWjBMid2HUtj7q fTXE5D4JMVpo8mNLSuUmTrodaSKRBL83fGXwDkkawiS5zxIHzJwpnAncthCu7XGaAjtE x7ZB40VXx78qDIJoUyssHQEH46L1dm4/Lh2RF/X/FRfJtYx9/WCp0fJRfVTp8Os/nydt VImBWkJaPS3idVs0mfBSuwHyEzvnwlIGzjvz7MChFYI5eQTKc8v/yNCow6KACZqJUQuV vpXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Q9QdO95hB/1a07szG5DQddpKrWRTLifgbJv4wAyhbh8=; b=or/duFD7HQnSZaFQxn8YdlQjoiA8dHe6+7kfmltaRGwSdjh2MdLB8fI4UIZu6iKpKj LVoJkyVIfOQUCUmAsyzn6CuoazmDy8c3A92iJlW9wRgnf7onwzfgcQJhYA16ucg54NWF BT3GRjSCVM8TRL2RQ437jD1j1OYjCHVHgLFh8L35G5J86VJQXA2iZE5FBxphqXS6PQBR M3CfdbAqCCu6zhT8t25G9r4t5pwZgd+X64Odl4C+FJHhGnPyBYyq/fUqXFgLOFXKh3fx wYKmW7W4HBeaZCSEejPSlo17LV95gglhn5kT9N6JvtIB0h4qSqZ2EjDvbQlGQ1eLrx7H 2s6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=pMf9S1yX; 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 s7-20020a170902ea0700b001589d3cab77si2438740plg.388.2022.05.11.03.32.50; Wed, 11 May 2022 03:33:04 -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=pMf9S1yX; 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 S239418AbiEKJjs (ORCPT + 99 others); Wed, 11 May 2022 05:39:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233551AbiEKJjS (ORCPT ); Wed, 11 May 2022 05:39:18 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFB255400E for ; Wed, 11 May 2022 02:39:14 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id x88so1737700pjj.1 for ; Wed, 11 May 2022 02:39:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Q9QdO95hB/1a07szG5DQddpKrWRTLifgbJv4wAyhbh8=; b=pMf9S1yXYeBoeprJoZzPWwFGJl0HKc3tOJr6+RpuubLn7bv3HAf39sm6vrkj0d1Dhs QTNj3odRa1DyTvvq0E8atDB4dbMBjYI0M4rIwnjiZUcOWxft1uFDlXyPFC9TSc1LooZM jN+VbwtqCcxBe0mJ0htdB6T7GBryn8JORIWMNn63XUSPSSB7Mrh9WR5JdLLMlLbbycC0 /Q5zAZcZhlSLdK/sgoK7dZuqyb1+G/Np7Fpk0fyx/hkF+SdqPV4JGWwkxKOYuO+s3AQN Rbv/ocVNxVpnE8J9JdYYd2jaV6O22ZZbzazz1o9xfdXhWwUDEE7ARaDHgLPFXcMuDxE5 mqiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Q9QdO95hB/1a07szG5DQddpKrWRTLifgbJv4wAyhbh8=; b=yUwQsBcKf9efYR6K5t0iiinxzQUEAh5n93BiLb0bSksoC3wlhdLBsL4291emDvoHMm ZbuqoH0GEMoyzZqBRCAL+pExqKLZW+u5ou5v59144l000nvSITH2MB39sE2sBJICT2YV z10xAoLjERsbFowdxroXTJXGsp5iF+kaXHDXyVL++h+5+FXGEE/Fh3uCelWOlAcKyT1C 5g4hKmZwl50/6tnWgHEbYG1tHT7y1EDH9nau+pKHvSYfhXrylhFaXziYigYk9CLR9m4z Y8fiJ7/Enh7fiEBDwbx9l7DHtvWIqhO6meueQQYUTL6Vr4cIFEgpi9sVBlmushBa4x4V X8MA== X-Gm-Message-State: AOAM5313BtUgbAr8HUx9679fmo+Q0KmH6B8WeiWCvKV4shh3fvcMWZo5 18SYbFXdvYJIEUFAmdQNk1o+cA== X-Received: by 2002:a17:90b:4ad1:b0:1dc:96fa:69aa with SMTP id mh17-20020a17090b4ad100b001dc96fa69aamr4404870pjb.189.1652261954413; Wed, 11 May 2022 02:39:14 -0700 (PDT) Received: from C02F52LSML85.bytedance.net ([139.177.225.241]) by smtp.gmail.com with ESMTPSA id k4-20020aa790c4000000b0050dc76281cdsm1159834pfk.167.2022.05.11.02.39.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 May 2022 02:39:14 -0700 (PDT) From: Feng zhou To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, rostedt@goodmis.org, mingo@redhat.com, jolsa@kernel.org, davemarchevsky@fb.com, joannekoong@fb.com, geliang.tang@suse.com Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, duanxiongchun@bytedance.com, songmuchun@bytedance.com, wangdongdong.6@bytedance.com, cong.wang@bytedance.com, zhouchengming@bytedance.com, zhoufeng.zf@bytedance.com, yosryahmed@google.com Subject: [PATCH bpf-next v2 0/2] Introduce access remote cpu elem support in BPF percpu map Date: Wed, 11 May 2022 17:38:52 +0800 Message-Id: <20220511093854.411-1-zhoufeng.zf@bytedance.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Feng Zhou Trace some functions, such as enqueue_task_fair, need to access the corresponding cpu, not the current cpu, and bpf_map_lookup_elem percpu map cannot do it. So add bpf_map_lookup_percpu_elem to accomplish it for percpu_array_map, percpu_hash_map, lru_percpu_hash_map. v1->v2: Addressed comments from Alexei Starovoitov. - add a selftest for bpf_map_lookup_percpu_elem. Feng Zhou (2): bpf: add bpf_map_lookup_percpu_elem for percpu map selftests/bpf: add test case for bpf_map_lookup_percpu_elem include/linux/bpf.h | 2 + include/uapi/linux/bpf.h | 9 ++++ kernel/bpf/arraymap.c | 15 ++++++ kernel/bpf/core.c | 1 + kernel/bpf/hashtab.c | 32 +++++++++++ kernel/bpf/helpers.c | 18 +++++++ kernel/bpf/verifier.c | 17 +++++- kernel/trace/bpf_trace.c | 2 + tools/include/uapi/linux/bpf.h | 9 ++++ .../bpf/prog_tests/map_lookup_percpu_elem.c | 46 ++++++++++++++++ .../bpf/progs/test_map_lookup_percpu_elem.c | 54 +++++++++++++++++++ 11 files changed, 203 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/map_lookup_percpu_elem.c create mode 100644 tools/testing/selftests/bpf/progs/test_map_lookup_percpu_elem.c -- 2.20.1