OSDN Git Service

sagit-ice-cold/kernel_xiaomi_msm8998.git
4 years agoproc: Don't let Google Camera and Settings run in the background
Sultan Alsawaf [Sat, 20 Jul 2019 17:56:17 +0000 (10:56 -0700)]
proc: Don't let Google Camera and Settings run in the background

Google Camera and Settings both burn through CPU in the background doing
nothing useful. In the case of Google Camera, it keeps polling sensors
in the background while it is doing nothing for the user.

Meanwhile, in Settings, when leaving the Adaptive brightness activity
via any means other than using the back button (e.g., the home button),
the GIF in the Adaptive brightness activity will continue playing in the
background. This bug applies to all of the dumb GIFs in Settings.

Kill both of these apps when they reach the background to stop them from
burning through battery.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agoARM: dts: msm8998: Increase UFS CPU latency requirement to 100 us
Sultan Alsawaf [Tue, 7 May 2019 08:51:50 +0000 (01:51 -0700)]
ARM: dts: msm8998: Increase UFS CPU latency requirement to 100 us

Voting for longer than 70 us provides access to another CPU idle state.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years ago{chiron,sagit}_defconfig: Use a timer frequency of 100 Hz
Sultan Alsawaf [Tue, 7 May 2019 01:10:37 +0000 (18:10 -0700)]
{chiron,sagit}_defconfig: Use a timer frequency of 100 Hz

The use of high CPU frequencies combined with a large number of cores
makes latency decent with a 100 Hz scheduler tick. Reducing the tick
rate from 300 Hz to 100 Hz improves throughput and significantly reduces
the number of interrupts firing off per second, improving power
consumption.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agoqcacld-3.0: Nuke as much debug bloat as possible
Sultan Alsawaf [Sun, 5 May 2019 21:54:15 +0000 (14:54 -0700)]
qcacld-3.0: Nuke as much debug bloat as possible

The overhead from all the debugging in this monstrosity of a driver is
measurably significant. Chop it all out.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agomsm: kgsl: Relax CPU latency requirements to save power
Sultan Alsawaf [Sun, 5 May 2019 04:29:14 +0000 (21:29 -0700)]
msm: kgsl: Relax CPU latency requirements to save power

Relaxing the CPU latency requirement by about 500 us won't significantly
hurt graphics performance. On the flip side, most SoCs have many idle
levels just below 1000 us in latency, with deeper idle levels having
latencies in excess of 2000 us. Changing the latency requirement to
1000 us allows most SoCs to use their deepest sub-1000-us idle state
while the GPU is active.

Additionally, since the lpm driver has been updated to allow power
levels with latencies equal to target latencies, change the wakeup
latency from 101 to 100 for clarity.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agosched/tune: Hard-code top-app's stune boost to 1
Sultan Alsawaf [Mon, 22 Apr 2019 09:07:57 +0000 (02:07 -0700)]
sched/tune: Hard-code top-app's stune boost to 1

Hard-code top-app's stune boost to 1 so that top-app processes are still
preferred to run on big cluster CPUs without significantly affecting the
CPU governor's frequency selection.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agocpuidle: lpm-levels: Allow exit latencies equal to target latencies
Sultan Alsawaf [Thu, 2 May 2019 00:54:26 +0000 (17:54 -0700)]
cpuidle: lpm-levels: Allow exit latencies equal to target latencies

This allows pm_qos votes with, say, 100 us for example to select power
levels with exit latencies equal to 100 us. The extra microsecond of
exit latency doesn't hurt.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years ago{chiron,sagit}_defconfig: Don't print pid and CPU in dmesg
Sultan Alsawaf [Thu, 18 Apr 2019 06:55:45 +0000 (23:55 -0700)]
{chiron,sagit}_defconfig: Don't print pid and CPU in dmesg

This cruft is annoying.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years ago{chiron,sagit}_defconfig: enable devfreq boost driver
0ranko0P [Mon, 23 Dec 2019 10:12:01 +0000 (18:12 +0800)]
{chiron,sagit}_defconfig: enable devfreq boost driver

4 years agomsm: mdss: Mark display-wake kthread as performance critical
Sultan Alsawaf [Mon, 15 Apr 2019 05:06:29 +0000 (22:06 -0700)]
msm: mdss: Mark display-wake kthread as performance critical

This kthread is responsible for powering on the display, so it needs to
run as soon as possible to minimize lag when turning the display on.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agomsm: mdss: Power on display asynchronously as early as possible
Sultan Alsawaf [Mon, 15 Apr 2019 05:04:53 +0000 (22:04 -0700)]
msm: mdss: Power on display asynchronously as early as possible

Currently, mdss powers on the display a long time after an unblank is
requested and gets completely blocked while powering on the display, so
if the display takes a very long time to turn on, then mdss will be
stuck unable to do anything else in the meantime. This results in a long
delay between trying to wake the device and the display actually
powering on.

In order to make the display turn on faster when waking the device from
sleep, start powering on the display as soon as the framebuffer unblank
event is received. This allows mdss to continue resuming while the
display takes its time powering on. A high-priority kthread is used here
to ensure the display powers on as quickly as possible.

In the event that the framebuffer unblank notifier is not used (such as
for AOD), the display will be powered on at the time that it is
requested via the MDSS_EVENT_LINK_READY event.

To make this work, kickoffs need to be blocked when they attempt to
power on the display, so that a kickoff won't continue while the display
is still powered off.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agomsm: mdss: Boost DDR bus when committing a new frame
Sultan Alsawaf [Sat, 20 Jul 2019 17:25:50 +0000 (10:25 -0700)]
msm: mdss: Boost DDR bus when committing a new frame

In order to reduce jank, request a DDR bus boost whenever a new frame is
ready to be rendered to the display. The boost should be sufficient
enough to render 60 FPS without any dropped frames when there is no
significant external source of load.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agodevfreq_boost: Mark boost kthreads as performance critical
Sultan Alsawaf [Thu, 18 Apr 2019 04:39:16 +0000 (21:39 -0700)]
devfreq_boost: Mark boost kthreads as performance critical

The boost kthreads are performance critical for obvious reasons.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agodevfreq_boost: Introduce devfreq boost driver
Sultan Alsawaf [Fri, 19 Apr 2019 05:07:57 +0000 (22:07 -0700)]
devfreq_boost: Introduce devfreq boost driver

This driver boosts enumerated devfreq devices upon input, and allows for
boosting specific devfreq devices on other custom events. The boost
frequencies for this driver should be set so that frame drops are
near-zero at the boosted frequencies and power consumption is minimized
at said frequencies. The goal of this driver is to provide an interface
to achieve optimal device performance by requesting boosts on key
events, such as when a frame is ready to rendered to the display.

Currently, support is only present for boosting the cpubw devfreq
device, but the driver is structured in a way that makes it easy to add
support for new boostable devfreq devices in the future.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agocpufreq: Kill userspace CPU boosting entirely
Sultan Alsawaf [Sat, 16 Jun 2018 22:51:07 +0000 (15:51 -0700)]
cpufreq: Kill userspace CPU boosting entirely

Kernel-based CPU boosting is used now, so stop userspace from messing with
it by turning scaling_min_freq into a no-op. Note that this is done instead
of making scaling_min_freq read-only so that userspace doesn't spit out
error messages when it can't do its boosting.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agofs: exec: block nfs injector from launching
Yaroslav Furman [Wed, 11 Dec 2019 15:43:56 +0000 (18:43 +0300)]
fs: exec: block nfs injector from launching

Another optimizer, duh...

Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
4 years ago{chiron,sagit}_defconfig: enable unwated apps blocker
0ranko0P [Fri, 20 Dec 2019 13:58:06 +0000 (21:58 +0800)]
{chiron,sagit}_defconfig: enable unwated apps blocker

4 years agofs: introduce unwated apps blocker
Yaroslav Furman [Tue, 10 Dec 2019 00:47:55 +0000 (03:47 +0300)]
fs: introduce unwated apps blocker

This is a POC commit which targets various Android optimiers,
that use 2011 tweaks and script to
"improve battery life and performance"
and completely mess up all the kernel settings, thus leading
to poor UX and whine from users.

Currently blocking: L Speed, FDE.AI

Now blocking: L Speed
Based on [1] and [2]:
https://github.com/RaphielGang/spins_kernel_xiaomi_sdm845/commit/75804821e68be3ece795402e175e36ebf7206540
https://github.com/kerneltoast/android_kernel_google_bluecross/commit/18f25c985ce1d23ca98f765249671e7252886e4d

Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
4 years agozram: Do not allow compression algorithm to be changed
Nathan Chancellor [Sun, 28 Oct 2018 17:09:32 +0000 (10:09 -0700)]
zram: Do not allow compression algorithm to be changed

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
4 years agozram: Move default compression algorithm choice to Kconfig
Nathan Chancellor [Sun, 28 Oct 2018 17:14:01 +0000 (10:14 -0700)]
zram: Move default compression algorithm choice to Kconfig

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
4 years agokernel: bpf: move syscall allocations to stack
Yaroslav Furman [Wed, 10 Jul 2019 23:36:23 +0000 (02:36 +0300)]
kernel: bpf: move syscall allocations to stack

These are really small, freed in the same function, very frequent.
Allocating them on stack will improve performance.

Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
4 years agokernel/printk: use on-stack allocations for kernel log
Yaroslav Furman [Sat, 13 Jul 2019 12:18:13 +0000 (15:18 +0300)]
kernel/printk: use on-stack allocations for kernel log

These allocationsare just 1kb in size, using kmalloc is not
worth it for them. This should speed up printing of kernel log
when uptime gets very long.

Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
4 years agomsm: gsi: disable debug driver
Yaroslav Furman [Thu, 5 Dec 2019 23:52:36 +0000 (02:52 +0300)]
msm: gsi: disable debug driver

Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
4 years agocpuidle: lpm-levels: Remove debug event logging
Danny Lin [Tue, 7 May 2019 05:47:02 +0000 (22:47 -0700)]
cpuidle: lpm-levels: Remove debug event logging

A measurably significant amount of CPU time is spent on logging events
for debugging purposes in lpm_cpuidle_enter. Kill the useless logging to
reduce overhead.

Signed-off-by: Danny Lin <danny@kdrag0n.dev>
Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
4 years agoipa_v3: fix some maybe-uninitialised warnings
Yaroslav Furman [Thu, 6 Jun 2019 07:32:46 +0000 (10:32 +0300)]
ipa_v3: fix some maybe-uninitialised warnings

Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
4 years agomm/slab_common: Align all caches' objects to hardware cachelines
Sultan Alsawaf [Thu, 27 Jun 2019 00:47:30 +0000 (17:47 -0700)]
mm/slab_common: Align all caches' objects to hardware cachelines

This only increases the memory used by all caches by about 10%, which is
relatively very little for the performance benefit of cacheline
alignment.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agoASoC: msm: qdsp6v2: Make version checking no-op
Yaroslav Furman [Sat, 1 Sep 2018 19:57:42 +0000 (22:57 +0300)]
ASoC: msm: qdsp6v2: Make version checking no-op

After Pie tag was released CAF added functions
for checking fw version that are not supported
by our DSP.

And kernel tell us about it by spamming:

[10186.137518] q6core_get_service_version: Failed to get service size for service id 7
with error -95
[10186.141517] q6core_get_service_version: Failed to get service size for service id 8
with error -95
[10186.151816] q6core_get_service_version: Failed to get service size for service id 7
with error -95
[10254.278514] q6core_get_service_version: Failed to get service size for service id 7
with error -95
[10254.282274] q6core_get_service_version: Failed to get service size for service id 8
with error -95
[10254.292154] q6core_get_service_version: Failed to get service size for service id 7
with error -95
[10294.549313] q6core_get_service_version: Failed to get service size for service id 7
with error -95
[10294.553506] q6core_get_service_version: Failed to get service size for service id 8
with error -95
[10294.563891] q6core_get_service_version: Failed to get service size for service id 7
with error -95

This results in certain audio apps getting focked up
after system suspends and then goes back online.

Change-Id: I09dfa1ee3adad8df62f79bc79a88a74f60d73b23
Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
4 years agoRevert "{chiron,sagit}_defconfig: enable bfq"
0ranko0P [Thu, 12 Dec 2019 12:49:25 +0000 (20:49 +0800)]
Revert "{chiron,sagit}_defconfig: enable bfq"

This reverts commit e34df45d2cab26ba0dbc4fdc106548f3e13eb395.

4 years agoRevert "BACKPORT: zsmalloc: introduce zs_huge_class_size()"
0ranko0P [Sat, 7 Dec 2019 12:43:59 +0000 (20:43 +0800)]
Revert "BACKPORT: zsmalloc: introduce zs_huge_class_size()"

This reverts commit 4d1ddb8d3b84e9e162217bf55e8aad6fa796b836.

4 years agoARM: dts: msm8998: Tune mincpubw configs
Julian Liu [Tue, 5 Nov 2019 04:38:35 +0000 (12:38 +0800)]
ARM: dts: msm8998: Tune mincpubw configs

4 years agof2fs: avoid kernel panic on corruption test
Jaegeuk Kim [Fri, 1 Nov 2019 16:34:21 +0000 (09:34 -0700)]
f2fs: avoid kernel panic on corruption test

xfstests/generic/475 complains kernel warn/panic while testing corrupted disk.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
4 years agof2fs: Check write pointer consistency of non-open zones
Shin'ichiro Kawasaki [Mon, 28 Oct 2019 06:58:01 +0000 (15:58 +0900)]
f2fs: Check write pointer consistency of non-open zones

To catch f2fs bugs in write pointer handling code for zoned block
devices, check write pointers of non-open zones that current segments do
not point to. Do this check at mount time, after the fsync data recovery
and current segments' write pointer consistency fix. Check two items
comparing write pointers with valid block maps in SIT.

The first item is check for zones with no valid blocks. When there is no
valid blocks in a zone, the write pointer should be at the start of the
zone. If not, next write operation to the zone will cause unaligned write
error. If write pointer is not at the zone start, make mount fail and ask
users to run fsck.

The second item is check between the write pointer position and the last
valid block in the zone. It is unexpected that the last valid block
position is beyond the write pointer. In such a case, report as the bug.
Fix is not required for such zone, because the zone is not selected for
next write operation until the zone get discarded.

Also move a constant F2FS_REPORT_ZONE from super.c to f2fs.h to use it
in segment.c also.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
4 years agof2fs: Check write pointer consistency of open zones
Shin'ichiro Kawasaki [Mon, 28 Oct 2019 06:58:00 +0000 (15:58 +0900)]
f2fs: Check write pointer consistency of open zones

On sudden f2fs shutdown, write pointers of zoned block devices can go
further but f2fs meta data keeps current segments at positions before the
write operations. After remounting the f2fs, this inconsistency causes
write operations not at write pointers and "Unaligned write command"
error is reported.

To avoid the error, compare current segments with write pointers of open
zones the current segments point to, during mount operation. If the write
pointer position is not aligned with the current segment position, assign
a new zone to the current segments. Also check the newly assigned zone
has write pointer at zone start. If not, make mount fail and ask users to
run fsck.

Perform the consistency check twice. Once during fsync recovery. Not to
lose the fsync data, do the check after fsync data gets restored and
before checkpoint commit which flushes data at current segment positions.
The second check is done at end of f2fs_fill_super() to make sure the
write pointer consistency regardless of fsync data recovery execution.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
4 years agof2fs: fix wrong description in document
Chao Yu [Tue, 22 Oct 2019 09:26:11 +0000 (17:26 +0800)]
f2fs: fix wrong description in document

As reported in bugzilla, default value of DEF_RAM_THRESHOLD was fixed by
commit 29710bcf9426 ("f2fs: fix wrong percentage"), however leaving wrong
description in document, fix it.

https://bugzilla.kernel.org/show_bug.cgi?id=205203

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
4 years agof2fs: cache global IPU bio
Chao Yu [Mon, 30 Sep 2019 10:53:25 +0000 (18:53 +0800)]
f2fs: cache global IPU bio

In commit 8648de2c581e ("f2fs: add bio cache for IPU"), we added
f2fs_submit_ipu_bio() in __write_data_page() as below:

__write_data_page()

if (!S_ISDIR(inode->i_mode) && !IS_NOQUOTA(inode)) {
f2fs_submit_ipu_bio(sbi, bio, page);
....
}

in order to avoid below deadlock:

Thread A Thread B
- __write_data_page (inode x, page y)
 - f2fs_do_write_data_page
  - set_page_writeback        ---- set writeback flag in page y
  - f2fs_inplace_write_data
 - f2fs_balance_fs
 - lock gc_mutex
 - lock gc_mutex
  - f2fs_gc
   - do_garbage_collect
    - gc_data_segment
     - move_data_page
      - f2fs_wait_on_page_writeback
       - wait_on_page_writeback  --- wait writeback of page y

However, the bio submission breaks the merge of IPU IOs.

So in this patch let's add a global bio cache for merged IPU pages,
then f2fs_wait_on_page_writeback() is able to submit bio if a
writebacked page is cached in global bio cache.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
4 years agof2fs: fix to avoid memory leakage in f2fs_listxattr
Randall Huang [Fri, 18 Oct 2019 06:56:22 +0000 (14:56 +0800)]
f2fs: fix to avoid memory leakage in f2fs_listxattr

In f2fs_listxattr, there is no boundary check before
memcpy e_name to buffer.
If the e_name_len is corrupted,
unexpected memory contents may be returned to the buffer.

Signed-off-by: Randall Huang <huangrandall@google.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
4 years agof2fs: check total_segments from devices in raw_super
Qiuyang Sun [Mon, 23 Sep 2019 04:22:35 +0000 (12:22 +0800)]
f2fs: check total_segments from devices in raw_super

For multi-device F2FS, we should check if the sum of total_segments from
all devices matches segment_count.

Signed-off-by: Qiuyang Sun <sunqiuyang@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
4 years agof2fs: update multi-dev metadata in resize_fs
Qiuyang Sun [Mon, 23 Sep 2019 04:21:39 +0000 (12:21 +0800)]
f2fs: update multi-dev metadata in resize_fs

Multi-device metadata should be updated in resize_fs as well.

Also, we check that the new FS size still reaches the last device.

Signed-off-by: Qiuyang Sun <sunqiuyang@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
4 years agof2fs: mark recovery flag correctly in read_raw_super_block()
Chengguang Xu via Linux-f2fs-devel [Fri, 27 Sep 2019 01:35:48 +0000 (09:35 +0800)]
f2fs: mark recovery flag correctly in read_raw_super_block()

On the combination of first fail and second success,
we will miss to mark recovery flag because currently
we reuse err variable in the loop.

Signed-off-by: Chengguang Xu <cgxu519@zoho.com.cn>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
4 years agof2fs: fix to update time in lazytime mode
Chao Yu [Fri, 27 Sep 2019 10:01:35 +0000 (18:01 +0800)]
f2fs: fix to update time in lazytime mode

generic/018 reports an inconsistent status of atime, the
testcase is as below:
- open file with O_SYNC
- write file to construct fraged space
- calc md5 of file
- record {a,c,m}time
- defrag file --- do nothing
- umount & mount
- check {a,c,m}time

The root cause is, as f2fs enables lazytime by default, atime
update will dirty vfs inode, rather than dirtying f2fs inode (by set
with FI_DIRTY_INODE), so later f2fs_write_inode() called from VFS will
fail to update inode page due to our skip:

f2fs_write_inode()
if (is_inode_flag_set(inode, FI_DIRTY_INODE))
return 0;

So eventually, after evict(), we lose last atime for ever.

To fix this issue, we need to check whether {a,c,m,cr}time is
consistent in between inode cache and inode page, and only skip
f2fs_update_inode() if f2fs inode is not dirty and time is
consistent as well.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
4 years agosimple_lmk: Change Kconfig defaults
Sultan Alsawaf [Tue, 5 Nov 2019 16:31:57 +0000 (08:31 -0800)]
simple_lmk: Change Kconfig defaults

Commit "simple_lmk: Make reclaim deterministic" changed Simple LMK's
behavior, so the default parameters must be updated as well to
compensate.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agosimple_lmk: Clean up some code style nitpicks
Sultan Alsawaf [Mon, 4 Nov 2019 19:17:16 +0000 (11:17 -0800)]
simple_lmk: Clean up some code style nitpicks

Using a parameter to pass around a unmodified pointer to a global
variable is crufty; just use the `victims` variable directly instead.
Also, compress the code in simple_lmk_init_set() a bit to make it look
cleaner.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: celtare21 <celtare21@gmail.com>
4 years agosimple_lmk: Make reclaim deterministic
Sultan Alsawaf [Mon, 4 Nov 2019 19:00:41 +0000 (11:00 -0800)]
simple_lmk: Make reclaim deterministic

The 20 ms delay in the reclaim thread is a hacky fudge factor that can
cause Simple LMK to behave wildly differently depending on the
circumstances of when it is invoked. When kswapd doesn't get enough CPU
time to finish up and go back to sleep within 20 ms, Simple LMK performs
superfluous reclaims.

This is suboptimal, so make Simple LMK more deterministic by eliminating
the delay and instead queuing up reclaim requests from kswapd.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: celtare21 <celtare21@gmail.com>
4 years agosimple_lmk: Fix broken multicopy atomicity for victims_to_kill
Sultan Alsawaf [Mon, 4 Nov 2019 18:49:21 +0000 (10:49 -0800)]
simple_lmk: Fix broken multicopy atomicity for victims_to_kill

When the reclaim thread writes to victims_to_kill on one CPU, it expects
the updated value to be immediately reflected on all CPUs in order for
simple_lmk_mm_freed() to work correctly. Due to the lack of memory
barriers to guarantee multicopy atomicity, simple_lmk_mm_freed() can be
given a victim's mm without knowing the correct victims_to_kill value,
which can cause the reclaim thread to remain stuck waiting forever for
all victims to be freed. This scenario, despite being rare, has been
observed.

Fix this by using proper atomic helpers with memory barriers.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: celtare21 <celtare21@gmail.com>
4 years agomsm: mdss: Silence debug logs
Julian Liu [Mon, 4 Nov 2019 09:13:45 +0000 (17:13 +0800)]
msm: mdss: Silence debug logs

4 years agosimple_lmk: Don't give victims privileges
Julian Liu [Fri, 1 Nov 2019 09:33:05 +0000 (17:33 +0800)]
simple_lmk: Don't give victims privileges

* When slmk is triggered, there are usually heavy tasks running.
  Increasing the victim's priority may result in unnecessary preemption and lag

4 years agodefconfig: Disable CC_STACKPROTECTOR_STRONG
Julian Liu [Thu, 31 Oct 2019 23:46:19 +0000 (07:46 +0800)]
defconfig: Disable CC_STACKPROTECTOR_STRONG

* save few size, idc others

4 years agoKbuild: don't pass "-C" to preprocessor when processing linker scripts
Linus Torvalds [Thu, 2 Nov 2017 21:10:37 +0000 (14:10 -0700)]
Kbuild: don't pass "-C" to preprocessor when processing linker scripts

For some odd historical reason, we preprocessed the linker scripts with
"-C", which keeps comments around.  That makes no sense, since the
comments are not meaningful for the build anyway.

And it actually breaks things, since linker scripts can't have C++ style
"//" comments in them, so keeping comments after preprocessing now
limits us in odd and surprising ways in our header files for no good
reason.

The -C option goes back to pre-git and pre-bitkeeper times, but seems to
have been historically used (along with "-traditional") for some
odd-ball architectures (ia64, MIPS and SH).  It probably didn't matter
back then either, but might possibly have been used to minimize the
difference between the original file and the pre-processed result.

The reason for this may be lost in time, but let's not perpetuate it
only because we can't remember why we did this crazy thing.

This was triggered by the recent addition of SPDX lines to the source
tree, where people apparently were confused about why header files
couldn't use the C++ comment format.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
4 years agoqcacld-3.0: Disable open-source flag
Julian Liu [Thu, 31 Oct 2019 03:54:32 +0000 (11:54 +0800)]
qcacld-3.0: Disable open-source flag

* It can disable some debug codes and make the driver more similar to OEM's

4 years agoqpnp-fg-gen3: Don't ratelimit interaction related props
Julian Liu [Wed, 30 Oct 2019 07:10:05 +0000 (15:10 +0800)]
qpnp-fg-gen3: Don't ratelimit interaction related props

* The state changes corresponding to these props should be immediately fed back in userspace.

4 years agoloop: avoid EAGAIN, if offset or block_size are changed
Jaegeuk Kim [Fri, 17 May 2019 23:37:50 +0000 (16:37 -0700)]
loop: avoid EAGAIN, if offset or block_size are changed

This patch tries to avoid EAGAIN due to nrpages!=0 that was originally trying
to drop stale pages resulting in wrong data access.

Report: https://bugs.chromium.org/p/chromium/issues/detail?id=938958#c38

Cc: <stable@vger.kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Cc: Bart Van Assche <bvanassche@acm.org>
Fixes: 5db470e229e2 ("loop: drop caches if offset or block_size are changed")
Reported-by: Gwendal Grignou <gwendal@chromium.org>
Reported-by: grygorii tertychnyi <gtertych@cisco.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Julian Liu <wlootlxt123@gmail.com>
4 years agoscatterlist: Speed up for_each_sg() loop macro
Sultan Alsawaf [Fri, 25 Oct 2019 02:00:35 +0000 (19:00 -0700)]
scatterlist: Speed up for_each_sg() loop macro

Scatterlists are chained in predictable arrays of up to
SG_MAX_SINGLE_ALLOC sg structs in length. Using this knowledge, speed up
for_each_sg() by using constant operations to determine when to simply
increment the sg pointer by one or get the next sg array in the chain.

Rudimentary measurements with a trivial loop body show that this yields
roughly a 2x performance gain.

The following simple test module proves the correctness of the new loop
definition by testing all the different edge cases of sg chains:
#include <linux/module.h>
#include <linux/scatterlist.h>
#include <linux/slab.h>

static int __init test_for_each_sg(void)
{
static const gfp_t gfp_flags = GFP_KERNEL | __GFP_NOFAIL;
        struct scatterlist *sg;
        struct sg_table *table;
        long old = 0, new = 0;
        unsigned int i, nents;

        table = kmalloc(sizeof(*table), gfp_flags);
        for (nents = 1; nents <= 3 * SG_MAX_SINGLE_ALLOC; nents++) {
                BUG_ON(sg_alloc_table(table, nents, gfp_flags));
                for (sg = table->sgl; sg; sg = sg_next(sg))
                        old ^= (long)sg;
                for_each_sg(table->sgl, sg, nents, i)
                        new ^= (long)sg;
                sg_free_table(table);
        }

        BUG_ON(old != new);
        kfree(table);
        return 0;
}
module_init(test_for_each_sg);

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agomm/shmem.c: fix unlikely() test of info->seals to test only for WRITE and GROW
Steven Rostedt (VMware) [Fri, 24 Feb 2017 22:59:10 +0000 (14:59 -0800)]
mm/shmem.c: fix unlikely() test of info->seals to test only for WRITE and GROW

Running my likely/unlikely profiler, I discovered that the test in
shmem_write_begin() that tests for info->seals as unlikely, is always
incorrect.  This is because shmem_get_inode() sets info->seals to have
F_SEAL_SEAL set by default, and it is unlikely to be cleared when
shmem_write_begin() is called.  Thus, the if statement is very likely.

But as the if statement block only cares about F_SEAL_WRITE and
F_SEAL_GROW, change the test to only test those two bits.

Link: http://lkml.kernel.org/r/20170203105656.7aec6237@gandalf.local.home
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Acked-by: Hugh Dickins <hughd@google.com>
Cc: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
4 years agosched/core: Remove unlikely() annotation from sched_move_task()
Steven Rostedt (VMware) [Mon, 6 Feb 2017 16:04:26 +0000 (11:04 -0500)]
sched/core: Remove unlikely() annotation from sched_move_task()

The check for 'running' in sched_move_task() has an unlikely() around it. That
is, it is unlikely that the task being moved is running. That use to be
true. But with a couple of recent updates, it is now likely that the task
will be running.

The first change came from ea86cb4b7621 ("sched/cgroup: Fix
cpu_cgroup_fork() handling") that moved around the use case of
sched_move_task() in do_fork() where the call is now done after the task is
woken (hence it is running).

The second change came from 8e5bfa8c1f84 ("sched/autogroup: Do not use
autogroup->tg in zombie threads") where sched_move_task() is called by the
exit path, by the task that is exiting. Hence it too is running.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Link: http://lkml.kernel.org/r/20170206110426.27ca6426@gandalf.local.home
Signed-off-by: Ingo Molnar <mingo@kernel.org>
4 years agolocking/rtmutex: Flip unlikely() branch to likely() in __rt_mutex_slowlock()
Steven Rostedt (VMware) [Thu, 19 Jan 2017 16:32:34 +0000 (11:32 -0500)]
locking/rtmutex: Flip unlikely() branch to likely() in __rt_mutex_slowlock()

Running my likely/unlikely profiler for 3 weeks on two production
machines, I discovered that the unlikely() test in
__rt_mutex_slowlock() checking if state is TASK_INTERRUPTIBLE is hit
100% of the time, making it a very likely case.

The reason is, on a vanilla kernel, the majority case of calling
rt_mutex() is from the futex code. This code is always called as
TASK_INTERRUPTIBLE. In the -rt patch, this code is commonly called when
PREEMPT_RT is enabled with TASK_UNINTERRUPTIBLE. But that's not the
likely scenario.

The rt_mutex() code should be optimized for the common vanilla case,
and that is from a futex, with TASK_INTERRUPTIBLE as the state.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20170119113234.1efeedd1@gandalf.local.home
Signed-off-by: Ingo Molnar <mingo@kernel.org>
4 years agolocking/rtmutex: Only warn once on a trylock from bad context
Sebastian Andrzej Siewior [Fri, 27 May 2016 13:47:18 +0000 (15:47 +0200)]
locking/rtmutex: Only warn once on a trylock from bad context

One warning should be enough to get one motivated to fix this. It is
possible that this happens more than once and that starts flooding the
output. Later the prints will be suppressed so we only get half of it.
Depending on the console system used it might not be helpful.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1464356838-1755-1-git-send-email-bigeasy@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
4 years agortmutex: Make wait_lock irq safe
Thomas Gleixner [Wed, 13 Jan 2016 10:25:38 +0000 (11:25 +0100)]
rtmutex: Make wait_lock irq safe

Sasha reported a lockdep splat about a potential deadlock between RCU boosting
rtmutex and the posix timer it_lock.

CPU0 CPU1

rtmutex_lock(&rcu->rt_mutex)
  spin_lock(&rcu->rt_mutex.wait_lock)
local_irq_disable()
spin_lock(&timer->it_lock)
spin_lock(&rcu->mutex.wait_lock)
--> Interrupt
    spin_lock(&timer->it_lock)

This is caused by the following code sequence on CPU1

     rcu_read_lock()
     x = lookup();
     if (x)
      spin_lock_irqsave(&x->it_lock);
     rcu_read_unlock();
     return x;

We could fix that in the posix timer code by keeping rcu read locked across
the spinlocked and irq disabled section, but the above sequence is common and
there is no reason not to support it.

Taking rt_mutex.wait_lock irq safe prevents the deadlock.

Reported-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
4 years agoASoC: tas2559: use power efficient workingqueues
Julian Liu [Mon, 28 Oct 2019 17:33:55 +0000 (01:33 +0800)]
ASoC: tas2559: use power efficient workingqueues

4 years agopower: supply: use power efficient workingqueues
Julian Liu [Sun, 27 Oct 2019 14:25:31 +0000 (22:25 +0800)]
power: supply: use power efficient workingqueues

* YEEEEEEE

4 years agoASoC: wcd9335: use power efficient workingqueues
Julian Liu [Sun, 27 Oct 2019 14:21:36 +0000 (22:21 +0800)]
ASoC: wcd9335: use power efficient workingqueues

4 years agomm, vmstat: Add likelihood labels to quiet_vmstat conditions
Danny Lin [Fri, 10 May 2019 05:33:48 +0000 (22:33 -0700)]
mm, vmstat: Add likelihood labels to quiet_vmstat conditions

These labels are based on observations from a running system as well as
from inspecting the code:

!delayed_work_pending:
  true  = 3509732
  false = 7495535

!need_update:
  true  = 6656251
  false = 840000

Signed-off-by: Danny Lin <danny@kdrag0n.dev>
4 years agomm: vmstat: use power efficient workingqueues
Julian Liu [Sun, 27 Oct 2019 14:11:01 +0000 (22:11 +0800)]
mm: vmstat: use power efficient workingqueues

4 years agoplatform: ipa: use power efficient workingqueues
Julian Liu [Sun, 27 Oct 2019 14:09:20 +0000 (22:09 +0800)]
platform: ipa: use power efficient workingqueues

4 years agoRevert "f2fs: Tune issue discard commands up to 128MB"
Julian Liu [Sun, 27 Oct 2019 13:27:16 +0000 (21:27 +0800)]
Revert "f2fs: Tune issue discard commands up to 128MB"

* We have a good gc strategy, don't need this
This reverts commit 8439a3a642a927cfb1432b5c50c44eaaa76a4686.

4 years agomsm: kgsl: Use for_each_sg() macro where possible
Sultan Alsawaf [Fri, 25 Oct 2019 17:52:33 +0000 (10:52 -0700)]
msm: kgsl: Use for_each_sg() macro where possible

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agoqseecom: Use for_each_sg() macro where possible
Sultan Alsawaf [Fri, 25 Oct 2019 17:52:01 +0000 (10:52 -0700)]
qseecom: Use for_each_sg() macro where possible

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agocrypto: msm: Use for_each_sg() macro where possible
Sultan Alsawaf [Fri, 25 Oct 2019 17:51:18 +0000 (10:51 -0700)]
crypto: msm: Use for_each_sg() macro where possible

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agokernel: sched: Mitigate non-boosted tasks preempting boosted tasks
Miguel de Dios [Mon, 29 Apr 2019 23:09:33 +0000 (16:09 -0700)]
kernel: sched: Mitigate non-boosted tasks preempting boosted tasks

Currently when a boosted task is scheduled we use prefer_idle to try and
get it to an idle core. Once it's scheduled, there is a possibility we
can schedule a non-boosted task on the same core where the boosted task
is running on. This change aims to mitigate that possibility by checking
if the core we're targeting has a boosted task and if so, use the next
best idle core instead.

Bug: 131626264
Change-Id: I3d321e1c71f96526f55f7f3a56e32db411311aa2
Signed-off-by: Miguel de Dios <migueldedios@google.com>
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: Julian Liu <wlootlxt123@gmail.com>
4 years agof2fs: gc_wake is unlikely as true
Julian Liu [Fri, 25 Oct 2019 13:26:04 +0000 (21:26 +0800)]
f2fs: gc_wake is unlikely as true

4 years agodefconfig: Disable UNMAP_KERNEL_AT_EL0
Julian Liu [Fri, 25 Oct 2019 12:26:21 +0000 (20:26 +0800)]
defconfig: Disable UNMAP_KERNEL_AT_EL0

4 years agof2fs: Tune background GC for Android
Julian Liu [Sun, 20 Oct 2019 17:29:25 +0000 (01:29 +0800)]
f2fs: Tune background GC for Android

4 years agof2fs: Tune issue discard commands up to 128MB
Julian Liu [Thu, 24 Oct 2019 22:02:31 +0000 (06:02 +0800)]
f2fs: Tune issue discard commands up to 128MB

https://android.googlesource.com/device/google/coral/+/refs/tags/android-10.0.0_r9/init.hardware.rc#550

4 years agopage-writeback: Hardcode dirty_background_ratio to 10
Julian Liu [Thu, 24 Oct 2019 21:10:49 +0000 (05:10 +0800)]
page-writeback: Hardcode dirty_background_ratio to 10

4 years agocpufreq: schedutil: tune default rate limit from Pixel
Julian Liu [Thu, 24 Oct 2019 21:04:58 +0000 (05:04 +0800)]
cpufreq: schedutil: tune default rate limit from Pixel

4 years agoarm64: Select ARCH_HAS_FAST_MULTIPLIER
Robin Murphy [Tue, 24 Apr 2018 15:25:47 +0000 (16:25 +0100)]
arm64: Select ARCH_HAS_FAST_MULTIPLIER

It is probably safe to assume that all Armv8-A implementations have a
multiplier whose efficiency is comparable or better than a sequence of
three or so register-dependent arithmetic instructions. Select
ARCH_HAS_FAST_MULTIPLIER to get ever-so-slightly nicer codegen in the
few dusty old corners which care.

In a contrived benchmark calling hweight64() in a loop, this does indeed
turn out to be a small win overall, with no measurable impact on
Cortex-A57 but about 5% performance improvement on Cortex-A53.

Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Danny Lin <danny@kdrag0n.dev>
4 years agosdcardfs: fix wrong ENOENT when creating a file
Jaegeuk Kim [Tue, 26 Jun 2018 06:00:24 +0000 (23:00 -0700)]
sdcardfs: fix wrong ENOENT when creating a file

There is subtle race condtion where lower_dentry is null. If we retry
lookup again, we should get the correct dentry.

Bug: 110585947
Bug: 110464178
Bug: 80587794
Bug: 37231161
Bug: 110199687
Change-Id: I39b95de4649b034287776f5c8a5d197b6ebd9ada
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
4 years agoARM: dts: msm8998: Recalibrate busy costs using better data
Sultan Alsawaf [Mon, 22 Apr 2019 09:03:46 +0000 (02:03 -0700)]
ARM: dts: msm8998: Recalibrate busy costs using better data

Power and performance were measured on a production wahoo device in the
kernel in a high-precision manner. Use the resulting data to create a
better energy model that reflects the actual behavior of production
hardware.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
wloot: Adapt to 98897c5c ("ARM: dts: msm8998: Remove few bottom frequencies of low energy efficiency")

4 years agoarm64/neon: Disable -Wincompatible-pointer-types when building with Clang
Nathan Chancellor [Fri, 15 Feb 2019 01:39:59 +0000 (18:39 -0700)]
arm64/neon: Disable -Wincompatible-pointer-types when building with Clang

After commit cc9f8349cb33 ("arm64: crypto: add NEON accelerated XOR
implementation"), Clang builds for arm64 started failing with the
following error message.

arch/arm64/lib/xor-neon.c:58:28: error: incompatible pointer types
assigning to 'const unsigned long *' from 'uint64_t *' (aka 'unsigned
long long *') [-Werror,-Wincompatible-pointer-types]
                v3 = veorq_u64(vld1q_u64(dp1 +  6), vld1q_u64(dp2 + 6));
                                         ^~~~~~~~
/usr/lib/llvm-9/lib/clang/9.0.0/include/arm_neon.h:7538:47: note:
expanded from macro 'vld1q_u64'
  __ret = (uint64x2_t) __builtin_neon_vld1q_v(__p0, 51); \
                                              ^~~~

There has been quite a bit of debate and triage that has gone into
figuring out what the proper fix is, viewable at the link below, which
is still ongoing. Ard suggested disabling this warning with Clang with a
pragma so no neon code will have this type of error. While this is not
at all an ideal solution, this build error is the only thing preventing
KernelCI from having successful arm64 defconfig and allmodconfig builds
on linux-next. Getting continuous integration running is more important
so new warnings/errors or boot failures can be caught and fixed quickly.

Link: https://github.com/ClangBuiltLinux/linux/issues/283
Suggested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Julian Liu <wlootlxt123@gmail.com>
4 years agoarm64/neon: add workaround for ambiguous C99 stdint.h types
Jackie Liu [Tue, 4 Dec 2018 01:43:22 +0000 (09:43 +0800)]
arm64/neon: add workaround for ambiguous C99 stdint.h types

In a way similar to ARM commit 09096f6a0ee2 ("ARM: 7822/1: add workaround
for ambiguous C99 stdint.h types"), this patch redefines the macros that
are used in stdint.h so its definitions of uint64_t and int64_t are
compatible with those of the kernel.

This patch comes from: https://patchwork.kernel.org/patch/3540001/
Wrote by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

We mark this file as a private file and don't have to override asm/types.h

Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
4 years agoion: fix a possible memory leak in ion_cma_allocate
Suren Baghdasaryan [Thu, 18 Apr 2019 19:42:44 +0000 (12:42 -0700)]
ion: fix a possible memory leak in ion_cma_allocate

The memory leak occurs when kmalloc() for info->table fails, info is freed
but info->cpu_addr allocation is left.
Fixes: eeeb940746de ("ion: add snapshot of ion support for MSM")

Bug: 130817249
Test: builds and boots
Change-Id: I7faf5be5129a46b2f874f4e3803470e5f5130a21
Reported-by: Mikael Magnusson <Mikael.Magnusson@sony.com>
Suggested-by: Mikael Magnusson <Mikael.Magnusson@sony.com>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
4 years agomm/page-writeback.c: place "not" inside of unlikely() statement in wb_domain_writeout...
Steven Rostedt (VMware) [Fri, 24 Feb 2017 22:59:24 +0000 (14:59 -0800)]
mm/page-writeback.c: place "not" inside of unlikely() statement in wb_domain_writeout_inc()

The likely/unlikely profiler noticed that the unlikely statement in
wb_domain_writeout_inc() is constantly wrong.  This is due to the "not"
(!) being outside the unlikely statement.  It is likely that
dom->period_time will be set, but unlikely that it wont be.  Move the
not into the unlikely statement.

Link: http://lkml.kernel.org/r/20170206120035.3c2e2b91@gandalf.local.home
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
4 years agolist: introduce list_for_each_entry_from_reverse helper
Jiri Pirko [Fri, 3 Feb 2017 09:29:05 +0000 (10:29 +0100)]
list: introduce list_for_each_entry_from_reverse helper

Similar to list_for_each_entry_continue and its reverse variant
list_for_each_entry_continue_reverse, introduce reverse helper for
list_for_each_entry_from.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomm/vmalloc: rework vmap_area_lock
Uladzislau Rezki (Sony) [Tue, 22 Oct 2019 15:58:00 +0000 (17:58 +0200)]
mm/vmalloc: rework vmap_area_lock

With the new allocation approach introduced in the 5.2 kernel, it
becomes possible to get rid of one global spinlock. By doing that
we can further improve the KVA from the performance point of view.

Basically we can have two independent locks, one for allocation
part and another one for deallocation, because of two different
entities: "free data structures" and "busy data structures".

As a result, allocation/deallocation operations can still interfere
between each other in case of running simultaneously on different
CPUs, it means there is still dependency, but with two locks it
becomes lower.

Summarizing:
  - it reduces the high lock contention
  - it allows to perform operations on "free" and "busy"
    trees in parallel on different CPUs. Please note it
    does not solve scalability issue.

Test results:
In order to evaluate this patch, we can run "vmalloc test driver"
to see how many CPU cycles it takes to complete all test cases
running sequentially. All online CPUs run it so it will cause
a high lock contention.

HiKey 960, ARM64, 8xCPUs, big.LITTLE:

<snip>
    sudo ./test_vmalloc.sh sequential_test_order=1
<snip>

<default>
[  390.950557] All test took CPU0=457126382 cycles
[  391.046690] All test took CPU1=454763452 cycles
[  391.128586] All test took CPU2=454539334 cycles
[  391.222669] All test took CPU3=455649517 cycles
[  391.313946] All test took CPU4=388272196 cycles
[  391.410425] All test took CPU5=384036264 cycles
[  391.492219] All test took CPU6=387432964 cycles
[  391.578433] All test took CPU7=387201996 cycles
<default>

<patched>
[  304.721224] All test took CPU0=391521310 cycles
[  304.821219] All test took CPU1=393533002 cycles
[  304.917120] All test took CPU2=392243032 cycles
[  305.008986] All test took CPU3=392353853 cycles
[  305.108944] All test took CPU4=297630721 cycles
[  305.196406] All test took CPU5=297548736 cycles
[  305.288602] All test took CPU6=297092392 cycles
[  305.381088] All test took CPU7=297293597 cycles
<patched>

~14%-23% patched variant is better.

Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
4 years agomm/vmalloc: add more comments to the adjust_va_to_fit_type()
Uladzislau Rezki (Sony) [Wed, 16 Oct 2019 09:54:38 +0000 (11:54 +0200)]
mm/vmalloc: add more comments to the adjust_va_to_fit_type()

When fit type is NE_FIT_TYPE there is a need in one extra object.
Usually the "ne_fit_preload_node" per-CPU variable has it and
there is no need in GFP_NOWAIT allocation, but there are exceptions.

This commit just adds more explanations, as a result giving
answers on questions like when it can occur, how often, under
which conditions and what happens if GFP_NOWAIT gets failed.

Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Acked-by: Michal Hocko <mhocko@suse.com>
4 years agomm/vmalloc: respect passed gfp_mask when do preloading
Uladzislau Rezki (Sony) [Wed, 16 Oct 2019 09:54:37 +0000 (11:54 +0200)]
mm/vmalloc: respect passed gfp_mask when do preloading

alloc_vmap_area() is given a gfp_mask for the page allocator.
Let's respect that mask and consider it even in the case when
doing regular CPU preloading, i.e. where a context can sleep.

Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
4 years agomm/vmalloc: remove preempt_disable/enable when do preloading
Uladzislau Rezki (Sony) [Wed, 16 Oct 2019 09:54:36 +0000 (11:54 +0200)]
mm/vmalloc: remove preempt_disable/enable when do preloading

Some background. The preemption was disabled before to guarantee
that a preloaded object is available for a CPU, it was stored for.

The aim was to not allocate in atomic context when spinlock
is taken later, for regular vmap allocations. But that approach
conflicts with CONFIG_PREEMPT_RT philosophy. It means that
calling spin_lock() with disabled preemption is forbidden
in the CONFIG_PREEMPT_RT kernel.

Therefore, get rid of preempt_disable() and preempt_enable() when
the preload is done for splitting purpose. As a result we do not
guarantee now that a CPU is preloaded, instead we minimize the
case when it is not, with this change.

For example i run the special test case that follows the preload
pattern and path. 20 "unbind" threads run it and each does
1000000 allocations. Only 3.5 times among 1000000 a CPU was
not preloaded. So it can happen but the number is negligible.

V2 - > V3:
    - update the commit message

V1 -> V2:
  - move __this_cpu_cmpxchg check when spin_lock is taken,
    as proposed by Andrew Morton
  - add more explanation in regard of preloading
  - adjust and move some comments

Fixes: 82dd23e84be3 ("mm/vmalloc.c: preload a CPU with one object for split purpose")
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Acked-by: Michal Hocko <mhocko@suse.com>
4 years agomm: vmalloc: show number of vmalloc pages in /proc/meminfo
Roman Gushchin [Fri, 12 Jul 2019 04:00:13 +0000 (21:00 -0700)]
mm: vmalloc: show number of vmalloc pages in /proc/meminfo

Vmalloc() is getting more and more used these days (kernel stacks, bpf and
percpu allocator are new top users), and the total % of memory consumed by
vmalloc() can be pretty significant and changes dynamically.

/proc/meminfo is the best place to display this information: its top goal
is to show top consumers of the memory.

Since the VmallocUsed field in /proc/meminfo is not in use for quite a
long time (it has been defined to 0 by a5ad88ce8c7f ("mm: get rid of
'vmalloc_info' from /proc/meminfo")), let's reuse it for showing the
actual physical memory consumption of vmalloc().

Link: http://lkml.kernel.org/r/20190417194002.12369-3-guro@fb.com
Signed-off-by: Roman Gushchin <guro@fb.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
4 years agomm/vmalloc.c: move 'area->pages' after if statement
Austin Kim [Mon, 23 Sep 2019 22:36:42 +0000 (15:36 -0700)]
mm/vmalloc.c: move 'area->pages' after if statement

If !area->pages statement is true where memory allocation fails, area is
freed.

In this case 'area->pages = pages' should not executed.  So move
'area->pages = pages' after if statement.

[akpm@linux-foundation.org: give area->pages the same treatment]
Link: http://lkml.kernel.org/r/20190830035716.GA190684@LGEARND20B15
Signed-off-by: Austin Kim <austindh.kim@gmail.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Uladzislau Rezki (Sony) <urezki@gmail.com>
Cc: Roman Gushchin <guro@fb.com>
Cc: Roman Penyaev <rpenyaev@suse.de>
Cc: Rick Edgecombe <rick.p.edgecombe@intel.com>
Cc: Mike Rapoport <rppt@linux.ibm.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
4 years agomm/vmalloc: modify struct vmap_area to reduce its size
Pengfei Li [Mon, 23 Sep 2019 22:36:39 +0000 (15:36 -0700)]
mm/vmalloc: modify struct vmap_area to reduce its size

Objective
---------

The current implementation of struct vmap_area wasted space.

After applying this commit, sizeof(struct vmap_area) has been
reduced from 11 words to 8 words.

Description
-----------

1) Pack "subtree_max_size", "vm" and "purge_list".  This is no problem
   because

A) "subtree_max_size" is only used when vmap_area is in "free" tree

B) "vm" is only used when vmap_area is in "busy" tree

C) "purge_list" is only used when vmap_area is in vmap_purge_list

2) Eliminate "flags".

;Since only one flag VM_VM_AREA is being used, and the same thing can be
done by judging whether "vm" is NULL, then the "flags" can be eliminated.

Link: http://lkml.kernel.org/r/20190716152656.12255-3-lpf.vector@gmail.com
Signed-off-by: Pengfei Li <lpf.vector@gmail.com>
Suggested-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Oleksiy Avramchenko <oleksiy.avramchenko@sonymobile.com>
Cc: Roman Gushchin <guro@fb.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
4 years agomm/vmalloc.c: avoid bogus -Wmaybe-uninitialized warning
Arnd Bergmann [Fri, 28 Jun 2019 19:07:09 +0000 (12:07 -0700)]
mm/vmalloc.c: avoid bogus -Wmaybe-uninitialized warning

gcc gets confused in pcpu_get_vm_areas() because there are too many
branches that affect whether 'lva' was initialized before it gets used:

  mm/vmalloc.c: In function 'pcpu_get_vm_areas':
  mm/vmalloc.c:991:4: error: 'lva' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      insert_vmap_area_augment(lva, &va->rb_node,
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       &free_vmap_area_root, &free_vmap_area_list);
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  mm/vmalloc.c:916:20: note: 'lva' was declared here
    struct vmap_area *lva;
                      ^~~

Add an intialization to NULL, and check whether this has changed before
the first use.

[akpm@linux-foundation.org: tweak comments]
Link: http://lkml.kernel.org/r/20190618092650.2943749-1-arnd@arndb.de
Fixes: 68ad4a330433 ("mm/vmalloc.c: keep track of free blocks for vmap allocation")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Cc: Joel Fernandes <joelaf@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
4 years agomm/vmalloc.c: fix percpu free VM area search criteria
Kuppuswamy Sathyanarayanan [Tue, 13 Aug 2019 22:37:31 +0000 (15:37 -0700)]
mm/vmalloc.c: fix percpu free VM area search criteria

Recent changes to the vmalloc code by commit 68ad4a330433
("mm/vmalloc.c: keep track of free blocks for vmap allocation") can
cause spurious percpu allocation failures.  These, in turn, can result
in panic()s in the slub code.  One such possible panic was reported by
Dave Hansen in following link https://lkml.org/lkml/2019/6/19/939.
Another related panic observed is,

 RIP: 0033:0x7f46f7441b9b
 Call Trace:
  dump_stack+0x61/0x80
  pcpu_alloc.cold.30+0x22/0x4f
  mem_cgroup_css_alloc+0x110/0x650
  cgroup_apply_control_enable+0x133/0x330
  cgroup_mkdir+0x41b/0x500
  kernfs_iop_mkdir+0x5a/0x90
  vfs_mkdir+0x102/0x1b0
  do_mkdirat+0x7d/0xf0
  do_syscall_64+0x5b/0x180
  entry_SYSCALL_64_after_hwframe+0x44/0xa9

VMALLOC memory manager divides the entire VMALLOC space (VMALLOC_START
to VMALLOC_END) into multiple VM areas (struct vm_areas), and it mainly
uses two lists (vmap_area_list & free_vmap_area_list) to track the used
and free VM areas in VMALLOC space.  And pcpu_get_vm_areas(offsets[],
sizes[], nr_vms, align) function is used for allocating congruent VM
areas for percpu memory allocator.  In order to not conflict with
VMALLOC users, pcpu_get_vm_areas allocates VM areas near the end of the
VMALLOC space.  So the search for free vm_area for the given requirement
starts near VMALLOC_END and moves upwards towards VMALLOC_START.

Prior to commit 68ad4a330433, the search for free vm_area in
pcpu_get_vm_areas() involves following two main steps.

Step 1:
    Find a aligned "base" adress near VMALLOC_END.
    va = free vm area near VMALLOC_END
Step 2:
    Loop through number of requested vm_areas and check,
        Step 2.1:
           if (base < VMALLOC_START)
              1. fail with error
        Step 2.2:
           // end is offsets[area] + sizes[area]
           if (base + end > va->vm_end)
               1. Move the base downwards and repeat Step 2
        Step 2.3:
           if (base + start < va->vm_start)
              1. Move to previous free vm_area node, find aligned
                 base address and repeat Step 2

But Commit 68ad4a330433 removed Step 2.2 and modified Step 2.3 as below:

        Step 2.3:
           if (base + start < va->vm_start || base + end > va->vm_end)
              1. Move to previous free vm_area node, find aligned
                 base address and repeat Step 2

Above change is the root cause of spurious percpu memory allocation
failures.  For example, consider a case where a relatively large vm_area
(~ 30 TB) was ignored in free vm_area search because it did not pass the
base + end < vm->vm_end boundary check.  Ignoring such large free
vm_area's would lead to not finding free vm_area within boundary of
VMALLOC_start to VMALLOC_END which in turn leads to allocation failures.

So modify the search algorithm to include Step 2.2.

Link: http://lkml.kernel.org/r/20190729232139.91131-1-sathyanarayanan.kuppuswamy@linux.intel.com
Fixes: 68ad4a330433 ("mm/vmalloc.c: keep track of free blocks for vmap allocation")
Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Reported-by: Dave Hansen <dave.hansen@intel.com>
Acked-by: Dennis Zhou <dennis@kernel.org>
Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Cc: Roman Gushchin <guro@fb.com>
Cc: sathyanarayanan kuppuswamy <sathyanarayanan.kuppuswamy@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
4 years agomm/vmalloc: do not keep unpurged areas in the busy tree
Uladzislau Rezki (Sony) [Tue, 16 Jul 2019 12:05:17 +0000 (14:05 +0200)]
mm/vmalloc: do not keep unpurged areas in the busy tree

The busy tree can be quite big, even though the area is freed
or unmapped it still stays there until "purge" logic removes
it.

1) Optimize and reduce the size of "busy" tree by removing a
node from it right away as soon as user triggers free paths.
It is possible to do so, because the allocation is done using
another augmented tree.

The vmalloc test driver shows the difference, for example the
"fix_size_alloc_test" is ~11% better comparing with default
configuration:

sudo ./test_vmalloc.sh performance

<default>
Summary: fix_size_alloc_test loops: 1000000 avg: 993985 usec
Summary: full_fit_alloc_test loops: 1000000 avg: 973554 usec
Summary: long_busy_list_alloc_test loops: 1000000 avg: 12617652 usec
<default>

<this patch>
Summary: fix_size_alloc_test loops: 1000000 avg: 882263 usec
Summary: full_fit_alloc_test loops: 1000000 avg: 973407 usec
Summary: long_busy_list_alloc_test loops: 1000000 avg: 12593929 usec
<this patch>

2) Since the busy tree now contains allocated areas only and does
not interfere with lazily free nodes, introduce the new function
show_purge_info() that dumps "unpurged" areas that is propagated
through "/proc/vmallocinfo".

3) Eliminate VM_LAZY_FREE flag.

Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
4 years agomm/vmalloc.c: switch to WARN_ON() and move it under unlink_va()
Uladzislau Rezki (Sony) [Thu, 6 Jun 2019 12:04:11 +0000 (14:04 +0200)]
mm/vmalloc.c: switch to WARN_ON() and move it under unlink_va()

Trigger a warning if an object that is about to be freed is detached.
We used to have a BUG_ON(), but even though it is considered as faulty
behaviour that is not a good reason to break a system.

Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
4 years agomm/vmalloc.c: get rid of one single unlink_va() when merge
Uladzislau Rezki (Sony) [Thu, 6 Jun 2019 12:04:10 +0000 (14:04 +0200)]
mm/vmalloc.c: get rid of one single unlink_va() when merge

It does not make sense to try to "unlink" the node that is definitely not
linked with a list nor tree.  On the first merge step VA just points to
the previously disconnected busy area.

On the second step, check if the node has been merged and do "unlink" if
so, because now it points to an object that must be linked.

Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Acked-by: Hillf Danton <hdanton@sina.com>
Reviewed-by: Roman Gushchin <guro@fb.com>
4 years agomm/vmalloc.c: preload a CPU with one object for split purpose
Uladzislau Rezki (Sony) [Thu, 6 Jun 2019 12:04:09 +0000 (14:04 +0200)]
mm/vmalloc.c: preload a CPU with one object for split purpose

Refactor the NE_FIT_TYPE split case when it comes to an allocation of one
extra object. We need it in order to build a remaining space. The preload
is done per CPU in non-atomic context with GFP_KERNEL flags.

More permissive parameters can be beneficial for systems which are suffer
from high memory pressure or low memory condition. For example on my KVM
system(4xCPUs, no swap, 256MB RAM) i can simulate the failure of page
allocation with GFP_NOWAIT flags. Using "stress-ng" tool and starting N
workers spinning on fork() and exit(), i can trigger below trace:

<snip>
[  179.815161] stress-ng-fork: page allocation failure: order:0, mode:0x40800(GFP_NOWAIT|__GFP_COMP), nodemask=(null),cpuset=/,mems_allowed=0
[  179.815168] CPU: 0 PID: 12612 Comm: stress-ng-fork Not tainted 5.2.0-rc3+ #1003
[  179.815170] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
[  179.815171] Call Trace:
[  179.815178]  dump_stack+0x5c/0x7b
[  179.815182]  warn_alloc+0x108/0x190
[  179.815187]  __alloc_pages_slowpath+0xdc7/0xdf0
[  179.815191]  __alloc_pages_nodemask+0x2de/0x330
[  179.815194]  cache_grow_begin+0x77/0x420
[  179.815197]  fallback_alloc+0x161/0x200
[  179.815200]  kmem_cache_alloc+0x1c9/0x570
[  179.815202]  alloc_vmap_area+0x32c/0x990
[  179.815206]  __get_vm_area_node+0xb0/0x170
[  179.815208]  __vmalloc_node_range+0x6d/0x230
[  179.815211]  ? _do_fork+0xce/0x3d0
[  179.815213]  copy_process.part.46+0x850/0x1b90
[  179.815215]  ? _do_fork+0xce/0x3d0
[  179.815219]  _do_fork+0xce/0x3d0
[  179.815226]  ? __do_page_fault+0x2bf/0x4e0
[  179.815229]  do_syscall_64+0x55/0x130
[  179.815231]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[  179.815234] RIP: 0033:0x7fedec4c738b
...
[  179.815237] RSP: 002b:00007ffda469d730 EFLAGS: 00000246 ORIG_RAX: 0000000000000038
[  179.815239] RAX: ffffffffffffffda RBX: 00007ffda469d730 RCX: 00007fedec4c738b
[  179.815240] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000001200011
[  179.815241] RBP: 00007ffda469d780 R08: 00007fededd6e300 R09: 00007ffda47f50a0
[  179.815242] R10: 00007fededd6e5d0 R11: 0000000000000246 R12: 0000000000000000
[  179.815243] R13: 0000000000000020 R14: 0000000000000000 R15: 0000000000000000
[  179.815245] Mem-Info:
[  179.815249] active_anon:12686 inactive_anon:14760 isolated_anon:0
                active_file:502 inactive_file:61 isolated_file:70
                unevictable:2 dirty:0 writeback:0 unstable:0
                slab_reclaimable:2380 slab_unreclaimable:7520
                mapped:15069 shmem:14813 pagetables:10833 bounce:0
                free:1922 free_pcp:229 free_cma:0
<snip>

Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
4 years agomm/vmalloc.c: remove "node" argument
Uladzislau Rezki (Sony) [Thu, 6 Jun 2019 12:04:08 +0000 (14:04 +0200)]
mm/vmalloc.c: remove "node" argument

Remove unused argument from the __alloc_vmap_area() function.

Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Roman Gushchin <guro@fb.com>
4 years agomm/vmalloc.c: convert vmap_lazy_nr to atomic_long_t
Uladzislau Rezki (Sony) [Tue, 14 May 2019 22:41:25 +0000 (15:41 -0700)]
mm/vmalloc.c: convert vmap_lazy_nr to atomic_long_t

vmap_lazy_nr variable has atomic_t type that is 4 bytes integer value on
both 32 and 64 bit systems.  lazy_max_pages() deals with "unsigned long"
that is 8 bytes on 64 bit system, thus vmap_lazy_nr should be 8 bytes on
64 bit as well.

Link: http://lkml.kernel.org/r/20190131162452.25879-1-urezki@gmail.com
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: William Kucharski <william.kucharski@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Thomas Garnier <thgarnie@google.com>
Cc: Oleksiy Avramchenko <oleksiy.avramchenko@sonymobile.com>
Cc: Joel Fernandes <joelaf@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
4 years agomm/vmap: add DEBUG_AUGMENT_LOWEST_MATCH_CHECK macro
Uladzislau Rezki (Sony) [Fri, 17 May 2019 21:31:37 +0000 (14:31 -0700)]
mm/vmap: add DEBUG_AUGMENT_LOWEST_MATCH_CHECK macro

This macro adds some debug code to check that vmap allocations are
happened in ascending order.

By default this option is set to 0 and not active.  It requires
recompilation of the kernel to activate it.  Set to 1, compile the
kernel.

[urezki@gmail.com: v4]
Link: http://lkml.kernel.org/r/20190406183508.25273-4-urezki@gmail.com
Link: http://lkml.kernel.org/r/20190402162531.10888-4-urezki@gmail.com
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Reviewed-by: Roman Gushchin <guro@fb.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Joel Fernandes <joelaf@google.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Oleksiy Avramchenko <oleksiy.avramchenko@sonymobile.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Thomas Garnier <thgarnie@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
4 years agomm/vmap: add DEBUG_AUGMENT_PROPAGATE_CHECK macro
Uladzislau Rezki (Sony) [Fri, 17 May 2019 21:31:34 +0000 (14:31 -0700)]
mm/vmap: add DEBUG_AUGMENT_PROPAGATE_CHECK macro

This macro adds some debug code to check that the augment tree is
maintained correctly, meaning that every node contains valid
subtree_max_size value.

By default this option is set to 0 and not active.  It requires
recompilation of the kernel to activate it.  Set to 1, compile the
kernel.

[urezki@gmail.com: v4]
Link: http://lkml.kernel.org/r/20190406183508.25273-3-urezki@gmail.com
Link: http://lkml.kernel.org/r/20190402162531.10888-3-urezki@gmail.com
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Reviewed-by: Roman Gushchin <guro@fb.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Joel Fernandes <joelaf@google.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Oleksiy Avramchenko <oleksiy.avramchenko@sonymobile.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Thomas Garnier <thgarnie@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
4 years agomm: vmalloc: pass proper vm_start into debugobjects
Chintan Pandya [Fri, 8 Jun 2018 00:06:53 +0000 (17:06 -0700)]
mm: vmalloc: pass proper vm_start into debugobjects

Client can call vunmap with some intermediate 'addr' which may not be
the start of the VM area.  Entire unmap code works with vm->vm_start
which is proper but debug object API is called with 'addr'.  This could
be a problem within debug objects.

Pass proper start address into debug object API.

[akpm@linux-foundation.org: fix warning]
Link: http://lkml.kernel.org/r/1523961828-9485-3-git-send-email-cpandya@codeaurora.org
Signed-off-by: Chintan Pandya <cpandya@codeaurora.org>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Byungchul Park <byungchul.park@lge.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Laura Abbott <labbott@redhat.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Wei Yang <richard.weiyang@gmail.com>
Cc: Yisheng Xie <xieyisheng1@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>