netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexei Starovoitov <ast@kernel.org>
To: <davem@davemloft.net>
Cc: <daniel@iogearbox.net>, <jakub.kicinski@netronome.com>,
	<jannh@google.com>, <netdev@vger.kernel.org>,
	<bpf@vger.kernel.org>, <kernel-team@fb.com>
Subject: [PATCH v2 bpf-next 04/10] bpf: convert temp arrays to kvcalloc
Date: Mon, 1 Apr 2019 21:27:43 -0700	[thread overview]
Message-ID: <20190402042749.3670015-5-ast@kernel.org> (raw)
In-Reply-To: <20190402042749.3670015-1-ast@kernel.org>

Temporary arrays used during program verification need to be vmalloc-ed
to support large bpf programs.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
 kernel/bpf/verifier.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 94cf6efc5df6..ad3494a881da 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -5313,13 +5313,13 @@ static int check_cfg(struct bpf_verifier_env *env)
 	int ret = 0;
 	int i, t;
 
-	insn_state = kcalloc(insn_cnt, sizeof(int), GFP_KERNEL);
+	insn_state = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL);
 	if (!insn_state)
 		return -ENOMEM;
 
-	insn_stack = kcalloc(insn_cnt, sizeof(int), GFP_KERNEL);
+	insn_stack = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL);
 	if (!insn_stack) {
-		kfree(insn_state);
+		kvfree(insn_state);
 		return -ENOMEM;
 	}
 
@@ -5417,8 +5417,8 @@ static int check_cfg(struct bpf_verifier_env *env)
 	ret = 0; /* cfg looks good */
 
 err_free:
-	kfree(insn_state);
-	kfree(insn_stack);
+	kvfree(insn_state);
+	kvfree(insn_stack);
 	return ret;
 }
 
@@ -7898,7 +7898,7 @@ static void free_states(struct bpf_verifier_env *env)
 			}
 	}
 
-	kfree(env->explored_states);
+	kvfree(env->explored_states);
 }
 
 static void print_verification_stats(struct bpf_verifier_env *env)
@@ -7994,7 +7994,7 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr,
 			goto skip_full_check;
 	}
 
-	env->explored_states = kcalloc(env->prog->len,
+	env->explored_states = kvcalloc(env->prog->len,
 				       sizeof(struct bpf_verifier_state_list *),
 				       GFP_USER);
 	ret = -ENOMEM;
-- 
2.20.0


  parent reply	other threads:[~2019-04-02  4:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-02  4:27 [PATCH v2 bpf-next 00/10] bpf: improve verifier scalability Alexei Starovoitov
2019-04-02  4:27 ` [PATCH v2 bpf-next 01/10] bpf: add verifier stats and log_level bit 2 Alexei Starovoitov
2019-04-02  4:27 ` [PATCH v2 bpf-next 02/10] bpf: improve verification speed by droping states Alexei Starovoitov
2019-04-02  4:27 ` [PATCH v2 bpf-next 03/10] bpf: improve verification speed by not remarking live_read Alexei Starovoitov
2019-04-02  4:27 ` Alexei Starovoitov [this message]
2019-04-02  4:27 ` [PATCH v2 bpf-next 05/10] bpf: verbose jump offset overflow check Alexei Starovoitov
2019-04-02  4:27 ` [PATCH v2 bpf-next 06/10] bpf: increase complexity limit and maximum program size Alexei Starovoitov
2019-04-02  4:27 ` [PATCH v2 bpf-next 07/10] bpf: increase verifier log limit Alexei Starovoitov
2019-04-02  4:27 ` [PATCH v2 bpf-next 08/10] libbpf: teach libbpf about log_level bit 2 Alexei Starovoitov
2019-04-02  4:27 ` [PATCH v2 bpf-next 09/10] selftests/bpf: add few verifier scale tests Alexei Starovoitov
2019-04-02  4:27 ` [PATCH v2 bpf-next 10/10] selftests/bpf: synthetic tests to push verifier limits Alexei Starovoitov
2019-04-04  0:01 ` [PATCH v2 bpf-next 00/10] bpf: improve verifier scalability Daniel Borkmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190402042749.3670015-5-ast@kernel.org \
    --to=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=jakub.kicinski@netronome.com \
    --cc=jannh@google.com \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).