From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3103C43381 for ; Fri, 1 Mar 2019 17:43:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6DE2F20848 for ; Fri, 1 Mar 2019 17:43:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="NeIwbMAU"; dkim=pass (1024-bit key) header.d=fb.onmicrosoft.com header.i=@fb.onmicrosoft.com header.b="gbpArMm3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388825AbfCARnq (ORCPT ); Fri, 1 Mar 2019 12:43:46 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:43194 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727418AbfCARnq (ORCPT ); Fri, 1 Mar 2019 12:43:46 -0500 Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x21HcWDN026046 for ; Fri, 1 Mar 2019 09:43:45 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=facebook; bh=4lbG1JNgnCXRFfe1WpU2GqQrHZmZMddBZvHVum8dPXk=; b=NeIwbMAUMabJDv/Fhl4HuXt1kz9Yw1D+J3DosmSCORGX7mwXlg4pw+wQo7moxus5KTTl qqCjer3A7adX0cM2kK0pmIkuZ8g+JnsawACXYq3fCJ3Cb+Snzq0sQxWVt+dKThXCHpUL MJALmg5XpS46NyyYvD90H2p5czeBEMCvaRE= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 2qy9af80ke-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 01 Mar 2019 09:43:45 -0800 Received: from frc-mbx08.TheFacebook.com (192.168.155.29) by frc-hub03.TheFacebook.com (192.168.177.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1713.5; Fri, 1 Mar 2019 09:43:44 -0800 Received: from frc-hub06.TheFacebook.com (192.168.177.76) by frc-mbx08.TheFacebook.com (192.168.155.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1713.5; Fri, 1 Mar 2019 09:43:44 -0800 Received: from NAM01-BY2-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1713.5 via Frontend Transport; Fri, 1 Mar 2019 09:43:43 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4lbG1JNgnCXRFfe1WpU2GqQrHZmZMddBZvHVum8dPXk=; b=gbpArMm3Gt8s/ZwNUp0DdMM30MEFKDlCrmudif2KG/xOZOOuOo1DYDmK79XM/2H96cmWUXuIpZjTQY78Xf29dOIoTj2sev2oaGaEWF0W5f5fmG8vCG3pR9YquMANHCmLzBXHgylwPZIclKrLUYsmgMLaIER8T0I83v6h3acZMdA= Received: from MN2PR15MB2656.namprd15.prod.outlook.com (20.179.146.26) by MN2PR15MB2942.namprd15.prod.outlook.com (20.178.251.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.21; Fri, 1 Mar 2019 17:43:42 +0000 Received: from MN2PR15MB2656.namprd15.prod.outlook.com ([fe80::bcca:6d5a:ead7:9321]) by MN2PR15MB2656.namprd15.prod.outlook.com ([fe80::bcca:6d5a:ead7:9321%5]) with mapi id 15.20.1643.022; Fri, 1 Mar 2019 17:43:42 +0000 From: Javier Honduvilla Coto To: Martin Lau CC: "netdev@vger.kernel.org" , Yonghong Song , Kernel Team Subject: Re: [PATCH bpf-next 1/3] bpf: add bpf_progenyof helper Thread-Topic: [PATCH bpf-next 1/3] bpf: add bpf_progenyof helper Thread-Index: AQHUziPfqF8M0tD5ZkW/n/TDI83+WKXzLoOAgAPhy4A= Date: Fri, 1 Mar 2019 17:43:42 +0000 Message-ID: <20190301174335.GB99700@fb.com> References: <20190226223651.3166820-1-javierhonduco@fb.com> <20190226223651.3166820-2-javierhonduco@fb.com> <20190227062639.jpzwmm63iygad5f7@kafai-mbp.dhcp.thefacebook.com> In-Reply-To: <20190227062639.jpzwmm63iygad5f7@kafai-mbp.dhcp.thefacebook.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MRXP264CA0034.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:14::22) To MN2PR15MB2656.namprd15.prod.outlook.com (2603:10b6:208:128::26) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [2620:10d:c092:200::1:de4a] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f3a0003d-6221-4ccd-747d-08d69e6d7200 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020);SRVR:MN2PR15MB2942; x-ms-traffictypediagnostic: MN2PR15MB2942: x-microsoft-exchange-diagnostics: 1;MN2PR15MB2942;20:+wuj1ewnJV1jb7YDoGKdqMI1CFf1hgxJD3m844G4yhnKdsekZMhm1VBV0ZaUkwWbuZfehaNLFD5gk6FGVnzPjd9utCfFlbL1V6ohlfryAPg9IckQJ7ofl4V6IME4OeB6RMqVKXLt88BCP8/ea5dm5IehonyPS1aNtWYzACEa7LU= x-microsoft-antispam-prvs: x-forefront-prvs: 09634B1196 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(136003)(396003)(39860400002)(376002)(366004)(189003)(199004)(476003)(11346002)(446003)(53936002)(36756003)(2906002)(68736007)(6116002)(54906003)(37006003)(2616005)(25786009)(1076003)(7736002)(8676002)(14454004)(99286004)(6862004)(81156014)(33656002)(4326008)(305945005)(81166006)(6512007)(229853002)(76176011)(256004)(106356001)(486006)(386003)(8936002)(5660300002)(478600001)(6486002)(14444005)(97736004)(86362001)(6436002)(102836004)(71200400001)(186003)(6246003)(71190400001)(6506007)(46003)(6636002)(105586002)(316002)(5024004)(52116002);DIR:OUT;SFP:1102;SCL:1;SRVR:MN2PR15MB2942;H:MN2PR15MB2656.namprd15.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: fb.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: GjjweV82gjggN8TipNYiIgcR0W2ihcOphUDU6Pt5v7SVJTdoh7WG8UtO96TE9Kwt4XaLumGa3YLrftHPoPGPhyLoORrn5w9u/65VSRbbVvoo81KGFRpv5EYR4wEYok3N3HLa9QMqPODMBch1J0NUvq+5/zx0DmfsUg5j5U16wP7pCjVjqNpd0xkqtwtKd+dEf5DXnKCsjtNTBnbBRtgZKPRnUfc18Qn+wBw18OLwTkUl4QTcygYLwa5dEgczIZ8RRhNGQyWKptBi3iR3yJPTl1g/S70cIytW6qylOftnCTjrXB6+1ptzS1TB/7SL3DBKn9jEWqrb5BPXntdy+hbVcRf9Jv867bBXBM6Fj2gP1JVYOyXCtbUlu4hQsl2zNUxYo4Wk7OoYD1//33K0CGf1PSYD1CL9M20JOggctWHSUWw= Content-Type: text/plain; charset="us-ascii" Content-ID: <6458804350A5AB46A52468BF9E892FA6@namprd15.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: f3a0003d-6221-4ccd-747d-08d69e6d7200 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Mar 2019 17:43:41.3174 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR15MB2942 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-01_12:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, Feb 27, 2019 at 06:26:41AM +0000, Martin Lau wrote: Sorry, accidentally did not reply to all your comments: > On Tue, Feb 26, 2019 at 02:36:49PM -0800, Javier Honduvilla Coto wrote: > > This patch adds the bpf_progenyof helper which receives a PID and retur= ns > What is progenof? progenyof is a helper we'd love to have in thr kernel as right now checking if the current process pid is among the progeny of some arbitrary pid has several disadvantages. There are more details in the first commit message > > > 1 if the process currently being executed is in the process hierarchy > > including itself or 0 if not. > > > > This is very useful in tracing programs when we want to filter by a > > given PID and all the children it might spawn. The current workarounds > > most people implement for this purpose have issues: > > > > - Attaching to process spawning syscalls and dynamically add those PIDs > > to some bpf map that would be used to filter is cumbersome and > > potentially racy. > > - Unrolling some loop to perform what this helper is doing consumes lot= s > > of instructions. That and the impossibility to jump backwards makes i= t > > really hard to be correct in really large process chains. > > > > Signed-off-by: Javier Honduvilla Coto > > --- > > include/linux/bpf.h | 1 + > > include/uapi/linux/bpf.h | 3 ++- > > kernel/bpf/core.c | 1 + > > kernel/bpf/helpers.c | 29 +++++++++++++++++++++++++++++ > > kernel/trace/bpf_trace.c | 2 ++ > > 5 files changed, 35 insertions(+), 1 deletion(-) > > > > diff --git a/include/linux/bpf.h b/include/linux/bpf.h > > index de18227b3d95..447395ba202b 100644 > > --- a/include/linux/bpf.h > > +++ b/include/linux/bpf.h > > @@ -921,6 +921,7 @@ extern const struct bpf_func_proto bpf_sk_redirect_= map_proto; > > extern const struct bpf_func_proto bpf_spin_lock_proto; > > extern const struct bpf_func_proto bpf_spin_unlock_proto; > > extern const struct bpf_func_proto bpf_get_local_storage_proto; > > +extern const struct bpf_func_proto bpf_progenyof_proto; > It seems only used in bpf_trace.c. Does it have to be here? Yes, we need it in bpf_trace.c where we are requiring it