diff mbox series

[bpf,1/2] bpf: Clarify a bpf_bprintf_prepare macro

Message ID 20210517092830.1026418-1-revest@chromium.org (mailing list archive)
State Accepted
Commit 8ba1030385e3c20491167282ac5c7a4ff9783c70
Delegated to: BPF
Headers show
Series [bpf,1/2] bpf: Clarify a bpf_bprintf_prepare macro | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present fail Series targets non-next tree, but doesn't contain any Fixes tags
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf
netdev/subject_prefix success Link
netdev/cc_maintainers warning 5 maintainers not CCed: netdev@vger.kernel.org yhs@fb.com kafai@fb.com john.fastabend@gmail.com songliubraving@fb.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 6 this patch: 6
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 25 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 6 this patch: 6
netdev/header_inline success Link

Commit Message

Florent Revest May 17, 2021, 9:28 a.m. UTC
The per-cpu buffers contain bprintf data rather than printf arguments.
The macro name and comment were a bit confusing, this rewords them in a
clearer way.

Signed-off-by: Florent Revest <revest@chromium.org>
---
 kernel/bpf/helpers.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Song Liu May 17, 2021, 5:54 p.m. UTC | #1
On Mon, May 17, 2021 at 2:29 AM Florent Revest <revest@chromium.org> wrote:
>
> The per-cpu buffers contain bprintf data rather than printf arguments.
> The macro name and comment were a bit confusing, this rewords them in a
> clearer way.
>
> Signed-off-by: Florent Revest <revest@chromium.org>

Acked-by: Song Liu <song@kernel.org>

> ---
>  kernel/bpf/helpers.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> index ef658a9ea5c9..3a5ab614cbb0 100644
> --- a/kernel/bpf/helpers.c
> +++ b/kernel/bpf/helpers.c
> @@ -692,13 +692,14 @@ static int bpf_trace_copy_string(char *buf, void *unsafe_ptr, char fmt_ptype,
>         return -EINVAL;
>  }
>
> -/* Per-cpu temp buffers which can be used by printf-like helpers for %s or %p
> +/* Per-cpu temp buffers used by printf-like helpers to store the bprintf binary
> + * arguments representation.
>   */
> -#define MAX_PRINTF_BUF_LEN     512
> +#define MAX_BPRINTF_BUF_LEN    512
>
>  /* Support executing three nested bprintf helper calls on a given CPU */
>  struct bpf_bprintf_buffers {
> -       char tmp_bufs[3][MAX_PRINTF_BUF_LEN];
> +       char tmp_bufs[3][MAX_BPRINTF_BUF_LEN];
>  };
>  static DEFINE_PER_CPU(struct bpf_bprintf_buffers, bpf_bprintf_bufs);
>  static DEFINE_PER_CPU(int, bpf_bprintf_nest_level);
> @@ -761,7 +762,7 @@ int bpf_bprintf_prepare(char *fmt, u32 fmt_size, const u64 *raw_args,
>                 if (num_args && try_get_fmt_tmp_buf(&tmp_buf))
>                         return -EBUSY;
>
> -               tmp_buf_end = tmp_buf + MAX_PRINTF_BUF_LEN;
> +               tmp_buf_end = tmp_buf + MAX_BPRINTF_BUF_LEN;
>                 *bin_args = (u32 *)tmp_buf;
>         }
>
> --
> 2.31.1.751.gd2f1c929bd-goog
>
patchwork-bot+netdevbpf@kernel.org May 17, 2021, 6:10 p.m. UTC | #2
Hello:

This series was applied to bpf/bpf.git (refs/heads/master):

On Mon, 17 May 2021 11:28:29 +0200 you wrote:
> The per-cpu buffers contain bprintf data rather than printf arguments.
> The macro name and comment were a bit confusing, this rewords them in a
> clearer way.
> 
> Signed-off-by: Florent Revest <revest@chromium.org>
> ---
>  kernel/bpf/helpers.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)

Here is the summary with links:
  - [bpf,1/2] bpf: Clarify a bpf_bprintf_prepare macro
    https://git.kernel.org/bpf/bpf/c/8ba1030385e3
  - [bpf,2/2] bpf: Avoid using ARRAY_SIZE on an uninitialized pointer
    https://git.kernel.org/bpf/bpf/c/d0c0fe10ce6d

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index ef658a9ea5c9..3a5ab614cbb0 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -692,13 +692,14 @@  static int bpf_trace_copy_string(char *buf, void *unsafe_ptr, char fmt_ptype,
 	return -EINVAL;
 }
 
-/* Per-cpu temp buffers which can be used by printf-like helpers for %s or %p
+/* Per-cpu temp buffers used by printf-like helpers to store the bprintf binary
+ * arguments representation.
  */
-#define MAX_PRINTF_BUF_LEN	512
+#define MAX_BPRINTF_BUF_LEN	512
 
 /* Support executing three nested bprintf helper calls on a given CPU */
 struct bpf_bprintf_buffers {
-	char tmp_bufs[3][MAX_PRINTF_BUF_LEN];
+	char tmp_bufs[3][MAX_BPRINTF_BUF_LEN];
 };
 static DEFINE_PER_CPU(struct bpf_bprintf_buffers, bpf_bprintf_bufs);
 static DEFINE_PER_CPU(int, bpf_bprintf_nest_level);
@@ -761,7 +762,7 @@  int bpf_bprintf_prepare(char *fmt, u32 fmt_size, const u64 *raw_args,
 		if (num_args && try_get_fmt_tmp_buf(&tmp_buf))
 			return -EBUSY;
 
-		tmp_buf_end = tmp_buf + MAX_PRINTF_BUF_LEN;
+		tmp_buf_end = tmp_buf + MAX_BPRINTF_BUF_LEN;
 		*bin_args = (u32 *)tmp_buf;
 	}