Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp658585pxa; Sat, 1 Aug 2020 01:52:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJAliT/VfyvmXtTHaLMzcjj+m551Ua7vZotYRyh61uyA3UEKRRZ9p6AyjeuhQPkoZzLdQQ X-Received: by 2002:aa7:c54e:: with SMTP id s14mr7436669edr.81.1596271974759; Sat, 01 Aug 2020 01:52:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596271974; cv=none; d=google.com; s=arc-20160816; b=gOt24Up7JD6cJvovKVxYYOyboDay0cBPBqEFj7pDARG42dgXKg6+299BWOTKjXPsyD 305pP0k7czfQ2Kf863iIZjrhHC0JRB0Wx7WlmxQg2ORAK+ZxZIiE67xdC20KgiWrOscA S+S9M3ROOTkUtjO9WuStSaq2b7AjiLfXJ+BD63f5py408AbzlgHT/5pQzlz5vbQFE1EK YPBw2SpITaLsepuPVUBZDuwk7bqJe06oYstWG2Ug8KkjL5tHjyP1TUyU30ePuyCZ62pF p4mol7pjf5ZTqxBpbPBQ+S6+tasA5xT3FKpi2GlXXGn8vJ9EvqxD1RxIWuc2hp1cGnov aarQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:smtp-origin-cluster :cc:to:smtp-origin-hostname:from:smtp-origin-hostprefix :dkim-signature; bh=NKQqwLFy8/q+xi0MOf7ccTYyH52VimvbRfy6sPrQxH0=; b=cTY3NhzvWgKwKeoL/42sjU3Y2DMFOXLlXXS6XOYsJ9u5uXbRVvIac4s4o/NkYxvxIa NVjFDZgvlqjD1Ztcn9MuLJ8x76XD8ckK5up4ZrX2d8OhRvdtZpfQFklo0YrxXcV3wC5C 1ECi/XASeM8oL6J269x6+Seds2i4Ew6Q1rOpD9JVlqoRsi9OiUCGsTNA5DtltIGbcABW H2mzY2XwK8/GRuh7be2LCveMQHD1yo0uuNxldJdM57dJIO7p+WPAOS6QtRbYES3jTfrb 0iS5lqCHqgQthygs9ZR7lc2qlclRhnzJ76RtAJcLQr8JCTYVRlJi4t1xhsw1wupcPuIl 1/UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=miRPqVAt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j8si5605837edh.122.2020.08.01.01.52.32; Sat, 01 Aug 2020 01:52:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=miRPqVAt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728674AbgHAIuA (ORCPT + 99 others); Sat, 1 Aug 2020 04:50:00 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:36650 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728490AbgHAIty (ORCPT ); Sat, 1 Aug 2020 04:49:54 -0400 Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0718fnn1023960 for ; Sat, 1 Aug 2020 01:49:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=NKQqwLFy8/q+xi0MOf7ccTYyH52VimvbRfy6sPrQxH0=; b=miRPqVAtOfsMZ4nFysxkGPoxisbN8mrDb4YFYJJ0/5IeMPPUhymb72Myis3STPwEwyjd Qd14JngWOW/TqnSV4TdssAP1OgMqpKSp+YIwfuQNTMWNraVog/1vPQEilv+nUb0vUrcy VvjfeaPQcMpp0sf2k7eWmNLuwrX9DZkMtvI= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 32n3qd07sv-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Sat, 01 Aug 2020 01:49:53 -0700 Received: from intmgw004.03.ash8.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::c) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Sat, 1 Aug 2020 01:49:49 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id 7AAC362E53C9; Sat, 1 Aug 2020 01:47:27 -0700 (PDT) Smtp-Origin-Hostprefix: devbig From: Song Liu Smtp-Origin-Hostname: devbig006.ftw2.facebook.com To: , , CC: , , , , , , , Song Liu Smtp-Origin-Cluster: ftw2c04 Subject: [PATCH bpf-next 2/5] libbpf: support BPF_PROG_TYPE_USER programs Date: Sat, 1 Aug 2020 01:47:18 -0700 Message-ID: <20200801084721.1812607-3-songliubraving@fb.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200801084721.1812607-1-songliubraving@fb.com> References: <20200801084721.1812607-1-songliubraving@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-08-01_07:2020-07-31,2020-08-01 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 malwarescore=0 adultscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008010067 X-FB-Internal: deliver Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add cpu_plus to bpf_prog_test_run_attr. Add BPF_PROG_SEC "user" for BPF_PROG_TYPE_USER programs. Signed-off-by: Song Liu --- tools/lib/bpf/bpf.c | 1 + tools/lib/bpf/bpf.h | 3 +++ tools/lib/bpf/libbpf.c | 1 + tools/lib/bpf/libbpf_probes.c | 1 + 4 files changed, 6 insertions(+) diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index e1bdf214f75fe..b28c3daa9c270 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c @@ -693,6 +693,7 @@ int bpf_prog_test_run_xattr(struct bpf_prog_test_run_= attr *test_attr) attr.test.ctx_size_in =3D test_attr->ctx_size_in; attr.test.ctx_size_out =3D test_attr->ctx_size_out; attr.test.repeat =3D test_attr->repeat; + attr.test.cpu_plus =3D test_attr->cpu_plus; =20 ret =3D sys_bpf(BPF_PROG_TEST_RUN, &attr, sizeof(attr)); test_attr->data_size_out =3D attr.test.data_size_out; diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h index 6d367e01d05e9..0c799740df566 100644 --- a/tools/lib/bpf/bpf.h +++ b/tools/lib/bpf/bpf.h @@ -205,6 +205,9 @@ struct bpf_prog_test_run_attr { void *ctx_out; /* optional */ __u32 ctx_size_out; /* in: max length of ctx_out * out: length of cxt_out */ + __u32 cpu_plus; /* specify which cpu to run the test with + * cpu_plus =3D cpu_id + 1. + * If cpu_plus =3D 0, run on current cpu */ }; =20 LIBBPF_API int bpf_prog_test_run_xattr(struct bpf_prog_test_run_attr *te= st_attr); diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index b9f11f854985b..9ce175a486214 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -6922,6 +6922,7 @@ static const struct bpf_sec_def section_defs[] =3D = { BPF_PROG_SEC("lwt_out", BPF_PROG_TYPE_LWT_OUT), BPF_PROG_SEC("lwt_xmit", BPF_PROG_TYPE_LWT_XMIT), BPF_PROG_SEC("lwt_seg6local", BPF_PROG_TYPE_LWT_SEG6LOCAL), + BPF_PROG_SEC("user", BPF_PROG_TYPE_USER), BPF_APROG_SEC("cgroup_skb/ingress", BPF_PROG_TYPE_CGROUP_SKB, BPF_CGROUP_INET_INGRESS), BPF_APROG_SEC("cgroup_skb/egress", BPF_PROG_TYPE_CGROUP_SKB, diff --git a/tools/lib/bpf/libbpf_probes.c b/tools/lib/bpf/libbpf_probes.= c index 5a3d3f0784081..163013084000e 100644 --- a/tools/lib/bpf/libbpf_probes.c +++ b/tools/lib/bpf/libbpf_probes.c @@ -112,6 +112,7 @@ probe_load(enum bpf_prog_type prog_type, const struct= bpf_insn *insns, case BPF_PROG_TYPE_STRUCT_OPS: case BPF_PROG_TYPE_EXT: case BPF_PROG_TYPE_LSM: + case BPF_PROG_TYPE_USER: default: break; } --=20 2.24.1