[TCWG CI] Regression caused by linux: Merge tag 'folio-5.16' of git://git.infradead.org/users/willy/pagecache:
commit 49f8275c7d9247cf1dd4440fc8162f784252c849
Merge: 8bb7eca972ad 121703c1c817
Author: Linus Torvalds <torvalds(a)linux-foundation.org>
Merge tag 'folio-5.16' of git://git.infradead.org/users/willy/pagecache
Results regressed to
# reset_artifacts:
-10
# build_abe binutils:
-9
# build_abe stage1:
-5
# build_abe qemu:
-2
# linux_n_obj:
37
# First few build errors in logs:
# 00:00:56 ./include/linux/page-flags.h:806:29: error: macro requires 2 arguments, but only 1 given
# 00:00:56 ./include/linux/page-flags.h:807:39: error: macro requires 2 arguments, but only 1 given
# 00:00:56 ./include/linux/page-flags.h:806:1: error: unknown type name ‘PAGEFLAG_FALSE’
# 00:00:56 ./include/linux/page-flags.h:807:25: error: expected ‘;’ before ‘static’
# 00:00:56 make[1]: *** [arch/arm/kernel/asm-offsets.s] Error 1
# 00:00:56 make: *** [prepare0] Error 2
from
# reset_artifacts:
-10
# build_abe binutils:
-9
# build_abe stage1:
-5
# build_abe qemu:
-2
# linux_n_obj:
29920
# linux build successful:
all
THIS IS THE END OF INTERESTING STUFF. BELOW ARE LINKS TO BUILDS, REPRODUCTION INSTRUCTIONS, AND THE RAW COMMIT.
This commit has regressed these CI configurations:
- tcwg_kernel/gnu-release-arm-mainline-allmodconfig
First_bad build: https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-arm-mainline-a…
Last_good build: https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-arm-mainline-a…
Baseline build: https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-arm-mainline-a…
Even more details: https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-arm-mainline-a…
Reproduce builds:
<cut>
mkdir investigate-linux-49f8275c7d9247cf1dd4440fc8162f784252c849
cd investigate-linux-49f8275c7d9247cf1dd4440fc8162f784252c849
# Fetch scripts
git clone https://git.linaro.org/toolchain/jenkins-scripts
# Fetch manifests and test.sh script
mkdir -p artifacts/manifests
curl -o artifacts/manifests/build-baseline.sh https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-arm-mainline-a… --fail
curl -o artifacts/manifests/build-parameters.sh https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-arm-mainline-a… --fail
curl -o artifacts/test.sh https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-arm-mainline-a… --fail
chmod +x artifacts/test.sh
# Reproduce the baseline build (build all pre-requisites)
./jenkins-scripts/tcwg_kernel-build.sh @@ artifacts/manifests/build-baseline.sh
# Save baseline build state (which is then restored in artifacts/test.sh)
mkdir -p ./bisect
rsync -a --del --delete-excluded --exclude /bisect/ --exclude /artifacts/ --exclude /linux/ ./ ./bisect/baseline/
cd linux
# Reproduce first_bad build
git checkout --detach 49f8275c7d9247cf1dd4440fc8162f784252c849
../artifacts/test.sh
# Reproduce last_good build
git checkout --detach 8bb7eca972ad531c9b149c0a51ab43a417385813
../artifacts/test.sh
cd ..
</cut>
Full commit (up to 1000 lines):
<cut>
commit 49f8275c7d9247cf1dd4440fc8162f784252c849
Merge: 8bb7eca972ad 121703c1c817
Author: Linus Torvalds <torvalds(a)linux-foundation.org>
Date: Mon Nov 1 08:47:59 2021 -0700
Merge tag 'folio-5.16' of git://git.infradead.org/users/willy/pagecache
Pull memory folios from Matthew Wilcox:
"Add memory folios, a new type to represent either order-0 pages or the
head page of a compound page. This should be enough infrastructure to
support filesystems converting from pages to folios.
The point of all this churn is to allow filesystems and the page cache
to manage memory in larger chunks than PAGE_SIZE. The original plan
was to use compound pages like THP does, but I ran into problems with
some functions expecting only a head page while others expect the
precise page containing a particular byte.
The folio type allows a function to declare that it's expecting only a
head page. Almost incidentally, this allows us to remove various calls
to VM_BUG_ON(PageTail(page)) and compound_head().
This converts just parts of the core MM and the page cache. For 5.17,
we intend to convert various filesystems (XFS and AFS are ready; other
filesystems may make it) and also convert more of the MM and page
cache to folios. For 5.18, multi-page folios should be ready.
The multi-page folios offer some improvement to some workloads. The
80% win is real, but appears to be an artificial benchmark (postgres
startup, which isn't a serious workload). Real workloads (eg building
the kernel, running postgres in a steady state, etc) seem to benefit
between 0-10%. I haven't heard of any performance losses as a result
of this series. Nobody has done any serious performance tuning; I
imagine that tweaking the readahead algorithm could provide some more
interesting wins. There are also other places where we could choose to
create large folios and currently do not, such as writes that are
larger than PAGE_SIZE.
I'd like to thank all my reviewers who've offered review/ack tags:
Christoph Hellwig, David Howells, Jan Kara, Jeff Layton, Johannes
Weiner, Kirill A. Shutemov, Michal Hocko, Mike Rapoport, Vlastimil
Babka, William Kucharski, Yu Zhao and Zi Yan.
I'd also like to thank those who gave feedback I incorporated but
haven't offered up review tags for this part of the series: Nick
Piggin, Mel Gorman, Ming Lei, Darrick Wong, Ted Ts'o, John Hubbard,
Hugh Dickins, and probably a few others who I forget"
* tag 'folio-5.16' of git://git.infradead.org/users/willy/pagecache: (90 commits)
mm/writeback: Add folio_write_one
mm/filemap: Add FGP_STABLE
mm/filemap: Add filemap_get_folio
mm/filemap: Convert mapping_get_entry to return a folio
mm/filemap: Add filemap_add_folio()
mm/filemap: Add filemap_alloc_folio
mm/page_alloc: Add folio allocation functions
mm/lru: Add folio_add_lru()
mm/lru: Convert __pagevec_lru_add_fn to take a folio
mm: Add folio_evictable()
mm/workingset: Convert workingset_refault() to take a folio
mm/filemap: Add readahead_folio()
mm/filemap: Add folio_mkwrite_check_truncate()
mm/filemap: Add i_blocks_per_folio()
mm/writeback: Add folio_redirty_for_writepage()
mm/writeback: Add folio_account_redirty()
mm/writeback: Add folio_clear_dirty_for_io()
mm/writeback: Add folio_cancel_dirty()
mm/writeback: Add folio_account_cleaned()
mm/writeback: Add filemap_dirty_folio()
...
Documentation/core-api/cachetlb.rst | 6 +
Documentation/core-api/mm-api.rst | 5 +
Documentation/filesystems/netfs_library.rst | 2 +
arch/arc/include/asm/cacheflush.h | 1 +
arch/arm/include/asm/cacheflush.h | 1 +
arch/m68k/include/asm/cacheflush_mm.h | 1 +
arch/mips/include/asm/cacheflush.h | 2 +
arch/nds32/include/asm/cacheflush.h | 1 +
arch/nios2/include/asm/cacheflush.h | 3 +-
arch/parisc/include/asm/cacheflush.h | 3 +-
arch/sh/include/asm/cacheflush.h | 3 +-
arch/xtensa/include/asm/cacheflush.h | 5 +-
fs/afs/write.c | 9 +-
fs/cachefiles/rdwr.c | 16 +-
fs/io_uring.c | 2 +-
fs/jfs/jfs_metapage.c | 1 +
include/asm-generic/cacheflush.h | 6 +
include/linux/backing-dev.h | 6 +-
include/linux/flex_proportions.h | 9 +-
include/linux/gfp.h | 22 +-
include/linux/highmem-internal.h | 11 +
include/linux/highmem.h | 37 ++
include/linux/huge_mm.h | 15 -
include/linux/ksm.h | 4 +-
include/linux/memcontrol.h | 264 ++++++++-----
include/linux/migrate.h | 4 +
include/linux/mm.h | 239 +++++++++---
include/linux/mm_inline.h | 103 +++--
include/linux/mm_types.h | 77 ++++
include/linux/mmdebug.h | 20 +
include/linux/netfs.h | 77 ++--
include/linux/page-flags.h | 267 +++++++++----
include/linux/page_idle.h | 99 +++--
include/linux/page_owner.h | 8 +-
include/linux/page_ref.h | 158 +++++++-
include/linux/pagemap.h | 585 ++++++++++++++++++----------
include/linux/rmap.h | 10 +-
include/linux/swap.h | 17 +-
include/linux/vmstat.h | 113 +++++-
include/linux/writeback.h | 9 +-
include/trace/events/pagemap.h | 46 ++-
include/trace/events/writeback.h | 28 +-
kernel/bpf/verifier.c | 2 +-
kernel/events/uprobes.c | 3 +-
lib/flex_proportions.c | 28 +-
mm/Makefile | 2 +-
mm/compaction.c | 4 +-
mm/filemap.c | 567 +++++++++++++--------------
mm/folio-compat.c | 142 +++++++
mm/huge_memory.c | 7 +-
mm/hugetlb.c | 2 +-
mm/internal.h | 36 +-
mm/khugepaged.c | 8 +-
mm/ksm.c | 34 +-
mm/memcontrol.c | 356 +++++++++--------
mm/memory-failure.c | 2 +-
mm/memory.c | 20 +-
mm/mempolicy.c | 10 +
mm/memremap.c | 2 +-
mm/migrate.c | 189 +++++----
mm/mlock.c | 3 +-
mm/page-writeback.c | 476 ++++++++++++----------
mm/page_alloc.c | 14 +-
mm/page_io.c | 4 +-
mm/page_owner.c | 10 +-
mm/rmap.c | 14 +-
mm/shmem.c | 7 +-
mm/swap.c | 197 +++++-----
mm/swap_state.c | 2 +-
mm/swapfile.c | 8 +-
mm/userfaultfd.c | 2 +-
mm/util.c | 111 +++---
mm/vmscan.c | 8 +-
mm/workingset.c | 52 +--
74 files changed, 2914 insertions(+), 1703 deletions(-)
diff --cc include/linux/page-flags.h
index fbfd3fad48f2,a68af80649a4..d8623d6e1141
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@@ -669,28 -776,14 +785,28 @@@ static inline int PageTransTail(struct
PAGEFLAG(DoubleMap, double_map, PF_SECOND)
TESTSCFLAG(DoubleMap, double_map, PF_SECOND)
#else
- TESTPAGEFLAG_FALSE(TransHuge)
- TESTPAGEFLAG_FALSE(TransCompound)
- TESTPAGEFLAG_FALSE(TransCompoundMap)
- TESTPAGEFLAG_FALSE(TransTail)
- PAGEFLAG_FALSE(DoubleMap)
- TESTSCFLAG_FALSE(DoubleMap)
+ TESTPAGEFLAG_FALSE(TransHuge, transhuge)
+ TESTPAGEFLAG_FALSE(TransCompound, transcompound)
+ TESTPAGEFLAG_FALSE(TransCompoundMap, transcompoundmap)
+ TESTPAGEFLAG_FALSE(TransTail, transtail)
+ PAGEFLAG_FALSE(DoubleMap, double_map)
+ TESTSCFLAG_FALSE(DoubleMap, double_map)
#endif
+#if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_TRANSPARENT_HUGEPAGE)
+/*
+ * PageHasHWPoisoned indicates that at least one subpage is hwpoisoned in the
+ * compound page.
+ *
+ * This flag is set by hwpoison handler. Cleared by THP split or free page.
+ */
+PAGEFLAG(HasHWPoisoned, has_hwpoisoned, PF_SECOND)
+ TESTSCFLAG(HasHWPoisoned, has_hwpoisoned, PF_SECOND)
+#else
+PAGEFLAG_FALSE(HasHWPoisoned)
+ TESTSCFLAG_FALSE(HasHWPoisoned)
+#endif
+
/*
* Check if a page is currently marked HWPoisoned. Note that this check is
* best effort only and inherently racy: there is no way to synchronize with
diff --cc mm/huge_memory.c
index c5142d237e48,e5ea5f775d5c..e5483347291c
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@@ -2424,10 -2425,8 +2425,10 @@@ static void __split_huge_page(struct pa
}
/* lock lru list/PageCompound, ref frozen by page_ref_freeze */
- lruvec = lock_page_lruvec(head);
+ lruvec = folio_lruvec_lock(folio);
+ ClearPageHasHWPoisoned(head);
+
for (i = nr - 1; i >= 1; i--) {
__split_huge_page_tail(head, i, lruvec, list);
/* Some pages can be beyond EOF: drop them from page cache */
</cut>
[TCWG CI] Regression caused by linux: btrfs: rework lzo_compress_pages() to make it subpage compatible:
commit 0078783c7089fc83f0072066b23908120d7990e9
Author: Qu Wenruo <wqu(a)suse.com>
btrfs: rework lzo_compress_pages() to make it subpage compatible
Results regressed to
# reset_artifacts:
-10
# build_abe binutils:
-9
# build_abe stage1:
-5
# build_abe qemu:
-2
# linux_n_obj:
19814
# First few build errors in logs:
# 00:31:06 lzo.c:(.text+0x79c): undefined reference to `__aeabi_uldivmod'
# 00:31:06 arm-linux-gnueabihf-ld: lzo.c:(.text+0xb2c): undefined reference to `__aeabi_uldivmod'
# 00:31:06 arm-linux-gnueabihf-ld: lzo.c:(.text+0xb78): undefined reference to `__aeabi_uldivmod'
# 00:31:14 make: *** [vmlinux] Error 1
from
# reset_artifacts:
-10
# build_abe binutils:
-9
# build_abe stage1:
-5
# build_abe qemu:
-2
# linux_n_obj:
19899
# linux build successful:
all
THIS IS THE END OF INTERESTING STUFF. BELOW ARE LINKS TO BUILDS, REPRODUCTION INSTRUCTIONS, AND THE RAW COMMIT.
This commit has regressed these CI configurations:
- tcwg_kernel/gnu-release-arm-next-allyesconfig
First_bad build: https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-arm-next-allye…
Last_good build: https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-arm-next-allye…
Baseline build: https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-arm-next-allye…
Even more details: https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-arm-next-allye…
Reproduce builds:
<cut>
mkdir investigate-linux-0078783c7089fc83f0072066b23908120d7990e9
cd investigate-linux-0078783c7089fc83f0072066b23908120d7990e9
# Fetch scripts
git clone https://git.linaro.org/toolchain/jenkins-scripts
# Fetch manifests and test.sh script
mkdir -p artifacts/manifests
curl -o artifacts/manifests/build-baseline.sh https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-arm-next-allye… --fail
curl -o artifacts/manifests/build-parameters.sh https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-arm-next-allye… --fail
curl -o artifacts/test.sh https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-arm-next-allye… --fail
chmod +x artifacts/test.sh
# Reproduce the baseline build (build all pre-requisites)
./jenkins-scripts/tcwg_kernel-build.sh @@ artifacts/manifests/build-baseline.sh
# Save baseline build state (which is then restored in artifacts/test.sh)
mkdir -p ./bisect
rsync -a --del --delete-excluded --exclude /bisect/ --exclude /artifacts/ --exclude /linux/ ./ ./bisect/baseline/
cd linux
# Reproduce first_bad build
git checkout --detach 0078783c7089fc83f0072066b23908120d7990e9
../artifacts/test.sh
# Reproduce last_good build
git checkout --detach d116c176e6e20f3ac111e7e6d1dd0e56d0e4eda7
../artifacts/test.sh
cd ..
</cut>
Full commit (up to 1000 lines):
<cut>
commit 0078783c7089fc83f0072066b23908120d7990e9
Author: Qu Wenruo <wqu(a)suse.com>
Date: Mon Sep 27 15:22:04 2021 +0800
btrfs: rework lzo_compress_pages() to make it subpage compatible
There are several problems in lzo_compress_pages() preventing it from
being subpage compatible:
- No page offset is calculated when reading from inode pages
For subpage case, we could have @start which is not aligned to
PAGE_SIZE.
Thus the destination where we read data from must take offset in page
into consideration.
- The padding for segment header is bound to PAGE_SIZE
This means, for subpage case we can skip several corners where on x86
machines we need to add padding zeros.
The rework will:
- Update the comment to replace "page" with "sector"
- Introduce a new helper, copy_compressed_data_to_page(), to do the copy
So that we don't need to bother page switches for both input and
output.
Now in lzo_compress_pages() we only care about page switching for
input, while in copy_compressed_data_to_page() we only care the page
switching for output.
- Only one main cursor
For lzo_compress_pages() we use @cur_in as main curor.
It will be the file offset we are currently at.
All other helper variables will be only declared inside the loop.
For copy_compressed_data_to_page() it's similar, we will have
@cur_out at the main cursor, which records how many bytes are in the
output.
- Get rid of kmap()/kunmap()
Instead of using __GFP_HIGHMEM and needs to do kmap()/kunmap(), just
get rid of that GFP flag, so we can use page_address() and never
bother the kmap()/kunmap() thing.
Signed-off-by: Qu Wenruo <wqu(a)suse.com>
Signed-off-by: David Sterba <dsterba(a)suse.com>
---
fs/btrfs/lzo.c | 270 ++++++++++++++++++++++++++++-----------------------------
1 file changed, 134 insertions(+), 136 deletions(-)
diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c
index c25dfd1a8a54..47003cec4046 100644
--- a/fs/btrfs/lzo.c
+++ b/fs/btrfs/lzo.c
@@ -32,19 +32,19 @@
* payload.
* One regular LZO compressed extent can have one or more segments.
* For inlined LZO compressed extent, only one segment is allowed.
- * One segment represents at most one page of uncompressed data.
+ * One segment represents at most one sector of uncompressed data.
*
* 2.1 Segment header
* Fixed size. LZO_LEN (4) bytes long, LE32.
* Records the total size of the segment (not including the header).
- * Segment header never crosses page boundary, thus it's possible to
- * have at most 3 padding zeros at the end of the page.
+ * Segment header never crosses sector boundary, thus it's possible to
+ * have at most 3 padding zeros at the end of the sector.
*
* 2.2 Data Payload
- * Variable size. Size up limit should be lzo1x_worst_compress(PAGE_SIZE)
- * which is 4419 for a 4KiB page.
+ * Variable size. Size up limit should be lzo1x_worst_compress(sectorsize)
+ * which is 4419 for a 4KiB sectorsize.
*
- * Example:
+ * Example with 4K sectorsize:
* Page 1:
* 0 0x2 0x4 0x6 0x8 0xa 0xc 0xe 0x10
* 0x0000 | Header | SegHdr 01 | Data payload 01 ... |
@@ -112,163 +112,161 @@ static inline size_t read_compress_length(const char *buf)
return le32_to_cpu(dlen);
}
+/*
+ * Will do:
+ *
+ * - Write a segment header into the destination
+ * - Copy the compressed buffer into the destination
+ * - Make sure we have enough space in the last sector to fit a segment header
+ * If not, we will pad at most (LZO_LEN (4)) - 1 bytes of zeros.
+ *
+ * Will allocate new pages when needed.
+ */
+static int copy_compressed_data_to_page(char *compressed_data,
+ size_t compressed_size,
+ struct page **out_pages,
+ u32 *cur_out,
+ const u32 sectorsize)
+{
+ u32 sector_bytes_left;
+ u32 orig_out;
+ struct page *cur_page;
+
+ /*
+ * We never allow a segment header crossing sector boundary, previous
+ * run should ensure we have enough space left inside the sector.
+ */
+ ASSERT((*cur_out / sectorsize) ==
+ (*cur_out + LZO_LEN - 1) / sectorsize);
+
+ cur_page = out_pages[*cur_out / PAGE_SIZE];
+ /* Allocate a new page */
+ if (!cur_page) {
+ cur_page = alloc_page(GFP_NOFS);
+ if (!cur_page)
+ return -ENOMEM;
+ out_pages[*cur_out / PAGE_SIZE] = cur_page;
+ }
+
+ write_compress_length(page_address(cur_page) + offset_in_page(*cur_out),
+ compressed_size);
+ *cur_out += LZO_LEN;
+
+ orig_out = *cur_out;
+
+ /* Copy compressed data */
+ while (*cur_out - orig_out < compressed_size) {
+ u32 copy_len = min_t(u32, sectorsize - *cur_out % sectorsize,
+ orig_out + compressed_size - *cur_out);
+
+ cur_page = out_pages[*cur_out / PAGE_SIZE];
+ /* Allocate a new page */
+ if (!cur_page) {
+ cur_page = alloc_page(GFP_NOFS);
+ if (!cur_page)
+ return -ENOMEM;
+ out_pages[*cur_out / PAGE_SIZE] = cur_page;
+ }
+
+ memcpy(page_address(cur_page) + offset_in_page(*cur_out),
+ compressed_data + *cur_out - orig_out, copy_len);
+
+ *cur_out += copy_len;
+ }
+
+ /*
+ * Check if we can fit the next segment header into the remaining space
+ * of the sector.
+ */
+ sector_bytes_left = round_up(*cur_out, sectorsize) - *cur_out;
+ if (sector_bytes_left >= LZO_LEN || sector_bytes_left == 0)
+ return 0;
+
+ /* The remaining size is not enough, pad it with zeros */
+ memset(page_address(cur_page) + offset_in_page(*cur_out), 0,
+ sector_bytes_left);
+ *cur_out += sector_bytes_left;
+ return 0;
+}
+
int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
u64 start, struct page **pages, unsigned long *out_pages,
unsigned long *total_in, unsigned long *total_out)
{
struct workspace *workspace = list_entry(ws, struct workspace, list);
+ const u32 sectorsize = btrfs_sb(mapping->host->i_sb)->sectorsize;
+ struct page *page_in = NULL;
int ret = 0;
- char *data_in;
- char *cpage_out, *sizes_ptr;
- int nr_pages = 0;
- struct page *in_page = NULL;
- struct page *out_page = NULL;
- unsigned long bytes_left;
- unsigned long len = *total_out;
- unsigned long nr_dest_pages = *out_pages;
- const unsigned long max_out = nr_dest_pages * PAGE_SIZE;
- size_t in_len;
- size_t out_len;
- char *buf;
- unsigned long tot_in = 0;
- unsigned long tot_out = 0;
- unsigned long pg_bytes_left;
- unsigned long out_offset;
- unsigned long bytes;
+ u64 cur_in = start; /* Points to the file offset of input data */
+ u32 cur_out = 0; /* Points to the current output byte */
+ u32 len = *total_out;
*out_pages = 0;
*total_out = 0;
*total_in = 0;
- in_page = find_get_page(mapping, start >> PAGE_SHIFT);
- data_in = page_address(in_page);
-
/*
- * store the size of all chunks of compressed data in
- * the first 4 bytes
+ * Skip the header for now, we will later come back and write the total
+ * compressed size
*/
- out_page = alloc_page(GFP_NOFS);
- if (out_page == NULL) {
- ret = -ENOMEM;
- goto out;
- }
- cpage_out = page_address(out_page);
- out_offset = LZO_LEN;
- tot_out = LZO_LEN;
- pages[0] = out_page;
- nr_pages = 1;
- pg_bytes_left = PAGE_SIZE - LZO_LEN;
-
- /* compress at most one page of data each time */
- in_len = min(len, PAGE_SIZE);
- while (tot_in < len) {
- ret = lzo1x_1_compress(data_in, in_len, workspace->cbuf,
- &out_len, workspace->mem);
- if (ret != LZO_E_OK) {
- pr_debug("BTRFS: lzo in loop returned %d\n",
- ret);
+ cur_out += LZO_LEN;
+ while (cur_in < start + len) {
+ u32 sector_off = (cur_in - start) % sectorsize;
+ u32 in_len;
+ size_t out_len;
+
+ /* Get the input page first */
+ if (!page_in) {
+ page_in = find_get_page(mapping, cur_in >> PAGE_SHIFT);
+ ASSERT(page_in);
+ }
+
+ /* Compress at most one sector of data each time */
+ in_len = min_t(u32, start + len - cur_in,
+ sectorsize - sector_off);
+ ASSERT(in_len);
+ ret = lzo1x_1_compress(page_address(page_in) +
+ offset_in_page(cur_in), in_len,
+ workspace->cbuf, &out_len,
+ workspace->mem);
+ if (ret < 0) {
+ pr_debug("BTRFS: lzo in loop returned %d\n", ret);
ret = -EIO;
goto out;
}
- /* store the size of this chunk of compressed data */
- write_compress_length(cpage_out + out_offset, out_len);
- tot_out += LZO_LEN;
- out_offset += LZO_LEN;
- pg_bytes_left -= LZO_LEN;
-
- tot_in += in_len;
- tot_out += out_len;
-
- /* copy bytes from the working buffer into the pages */
- buf = workspace->cbuf;
- while (out_len) {
- bytes = min_t(unsigned long, pg_bytes_left, out_len);
-
- memcpy(cpage_out + out_offset, buf, bytes);
-
- out_len -= bytes;
- pg_bytes_left -= bytes;
- buf += bytes;
- out_offset += bytes;
-
- /*
- * we need another page for writing out.
- *
- * Note if there's less than 4 bytes left, we just
- * skip to a new page.
- */
- if ((out_len == 0 && pg_bytes_left < LZO_LEN) ||
- pg_bytes_left == 0) {
- if (pg_bytes_left) {
- memset(cpage_out + out_offset, 0,
- pg_bytes_left);
- tot_out += pg_bytes_left;
- }
-
- /* we're done, don't allocate new page */
- if (out_len == 0 && tot_in >= len)
- break;
-
- if (nr_pages == nr_dest_pages) {
- out_page = NULL;
- ret = -E2BIG;
- goto out;
- }
-
- out_page = alloc_page(GFP_NOFS);
- if (out_page == NULL) {
- ret = -ENOMEM;
- goto out;
- }
- cpage_out = page_address(out_page);
- pages[nr_pages++] = out_page;
-
- pg_bytes_left = PAGE_SIZE;
- out_offset = 0;
- }
- }
+ ret = copy_compressed_data_to_page(workspace->cbuf, out_len,
+ pages, &cur_out, sectorsize);
+ if (ret < 0)
+ goto out;
+
+ cur_in += in_len;
- /* we're making it bigger, give up */
- if (tot_in > 8192 && tot_in < tot_out) {
+ /*
+ * Check if we're making it bigger after two sectors.
+ * And if we're making it bigger, give up.
+ */
+ if (cur_in - start > sectorsize * 2 &&
+ cur_in - start < cur_out) {
ret = -E2BIG;
goto out;
}
- /* we're all done */
- if (tot_in >= len)
- break;
-
- if (tot_out > max_out)
- break;
-
- bytes_left = len - tot_in;
- put_page(in_page);
-
- start += PAGE_SIZE;
- in_page = find_get_page(mapping, start >> PAGE_SHIFT);
- data_in = page_address(in_page);
- in_len = min(bytes_left, PAGE_SIZE);
- }
-
- if (tot_out >= tot_in) {
- ret = -E2BIG;
- goto out;
+ /* Check if we have reached page boundary */
+ if (IS_ALIGNED(cur_in, PAGE_SIZE)) {
+ put_page(page_in);
+ page_in = NULL;
+ }
}
- /* store the size of all chunks of compressed data */
- sizes_ptr = page_address(pages[0]);
- write_compress_length(sizes_ptr, tot_out);
+ /* Store the size of all chunks of compressed data */
+ write_compress_length(page_address(pages[0]), cur_out);
ret = 0;
- *total_out = tot_out;
- *total_in = tot_in;
+ *total_out = cur_out;
+ *total_in = cur_in - start;
out:
- *out_pages = nr_pages;
-
- if (in_page)
- put_page(in_page);
-
+ *out_pages = DIV_ROUND_UP(cur_out, PAGE_SIZE);
return ret;
}
</cut>
Qualcomm crypto engine is also available on sm8250 SoC.
It supports hardware accelerated algorithms for encryption
and authentication. It also provides support for aes, des, 3des
encryption algorithms and sha1, sha256, hmac(sha1), hmac(sha256)
authentication algorithms.
While at it, also make a minor fix in 'sdm845.dtsi', to make
sure it confirms with the other .dtsi files which expose
crypto nodes on qcom SoCs.
Cc: Thara Gopinath <thara.gopinath(a)linaro.org>
Cc: Bjorn Andersson <bjorn.andersson(a)linaro.org>
Cc: Rob Herring <robh+dt(a)kernel.org>
Cc: Andy Gross <agross(a)kernel.org>
Cc: Herbert Xu <herbert(a)gondor.apana.org.au>
Cc: David S. Miller <davem(a)davemloft.net>
Cc: Stephen Boyd <sboyd(a)kernel.org>
Cc: Michael Turquette <mturquette(a)baylibre.com>
Cc: linux-clk(a)vger.kernel.org
Cc: linux-crypto(a)vger.kernel.org
Cc: devicetree(a)vger.kernel.org
Cc: linux-kernel(a)vger.kernel.org
Cc: bhupesh.linux(a)gmail.com
Bhupesh Sharma (8):
dt-bindings: qcom-qce: Add 'iommus' to required properties
dt-bindings: crypto : Add new compatible strings for qcom-qce
arm64/dts: qcom: sdm845: Use RPMH_CE_CLK macro directly
dt-bindings/clock: qcom: sm8250: Add gcc clocks for sm8250 crypto
block
clk: qcom: clk-rpmh: Add CE clock on sm8250
clk: qcom: Add gcc clocks for crypto block on sm8250
drivers: crypto: qce: Enable support for crypto engine on sm8250.
arm64/dts: qcom: sm8250: Add dt entries to support crypto engine.
.../devicetree/bindings/crypto/qcom-qce.txt | 7 ++-
arch/arm64/boot/dts/qcom/sdm845.dtsi | 4 +-
arch/arm64/boot/dts/qcom/sm8250.dtsi | 36 +++++++++++++++
drivers/clk/qcom/clk-rpmh.c | 1 +
drivers/clk/qcom/gcc-sm8250.c | 44 +++++++++++++++++++
drivers/crypto/qce/core.c | 1 +
include/dt-bindings/clock/qcom,gcc-sm8250.h | 3 ++
7 files changed, 93 insertions(+), 3 deletions(-)
--
2.29.2