[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201124060755.1405602-17-ira.weiny@intel.com>
Date: Mon, 23 Nov 2020 22:07:54 -0800
From: ira.weiny@...el.com
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Ira Weiny <ira.weiny@...el.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Jérôme Glisse <jglisse@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Dave Hansen <dave.hansen@...el.com>,
Matthew Wilcox <willy@...radead.org>,
Christoph Hellwig <hch@...radead.org>,
Dan Williams <dan.j.williams@...el.com>,
Al Viro <viro@...iv.linux.org.uk>,
Eric Biggers <ebiggers@...nel.org>,
Luis Chamberlain <mcgrof@...nel.org>,
Patrik Jakobsson <patrik.r.jakobsson@...il.com>,
Jani Nikula <jani.nikula@...ux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@...el.com>,
David Howells <dhowells@...hat.com>, Chris Mason <clm@...com>,
Josef Bacik <josef@...icpanda.com>,
David Sterba <dsterba@...e.com>,
Steve French <sfrench@...ba.org>,
Jaegeuk Kim <jaegeuk@...nel.org>, Chao Yu <yuchao0@...wei.com>,
Nicolas Pitre <nico@...xnic.net>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
Brian King <brking@...ibm.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Kirti Wankhede <kwankhede@...dia.com>,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: [PATCH 16/17] lib: Use mempcy_to/from_page()
From: Ira Weiny <ira.weiny@...el.com>
Remove kmap/mem*()/kunmap pattern and use memcpy_to/from_page()
Cc: Alexei Starovoitov <ast@...nel.org>
Cc: Daniel Borkmann <daniel@...earbox.net>
Cc: "Jérôme Glisse" <jglisse@...hat.com>
Signed-off-by: Ira Weiny <ira.weiny@...el.com>
---
lib/test_bpf.c | 11 ++---------
lib/test_hmm.c | 10 ++--------
2 files changed, 4 insertions(+), 17 deletions(-)
diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index ca7d635bccd9..def048bc1c48 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -14,6 +14,7 @@
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/if_vlan.h>
+#include <linux/pagemap.h>
#include <linux/random.h>
#include <linux/highmem.h>
#include <linux/sched.h>
@@ -6499,25 +6500,17 @@ 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_to_page(page, 0, test->frag_data, MAX_DATA);
skb_add_rx_frag(skb, 0, page, 0, MAX_DATA, MAX_DATA);
}
return skb;
-err_free_page:
- __free_page(page);
err_kfree_skb:
kfree_skb(skb);
return NULL;
diff --git a/lib/test_hmm.c b/lib/test_hmm.c
index 80a78877bd93..6a5fe7c4088b 100644
--- a/lib/test_hmm.c
+++ b/lib/test_hmm.c
@@ -321,16 +321,13 @@ static int dmirror_do_read(struct dmirror *dmirror, unsigned long start,
for (pfn = start >> PAGE_SHIFT; pfn < (end >> PAGE_SHIFT); pfn++) {
void *entry;
struct page *page;
- void *tmp;
entry = xa_load(&dmirror->pt, pfn);
page = xa_untag_pointer(entry);
if (!page)
return -ENOENT;
- tmp = kmap(page);
- memcpy(ptr, tmp, PAGE_SIZE);
- kunmap(page);
+ memcpy_from_page(ptr, page, 0, PAGE_SIZE);
ptr += PAGE_SIZE;
bounce->cpages++;
@@ -390,16 +387,13 @@ static int dmirror_do_write(struct dmirror *dmirror, unsigned long start,
for (pfn = start >> PAGE_SHIFT; pfn < (end >> PAGE_SHIFT); pfn++) {
void *entry;
struct page *page;
- void *tmp;
entry = xa_load(&dmirror->pt, pfn);
page = xa_untag_pointer(entry);
if (!page || xa_pointer_tag(entry) != DPT_XA_TAG_WRITE)
return -ENOENT;
- tmp = kmap(page);
- memcpy(tmp, ptr, PAGE_SIZE);
- kunmap(page);
+ memcpy_to_page(page, 0, ptr, PAGE_SIZE);
ptr += PAGE_SIZE;
bounce->cpages++;
--
2.28.0.rc0.12.gb6a658bd00c9
Powered by blists - more mailing lists