From patchwork Sun Apr 3 14:42:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12799618 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 410F1C4332F for ; Sun, 3 Apr 2022 14:43:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358543AbiDCOpF (ORCPT ); Sun, 3 Apr 2022 10:45:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349257AbiDCOpF (ORCPT ); Sun, 3 Apr 2022 10:45:05 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90C1D3388D; Sun, 3 Apr 2022 07:43:11 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id w7so6654405pfu.11; Sun, 03 Apr 2022 07:43:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b08Jd4YgKGr0lzJ8+d7+I0YJDT94b5X1ccud/BP7cUc=; b=Lp43tFnEj5TEr7qsXgZv9MNlKXoP99rH82SOAethLHVB2ZpyVvWS/ivkt9NM66a8/M oOf4Aq1rmKYUVawxSXkMYaSsZMwgAUYioPkuF5dhAxx39GTtOaHFRgKJQLUid7eu0fln A2s6GTX1EGPKW63jwqtsWpphqk/bz6smetY/KvVmnds9IW+BzuTcJ1KnKfpH3lUHsZ9g vXkCib5dYc3ZdTGPSqKlJrsj2CZL21jHHILtLvhkn6+0kCxp7dTzpemWC7A3m7x1FjtR LY/KIABQXLoP1TNeZjG/zRESbeqrSCWUD1pk71PJGYLxoLOrql9DbIws+veoJ8hq+zlo bZTA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=b08Jd4YgKGr0lzJ8+d7+I0YJDT94b5X1ccud/BP7cUc=; b=SGBQrlDsCE7yJRtrjcLiEBAr8XowzQ0u/dAgt+QLpWmvGKclZopuy7JX2zhioPo6FV 4wq4fLb1NCInK5b1LpQIGYAZ9s1xu03n0/AVaJbKxKmwlw8n7t7JSrW5xQptjWmitQOM P8wsG1GkqZXMrsiBUmGo90fZzteAF2mct0+jkNn5syhNpZJTlSXG5pFJRut8LV0cEo6o 6Q1iZua5ois1rOEQPeq0pGpxnPLV6Ts/54AyFQkS2YkBb3B5XvGdFuY8oQlpXZWLnH7p T2lPUOQdvDCg5TN2huScaXeqwpdmn5Ydnf4g+gyPjz+YOwm8kfY07mjQF00RL0hY4nMG uszA== X-Gm-Message-State: AOAM530KJ+LtHY/qjpxQfmac1tiI6Ok4Fo3kxJxQcORx5RkPJ87I+eOG PY+i31c8Fidt+F3dfbE9pas= X-Google-Smtp-Source: ABdhPJxE+S+SYzDeKPX0k3yehx1kwsMWE+iEkRr5fQEPrC56I6sqKdCI615wx+1C0cTwOebGYjWH9Q== X-Received: by 2002:a63:35c3:0:b0:380:6a04:cecc with SMTP id c186-20020a6335c3000000b003806a04ceccmr22638794pga.455.1648996990959; Sun, 03 Apr 2022 07:43:10 -0700 (PDT) Received: from vultr.guest ([2001:19f0:6001:51a7:5400:3ff:feee:9f61]) by smtp.gmail.com with ESMTPSA id c18-20020a056a000ad200b004cdccd3da08sm9464910pfl.44.2022.04.03.07.43.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 07:43:10 -0700 (PDT) From: Yafang Shao 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 Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Yafang Shao Subject: [PATCH bpf-next v2 1/9] bpf: selftests: Use libbpf 1.0 API mode in bpf constructor Date: Sun, 3 Apr 2022 14:42:52 +0000 Message-Id: <20220403144300.6707-2-laoar.shao@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220403144300.6707-1-laoar.shao@gmail.com> References: <20220403144300.6707-1-laoar.shao@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net In libbpf 1.0 API mode, it will bump rlimit automatically if there's no memcg-basaed accounting, so we can use libbpf 1.0 API mode instead in case we want to run it in an old kernel. The constructor is renamed to bpf_strict_all_ctor(). Signed-off-by: Yafang Shao --- tools/testing/selftests/bpf/bpf_rlimit.h | 26 +++--------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/tools/testing/selftests/bpf/bpf_rlimit.h b/tools/testing/selftests/bpf/bpf_rlimit.h index 9dac9b30f8ef..d050f7d0bb5c 100644 --- a/tools/testing/selftests/bpf/bpf_rlimit.h +++ b/tools/testing/selftests/bpf/bpf_rlimit.h @@ -1,28 +1,8 @@ #include #include -static __attribute__((constructor)) void bpf_rlimit_ctor(void) +static __attribute__((constructor)) void bpf_strict_all_ctor(void) { - struct rlimit rlim_old, rlim_new = { - .rlim_cur = RLIM_INFINITY, - .rlim_max = RLIM_INFINITY, - }; - - getrlimit(RLIMIT_MEMLOCK, &rlim_old); - /* For the sake of running the test cases, we temporarily - * set rlimit to infinity in order for kernel to focus on - * errors from actual test cases and not getting noise - * from hitting memlock limits. The limit is on per-process - * basis and not a global one, hence destructor not really - * needed here. - */ - if (setrlimit(RLIMIT_MEMLOCK, &rlim_new) < 0) { - perror("Unable to lift memlock rlimit"); - /* Trying out lower limit, but expect potential test - * case failures from this! - */ - rlim_new.rlim_cur = rlim_old.rlim_cur + (1UL << 20); - rlim_new.rlim_max = rlim_old.rlim_max + (1UL << 20); - setrlimit(RLIMIT_MEMLOCK, &rlim_new); - } + /* Use libbpf 1.0 API mode */ + libbpf_set_strict_mode(LIBBPF_STRICT_ALL); } From patchwork Sun Apr 3 14:42:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12799619 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A5F2C433FE for ; Sun, 3 Apr 2022 14:43:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359055AbiDCOpM (ORCPT ); Sun, 3 Apr 2022 10:45:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359020AbiDCOpG (ORCPT ); Sun, 3 Apr 2022 10:45:06 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D9193388D; Sun, 3 Apr 2022 07:43:12 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id h19so6706789pfv.1; Sun, 03 Apr 2022 07:43:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sOFjfSMnG30lHn+Yoz/l/DHCL+27lA4clMfQyl/6D4M=; b=AZeBJQGFjUUiY05NywDQp7gONkA2ExEMeJ/V9L3yHIPWABY5HdK88n34COlKJQuneY v0xz1VhnG0U7TKkERZUwRGsh8TifdcHiTKH25NtIa40681AWHVnLPTNvjXhQup3YdF9e i++O0iiQ6UflQO5DEwQvH4YvrNSVeZ54oTYSho1KIe7k8yb8az+Ey+msAvMxvCZ9g6Ih lXt3oO/RrAdOfX2Xsld1Qi7uLJMntLHqSBtMskaw5hEWA6g6P3x9CYAPpupCl+M0GPQ+ WfGehlwe1HfcMMq8XwZdoIfXuT/h6UING84Yyr6Z0B9wnQybH2jJVkWQS8qu6J1B1jgM RJfg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=sOFjfSMnG30lHn+Yoz/l/DHCL+27lA4clMfQyl/6D4M=; b=nOGBEZnNJZRP7Y7G7DdjJ+Qh5HDekYaivYMT5yHygeEnwYPmywaMJDSV6tSKx1Ptr6 H8T+k1DwrvCysklPBPMse9gpNCj15aEQ81QMVOWaR3HWZi433zi3LUw7ueAXLt//CSkZ MXL1tMqCQ/uEP1q2hwjwoHh5SLGNQWsqpCap9XDM1bBjM0o13M1CwOy5rKj8e1t4sBBX oObhTmrJzTTvbLCjMcR4Rj/aWNJ+WukQWmRkJ/pEtVqL73RB6nTRebED3V1/xVVJfNGX L8xD3v1R2e3AtJAlRBWoovzKz1C3Ci7ri9AcC4ZNFNBbK/rqxPEUEYDEynJkF+iEgaaP DgqQ== X-Gm-Message-State: AOAM530LnvHChAEdX+QG7UZ/kuZdOSJ0VnMLvL2cLNpw1mp4uAzFDLkX kUWY6aT2xjVe3qE/qJBN9uA= X-Google-Smtp-Source: ABdhPJyyxnF8DPsdX9vUroivyQCzmBsQQWqM6ohN4nuucYbQAslXphejm0NZv5oxIme/EBBjf0hvcA== X-Received: by 2002:a05:6a00:438b:b0:4fa:a67c:7ca0 with SMTP id bt11-20020a056a00438b00b004faa67c7ca0mr19795268pfb.5.1648996992065; Sun, 03 Apr 2022 07:43:12 -0700 (PDT) Received: from vultr.guest ([2001:19f0:6001:51a7:5400:3ff:feee:9f61]) by smtp.gmail.com with ESMTPSA id c18-20020a056a000ad200b004cdccd3da08sm9464910pfl.44.2022.04.03.07.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 07:43:11 -0700 (PDT) From: Yafang Shao 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 Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Yafang Shao Subject: [PATCH bpf-next v2 2/9] bpf: selftests: Use bpf strict all ctor in xdping Date: Sun, 3 Apr 2022 14:42:53 +0000 Message-Id: <20220403144300.6707-3-laoar.shao@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220403144300.6707-1-laoar.shao@gmail.com> References: <20220403144300.6707-1-laoar.shao@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Aoid using the deprecated RLIMIT_MEMLOCK. Signed-off-by: Yafang Shao --- tools/testing/selftests/bpf/xdping.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tools/testing/selftests/bpf/xdping.c b/tools/testing/selftests/bpf/xdping.c index c567856fd1bc..46ba0d7f73e8 100644 --- a/tools/testing/selftests/bpf/xdping.c +++ b/tools/testing/selftests/bpf/xdping.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -20,6 +19,7 @@ #include "bpf/bpf.h" #include "bpf/libbpf.h" +#include "bpf_rlimit.h" #include "xdping.h" #include "testing_helpers.h" @@ -89,7 +89,6 @@ int main(int argc, char **argv) { __u32 mode_flags = XDP_FLAGS_DRV_MODE | XDP_FLAGS_SKB_MODE; struct addrinfo *a, hints = { .ai_family = AF_INET }; - struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY}; __u16 count = XDPING_DEFAULT_COUNT; struct pinginfo pinginfo = { 0 }; const char *optstr = "c:I:NsS"; @@ -167,11 +166,6 @@ int main(int argc, char **argv) freeaddrinfo(a); } - if (setrlimit(RLIMIT_MEMLOCK, &r)) { - perror("setrlimit(RLIMIT_MEMLOCK)"); - return 1; - } - snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]); if (bpf_prog_test_load(filename, BPF_PROG_TYPE_XDP, &obj, &prog_fd)) { From patchwork Sun Apr 3 14:42:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12799620 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 199B2C43217 for ; Sun, 3 Apr 2022 14:43:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359064AbiDCOpN (ORCPT ); Sun, 3 Apr 2022 10:45:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349257AbiDCOpH (ORCPT ); Sun, 3 Apr 2022 10:45:07 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8FC4396B2; Sun, 3 Apr 2022 07:43:13 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id q19so6287247pgm.6; Sun, 03 Apr 2022 07:43:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sR1PYjJd65B0ytgSsHdKVZKV5nNYshMABOqYKn9lox8=; b=LZi8IzMnimNyLNBd6suPuAINdu/e7qwXK8VryE4oBrkMpsDkKcZSboMZ2I6yMzNf21 /YMJNbVSVk5onxm9BfDazLxkmVRIW+TvCc1HMf2LKCexSgMFsquV2xIWxDYxd40S5mwU L1RxhSG6NOPHZnerj2YSoM7t2s+NKLHISfUjD6wknBa/7vvcIvs42mb0k6U//mcMcW7I LA6DrRiO2IHbOaudYKijfwcg5PvW0eHbFDcQ9FmuYqHkoeGfyqctKHFi0j5QOzlO2FZ4 Vb8tiMTm1scJE8mlKoPy/zV7ekXKeXpm7SVWZS8QCqjemp7PTXmxj5MDSq4mXECBMg9w UwsQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=sR1PYjJd65B0ytgSsHdKVZKV5nNYshMABOqYKn9lox8=; b=Ed7eXffwxEiDg5rXZ5IUFAihdYRl9J9oxPPAsz4F6BKzEydvAyshg+LZtKlyvpZfK0 8hq/qYNuB+Rd6a2x7SEp36GoLiiSM5EvFMie8hQF1VFR+DKI4VPIC+ihiYxKKmw7QLqE +/2RxSWPFGRl5K6uEJ0xqqIUGKXf7m/yh0lpfkDEcytLpc6KjC7yyAl1Z7/Z46bMJImx dKjHy/3KUIJfUxQDNzf55lNtKc+CUiPaP6KSifeQ3bUirFGTdimDHLEence047qSuepl hRXF8uR1yrswXP84Rp6Sdwd6xkGYbVqWl2FRLT14eCY/rFXNFzM6E7bXgU4Vs1W5WauE m2EQ== X-Gm-Message-State: AOAM530Qm7T4vQfPSLJ1dgzQOy3btPPEwQ8k7pbVKz2T2hvS15Kli+VL 8CAWXA/oVQ4666m+gbLhTX4= X-Google-Smtp-Source: ABdhPJwkGCeaXYeYfgt/uFJDdPmmT52oIMZVi/me70gQQfAfgDjXbRmQE6+a6KdTnjLBDuHA+Qlr1w== X-Received: by 2002:a62:1ad3:0:b0:4fa:686f:9938 with SMTP id a202-20020a621ad3000000b004fa686f9938mr19906721pfa.6.1648996993265; Sun, 03 Apr 2022 07:43:13 -0700 (PDT) Received: from vultr.guest ([2001:19f0:6001:51a7:5400:3ff:feee:9f61]) by smtp.gmail.com with ESMTPSA id c18-20020a056a000ad200b004cdccd3da08sm9464910pfl.44.2022.04.03.07.43.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 07:43:12 -0700 (PDT) From: Yafang Shao 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 Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Yafang Shao Subject: [PATCH bpf-next v2 3/9] bpf: selftests: Use bpf strict all ctor in xdpxceiver Date: Sun, 3 Apr 2022 14:42:54 +0000 Message-Id: <20220403144300.6707-4-laoar.shao@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220403144300.6707-1-laoar.shao@gmail.com> References: <20220403144300.6707-1-laoar.shao@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Avoid using the deprecated RLIMIT_MEMLOCK. Signed-off-by: Yafang Shao --- tools/testing/selftests/bpf/xdpxceiver.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/bpf/xdpxceiver.c b/tools/testing/selftests/bpf/xdpxceiver.c index 5f8296d29e77..1be14e0c236e 100644 --- a/tools/testing/selftests/bpf/xdpxceiver.c +++ b/tools/testing/selftests/bpf/xdpxceiver.c @@ -90,13 +90,14 @@ #include #include #include -#include #include #include #include #include #include #include + +#include "bpf_rlimit.h" #include "xdpxceiver.h" #include "../kselftest.h" @@ -1448,15 +1449,11 @@ static void ifobject_delete(struct ifobject *ifobj) int main(int argc, char **argv) { - struct rlimit _rlim = { RLIM_INFINITY, RLIM_INFINITY }; struct pkt_stream *pkt_stream_default; struct ifobject *ifobj_tx, *ifobj_rx; struct test_spec test; u32 i, j; - if (setrlimit(RLIMIT_MEMLOCK, &_rlim)) - exit_with_error(errno); - ifobj_tx = ifobject_create(); if (!ifobj_tx) exit_with_error(ENOMEM); From patchwork Sun Apr 3 14:42:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12799621 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17CD1C4332F for ; Sun, 3 Apr 2022 14:43:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359060AbiDCOpQ (ORCPT ); Sun, 3 Apr 2022 10:45:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359050AbiDCOpI (ORCPT ); Sun, 3 Apr 2022 10:45:08 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4690396BE; Sun, 3 Apr 2022 07:43:14 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id o5-20020a17090ad20500b001ca8a1dc47aso1004258pju.1; Sun, 03 Apr 2022 07:43:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5CxbSxA/J1soVGI5URWZ3SJvoX16Jti84XlHml42gb0=; b=CGwtQuWXU/VwhcRt7NCPMRag0RxSznS6oEMmSlI/uZ30bVxa79K9LBvTXpeNLtW0Wl Dk5Y71QMfKxgkBdBJqVB1bgt7jIcd3+J9jXJYvSegnZqZZk/2adPP2WqyStW6Qm+Cg7I K7EydzJO2vBPBwvPsmb/X27d8SCwsJMvRwlTd/NK6+DNFqq6hseoAhc/Ql8Iykliap+t b8hZEH7JQKlumlK34TdbEbSp7srUj8BP3tTeQtit1Gb6ijTsbpTH2YlGSAz48Xo3P7FV blm8ii1fZHbgayNyM3LnCVgzujsBhpqblFojiFBnKXQcUre2LF0os4exMzGQtA3oFpZF oYLw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=5CxbSxA/J1soVGI5URWZ3SJvoX16Jti84XlHml42gb0=; b=FWTz8LpOBtKwAdKNnmVaDsoRoXoBcK1BUWpvQP5FuGC/UEBhC0ZwI0n8vC2UYxfDTE QI+OruwSyt85yZRfIqISpnJPJioHlkOYD42P4lWcfTN9cZ//gsD5ij6QgZnVPJl4Sra2 SQ+C/uHZkUL3Qcpe72x3/R1s9rsdguDAgkcWbGJkH9Qprf9rYTlksGISr79jBkY0H+cW puCioBRWEDIpaXjw/RXYd3ZokwolSSyCUR7nlpoX2EvEHE/6fwXZNXMLaYorSjeXyx2P IDyFKqe8JGjha5LLUBak0J/wVSY2NXOQqFjqLx5mTNtyWLxxlmXcEVbWUu2D3h1AEgbj Ro+Q== X-Gm-Message-State: AOAM530Gf57YNC7NOZAL4QIIXzvK9wDU0sY6R5ZrDu+Cb4NUvr31t0ga 0/u4pBkPw2JGBo4pXBBb9Dw= X-Google-Smtp-Source: ABdhPJyZ3MeZYp7fgly/e9xEJIXa59fmV7ckCKAEZ4S5NEUtvnjv2F4NaPOLcRjF+RGKGF/LHJ2peA== X-Received: by 2002:a17:90a:8581:b0:1b2:7541:af6c with SMTP id m1-20020a17090a858100b001b27541af6cmr21633631pjn.48.1648996994414; Sun, 03 Apr 2022 07:43:14 -0700 (PDT) Received: from vultr.guest ([2001:19f0:6001:51a7:5400:3ff:feee:9f61]) by smtp.gmail.com with ESMTPSA id c18-20020a056a000ad200b004cdccd3da08sm9464910pfl.44.2022.04.03.07.43.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 07:43:13 -0700 (PDT) From: Yafang Shao 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 Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Yafang Shao Subject: [PATCH bpf-next v2 4/9] bpf: samples: Replace RLIMIT_MEMLOCK with LIBBPF_STRICT_ALL in xdpsock_user Date: Sun, 3 Apr 2022 14:42:55 +0000 Message-Id: <20220403144300.6707-5-laoar.shao@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220403144300.6707-1-laoar.shao@gmail.com> References: <20220403144300.6707-1-laoar.shao@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Avoid using the deprecated RLIMIT_MEMLOCK. Signed-off-by: Yafang Shao --- samples/bpf/xdpsock_user.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c index 6f3fe30ad283..be7d2572e3e6 100644 --- a/samples/bpf/xdpsock_user.c +++ b/samples/bpf/xdpsock_user.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -1886,7 +1885,6 @@ int main(int argc, char **argv) { struct __user_cap_header_struct hdr = { _LINUX_CAPABILITY_VERSION_3, 0 }; struct __user_cap_data_struct data[2] = { { 0 } }; - struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY}; bool rx = false, tx = false; struct sched_param schparam; struct xsk_umem_info *umem; @@ -1917,11 +1915,8 @@ int main(int argc, char **argv) data[1].effective, data[1].inheritable, data[1].permitted); } } else { - if (setrlimit(RLIMIT_MEMLOCK, &r)) { - fprintf(stderr, "ERROR: setrlimit(RLIMIT_MEMLOCK) \"%s\"\n", - strerror(errno)); - exit(EXIT_FAILURE); - } + /* Use libbpf 1.0 API mode */ + libbpf_set_strict_mode(LIBBPF_STRICT_ALL); if (opt_num_xsks > 1) load_xdp_program(argv, &obj); From patchwork Sun Apr 3 14:42:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12799624 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 123D7C433F5 for ; Sun, 3 Apr 2022 14:43:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359048AbiDCOpU (ORCPT ); Sun, 3 Apr 2022 10:45:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359061AbiDCOpL (ORCPT ); Sun, 3 Apr 2022 10:45:11 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F06843981F; Sun, 3 Apr 2022 07:43:15 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id i10-20020a17090a2aca00b001ca56c9ab16so2450441pjg.1; Sun, 03 Apr 2022 07:43:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HK1eCo+mLyg/XwHakRoHzB489bRiG0WUI2kqqYfKxfI=; b=iOw6e84K4C8ZnEXtf2bHwuPAcdTJ/cpmEMfUAPJ1S9UlI6Coju+rBPEA9Los7Ij2gM Nt2AZeLK6LR67J6MYEc/pJtcUR/gyOgCwGuYgtxRFwkTi2CFYTYHsulaICx6sV3dj9jb 4oyvTNAvgSGrvIyM5iqOXd14C3FeaalYb8heMv+EfPbr3d2ZTZ9xD7Zq2nIAMrBHVggf akAxs4VVIbvTW7nEAEas0FUalerILTP0+Q5hKWyb+llOFkEqLcrVvO7CokLHk6sSjJjZ E/CTfv4LiaNBBJmPnIe35PnvFV4In8c4OJo7oY96TGM5jQHgytI0GvxVvrsj1+fH2Vcw T/HQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=HK1eCo+mLyg/XwHakRoHzB489bRiG0WUI2kqqYfKxfI=; b=RhPFmiL+OifzRq9VrFIaIkLU5rMyO8LN4jul/+XzBe5SkI1OUOKeuwc0KgQVej9nf0 rgSbURedb9+VOXHDKpvgt1QfaE1unc4Ww7XCNPjwfiHbHR+DnRIxR6W/CJ4vvKPZGnIr IXbvgYLholAfmS0azTvtLRu5fpY1oQvRlDb7f/3oVccQpkEySJKb/uHF1I0g6vWTFq/K qLjo5RwODo32ndHDKfTeVzLjoT9tf0SauD+HMlam9EWSKr7V0RebRCu99y4aWzuyVNal ClTSBuwp6aRR3+iQnU37UFUQT20ae8w4BCNdLz1eX6delToQ7Jj58WjtLIUFQ5PP8Suo czIg== X-Gm-Message-State: AOAM533kAuXBRWQ8NN2Jk5p8ElaqE/PYKdbXxYttcWko2zQlWFOe/zzH iVxVPN8I3zP2G3JzvDkEbYc= X-Google-Smtp-Source: ABdhPJwOfaaNu1LoKq7NdT94IdbsccNTltJ7Gu2VDErAbpxv7RuVwbJdiAXOD4dgMBW6tLp5NNRZcw== X-Received: by 2002:a17:902:d505:b0:154:76c2:f7bb with SMTP id b5-20020a170902d50500b0015476c2f7bbmr54682361plg.83.1648996995403; Sun, 03 Apr 2022 07:43:15 -0700 (PDT) Received: from vultr.guest ([2001:19f0:6001:51a7:5400:3ff:feee:9f61]) by smtp.gmail.com with ESMTPSA id c18-20020a056a000ad200b004cdccd3da08sm9464910pfl.44.2022.04.03.07.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 07:43:15 -0700 (PDT) From: Yafang Shao 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 Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Yafang Shao Subject: [PATCH bpf-next v2 5/9] bpf: samples: Replace RLIMIT_MEMLOCK with LIBBPF_STRICT_ALL in xsk_fwd Date: Sun, 3 Apr 2022 14:42:56 +0000 Message-Id: <20220403144300.6707-6-laoar.shao@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220403144300.6707-1-laoar.shao@gmail.com> References: <20220403144300.6707-1-laoar.shao@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Avoid using the deprecated RLIMIT_MEMLOCK. Signed-off-by: Yafang Shao --- samples/bpf/xsk_fwd.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/samples/bpf/xsk_fwd.c b/samples/bpf/xsk_fwd.c index 2220509588a0..2324e18ccc7e 100644 --- a/samples/bpf/xsk_fwd.c +++ b/samples/bpf/xsk_fwd.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -131,7 +130,6 @@ static struct bpool * bpool_init(struct bpool_params *params, struct xsk_umem_config *umem_cfg) { - struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY}; u64 n_slabs, n_slabs_reserved, n_buffers, n_buffers_reserved; u64 slabs_size, slabs_reserved_size; u64 buffers_size, buffers_reserved_size; @@ -140,9 +138,8 @@ bpool_init(struct bpool_params *params, u8 *p; int status; - /* mmap prep. */ - if (setrlimit(RLIMIT_MEMLOCK, &r)) - return NULL; + /* Use libbpf 1.0 API mode */ + libbpf_set_strict_mode(LIBBPF_STRICT_ALL); /* bpool internals dimensioning. */ n_slabs = (params->n_buffers + params->n_buffers_per_slab - 1) / From patchwork Sun Apr 3 14:42:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12799622 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 772E6C4332F for ; Sun, 3 Apr 2022 14:43:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359073AbiDCOpR (ORCPT ); Sun, 3 Apr 2022 10:45:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359062AbiDCOpL (ORCPT ); Sun, 3 Apr 2022 10:45:11 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 095A839828; Sun, 3 Apr 2022 07:43:16 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id q142so4523027pgq.9; Sun, 03 Apr 2022 07:43:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G/TVx2XnkKIhWcX5k9unvUl8sU5ccEHxJlPYgV8oyCQ=; b=dXwLblJF7O8d8wO55CIc+bGJKbYdGX1/nE3Ilfjt9orEYzXTDbobIYWOvTrMIvDHwS R92Dz6LWTOeXvvGxkTfIzwK6RVtwvu6GNYjSd0G8vjPAQEF0tqwvdymaB2VS9EBhCM98 vQ0THoPcBIEK0IW5Lfbmg0saUoDWCrazPOZsEa2g5hykS06vha9aLjvzPWegdpXALKy7 NvNBX2dPa24n1n0nC/Rc0ga/KyetnMbQABYiPuNCRISxu2lox3BgSex5rT9MxIMj+6ex MRO6rw/n+4eP7cQs+VDCwPQij9/YrAQieZHw2Xtfgm+VnsunsdjOozK3rtU7ctIZFQK0 eNHg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=G/TVx2XnkKIhWcX5k9unvUl8sU5ccEHxJlPYgV8oyCQ=; b=BZnaeP7f2Kyaj1a9qO5PEPdeou1lZf7N5rnSvGvCvlVkSSejxlWQbYPYogzOfZ2vbM zM9viKncwTAybWD2d2eU2RqfgKYNNwbi0SzzkVnRfp89W1gkWAHy/CpXZmc1jqrhVA1/ /GmlScAMVO2nUqdZyvU4NYWYXHRFCqeJ9kGcHTx/CIQENR50NVxJ5xQzq5HWAaZKv4ga lc80PK0lI0mj0/kc/kx5BTphyEb34H+1/xG6X3A8lpqi/asJLQ5oLYtO1iqwGHJ3EEec diNSHF1pKYYu1Bsr85l+WFAxGfLeEvU5y2JOE+kEFmRXkFeMG+5XMt51Xk1oop7amGyM dKUw== X-Gm-Message-State: AOAM533IMxUaLjK7VLj+R0U6aCFh0V62QXv8/KfnsNagbMaHMh1btSd0 8ItBNNkOtPy7K/lzMR39V7E= X-Google-Smtp-Source: ABdhPJylsNm2gon9FQbC/cKegPNY9RiDuoiN1RZsHsCiDLgTPk3PNw1/OYxNe69MN1tjcn4h2eCRiA== X-Received: by 2002:a05:6a00:a15:b0:4fb:4112:870e with SMTP id p21-20020a056a000a1500b004fb4112870emr19621715pfh.11.1648996996435; Sun, 03 Apr 2022 07:43:16 -0700 (PDT) Received: from vultr.guest ([2001:19f0:6001:51a7:5400:3ff:feee:9f61]) by smtp.gmail.com with ESMTPSA id c18-20020a056a000ad200b004cdccd3da08sm9464910pfl.44.2022.04.03.07.43.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 07:43:16 -0700 (PDT) From: Yafang Shao 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 Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Yafang Shao Subject: [PATCH bpf-next v2 6/9] bpf: runqslower: Replace RLIMIT_MEMLOCK with LIBBPF_STRICT_ALL Date: Sun, 3 Apr 2022 14:42:57 +0000 Message-Id: <20220403144300.6707-7-laoar.shao@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220403144300.6707-1-laoar.shao@gmail.com> References: <20220403144300.6707-1-laoar.shao@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Avoid using the deprecated RLIMIT_MEMLOCK. Signed-off-by: Yafang Shao --- tools/bpf/runqslower/runqslower.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/tools/bpf/runqslower/runqslower.c b/tools/bpf/runqslower/runqslower.c index d78f4148597f..3439ded327f8 100644 --- a/tools/bpf/runqslower/runqslower.c +++ b/tools/bpf/runqslower/runqslower.c @@ -88,16 +88,6 @@ int libbpf_print_fn(enum libbpf_print_level level, return vfprintf(stderr, format, args); } -static int bump_memlock_rlimit(void) -{ - struct rlimit rlim_new = { - .rlim_cur = RLIM_INFINITY, - .rlim_max = RLIM_INFINITY, - }; - - return setrlimit(RLIMIT_MEMLOCK, &rlim_new); -} - void handle_event(void *ctx, int cpu, void *data, __u32 data_sz) { const struct runq_event *e = data; @@ -133,11 +123,8 @@ int main(int argc, char **argv) libbpf_set_print(libbpf_print_fn); - err = bump_memlock_rlimit(); - if (err) { - fprintf(stderr, "failed to increase rlimit: %d", err); - return 1; - } + /* Use libbpf 1.0 API mode */ + libbpf_set_strict_mode(LIBBPF_STRICT_ALL); obj = runqslower_bpf__open(); if (!obj) { From patchwork Sun Apr 3 14:42:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12799623 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DAEBC43217 for ; Sun, 3 Apr 2022 14:43:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359077AbiDCOpT (ORCPT ); Sun, 3 Apr 2022 10:45:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359048AbiDCOpL (ORCPT ); Sun, 3 Apr 2022 10:45:11 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB47739832; Sun, 3 Apr 2022 07:43:17 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id ku13-20020a17090b218d00b001ca8fcd3adeso781197pjb.2; Sun, 03 Apr 2022 07:43:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=29tSKU5CIi5toN+mzQg/xoJLGhPPII1qeJKEVizdgAc=; b=d/Ou5tvfP6DRmk0vvgWKuKibg8pLMW3OVJ81L/nWqVAsTitwIxHXBQI+F3YSkwCy1k g4Tm40B2xZk0HE30DcrRZQTikZi/hZCofvIe4RD5t3du4zUzcn3YTWi6ZJQR7FUaEPJ3 MWOvv9nIc+a1WDM+3VAmyckbcEL1gtaDYeX95l3uitrsfDFHagTBRKZ/SjqvGXyrhqug VQeJ4iEJiuDa/2LUSTgC5FfKQoVctK7hiwTvRgLUsyN6VOleHul0fjmEm5toXpnujwhp F6+AYO6mCmT3wmdc12Viok/60dn5D3lRyHflceRmfb7/J7ojdxz8cBN7Qh7F2Z5am7Yj mf0w== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=29tSKU5CIi5toN+mzQg/xoJLGhPPII1qeJKEVizdgAc=; b=ISP3RTM0rESSUw1GZSACukPJeKQrwJn6BEnwkizlQqXjkA2K4TJ7lLeTSfBWeXhmud 12I2lnJ5DcKWs8OZHxj3WSIBHAC1662yi13dvn1J9WQ3LlatgLsV0g2XQSSWlHUePWbc qitXVcJWowvmopnSEs2zeSmZhngbNU9gEAy6ELbDSggAb6GNpZjKNd0GACeZjMGMXBwg hLuY2+C4l6lZpt56enfYU/arFW3TAB34vJ/Oy6lQexYgaa5imz9x3M5LZr+GT8oXoulN QrIbdfzXb3rYhwdGEoXYrmU+qMSLqPC8upbHZW2rel9PZ0n7v5DieNo2p2xX7Y3nDBif /gCQ== X-Gm-Message-State: AOAM533C5/JHMxh3TPshmIa6IRX8ORWxkdYSOQdEFH+tSIB2Z+8jjcm8 s5IHlFEjQGGCI7cyqsijyVY= X-Google-Smtp-Source: ABdhPJxgg+6HW/nkYND6FIYpSIwOCVgVCwhgP5w4gjjUPKxo+8FTUhk6R9FpRkCJOcLy05nHRyCiXg== X-Received: by 2002:a17:903:11cc:b0:151:71e4:dadc with SMTP id q12-20020a17090311cc00b0015171e4dadcmr18883879plh.78.1648996997480; Sun, 03 Apr 2022 07:43:17 -0700 (PDT) Received: from vultr.guest ([2001:19f0:6001:51a7:5400:3ff:feee:9f61]) by smtp.gmail.com with ESMTPSA id c18-20020a056a000ad200b004cdccd3da08sm9464910pfl.44.2022.04.03.07.43.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 07:43:17 -0700 (PDT) From: Yafang Shao 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 Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Yafang Shao Subject: [PATCH bpf-next v2 7/9] bpf: bpftool: Remove useless return value of libbpf_set_strict_mode Date: Sun, 3 Apr 2022 14:42:58 +0000 Message-Id: <20220403144300.6707-8-laoar.shao@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220403144300.6707-1-laoar.shao@gmail.com> References: <20220403144300.6707-1-laoar.shao@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net libbpf_set_strict_mode alwasy return 0, so we don't need to check whether the return value is 0 or not. Signed-off-by: Yafang Shao --- tools/bpf/bpftool/main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c index e81227761f5d..451cefc2d0da 100644 --- a/tools/bpf/bpftool/main.c +++ b/tools/bpf/bpftool/main.c @@ -507,9 +507,7 @@ int main(int argc, char **argv) * It will still be rejected if users use LIBBPF_STRICT_ALL * mode for loading generated skeleton. */ - ret = libbpf_set_strict_mode(LIBBPF_STRICT_ALL & ~LIBBPF_STRICT_MAP_DEFINITIONS); - if (ret) - p_err("failed to enable libbpf strict mode: %d", ret); + libbpf_set_strict_mode(LIBBPF_STRICT_ALL & ~LIBBPF_STRICT_MAP_DEFINITIONS); } argc -= optind; From patchwork Sun Apr 3 14:42:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12799625 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EC2FC433FE for ; Sun, 3 Apr 2022 14:43:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348561AbiDCOpV (ORCPT ); Sun, 3 Apr 2022 10:45:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359054AbiDCOpM (ORCPT ); Sun, 3 Apr 2022 10:45:12 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24827396B2; Sun, 3 Apr 2022 07:43:19 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id c2so6269293pga.10; Sun, 03 Apr 2022 07:43:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6tbHk2+CAC5YQR/AzksFLm5f5AJ/80aev2xPCgPl5tA=; b=e5vYXo9voRKnA5EfdGL/2VYBbYFH6k7dPahjpKz0UskqllFrR+G1+eO7X5zdjt5I9A cDOtjELWRVyUiWMgXIpYYYQfVOo8921212JOfxvW3hS2qnoU40z2FOxZouhuMi8riXQ1 k7kslLYK1orvsjmN7dkjeh+gOy8VPFHBEjXwYQgLSgd6y0MaRDN5yoibOUgocXETxQAU KRiKtOgluempkaWgSrekH61PU7rHzn2km5/kJBYHenedR94oVPRPppv86eZAE+utZWXs xQ/+bkBWwdKugkxrTRhlBYwWqj7vfD/IvHLhMXRqcasSE342jRz+v7N7LzBC1+Jv8NQK haww== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=6tbHk2+CAC5YQR/AzksFLm5f5AJ/80aev2xPCgPl5tA=; b=tJJmDu39jn3hUdStshIEHMp84adlSpXyyFXHxfmE/EN/O/qEWkENDAT1Q/48e5bANw S/LY4OztF3N00z865CvRuNJ2B9vWgiGD/jrPt45t5227qvQAu14CZPIuF7VibH0MbqHp 3KYocJ98AdY3VXVrhAZY4+iWQlb38BgijDUHaMqDiKZuxPzw9/IjpYOdXN/utCpC1Uii 0T583HxtvD+Jg0TgmmlY7pKXMtUdC8Z1stETT0t9gFXbUA+jXNx2l/crAFz8Su6mp7Vf SGgDLlcA0e1NHaO0kwHevQaxUxXMqkHkXRHpqHMdWWHeiXfCmeuMhEyicCXygW9l3R0O ANUw== X-Gm-Message-State: AOAM530MzAe1q8cE551sYyV93EY37aNEbe/hkKLNS5NdBD4QAdW2JZMI wwiIsjZPE/kXn+HfBiWzGkc= X-Google-Smtp-Source: ABdhPJxM8su8FkFzY+mTx8zV864MB5EHXhrsr7BUDk9v6BvfIYwFXb1/DeMNIItWSyceCIGXyB/g7A== X-Received: by 2002:a63:1a5f:0:b0:381:f043:320d with SMTP id a31-20020a631a5f000000b00381f043320dmr22770436pgm.63.1648996998574; Sun, 03 Apr 2022 07:43:18 -0700 (PDT) Received: from vultr.guest ([2001:19f0:6001:51a7:5400:3ff:feee:9f61]) by smtp.gmail.com with ESMTPSA id c18-20020a056a000ad200b004cdccd3da08sm9464910pfl.44.2022.04.03.07.43.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 07:43:18 -0700 (PDT) From: Yafang Shao 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 Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Yafang Shao Subject: [PATCH bpf-next v2 8/9] bpf: bpftool: Set LIBBPF_STRICT_AUTO_RLIMIT_MEMLOCK for legacy libbpf Date: Sun, 3 Apr 2022 14:42:59 +0000 Message-Id: <20220403144300.6707-9-laoar.shao@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220403144300.6707-1-laoar.shao@gmail.com> References: <20220403144300.6707-1-laoar.shao@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net LIBBPF_STRICT_AUTO_RLIMIT_MEMLOCK has already been set for non legacy libbpf, let's also set it for legacy libbpf then we can avoid setting the deprecatred RLIMIT_MEMLOCK directly. Signed-off-by: Yafang Shao --- tools/bpf/bpftool/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c index 451cefc2d0da..9062ef2b8767 100644 --- a/tools/bpf/bpftool/main.c +++ b/tools/bpf/bpftool/main.c @@ -508,6 +508,8 @@ int main(int argc, char **argv) * mode for loading generated skeleton. */ libbpf_set_strict_mode(LIBBPF_STRICT_ALL & ~LIBBPF_STRICT_MAP_DEFINITIONS); + } else { + libbpf_set_strict_mode(LIBBPF_STRICT_AUTO_RLIMIT_MEMLOCK); } argc -= optind; From patchwork Sun Apr 3 14:43:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12799626 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73AFDC433F5 for ; Sun, 3 Apr 2022 14:43:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359078AbiDCOpX (ORCPT ); Sun, 3 Apr 2022 10:45:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359066AbiDCOpN (ORCPT ); Sun, 3 Apr 2022 10:45:13 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 386063388D; Sun, 3 Apr 2022 07:43:20 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id y10so6682514pfa.7; Sun, 03 Apr 2022 07:43:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WSiOa7a2+6arsE8Kmiwhve3HvAwmlZuKMpROItnSNl8=; b=W3793xmTSpKlfp98wRoQUpjy+9NUO+i++6tMx2Tx3mtUHEnT/uURSD2tsZy5OTffkB DusF3ye0oSQLRn5y1PMWaKe+p0L+HR061su2LaMWQH3xboblxP49maWjnMGlYg8oagjx s2+h7xrRPKZsQPZEIVfrMTnd++jrl7Zge67KrwqpRyjw5X5YjAFeUs8tUasKQreldEuY SJlxsZSWVHdJeL8jvYv+gCXPf9EsfuiEH7xa5b4izjgWSawhXgUU6HcZ0wrQu4x5y15G +CufNixj2yna+y+ktqQm38plIbEP8UZ1uZwN/nMWOIOz4dNB4KRwJuIszvkGTI9LMoTO wiPA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=WSiOa7a2+6arsE8Kmiwhve3HvAwmlZuKMpROItnSNl8=; b=p9MbdUPQHikDjeVi68A2RNAiBzT5NMdNxT2ZM2Bk9Y4nwHhCeJHT/WiTpNVckoRLwq ASMSsqiRlhrKEmhmU9BrrFjqhlB0OdkoWcq/aQpN4lSR4oFjIpSkHy3cEJbv4BR7p2+1 sL/084Am+8IhTyhH+Fn3U9SShirYccxY/gl2NG5GjoeGP2UGj2J0d1BFha2JtIuaxCIp PEqkX9YY1vksTqbTBfkegiBxTqDQGoO+4V929IL0GiW3FKVyg1vhI5kFwz4lX72f1Po8 o4Jy2otv48nkuVytcWkb6xo6XSjETNjp/VNj6hrvNd2sNQSAzxCftLHd8/6zTxe/Ha0u X+aw== X-Gm-Message-State: AOAM531VNT767VeCASyfjMARZDLxAVMjxd01fI5cDdG4sVojeNKDUHmt G9OqvGOjVLMz9p7aSSiFl2Y= X-Google-Smtp-Source: ABdhPJxPiaWNrR1RLL8662JvlVJe4BoIw34MBChcU/D4sc7OcrQ/NO+LcgJ0S00wmq/q16Sls70Tqg== X-Received: by 2002:a63:3489:0:b0:398:7008:bb25 with SMTP id b131-20020a633489000000b003987008bb25mr22272671pga.242.1648996999692; Sun, 03 Apr 2022 07:43:19 -0700 (PDT) Received: from vultr.guest ([2001:19f0:6001:51a7:5400:3ff:feee:9f61]) by smtp.gmail.com with ESMTPSA id c18-20020a056a000ad200b004cdccd3da08sm9464910pfl.44.2022.04.03.07.43.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 07:43:19 -0700 (PDT) From: Yafang Shao 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 Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Yafang Shao Subject: [PATCH bpf-next v2 9/9] bpf: bpftool: Remove useless rlimit setting Date: Sun, 3 Apr 2022 14:43:00 +0000 Message-Id: <20220403144300.6707-10-laoar.shao@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220403144300.6707-1-laoar.shao@gmail.com> References: <20220403144300.6707-1-laoar.shao@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net As we have already set LIBBPF_STRICT_AUTO_RLIMIT_MEMLOCK, we don't need to bump RLIMIT_MEMLOCK any more. Signed-off-by: Yafang Shao --- tools/bpf/bpftool/common.c | 7 ------- tools/bpf/bpftool/feature.c | 2 -- tools/bpf/bpftool/main.h | 2 -- tools/bpf/bpftool/map.c | 2 -- tools/bpf/bpftool/pids.c | 1 - tools/bpf/bpftool/prog.c | 3 --- tools/bpf/bpftool/struct_ops.c | 2 -- 7 files changed, 19 deletions(-) diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c index 0c1e06cf50b9..6b1e67851690 100644 --- a/tools/bpf/bpftool/common.c +++ b/tools/bpf/bpftool/common.c @@ -119,13 +119,6 @@ static bool is_bpffs(char *path) return (unsigned long)st_fs.f_type == BPF_FS_MAGIC; } -void set_max_rlimit(void) -{ - struct rlimit rinf = { RLIM_INFINITY, RLIM_INFINITY }; - - setrlimit(RLIMIT_MEMLOCK, &rinf); -} - static int mnt_fs(const char *target, const char *type, char *buff, size_t bufflen) { diff --git a/tools/bpf/bpftool/feature.c b/tools/bpf/bpftool/feature.c index 290998c82de1..19c484e63da4 100644 --- a/tools/bpf/bpftool/feature.c +++ b/tools/bpf/bpftool/feature.c @@ -1136,8 +1136,6 @@ static int do_probe(int argc, char **argv) __u32 ifindex = 0; char *ifname; - set_max_rlimit(); - while (argc) { if (is_prefix(*argv, "kernel")) { if (target != COMPONENT_UNSPEC) { diff --git a/tools/bpf/bpftool/main.h b/tools/bpf/bpftool/main.h index 6e9277ffc68c..aa99ffab451a 100644 --- a/tools/bpf/bpftool/main.h +++ b/tools/bpf/bpftool/main.h @@ -102,8 +102,6 @@ int detect_common_prefix(const char *arg, ...); void fprint_hex(FILE *f, void *arg, unsigned int n, const char *sep); void usage(void) __noreturn; -void set_max_rlimit(void); - int mount_tracefs(const char *target); struct obj_ref { diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c index c26378f20831..877387ef79c7 100644 --- a/tools/bpf/bpftool/map.c +++ b/tools/bpf/bpftool/map.c @@ -1342,8 +1342,6 @@ static int do_create(int argc, char **argv) goto exit; } - set_max_rlimit(); - fd = bpf_map_create(map_type, map_name, key_size, value_size, max_entries, &attr); if (fd < 0) { p_err("map create failed: %s", strerror(errno)); diff --git a/tools/bpf/bpftool/pids.c b/tools/bpf/bpftool/pids.c index bb6c969a114a..e2d00d3cd868 100644 --- a/tools/bpf/bpftool/pids.c +++ b/tools/bpf/bpftool/pids.c @@ -108,7 +108,6 @@ int build_obj_refs_table(struct hashmap **map, enum bpf_obj_type type) p_err("failed to create hashmap for PID references"); return -1; } - set_max_rlimit(); skel = pid_iter_bpf__open(); if (!skel) { diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index bc4e05542c2b..d5ba3b6f30ae 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c @@ -1603,8 +1603,6 @@ static int load_with_options(int argc, char **argv, bool first_prog_only) } } - set_max_rlimit(); - if (verifier_logs) /* log_level1 + log_level2 + stats, but not stable UAPI */ open_opts.kernel_log_level = 1 + 2 + 4; @@ -2302,7 +2300,6 @@ static int do_profile(int argc, char **argv) } } - set_max_rlimit(); err = profiler_bpf__load(profile_obj); if (err) { p_err("failed to load profile_obj"); diff --git a/tools/bpf/bpftool/struct_ops.c b/tools/bpf/bpftool/struct_ops.c index e08a6ff2866c..2535f079ed67 100644 --- a/tools/bpf/bpftool/struct_ops.c +++ b/tools/bpf/bpftool/struct_ops.c @@ -501,8 +501,6 @@ static int do_register(int argc, char **argv) if (libbpf_get_error(obj)) return -1; - set_max_rlimit(); - if (bpf_object__load(obj)) { bpf_object__close(obj); return -1;