mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ira Weiny <ira.weiny@intel.com>
To: Sumitra Sharma <sumitraartsy@gmail.com>,
	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>
Cc: Ira Weiny <ira.weiny@intel.com>, Fabio <fmdefrancesco@gmail.com>,
	"Deepak R Varma" <drv@mailo.com>,
	Sumitra Sharma <sumitraartsy@gmail.com>
Subject: Re: [PATCH v3] lib/test_bpf: Call page_address() on page acquired with GFP_KERNEL flag
Date: Mon, 26 Jun 2023 13:36:28 -0700	[thread overview]
Message-ID: <6499f6cc97d6e_7517929478@iweiny-mobl.notmuch> (raw)
In-Reply-To: <20230622075244.GA426694@sumitra.com>

Sumitra Sharma wrote:
> generate_test_data() acquires a page with alloc_page(GFP_KERNEL).
> The GFP_KERNEL is typical for kernel-internal allocations.
> The caller requires ZONE_NORMAL or a lower zone for direct access.
> 
> Therefore the page cannot come from ZONE_HIGHMEM. Thus there's
> no need to map it with kmap().
> 
> Also, the kmap() is being deprecated in favor of
> kmap_local_page() [1].
> 
> Hence, use a plain page_address() directly.
> 
> Since the page passed to the page_address() is not from the highmem
> zone, the page_address() function will always return a valid kernel
> virtual address and will not return NULL. Hence, remove the check
> 'if (!ptr)'.
> 
> Remove the unused variable 'ptr'.
> 
> [1]: https://lore.kernel.org/all/20220813220034.806698-1-ira.weiny
> @intel.com/

Odd line break here which makes looking at this reference harder.

> 
> Suggested-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> Signed-off-by: Sumitra Sharma <sumitraartsy@gmail.com>

The code looks good though.

Reviewed-by: Ira Weiny <ira.weiny@intel.com>

> ---
> 
> - Link to v1: https://lore.kernel.org/bpf/20230613073020.GA359792@sumitra.com/T/
> - Link to v2: https://lore.kernel.org/lkml/3564297.R56niFO833@suse/T/
> 
> Changes in v3:
> Noted by: Fabio M. De Francesco<fmdefrancesco@gmail.com>
> 	- Remove the check 'if (!ptr)'.
> 	- Remove the unused variable 'ptr'.
> 	- Change the commit message.
> 
> Changes in v2:
> Noted by: Fabio M. De Francesco<fmdefrancesco@gmail.com>
> 	- Remove the kmap() call and call page_address() instead.
> 	- Change the commit subject and message.
> 
> 
>  lib/test_bpf.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/lib/test_bpf.c b/lib/test_bpf.c
> index ade9ac672adb..448bc1b0b8b5 100644
> --- a/lib/test_bpf.c
> +++ b/lib/test_bpf.c
> @@ -14381,18 +14381,12 @@ static void *generate_test_data(struct bpf_test *test, int sub)
>  		 * single fragment to the skb, filled with
>  		 * test->frag_data.
>  		 */
> -		void *ptr;
> -
>  		page = alloc_page(GFP_KERNEL);
>  
>  		if (!page)
>  			goto err_kfree_skb;
>  
> -		ptr = kmap(page);
> -		if (!ptr)
> -			goto err_free_page;
> -		memcpy(ptr, test->frag_data, MAX_DATA);
> -		kunmap(page);
> +		memcpy(page_address(page), test->frag_data, MAX_DATA);
>  		skb_add_rx_frag(skb, 0, page, 0, MAX_DATA, MAX_DATA);
>  	}
>  
> -- 
> 2.25.1
> 



  reply	other threads:[~2023-06-26 20:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-22  7:52 Sumitra Sharma
2023-06-26 20:36 ` Ira Weiny [this message]
2023-06-22  8:07 Sumitra Sharma
2023-06-22 22:00 ` kernel test robot

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=6499f6cc97d6e_7517929478@iweiny-mobl.notmuch \
    --to=ira.weiny@intel.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=drv@mailo.com \
    --cc=fmdefrancesco@gmail.com \
    --cc=haoluo@google.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

all inboxes | Powered by JetHome®