aboutsummaryrefslogtreecommitdiff
path: root/en/devices/architecture/kernel/squashfs.html
diff options
context:
space:
mode:
authorAndroid Partner Docs <noreply@android.com>2017-08-22 10:41:24 -0700
committerClay Murphy <claym@google.com>2017-08-22 15:01:44 -0700
commitf16c42333aa6b2de30a344dd68246d4a33d93e7d (patch)
tree311af599312cacb21c888aeae828cae59b0d64a1 /en/devices/architecture/kernel/squashfs.html
parent04426e67ca3ee557a0083f9b3c6ba789021bd7a0 (diff)
downloadsource.android.com-f16c42333aa6b2de30a344dd68246d4a33d93e7d.tar.gz
Docs: Changes to source.android.com
- 166080694 Devsite localized content from translation request a3d5a7... by Android Partner Docs <noreply@android.com> - 166079245 Remove duplicate TOC entry to oob-users.html. by mheco <mheco@google.com> - 166002955 Update builds for Oreo by Android Partner Docs <noreply@android.com> - 165977566 Fixing bad conversion by hvm <hvm@google.com> - 165977199 Edit links to point to public source files in AOSP. by cqn <cqn@google.com> - 165962883 Add codename to CTS downloads page. by gdimino <gdimino@google.com> - 165955117 Integration of O branch into mainline. by gdimino <gdimino@google.com> - 165638251 Update July public Android security bulletin to remove QC... by Android Partner Docs <noreply@android.com> - 165638198 Update June public Android security bulletin to remove QC... by Android Partner Docs <noreply@android.com> - 165638174 Update May public Android security bulletin to remove QC ... by Android Partner Docs <noreply@android.com> - 165638096 Update April public Android security bulletin to remove Q... by Android Partner Docs <noreply@android.com> - 165528993 Update to Keymaster 2 and remove requirements language by daroberts <daroberts@google.com> - 165511119 Add Bluetooth verification / debug information by cqn <cqn@google.com> - 165491345 Fixed link broken by file rename. by cqn <cqn@google.com> - 165381648 Fixed broken image paths and renamed HCI Requirements file. by cqn <cqn@google.com> - 165365185 Created high-level Bluetooth directory and added HTML ver... by cqn <cqn@google.com> - 165335694 Devsite localized content from translation request 66a39c... by Android Partner Docs <noreply@android.com> - 165246927 Update August 2017 bulletin with CVE-2017-0687 by daroberts <daroberts@google.com> PiperOrigin-RevId: 166080694 Change-Id: I2d3a8d77fa6a66c2099f13ba2e864545328fd17a
Diffstat (limited to 'en/devices/architecture/kernel/squashfs.html')
-rw-r--r--en/devices/architecture/kernel/squashfs.html114
1 files changed, 114 insertions, 0 deletions
diff --git a/en/devices/architecture/kernel/squashfs.html b/en/devices/architecture/kernel/squashfs.html
new file mode 100644
index 00000000..93b97ad0
--- /dev/null
+++ b/en/devices/architecture/kernel/squashfs.html
@@ -0,0 +1,114 @@
+<html devsite>
+ <head>
+ <title>Optimizing SquashFS at the Kernel Level</title>
+ <meta name="project_path" value="/_project.yaml" />
+ <meta name="book_path" value="/_book.yaml" />
+ </head>
+ <body>
+ <!--
+ Copyright 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+ <p>
+ SquashFS is a compressed read-only filesystem for Linux. The file system is
+ read-only by design and thus suitable for use on the system partition. Many
+ Android devices may benefit from using this file system for their system
+ partition, for example, the following:
+ </p><ul>
+ <li>Devices with a low capacity storage such as Android Watch.
+ <li>Devices with a slow flash storage (compression reduces the number of block
+ I/Os).</li></ul>
+ <p>
+ Unfortunately the performance of SquashFS lags behind ext4.
+ </p>
+ <h2 id="optimizations">Optimizations</h2>
+ <p>
+ The following optimizations have been implemented to improve the performance of
+ SquashFS.
+ </p>
+ <h3 id="reduce-the-memory-usage-and-memcpy">Reduce the memory usage and
+ memcpy</h3>
+ <p>
+ When reading a block (default 128K), SquashFS tries to grab all the pages
+ covering this block.
+ </p>
+ <p>
+ If a single page is up-to-date or locked, it falls back to allocating a full
+ block, submitting a read request, and then copying its content to the pages.
+ </p>
+ <p>
+ This approach is very ineffective; after some time the page cache is likely to
+ contain pages that are up-to-date even if the adjacent pages are not.
+ </p>
+ <p>
+ The code is now able to handle blocks with holes (=missing pages). This
+ improves performance in the following ways:
+ </p><ul>
+ <li>Reduces the number of <code>memcpy</code> calls
+ <li>Decreases memory allocations</li></ul>
+ <h3 id="asynchronous-reads">Asynchronous reads</h3>
+ <p>
+ SquashFS still uses the deprecated <code>ll_rw_block()</code> function. There
+ are two problems with this approach:
+ </p><ul>
+ <li>As the name implies, the function waits for the reads to complete before
+ returning. This is redundant since <code>.readpage()</code> already waits on the
+ page's lock. Moreover, we need an asynchronous mechanism to efficiently
+ implement <code>.readpages()</code>.
+ <li>Merging the read requests entirely depends on the I/O scheduler.
+ <code>ll_rw_block()</code> simply creates one request per buffer. SquashFS has
+ more information than the I/O scheduler about what should be merged. Moreover,
+ merging the request means that we rely less on the I/O scheduler.</li></ul>
+ <p>
+ For these reasons, the <code>ll_rw_block()</code> function has been replaced
+ with <code>submit_bio()</code>.
+ </p>
+ <h3 id="readpages-prefetching">Readpages (prefetching)</h3>
+ <p>
+ SquashFS does not implement <code>.readpages()</code>, so the kernel repeatedly
+ calls <code>.readpage()</code>.
+ </p>
+ <p>
+ Now that our read requests are asynchronous, the kernel can truly prefetch pages
+ using its asynchronous read-ahead mechanism.
+ </p>
+ <h3 id="optimize-reading-uncompressed-blocks">Optimize reading uncompressed
+ blocks</h3>
+ <p>
+ Modern systems such as Android contain a lot of files that are already
+ compressed. As a consequence, the image contains a lot of blocks that can't be
+ compressed.
+ </p>
+ <p>
+ SquashFS handles compressed and uncompressed blocks using the same logic: when
+ asked to read a single page, it actually reads a full block (default 128k).
+ While this is necessary for compressed blocks, it is just a waste of resources
+ for uncompressed blocks.
+ </p>
+ <p>
+ Instead of reading a full block, SquashFS now just reads what is advised by the
+ readahead algorithm.
+ </p>
+ <p>
+ This greatly improves the performance of random reads.
+ </p>
+ <h2 id="code">Code</h2>
+ <p>
+ SquashFS code optimizations are available in AOSP:
+ </p><ul>
+ <li><a
+ href="https://android-review.googlesource.com/#/q/topic:squashfs">https://android-review.googlesource.com/#/q/topic:squashfs</a></li></ul>
+ </body>
+</html>