Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic set of tree - upbringing #1

Merged
merged 95 commits into from
Feb 9, 2020

Conversation

tytydraco
Copy link

No description provided.

Inkypen79 and others added 30 commits February 5, 2020 15:58
Change-Id: If818650729fb0c01dff69c37bddaee81c9c67ed7
Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
SELinux doesn't actually need audit support. In fact, auditing is not
particularly useful on production kernels, where minimal debugging is
needed.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
/dev/random on Android cannot even properly generate a UUID;
it's practically unusable.

There are no programs/applications on Android that should use /dev/random.

Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
Signed-off-by: Alex Naidis <alex.naidis@linux.com>
We won't be using this with an Adreno 3xx/4xx/5xx GPU.

Signed-off-by: kdrag0n <dragon@khronodragon.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Qualcomm devices actually use LPM-based governors (QCOM), therefore this
is a useless driver to have.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
This driver does not actually depend on CONFIG_PROFILING. Remove this
false dependency.

Test: compiles and boots with profiling disabled
Signed-off-by: Danny Lin <danny@kdrag0n.dev>
Some kernel code currently depends on the profiling subsystem solely for
its task exit notifier. The rest of the profiling subsystem is left
unused.

Add a simple task exit notifier implemented in kernel/exit.c to make
such code work properly even when profiling is disabled. This will allow
unnecessary profiling code to be disabled without breakage.

Signed-off-by: Danny Lin <danny@kdrag0n.dev>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Now that we have a simple task exit notifier system to notify
uid_sys_stats when tasks exit independently of the profiling subsystem,
remove this unnecessary dependency.

Test: /proc/uid_cputime shows valid stats with profiling disabled
Signed-off-by: Danny Lin <danny@kdrag0n.dev>
Updated for 4.14 kernel support.

The purpose of Anxiety is to improve throughput on latency-sensitive
tasks on embedded flash storage devices. On modern devices, embedded
systems contain relatively fast storage, so spending too much time with
complicated queue-shifting scheduling algorithms may end up
bottlenecking the device. Similarly to the No-op I/O scheduler, Anxiety
works with a FIFO queue; however, Anxiety includes basic request logic
based on READ v. WRITE requests. WRITE requests are starved at a fixed
ratio, defined as the `max_writes_starved` tunable. READ requests are
given priority over WRITE requests due to their essentiality in
determining load-time latency.

------------------TEST--------------------
SCHEDULERS	Anxiety		CFQ
S. READ		286.22		280.74
S. WRITE	221.01		174.0
R. READ		41.35		47.89
R. WRITE	10.65		10.7
SQL INS.	1276.57		1121.25
SQL UPD.	2920.97		2978.74
SQL DEL.	2503.16		2642.3
------------------------------------------

Tests were done using AndroBench on a Xiaomi Mi A2 on the latest 4.4.178
patch. This application has been known to be misrepresentative on I/O
scores in the past.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
By scheduling the last woken task first, we can increase cache locality
since that task is likely to touch the same data as before.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Some requests would like to be treated as a synchronous request. In this
case, we can allow these special requests to be part of the READ FIFO
list. They are treated as READ requests, inheriting their request
biases. Also, READ requests are always treated as sync.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Red Hat linux states that vmstat updates can be mildly expensive.
Increase from 1 second to 10 seconds.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Since we have an excess of available ram, we can bump the dirty ratios
for some additional performance improvements. Keeping the dirty ratio
high and the dirty background ratio low allows for less blocking
writeback while still allowing most dirty pages to stay in ram when they
can benefit by doing so.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
There's no sense in creating scheduler-specific methods for handling
former / latter requests.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
This is mainly for readability.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
This adds a great deal of latency to block requests due to disabling
preemption temporarily during statistics collection.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
This takes RCU and tasks locks to simply print debugging information,
which with certain log levels will not even display. DIsable this by
default.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Allow maintainers to select ASLR_FULL, ASLR_PARTIAL, or ASLR_NONE. Be
warned, this commit allows users to disable ASLR entirely in the kernel,
which can be a critical security issue.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
When using video rendering with vidc, CMA fills up quickly and LMKd
begins killing off other tasks to free up more contiguous memory. Since
we have 8 GB of RAM, lets bump our CMA to 256 MiB.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Sacrafice some bandwidth for lower latency on lossy networks.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
By disabling CONFIG_SCHED_DEBUG, the scheduler sysctl parameters can be
configured kernel-side without Android init scripts overwriting our
values.

According to the Linux Kernel CFS documentation, the scheduling period
will be sysctl_sched_latency as long as the number of running threads
is less than sysctl_sched_latency / sysctl_sched_min_granularity (10
with this commit). Otherwise, the scheduling period becomes
sysctl_sched_min_granularity * number_of_running_threads.

On average, /proc/stat's procs_running remains at under 10 processes,
excluding the occasional outliers. At this state, the scheduler will be
able to provide equal timeslices in under sysctl_sched_latency ms (10ms
with this commit) as long as there 10 or less processes running at any
one moment.

Testing has yet to be done. Do not pick unless you are willing to test.
This commit may not be stable or beneficial.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
In an ideal world, Android would request only the amount of memory it
needs, and nothing more or less. Unfortunately, some apps request too
little memory, requiring the kernel to guess how much (if any) memory to
overcommit.

We could skip this process by setting overcommit_memory to 1, so
applications can request up to 50% of the system memory. We will rely on
lmkd to garbage collect unfreed memory.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
There is a high probability that the specific CPU that makes an I/O
request may be repeated. For example, the same CPU may read the same
data multiple times when reading a database. This flag forces requests
to be completed on the same CPU that requested them. Additionally, this
prevents a scenario where one CPU is pinned with handling multiple block
requests from other CPUs. Since we have an 8 core system, we are in no
shortage of available CPUs to handle block requests.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
This value is set to the number of pages in which to calculate whether
or not to force writeback (likely blocking). On Android systems as of
now, the page size is 4 KiB. The default value for ratelimit_pages is
32, meaning that after 128 KiB of dirtied pages, the function will be
called. Let's increase this to 256, meaning that after 1024 KiB (or 1
MiB) of dirtied pages, the function will be called. Regardless, the
dirty background ratio is set to 10, which is (for our size of RAM),
equivelent to around 1638 KiB.

In theory, we should reduce overhead by calling the writeback checking
function less.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
We can more utilize our available RAM better like this.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
We don't want sched_nr_migrate to be too high, as that would impact
real-time latencies as the load balancing process for SCHED_OTHER
disallows IRQ interrupts.

Instead of making this a constant value, let's use an amount that
relates to the CPU performance of a device.

Consider that a device with a very weak 4 core processor needs to load
balance 32 tasks from the most busy-but-idle CPU. That balancing would
take significantly longer than a device with 8 cores.

On the contrary view, that same 8 core device balancing 32 tasks would
have no issues with SCHED_OTHER performance, however, real-time tasks
would suffer more jitter than is necessary.

Let's only balance as many tasks as there are CPUs in a device for
optimal SCHED_OTHER performance and SCHED_FIFO / SCHED_RR latency.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Mobile devices do not benefit from hispeed frequency boosting.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
There is little benefit to increasing CPU frequencies when we are
waiting on our flash chip to finish up.

I have seen commits that make iowait boosting optional, but I would like
to erase all traces of the boosting as to avoid any unnecessary
timestamping or overhead in the governor.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
This is not a great decision for real-time workloads.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Don't take priority over other workqueues.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
An article from 2014 (old but relevant) discussed the impact of
readahead on flash storage and its effects on SQLine and DBMS
performance. What was discovered was that turning off readahead could
improve performance and power consumption by 70% (sequential; 60% for
random).

https://www.semanticscholar.org/paper/Revisiting-read-ahead-efficiency-for-raw-NAND-flash-Olivier-Boukhobza/297f3d189dcd9b099f8f6b5fbc7e304db395a683

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
We can prevent overflowing our scheduling period by allowing double the
number of round-robin tasks to get a timeslice per scheduling period.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
If we are not busy with a userspace task, quickly check for wakelocks
that could be cleaned up. Otherwise, fallback to the previous counter
method until the max count is reached or the current CPU becomes idle.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Also, abolish the anxiety_can_dispatch method.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Otherwise, if no requests are dispatched, the counter could be
initialized to anything, causing a possible panic.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Both options in the dispath method will already check the sync and async
lists to make sure they are not empty. It might not be worth checking
twice.

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
@Inkypen79 Inkypen79 merged commit eda2e97 into Inkypen79:lineage-16.0 Feb 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants