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=-3.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=no 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 9D131FA372C for ; Fri, 8 Nov 2019 04:20:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 729642178F for ; Fri, 8 Nov 2019 04:20:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="mr7BVoIK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728889AbfKHEUr (ORCPT ); Thu, 7 Nov 2019 23:20:47 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:13998 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726618AbfKHEUr (ORCPT ); Thu, 7 Nov 2019 23:20:47 -0500 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 xA84KL7w030798 for ; Thu, 7 Nov 2019 20:20:46 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=facebook; bh=3wXOvqwWqtSRCarD3S0whkHi9qTivXaF8erfbqGKlRk=; b=mr7BVoIKSrYa7njdYGNAGFRv5MscFm7TuhoHA/7s+w7+gbX0PLIHICzymy0DjAY1nMYo Ona4xTnWQUR3FB8zbDVHkgBU2NuqdH5GCY10h6ng2CfrGX6EXcsZV5g98ClfPSWsgabe w/h5WdPykJMOl0KB+SXo79xP7qyq7H9Btvc= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 2w41ujh61k-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 07 Nov 2019 20:20:45 -0800 Received: from 2401:db00:2050:5076:face:0:9:0 (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 7 Nov 2019 20:20:44 -0800 Received: by devbig012.ftw2.facebook.com (Postfix, from userid 137359) id B937A2EC19DF; Thu, 7 Nov 2019 20:20:43 -0800 (PST) Smtp-Origin-Hostprefix: devbig From: Andrii Nakryiko Smtp-Origin-Hostname: devbig012.ftw2.facebook.com To: , , , CC: , , Andrii Nakryiko Smtp-Origin-Cluster: ftw2c04 Subject: [PATCH bpf-next 0/3] Add support for memory-mapping BPF array maps Date: Thu, 7 Nov 2019 20:20:38 -0800 Message-ID: <20191108042041.1549144-1-andriin@fb.com> X-Mailer: git-send-email 2.17.1 X-FB-Internal: Safe MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-07_07:2019-11-07,2019-11-07 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 bulkscore=0 clxscore=1015 suspectscore=8 priorityscore=1501 spamscore=0 mlxlogscore=502 lowpriorityscore=0 phishscore=0 malwarescore=0 mlxscore=0 adultscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911080041 X-FB-Internal: deliver Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch set adds ability to memory-map BPF array maps (single- and multi-element). The primary use case is memory-mapping BPF array maps, created to back global data variables, created by libbpf implicitly. This allows for much better usability, along with avoiding syscalls to read or update data completely. Due to memory-mapping requirements, BPF array map that is supposed to be memory-mapped, has to be created with special BPF_F_MMAPABLE attribute, which triggers slightly different memory allocation strategy internally. See patch 1 for details. Libbpf is extended to detect kernel support for this flag, and if supported, will specify it for all global data maps automatically. Andrii Nakryiko (3): bpf: add mmap() support for BPF_MAP_TYPE_ARRAY libbpf: make global data internal arrays mmap()-able, if possible selftests/bpf: add BPF_TYPE_MAP_ARRAY mmap() tests include/linux/bpf.h | 8 +- include/uapi/linux/bpf.h | 3 + kernel/bpf/arraymap.c | 96 ++++++++++- kernel/bpf/syscall.c | 39 +++++ tools/include/uapi/linux/bpf.h | 3 + tools/lib/bpf/libbpf.c | 31 +++- .../selftests/bpf/prog_tests/core_reloc.c | 45 +++-- tools/testing/selftests/bpf/prog_tests/mmap.c | 154 ++++++++++++++++++ tools/testing/selftests/bpf/progs/test_mmap.c | 31 ++++ 9 files changed, 380 insertions(+), 30 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/mmap.c create mode 100644 tools/testing/selftests/bpf/progs/test_mmap.c -- 2.17.1