public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
To: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>,
	bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
	Sumitra Sharma <sumitraartsy@gmail.com>
Cc: Ira Weiny <ira.weiny@intel.com>, Deepak R Varma <drv@mailo.com>
Subject: Re: [PATCH v2] lib/test_bpf: Call page_address() on page acquired with GFP_KERNEL flag
Date: Sun, 18 Jun 2023 07:07:00 +0200	[thread overview]
Message-ID: <3564297.R56niFO833@suse> (raw)
In-Reply-To: <20230613071756.GA359746@sumitra.com>

On martedì 13 giugno 2023 09:17:56 CEST Sumitra Sharma wrote:
> generate_test_data() acquires a page with alloc_page(GFP_KERNEL). Pages
> allocated with GFP_KERNEL cannot come from Highmem. This is why
> there is no need to call kmap() on them.
> 
> Therefore, use a plain page_address() on that page.
> 
> Suggested-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> Signed-off-by: Sumitra Sharma <sumitraartsy@gmail.com>
> ---
> 
> Changes in v2:
> 	- Remove the kmap() call and call page_address() instead.

NIT: Give credit to whom asked you for this removal and explain why the 
mapping is not required.

> 	- Change the commit subject and message.
> 
>  lib/test_bpf.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/lib/test_bpf.c b/lib/test_bpf.c
> index ade9ac672adb..70fcd0bcf14b 100644
> --- a/lib/test_bpf.c
> +++ b/lib/test_bpf.c
> @@ -14388,11 +14388,10 @@ static void *generate_test_data(struct bpf_test
> *test, int sub) if (!page)
>  			goto err_kfree_skb;
> 
> -		ptr = kmap(page);
> +		ptr = page_address(page);
>  		if (!ptr)
>  			goto err_free_page;

What is the reason of this test? Could "ptr" ever be NULL? What is the code 
checking just few lines above this latter test?

Please, take a deeper look at this function as a whole.

Fabio

>  		memcpy(ptr, test->frag_data, MAX_DATA);
> -		kunmap(page);
>  		skb_add_rx_frag(skb, 0, page, 0, MAX_DATA, MAX_DATA);
>  	}
> 
> --
> 2.25.1





  reply	other threads:[~2023-06-18  5:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-13  7:17 [PATCH v2] lib/test_bpf: Call page_address() on page acquired with GFP_KERNEL flag Sumitra Sharma
2023-06-18  5:07 ` Fabio M. De Francesco [this message]
2023-06-22  5:13   ` Sumitra Sharma

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=3564297.R56niFO833@suse \
    --to=fmdefrancesco@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=drv@mailo.com \
    --cc=haoluo@google.com \
    --cc=ira.weiny@intel.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=sumitraartsy@gmail.com \
    --cc=yhs@fb.com \
    /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