All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <kch@nvidia.com>
To: <linux-block@vger.kernel.org>
Cc: <axboe@kernel.dk>, Chaitanya Kulkarni <kch@nvidia.com>
Subject: [PATCH 1/4] brd: use memcpy_to_page() in copy_to_brd()
Date: Tue, 28 Mar 2023 12:56:23 -0700	[thread overview]
Message-ID: <20230328195626.12075-2-kch@nvidia.com> (raw)
In-Reply-To: <20230328195626.12075-1-kch@nvidia.com>

In copy_to_brd() it uses kmap_atomic() call on the page in question to
create destination page mapping on buffer (dst), then it uses memcpy()
call to copy the data from source pointer onto mapped buffer (dst) with
added offset and size equals to number of bytes stored in copy variable.
Then it uses the kunmap_atomic(), also from :include/linux/highmem.h:

"kmap_atomic - Atomically map a page for temporary usage - Deprecated!"

Use memcpy_from_page() helper does the same job of mapping and copying
except it uses non deprecated kmap_local_page() and kunmap_local().

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/block/brd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 34177f1bd97d..91ab0a76a39f 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -197,9 +197,7 @@ static void copy_to_brd(struct brd_device *brd, const void *src,
 	page = brd_lookup_page(brd, sector);
 	BUG_ON(!page);
 
-	dst = kmap_atomic(page);
-	memcpy(dst + offset, src, copy);
-	kunmap_atomic(dst);
+	memcpy_to_page(page, offset, src, copy);
 
 	if (copy < n) {
 		src += copy;
-- 
2.29.0


  reply	other threads:[~2023-03-28 19:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-28 19:56 [PATCH 0/4] brd: usr memcpy_[to|from]_page() in brd Chaitanya Kulkarni
2023-03-28 19:56 ` Chaitanya Kulkarni [this message]
2023-03-28 19:56 ` [PATCH 2/4] brd: use memcpy_to_page() in copy_to_brd() Chaitanya Kulkarni
2023-03-28 19:56 ` [PATCH 3/4] brd: use memcpy_from_page() in copy_from_brd() Chaitanya Kulkarni
2023-03-28 19:56 ` [PATCH 4/4] " Chaitanya Kulkarni

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=20230328195626.12075-2-kch@nvidia.com \
    --to=kch@nvidia.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.