Message ID | 20221122145300.251210-1-void@manifault.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2253722wrr; Tue, 22 Nov 2022 06:58:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf6HPFzextweGacGRR9OgYvuo8KJIwuA1Q/STWB9MdSIeyRYNnFHL5khfRkHovbrDwl2kDTh X-Received: by 2002:a63:5a10:0:b0:476:c39b:bd67 with SMTP id o16-20020a635a10000000b00476c39bbd67mr9893387pgb.46.1669129122752; Tue, 22 Nov 2022 06:58:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669129122; cv=none; d=google.com; s=arc-20160816; b=ZrjZZvm7CL6OmzqMnvxEk9YvR+boY/wGw+jZF9e03fnpqb/d5am7gVZGavTc7R667f 3FmpcIsKJAKLLwm5K+3k5sa2s/P9J4/BXZ1zan+KtUzEPguKbT9nmYlK7JqDIDCoLrPS aNc2U9/05WQWFMPju3TsXiEgd3UitMjGQQX1jPEwv99y3gAuJqQQhtXwuVr542CxuHLc HpUY/EZ7xwWOew5dB3FHx2WG1Xv80bJKn0kHQXVyAZNy+CrX6PMKAqwOu1Zxhwk+8Y2n ngG7ZVhmB+L6IANPT8hTJ2l96qk3Wbjb0IpFmVBfQ4nsOsGnf/ZbWa2W3OvdTFaUMbqI QVaQ== 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; bh=A3hb6DfOCI3nB34nDd97tw95U/oUgwjCRt/XOk9zLe8=; b=paCsSWEvwTsFuwuqxKNOA+Xgdb+dAoQRIVAbJFGFWa6LN5yTBV+jCPZiFIXScWoODC 08nvEMgLdppe+11TWVj+bayESQphlBzB+H3+CEY2W+SP+TylYesc72eGUSQq4F5lSQKM 5rc9oMh13cCaObGpNeqQ7XloNFiRfF63l0vHZF+q/yhV800+R6crZhS+YYlvboTTUK95 nI0+ePnUkBtxlIt9cP8nYjPex6SUjtR1yUpDeHMNGvImkKSc50zYIOdtp1veBtv17okv 1Fw2FASlc0/uWQApPJMBQ7GOF6oEJk1LC8jORJL7PAhlqe2mLNP4anBYvSNTIscAWJ45 8YEQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f35-20020a631023000000b0043a93738a14si13995669pgl.167.2022.11.22.06.58.29; Tue, 22 Nov 2022 06:58:42 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234123AbiKVOyj (ORCPT <rfc822;cjcooper78@gmail.com> + 99 others); Tue, 22 Nov 2022 09:54:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233833AbiKVOxd (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 22 Nov 2022 09:53:33 -0500 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B7B917A91; Tue, 22 Nov 2022 06:53:05 -0800 (PST) Received: by mail-qt1-f172.google.com with SMTP id w4so9432877qts.0; Tue, 22 Nov 2022 06:53:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=A3hb6DfOCI3nB34nDd97tw95U/oUgwjCRt/XOk9zLe8=; b=XNNEg8qlB1GRGQiqDd0kbnBg3zREWCd5+0HE0iyxoU58mseHmO6m4K+M8WjUbOGK12 D1RYL9GXXum7UT1Py5+EyybehfNaHfhcXOxyWme3N/y7uJY1sq16lGF3PyIFV9M4Iofm RvhQrHuZdw7W5Yhk5YMjL0kO74eJ8Wcg3Jlkt+aOuHpj37A4EReXaCjQ69rJm65bYVJL UPaNIU9ewGowO3x4u1V+9be4oKOIFNyrOm407O+HYz6OXmmVDSdzYVWrQl0qc4P48/9x 7ZXRmXuwVdaBH0ha7yiZVRwvH/DEmYdydtAow8g5/bOj0aWH461KWTfXPuyv89cQg79Y Vpmg== X-Gm-Message-State: ANoB5pl7obaps0xIcmoIJM4ovLgltCnoh7auuTFaniKEhq4K8x2EZrs6 0gdskd3+zMYXk3iCidYuAQaftippPqSCNjsw X-Received: by 2002:a05:622a:514a:b0:3a5:2029:df77 with SMTP id ew10-20020a05622a514a00b003a52029df77mr5219566qtb.225.1669128784125; Tue, 22 Nov 2022 06:53:04 -0800 (PST) Received: from localhost ([2620:10d:c091:480::1:3170]) by smtp.gmail.com with ESMTPSA id bl3-20020a05620a1a8300b006fae7e6204bsm10482804qkb.108.2022.11.22.06.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 06:53:03 -0800 (PST) From: David Vernet <void@manifault.com> To: bpf@vger.kernel.org Cc: ast@kernel.org, andrii@kernel.org, daniel@iogearbox.net, martin.lau@linux.dev, yhs@fb.com, song@kernel.org, sdf@google.com, john.fastabend@gmail.com, kpsingh@kernel.org, jolsa@kernel.org, haoluo@google.com, tj@kernel.org, kernel-team@fb.com, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next 0/2] Add kfunc for doing pid -> task lookup Date: Tue, 22 Nov 2022 08:52:58 -0600 Message-Id: <20221122145300.251210-1-void@manifault.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750208739029642835?= X-GMAIL-MSGID: =?utf-8?q?1750208739029642835?= |
Series |
Add kfunc for doing pid -> task lookup
|
|
Message
David Vernet
Nov. 22, 2022, 2:52 p.m. UTC
A series of prior patches added support for storing struct task_struct * objects as kptrs. This patch set proposes extending this with another kfunc called bpf_task_from_pid() which performs a lookup of a task from its pid, from the root pid namespace idr. This allows BPF programs that don't have a kptr to a task, to instead perform a lookup by pid. This will be useful for programs that are tracking pids and want, e.g., to do a lookup to find task->comm. David Vernet (2): bpf: Add bpf_task_from_pid() kfunc selftests/bpf: Add selftests for bpf_task_from_pid() kernel/bpf/helpers.c | 20 +++++ .../selftests/bpf/prog_tests/task_kfunc.c | 3 + .../selftests/bpf/progs/task_kfunc_common.h | 1 + .../selftests/bpf/progs/task_kfunc_success.c | 73 +++++++++++++++++++ 4 files changed, 97 insertions(+)
Comments
Hello: This series was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <ast@kernel.org>: On Tue, 22 Nov 2022 08:52:58 -0600 you wrote: > A series of prior patches added support for storing struct task_struct * > objects as kptrs. This patch set proposes extending this with another > kfunc called bpf_task_from_pid() which performs a lookup of a task from > its pid, from the root pid namespace idr. > > This allows BPF programs that don't have a kptr to a task, to instead > perform a lookup by pid. This will be useful for programs that are > tracking pids and want, e.g., to do a lookup to find task->comm. > > [...] Here is the summary with links: - [bpf-next,1/2] bpf: Add bpf_task_from_pid() kfunc https://git.kernel.org/bpf/bpf-next/c/3f0e6f2b41d3 - [bpf-next,2/2] selftests/bpf: Add selftests for bpf_task_from_pid() https://git.kernel.org/bpf/bpf-next/c/f471748b7fe5 You are awesome, thank you!