OSDN Git Service
Jaegeuk Kim [Tue, 3 Sep 2019 02:06:26 +0000 (10:06 +0800)]
f2fs: convert inline_data in prior to i_size_write
In below call path, we change i_size before inline conversion, however,
if we failed to convert inline inode, the inode may have wrong i_size
which is larger than max inline size, result inline inode corruption.
- f2fs_setattr
- truncate_setsize
- f2fs_convert_inline_inode
This patch reorders truncate_setsize() and f2fs_convert_inline_inode()
to guarantee inline_data has valid i_size.
Fixes:
0cab80ee0c9e ("f2fs: fix to convert inline inode in ->setattr")
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Tue, 3 Sep 2019 02:06:25 +0000 (10:06 +0800)]
f2fs: fix error path of f2fs_convert_inline_page()
In error path of f2fs_convert_inline_page(), we missed to truncate newly
reserved block in .i_addrs[0] once we failed in get_node_info(), fix it.
Fixes:
7735730d39d7 ("f2fs: fix to propagate error from __get_meta_page()")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Tue, 27 Aug 2019 10:17:55 +0000 (18:17 +0800)]
f2fs: add missing documents of reserve_root/resuid/resgid
Add missing documents.
Fixes:
7e65be49ed94f ("f2fs: add reserved blocks for root user")
Fixes:
7c2e59632b846 ("f2fs: add resgid and resuid to reserve root blocks")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Jaegeuk Kim [Thu, 29 Aug 2019 02:58:26 +0000 (19:58 -0700)]
f2fs: fix flushing node pages when checkpoint is disabled
This patch fixes skipping node page writes when checkpoint is disabled.
In this period, we can't rely on checkpoint to flush node pages.
Fixes:
fd8c8caf7e7c ("f2fs: let checkpoint flush dnode page of regular")
Fixes:
4354994f097d ("f2fs: checkpoint disabling")
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Fri, 23 Aug 2019 09:58:36 +0000 (17:58 +0800)]
f2fs: enhance f2fs_is_checkpoint_ready()'s readability
This patch changes sematics of f2fs_is_checkpoint_ready()'s return
value as: return true when checkpoint is ready, other return false,
it can improve readability of below conditions.
f2fs_submit_page_write()
...
if (is_sbi_flag_set(sbi, SBI_IS_SHUTDOWN) ||
!f2fs_is_checkpoint_ready(sbi))
__submit_merged_bio(io);
f2fs_balance_fs()
...
if (!f2fs_is_checkpoint_ready(sbi))
return;
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Fri, 23 Aug 2019 09:58:35 +0000 (17:58 +0800)]
f2fs: clean up __bio_alloc()'s parameter
Just cleanup, no logic change.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Fri, 23 Aug 2019 09:58:34 +0000 (17:58 +0800)]
f2fs: fix wrong error injection path in inc_valid_block_count()
If FAULT_BLOCK type error injection is on, in inc_valid_block_count()
we may decrease sbi->alloc_valid_block_count percpu stat count
incorrectly, fix it.
Fixes:
36b877af7992 ("f2fs: Keep alloc_valid_block_count in sync")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Thu, 22 Aug 2019 12:17:56 +0000 (20:17 +0800)]
f2fs: fix to writeout dirty inode during node flush
As Eric reported:
On xfstest generic/204 on f2fs, I'm getting a kernel BUG.
allocate_segment_by_default+0x9d/0x100 [f2fs]
f2fs_allocate_data_block+0x3c0/0x5c0 [f2fs]
do_write_page+0x62/0x110 [f2fs]
f2fs_do_write_node_page+0x2b/0xa0 [f2fs]
__write_node_page+0x2ec/0x590 [f2fs]
f2fs_sync_node_pages+0x756/0x7e0 [f2fs]
block_operations+0x25b/0x350 [f2fs]
f2fs_write_checkpoint+0x104/0x1150 [f2fs]
f2fs_sync_fs+0xa2/0x120 [f2fs]
f2fs_balance_fs_bg+0x33c/0x390 [f2fs]
f2fs_write_node_pages+0x4c/0x1f0 [f2fs]
do_writepages+0x1c/0x70
__writeback_single_inode+0x45/0x320
writeback_sb_inodes+0x273/0x5c0
wb_writeback+0xff/0x2e0
wb_workfn+0xa1/0x370
process_one_work+0x138/0x350
worker_thread+0x4d/0x3d0
kthread+0x109/0x140
The root cause of this issue is, in a very small partition, e.g.
in generic/204 testcase of fstest suit, filesystem's free space
is 50MB, so at most we can write 12800 inline inode with command:
`echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > $SCRATCH_MNT/$i`,
then filesystem will have:
- 12800 dirty inline data page
- 12800 dirty inode page
- and 12800 dirty imeta (dirty inode)
When we flush node-inode's page cache, we can also flush inline
data with each inode page, however it will run out-of-free-space
in device, then once it triggers checkpoint, there is no room for
huge number of imeta, at this time, GC is useless, as there is no
dirty segment at all.
In order to fix this, we try to recognize inode page during
node_inode's page flushing, and update inode page from dirty inode,
so that later another imeta (dirty inode) flush can be avoided.
Reported-and-tested-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Sahitya Tummala [Wed, 7 Aug 2019 13:40:32 +0000 (19:10 +0530)]
f2fs: Fix indefinite loop in f2fs_gc()
Policy - Foreground GC, LFS and greedy GC mode.
Under this policy, f2fs_gc() loops forever to GC as it doesn't have
enough free segements to proceed and thus it keeps calling gc_more
for the same victim segment. This can happen if the selected victim
segment could not be GC'd due to failed blkaddr validity check i.e.
is_alive() returns false for the blocks set in current validity map.
Fix this by keeping track of such invalid segments and skip those
segments for selection in get_victim_by_default() to avoid endless
GC loop under such error scenarios. Currently, add this logic under
CONFIG_F2FS_CHECK_FS to be able to root cause the issue in debug
version.
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
[Jaegeuk Kim: fix wrong bitmap size]
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Fri, 26 Jul 2019 07:41:20 +0000 (15:41 +0800)]
f2fs: allocate memory in batch in build_sit_info()
build_sit_info() allocate all bitmaps for each segment one by one,
it's quite low efficiency, this pach changes to allocate large
continuous memory at a time, and divide it and assign for each bitmaps
of segment. For large size image, it can expect improving its mount
speed.
Signed-off-by: Chen Gong <gongchen4@huawei.com>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Fri, 16 Aug 2019 03:03:34 +0000 (11:03 +0800)]
f2fs: fix to avoid data corruption by forbidding SSR overwrite
There is one case can cause data corruption.
- write 4k to fileA
- fsync fileA, 4k data is writebacked to lbaA
- write 4k to fileA
- kworker flushs 4k to lbaB; dnode contain lbaB didn't be persisted yet
- write 4k to fileB
- kworker flush 4k to lbaA due to SSR
- SPOR -> dnode with lbaA will be recovered, however lbaA contains fileB's
data
One solution is tracking all fsynced file's block history, and disallow
SSR overwrite on newly invalidated block on that file.
However, during recovery, no matter the dnode is flushed or fsynced, all
previous dnodes until last fsynced one in node chain can be recovered,
that means we need to record all block change in flushed dnode, which
will cause heavy cost, so let's just use simple fix by forbidding SSR
overwrite directly.
Fixes:
5b6c6be2d878 ("f2fs: use SSR for warm node as well")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Fri, 2 Aug 2019 10:15:48 +0000 (18:15 +0800)]
Revert "f2fs: avoid out-of-range memory access"
As Pavel Machek reported:
"We normally use -EUCLEAN to signal filesystem corruption. Plus, it is
good idea to report it to the syslog and mark filesystem as "needing
fsck" if filesystem can do that."
Still we need improve the original patch with:
- use unlikely keyword
- add message print
- return EUCLEAN
However, after rethink this patch, I don't think we should add such
condition check here as below reasons:
- We have already checked the field in f2fs_sanity_check_ckpt(),
- If there is fs corrupt or security vulnerability, there is nothing
to guarantee the field is integrated after the check, unless we do
the check before each of its use, however no filesystem does that.
- We only have similar check for bitmap, which was added due to there
is bitmap corruption happened on f2fs' runtime in product.
- There are so many key fields in SB/CP/NAT did have such check
after f2fs_sanity_check_{sb,cp,..}.
So I propose to revert this unneeded check.
This reverts commit
56f3ce675103e3fb9e631cfb4131fc768bc23e9a.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Lihong Kou [Mon, 5 Aug 2019 11:13:52 +0000 (19:13 +0800)]
f2fs: cleanup the code in build_sit_entries.
We do not need to set the SBI_NEED_FSCK flag in the error paths, if we
return error here, we will not update the checkpoint flag, so the code
is useless, just remove it.
Signed-off-by: Lihong Kou <koulihong@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Mon, 5 Aug 2019 10:27:25 +0000 (18:27 +0800)]
f2fs: fix wrong available node count calculation
In mkfs, we have counted quota file's node number in cp.valid_node_count,
so we have to avoid wrong substraction of quota node number in
.available_nid/.avail_node_count calculation.
f2fs_write_check_point_pack()
{
..
set_cp(valid_node_count, 1 + c.quota_inum + c.lpf_inum);
Fixes:
292c196a3695 ("f2fs: reserve nid resource for quota sysfile")
Fixes:
7b63f72f73af ("f2fs: fix to do sanity check on valid node/block count")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Lihong Kou [Mon, 5 Aug 2019 07:27:24 +0000 (15:27 +0800)]
f2fs: remove duplicate code in f2fs_file_write_iter
We will do the same check in generic_write_checks.
if (iocb->ki_flags & IOCB_NOWAIT) && !(iocb->ki_flags & IOCB_DIRECT)
return -EINVAL;
just remove the same check in f2fs_file_write_iter.
Signed-off-by: Lihong Kou <koulihong@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Mon, 29 Jul 2019 15:02:29 +0000 (23:02 +0800)]
f2fs: fix to migrate blocks correctly during defragment
During defragment, we missed to trigger fragmented blocks migration
for below condition:
In defragment region:
- total number of valid blocks is smaller than 512;
- the tail part of the region are all holes;
In addtion, return zero to user via range->len if there is no
fragmented blocks.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Thu, 15 Aug 2019 11:45:35 +0000 (19:45 +0800)]
f2fs: use wrapped f2fs_cp_error()
Just cleanup, no logic change.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Thu, 15 Aug 2019 11:45:36 +0000 (19:45 +0800)]
f2fs: fix to use more generic EOPNOTSUPP
EOPNOTSUPP is widely used as error number indicating operation is
not supported in syscall, and ENOTSUPP was defined and only used
for NFSv3 protocol, so use EOPNOTSUPP instead.
Fixes:
0a2aa8fbb969 ("f2fs: refactor __exchange_data_block for speed up")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Thu, 15 Aug 2019 11:45:34 +0000 (19:45 +0800)]
f2fs: use wrapped IS_SWAPFILE()
Just cleanup, no logic change.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Fri, 26 Jul 2019 07:43:17 +0000 (15:43 +0800)]
f2fs: fix to avoid call kvfree under spinlock
vfree() don't wish to be called from interrupt context, move it
out of spin_lock_irqsave() coverage.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Jia-Ju Bai [Fri, 26 Jul 2019 03:45:12 +0000 (11:45 +0800)]
fs: f2fs: Remove unnecessary checks of SM_I(sbi) in update_general_status()
In fill_super() and put_super(), f2fs_destroy_stats() is called
in prior to f2fs_destroy_segment_manager(), so if current
sbi can still be visited in global stat list, SM_I(sbi) should be
released yet.
For this reason, SM_I(sbi) does not need to be checked in
update_general_status().
Thank Chao Yu for advice.
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Thu, 25 Jul 2019 14:39:11 +0000 (22:39 +0800)]
f2fs: disallow direct IO in atomic write
Atomic write needs page cache to cache data of transaction,
direct IO should never be allowed in atomic write, detect
and deny it when open atomic write file.
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Thu, 25 Jul 2019 09:33:37 +0000 (17:33 +0800)]
f2fs: fix to handle quota_{on,off} correctly
With quota_ino feature on, generic/232 reports an inconsistence issue
on the image.
The root cause is that the testcase tries to:
- use quotactl to shutdown journalled quota based on sysfile;
- and then use quotactl to enable/turn on quota based on specific file
(aquota.user or aquota.group).
Eventually, quota sysfile will be out-of-update due to following specific
file creation.
Change as below to fix this issue:
- deny enabling quota based on specific file if quota sysfile exists.
- set SBI_QUOTA_NEED_REPAIR once sysfile based quota shutdowns via
ioctl.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Mon, 22 Jul 2019 09:57:06 +0000 (17:57 +0800)]
f2fs: fix to detect cp error in f2fs_setxattr()
It needs to return -EIO if filesystem has been shutdown, fix the
miss case in f2fs_setxattr().
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Mon, 22 Jul 2019 09:57:05 +0000 (17:57 +0800)]
f2fs: fix to spread f2fs_is_checkpoint_ready()
We missed to call f2fs_is_checkpoint_ready() in several places, it may
allow space allocation even when free space was exhausted during
checkpoint is disabled, fix to add them.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Mon, 22 Jul 2019 10:03:50 +0000 (18:03 +0800)]
f2fs: support fiemap() for directory inode
Adjust f2fs_fiemap() to support fiemap() on directory inode.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Fri, 19 Jul 2019 07:18:44 +0000 (15:18 +0800)]
f2fs: fix to avoid discard command leak
=============================================================================
BUG discard_cmd (Tainted: G B OE ): Objects remaining in discard_cmd on __kmem_cache_shutdown()
-----------------------------------------------------------------------------
INFO: Slab 0xffffe1ac481d22c0 objects=36 used=2 fp=0xffff936b4748bf50 flags=0x2ffff0000000100
Call Trace:
dump_stack+0x63/0x87
slab_err+0xa1/0xb0
__kmem_cache_shutdown+0x183/0x390
shutdown_cache+0x14/0x110
kmem_cache_destroy+0x195/0x1c0
f2fs_destroy_segment_manager_caches+0x21/0x40 [f2fs]
exit_f2fs_fs+0x35/0x641 [f2fs]
SyS_delete_module+0x155/0x230
? vtime_user_exit+0x29/0x70
do_syscall_64+0x6e/0x160
entry_SYSCALL64_slow_path+0x25/0x25
INFO: Object 0xffff936b4748b000 @offset=0
INFO: Object 0xffff936b4748b070 @offset=112
kmem_cache_destroy discard_cmd: Slab cache still has objects
Call Trace:
dump_stack+0x63/0x87
kmem_cache_destroy+0x1b4/0x1c0
f2fs_destroy_segment_manager_caches+0x21/0x40 [f2fs]
exit_f2fs_fs+0x35/0x641 [f2fs]
SyS_delete_module+0x155/0x230
do_syscall_64+0x6e/0x160
entry_SYSCALL64_slow_path+0x25/0x25
Recovery can cache discard commands, so in error path of fill_super(),
we need give a chance to handle them, otherwise it will lead to leak
of discard_cmd slab cache.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Fri, 12 Jul 2019 08:57:00 +0000 (16:57 +0800)]
f2fs: disallow switching io_bits option during remount
If IO alignment feature is turned on after remount, we didn't
initialize mempool of it, it turns out we will encounter panic
during IO submission due to access NULL mempool pointer.
This feature should be set only at mount time, so simply deny
configuring during remount.
This fixes bug reported in bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=204135
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Fri, 12 Jul 2019 08:55:42 +0000 (16:55 +0800)]
f2fs: fix panic of IO alignment feature
Since
07173c3ec276 ("block: enable multipage bvecs"), one bio vector
can store multi pages, so that we can not calculate max IO size of
bio as PAGE_SIZE * bio->bi_max_vecs. However IO alignment feature of
f2fs always has that assumption, so finally, it may cause panic during
IO submission as below stack.
kernel BUG at fs/f2fs/data.c:317!
RIP: 0010:__submit_merged_bio+0x8b0/0x8c0
Call Trace:
f2fs_submit_page_write+0x3cd/0xdd0
do_write_page+0x15d/0x360
f2fs_outplace_write_data+0xd7/0x210
f2fs_do_write_data_page+0x43b/0xf30
__write_data_page+0xcf6/0x1140
f2fs_write_cache_pages+0x3ba/0xb40
f2fs_write_data_pages+0x3dd/0x8b0
do_writepages+0xbb/0x1e0
__writeback_single_inode+0xb6/0x800
writeback_sb_inodes+0x441/0x910
wb_writeback+0x261/0x650
wb_workfn+0x1f9/0x7a0
process_one_work+0x503/0x970
worker_thread+0x7d/0x820
kthread+0x1ad/0x210
ret_from_fork+0x35/0x40
This patch adds one extra condition to check left space in bio while
trying merging page to bio, to avoid panic.
This bug was reported in bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=204043
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Chao Yu [Fri, 12 Jul 2019 08:55:41 +0000 (16:55 +0800)]
f2fs: introduce {page,io}_is_mergeable() for readability
Wrap merge condition into function for readability, no logic change.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Jaegeuk Kim [Wed, 31 Jul 2019 20:27:05 +0000 (13:27 -0700)]
f2fs: fix livelock in swapfile writes
This patch fixes livelock in the below call path when writing swap pages.
[46374.617256] c2 701 __switch_to+0xe4/0x100
[46374.617265] c2 701 __schedule+0x80c/0xbc4
[46374.617273] c2 701 schedule+0x74/0x98
[46374.617281] c2 701 rwsem_down_read_failed+0x190/0x234
[46374.617291] c2 701 down_read+0x58/0x5c
[46374.617300] c2 701 f2fs_map_blocks+0x138/0x9a8
[46374.617310] c2 701 get_data_block_dio_write+0x74/0x104
[46374.617320] c2 701 __blockdev_direct_IO+0x1350/0x3930
[46374.617331] c2 701 f2fs_direct_IO+0x55c/0x8bc
[46374.617341] c2 701 __swap_writepage+0x1d0/0x3e8
[46374.617351] c2 701 swap_writepage+0x44/0x54
[46374.617360] c2 701 shrink_page_list+0x140/0xe80
[46374.617371] c2 701 shrink_inactive_list+0x510/0x918
[46374.617381] c2 701 shrink_node_memcg+0x2d4/0x804
[46374.617391] c2 701 shrink_node+0x10c/0x2f8
[46374.617400] c2 701 do_try_to_free_pages+0x178/0x38c
[46374.617410] c2 701 try_to_free_pages+0x348/0x4b8
[46374.617419] c2 701 __alloc_pages_nodemask+0x7f8/0x1014
[46374.617429] c2 701 pagecache_get_page+0x184/0x2cc
[46374.617438] c2 701 f2fs_new_node_page+0x60/0x41c
[46374.617449] c2 701 f2fs_new_inode_page+0x50/0x7c
[46374.617460] c2 701 f2fs_init_inode_metadata+0x128/0x530
[46374.617472] c2 701 f2fs_add_inline_entry+0x138/0xd64
[46374.617480] c2 701 f2fs_do_add_link+0xf4/0x178
[46374.617488] c2 701 f2fs_create+0x1e4/0x3ac
[46374.617497] c2 701 path_openat+0xdc0/0x1308
[46374.617507] c2 701 do_filp_open+0x78/0x124
[46374.617516] c2 701 do_sys_open+0x134/0x248
[46374.617525] c2 701 SyS_openat+0x14/0x20
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Julian Liu [Thu, 3 Oct 2019 05:54:50 +0000 (13:54 +0800)]
f2fs: Exit gc thread correctly
Julian Liu [Tue, 1 Oct 2019 23:41:11 +0000 (07:41 +0800)]
printk: silence healthd and batteryd logs
* <3>batteryd, <4>healthd
Julian Liu [Wed, 2 Oct 2019 06:22:26 +0000 (14:22 +0800)]
f2fs: fix dead wakelock holding
Julian Liu [Sun, 29 Sep 2019 14:27:12 +0000 (22:27 +0800)]
video: fbdev: Remove extraneous parentheses
Julian Liu [Sun, 29 Sep 2019 14:25:08 +0000 (22:25 +0800)]
camera_v2: ois: Remove extraneous parentheses
Julian Liu [Sun, 29 Sep 2019 14:22:48 +0000 (22:22 +0800)]
cpuidle: lpm-levels: Remove unused variable
Park Ju Hyung [Wed, 14 Aug 2019 15:37:15 +0000 (00:37 +0900)]
f2fs: trigger rapid GC only when screen state actually changes
While it's normal for these events to happen after the other one,
with AOD or poorly made kernel source, we can receive the same event
consequently.
Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
Julian Liu [Sat, 28 Sep 2019 20:10:54 +0000 (04:10 +0800)]
f2fs: Stop gc if less invalid blocks when not charging
Julian Liu [Sat, 28 Sep 2019 19:53:24 +0000 (03:53 +0800)]
f2fs: Optimize invalid block calculation
Julian Liu [Sat, 28 Sep 2019 11:05:07 +0000 (19:05 +0800)]
Revert "Makefile: Use O3 optimization level for Clang LTO"
This reverts commit
9385ccbfc41bb3f700f444f7542e0e2f6f2cc8ce.
Julian Liu [Sat, 28 Sep 2019 10:51:52 +0000 (18:51 +0800)]
Revert "kbuild: use LLVM integrated assembler for C files"
* we are still not using llvm as
This reverts commit
8e6f3377e608364f55330eb1f2b85596bbfe72d3.
Julian Liu [Fri, 27 Sep 2019 15:07:18 +0000 (23:07 +0800)]
f2fs: Also execute rapid gc without charging
Sultan Alsawaf [Fri, 27 Sep 2019 01:03:04 +0000 (18:03 -0700)]
iommu: msm: Rewrite to improve clarity and performance
This scope of this driver's lock usage is extremely wide, leading to
excessively long lock hold times. Additionally, there is lots of
excessive linked-list traversal and unnecessary dynamic memory
allocation in a critical path, causing poor performance across the
board.
Fix all of this by greatly reducing the scope of the locks used and by
significantly reducing the amount of operations performed when
msm_dma_map_sg_attrs() is called. The entire driver's code is overhauled
for better cleanliness and performance.
Note that ION must be modified to pass a known structure via the private
dma_buf pointer, so that the iommu driver can prevent races when
operating on the same buffer concurrently. This is the only way to
eliminate said buffer races without hurting the iommu driver's
performance.
Some additional members are added to the device struct as well to make
these various performance improvements possible.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Thierry Strudel [Wed, 9 May 2018 18:39:23 +0000 (11:39 -0700)]
Revert "USB: set hub's default autosuspend delay as 0"
Certain USB-C devices are failing to enumerate if the bus
transitions from active to suspend between connection and enumeration.
When a USB-C accessory is inserted in a phone and is detected by the
CC lines, the controller driver is loaded and the only devices present
on the bus are the root hubs, until the device enumerations.
As a result, a suspend transition between device connection and
enumeration is very likely.
This change leaves the hub autosuspend set to the usbcore.autosuspend
value so a value can be set high enough to prevent this race.
This reverts:
commit
596d789a211d ("USB: set hub's default autosuspend delay as 0")
This patch sets hub device's default autosuspend delay as 0 to
speedup bus suspend, see comments in code for details.
Bug:
71936484
Change-Id: If9b50c52fdbbece154ca9adf559cd93db89fb0f3
Signed-off-by: Thierry Strudel <tstrudel@google.com>
Signed-off-by: Andrew Chant <achant@google.com>
Sultan Alsawaf [Sun, 14 Oct 2018 07:52:53 +0000 (00:52 -0700)]
msm: kgsl: Increase worker thread priority
Currently, the kgsl worker thread is erroneosly ranked right below
Android's audio threads in terms of priority.
The kgsl worker thread is in the critical path for rendering frames to the
display, so increase its priority to match the priority of MDSS' kthread (mdss_fb0).
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Danny Lin <danny@kdrag0n.dev>
Julian Liu [Mon, 23 Sep 2019 10:34:12 +0000 (18:34 +0800)]
Revert "msm: kgsl: Increase priority of RT thread"
This reverts commit
276fd756b9847aa4ede44860fb772fed1eb97348.
Danny Lin [Sun, 22 Sep 2019 22:50:10 +0000 (15:50 -0700)]
Revert "ANDROID: sdcardfs: Allocate temporary name buffer on the stack"
This reverts commit
674f131b53ee1b4c22d0391ab48a46a583ef0962.
This causes stack overflows when combined with commit
f16b4c07c7602
("quota_tree: Avoid dynamic memory allocations"). Revert this and retain
the quota_tree commit since it allocates more often than sdcardfs.
Known triggers are Asus' Twin Apps feature as well as using rsync to
transfer files in /sdcard.
[ 74.545384] Kernel panic - not syncing: kernel stack overflow
[ 74.545389] CPU: 1 PID: 581 Comm: Binder:503_3 Tainted: G S W
4.14.146-Proton-gfaa3aaa2 #1089
[ 74.545394] Hardware name: Qualcomm Technologies, Inc. SM8150 V2 PM8150 KIRIN MP (DT)
[ 74.545398] Call trace:
[ 74.545405] dump_backtrace+0x0/0x218
[ 74.545410] show_stack+0x14/0x1c
[ 74.545418] dump_stack+0xbc/0x100
[ 74.545424] panic+0x110/0x284
[ 74.545429] panic+0x0/0x284
[ 74.545434] handle_bad_stack+0x110/0x124
[ 74.545439] __bad_stack+0x88/0x8c
[ 74.545443] pagecache_get_page+0x4/0x3f4
[ 74.545448] read_cache_page_gfp+0x1c/0x24
[ 74.545455] f2fs_quota_read+0xa4/0x3cc
[ 74.545461] do_insert_tree+0x8c/0x998
[ 74.545466] do_insert_tree+0x1c8/0x998
[ 74.545471] do_insert_tree+0x1c8/0x998
[ 74.545476] do_insert_tree+0x1c8/0x998
[ 74.545481] qtree_write_dquot+0x144/0x2c0
[ 74.545486] v2_write_dquot+0x58/0x84
[ 74.545492] dquot_acquire+0xe0/0x128
[ 74.545497] f2fs_dquot_acquire+0x30/0x6c
[ 74.545502] dqget+0x3a8/0x510
[ 74.545507] dquot_transfer+0xb8/0x15c
[ 74.545511] f2fs_setattr+0x10c/0x3cc
[ 74.545517] notify_change2+0x2b0/0x3a8
[ 74.545523] fixup_lower_ownership+0x138/0x3ac
[ 74.545529] sdcardfs_lookup+0x4d0/0x538
[ 74.545534] lookup_slow+0x9c/0x194
[ 74.545539] walk_component+0x120/0x1b0
[ 74.545544] path_lookupat+0x94/0x27c
[ 74.545548] filename_lookup+0x8c/0x1e0
[ 74.545552] user_path_at_empty+0x44/0x54
[ 74.545558] vfs_statx+0x84/0x124
[ 74.545563] SyS_newfstatat+0x30/0x6c
[ 74.545568] el0_svc_naked+0x34/0x38
Signed-off-by: Danny Lin <danny@kdrag0n.dev>
Julian Liu [Thu, 19 Sep 2019 16:00:09 +0000 (00:00 +0800)]
defconfig: Enable lmk adj rbtree
Julian Liu [Mon, 16 Sep 2019 14:33:02 +0000 (22:33 +0800)]
Makefile: Pass optimization flags to assembler
wloot [Sat, 1 Jun 2019 21:15:08 +0000 (05:15 +0800)]
Makefile: Optimize for our CPU
Joe Maples [Fri, 10 Nov 2017 15:51:18 +0000 (10:51 -0500)]
Makefile: Compile with O3
Signed-off-by: Joe Maples <joe@frap129.org>
Park Ju Hyung [Sat, 6 Jul 2019 18:00:59 +0000 (03:00 +0900)]
qcacld: check if auth_tag_len exceeds sizeof(hash)
Without this check, memcmp() compile-time check fails
Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
0ranko0P [Tue, 29 Oct 2019 12:03:59 +0000 (20:03 +0800)]
qcacld: disable more debugs
0ranko0P [Tue, 29 Oct 2019 04:10:09 +0000 (12:10 +0800)]
qcacld: disable tso debugging
Park Ju Hyung [Thu, 7 Mar 2019 02:11:33 +0000 (11:11 +0900)]
qcacld: nuke rx_wakelock code entirely
We're not allowing this to be configurable on this kernel.
Nuke this entirely to reduce resource usage.
Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
Park Ju Hyung [Mon, 15 Apr 2019 09:47:58 +0000 (18:47 +0900)]
qcacld: initialize variables to avoid errors during compilation
Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
Harsh Shandilya [Sun, 6 Oct 2019 15:35:45 +0000 (21:05 +0530)]
power: qcom: Silence clang warning
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
0ranko0P [Mon, 28 Oct 2019 11:37:05 +0000 (19:37 +0800)]
drivers: video: fbdev: update from sagit-p-oss
Julian Liu [Sat, 20 Jul 2019 09:55:59 +0000 (17:55 +0800)]
qcacld-3.0: Fix another uninitialized variable
Clang warns:
drivers/staging/qcacld-3.0/core/sme/src/csr/csr_util.c:1819:8: error:
variable 'phyMode2' is used uninitialized whenever 'if' condition is
false [-Werror,-Wsometimes-uninitialized]
if (eCSR_DOT11_MODE_AUTO & phyMode) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/staging/qcacld-3.0/core/sme/src/csr/csr_util.c:1826:36: note:
uninitialized use occurs here
fMatch = csr_get_phy_mode_in_use(phyMode2, phyModeInBssDesc,
^~~~~~~~
drivers/staging/qcacld-3.0/core/sme/src/csr/csr_util.c:1819:4: note:
remove the 'if' if its condition is always true
if (eCSR_DOT11_MODE_AUTO & phyMode) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/staging/qcacld-3.0/core/sme/src/csr/csr_util.c:1797:2: note:
variable 'phyMode2' is declared here
eCsrPhyMode phyModeInBssDesc = eCSR_DOT11_MODE_AUTO, phyMode2;
^
1 error generated.
0Ranko0P [Mon, 21 Oct 2019 12:31:15 +0000 (20:31 +0800)]
Merge f2fs changes from branch 'memeuibut8.2' of https://github.com/wloot/android_kernel_xiaomi_msm8998
Jeff Vanhoof [Thu, 19 Oct 2017 10:39:30 +0000 (05:39 -0500)]
lowmemorykiller: Account for extra_free_kbytes in calcuations
Account for extra_free_kbytes in calcuations
CRs-fixed: (CR)
Signed-off-by: Jeff Vanhoof <qjv001@motorola.com>
Change-Id: I2c44a1775d43fad40cf49d6303b7552c2c089b6e
Reviewed-on: https://gerrit.mot.com/
1076213
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Coverity Analysis <coverity@motorola.com>
Reviewed-by: Igor Kovalenko <igork@motorola.com>
Submit-Approved: Jira Key
Park Ju Hyung [Thu, 20 Jul 2017 13:04:03 +0000 (22:04 +0900)]
lmk: add inline keywords to in-loop functions
Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
Park Ju Hyung [Thu, 20 Jul 2017 13:01:51 +0000 (22:01 +0900)]
lmk: add static keywords to locally used variables
Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
Josh Galicia [Thu, 15 Sep 2016 18:43:49 +0000 (13:43 -0500)]
lowmemorykiller: redesign memory instrumentation
Add tracking node for LMK counts for memory instrumentation.
Change-Id: I7cd201dd4b84de81f08da580b590dad35673753b
Signed-off-by: Josh Galicia <cjg040@motorola.com>
Reviewed-on: https://gerrit.mot.com/899855
SLTApproved: Slta Waiver <sltawvr@motorola.com>
SME-Granted: SME Approvals Granted
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Christopher Fries <cfries@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
Signed-off-by: Alex Naidis <alex.naidis@linux.com>
Park Ju Hyung [Wed, 17 Jul 2019 17:43:50 +0000 (02:43 +0900)]
lmk: import rbtree changes from Motorola
Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
Signed-off-by: Julian Liu <wlootlxt123@gmail.com>
[@wloot: backport to k4.4]
Julian Liu [Thu, 19 Sep 2019 15:44:40 +0000 (23:44 +0800)]
lowmemorykiller: fix compilation with 4.4
Julian Liu [Thu, 19 Sep 2019 15:13:56 +0000 (23:13 +0800)]
lowmemorykiller: checkout to android-4.9
Julian Liu [Thu, 19 Sep 2019 15:10:05 +0000 (23:10 +0800)]
Revert "{chiron,sagit}_defconfig: Use Simple LMK"
This reverts commit
ca0e1a2fd5be9399388af504886a2622315bc7bd.
Julian Liu [Fri, 20 Sep 2019 03:57:25 +0000 (11:57 +0800)]
treewide: revert "remove duplicate const specifier" patchs
* C defined grammar
Julian Liu [Thu, 19 Sep 2019 19:38:00 +0000 (03:38 +0800)]
fs: proc: cpumaxfreq: Fix memory leak in cpumaxfreq_open
Julian Liu [Thu, 19 Sep 2019 18:37:59 +0000 (02:37 +0800)]
camera_v2: Fix memory leak in msm_eeprom_platform_probe
Julian Liu [Thu, 19 Sep 2019 18:50:14 +0000 (02:50 +0800)]
net: ipc_router: Fix memory leak when IPC_LOGGING disabled
Julian Liu [Wed, 18 Sep 2019 18:54:17 +0000 (02:54 +0800)]
Revert "camera_v2: update from sagit-p-oss"
This reverts commit
e67a25de54ccdc249c887d7ad4829dc1dd127c3f.
Danny Lin [Mon, 6 May 2019 04:59:37 +0000 (21:59 -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>
Sultan Alsawaf [Mon, 15 Oct 2018 03:23:55 +0000 (20:23 -0700)]
{chiron,sagit}_defconfig: omit frame pointer
This improves performance by freeing up a register at the expense of a huge
hit to ease of debugging. Since this kernel is not actively being debugged
for anything though, frame pointers can be disabled.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Change-Id: I98f88e981f01336923e08a4585a2b5c6b174512b
Sultan Alsawaf [Mon, 15 Oct 2018 03:21:25 +0000 (20:21 -0700)]
arm64: don't force FRAME_POINTER
Change-Id: I08261db2f80fb11b7e02af64a4ec011c2dab2b39
Sultan Alsawaf [Sun, 12 May 2019 20:12:25 +0000 (13:12 -0700)]
{chiron,sagit}_defconfig: Use Simple LMK
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
[wight554: apply wahoo change on chiron and sagit]
Signed-off-by: Volodymyr Zhdanov <wight554@gmail.com>
Sultan Alsawaf [Sun, 12 May 2019 20:12:21 +0000 (13:12 -0700)]
simple_lmk: Mark reclaim kthread as performance critical
Simple LMK's reclaim thread needs to run as quickly as possible to
reduce memory allocation latency when memory pressure is high. Mark it
as performance critical to schedule it on faster CPUs.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Sultan Alsawaf [Wed, 21 Aug 2019 15:45:15 +0000 (08:45 -0700)]
simple_lmk: Introduce Simple Low Memory Killer for Android
This is a complete low memory killer solution for Android that is small
and simple. Processes are killed according to the priorities that
Android gives them, so that the least important processes are always
killed first. Processes are killed until memory deficits are satisfied,
as observed from kswapd struggling to free up pages. Simple LMK stops
killing processes when kswapd finally goes back to sleep.
The only tunables are the desired amount of memory to be freed per
reclaim event and desired frequency of reclaim events. Simple LMK tries
to free at least the desired amount of memory per reclaim and waits
until all of its victims' memory is freed before proceeding to kill more
processes.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
宋金时 [Thu, 10 May 2018 02:05:03 +0000 (02:05 +0000)]
ANDROID: binder: correct the cmd print for BINDER_WORK_RETURN_ERROR
When to execute binder_stat_br the e->cmd has been modifying as BR_OK
instead of the original return error cmd, in fact we want to know the
original return error, such as BR_DEAD_REPLY or BR_FAILED_REPLY, etc.
instead of always BR_OK, in order to avoid the value of the e->cmd is
always BR_OK, so we need assign the value of the e->cmd to cmd before
e->cmd = BR_OK.
Signed-off-by: songjinshi <songjinshi@xiaomi.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Todd Kjos [Tue, 8 Aug 2017 22:48:36 +0000 (15:48 -0700)]
binder: fix incorrect cmd to binder_stat_br
commit
26549d177410 ("binder: guarantee txn complete / errors delivered
in-order") passed the locally declared and undefined cmd
to binder_stat_br() which results in a bogus cmd field in a trace
event and BR stats are incremented incorrectly.
Change to use e->cmd which has been initialized.
Signed-off-by: Todd Kjos <tkjos@google.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes:
26549d177410 ("binder: guarantee txn complete / errors delivered in-order")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Sultan Alsawaf [Thu, 1 Aug 2019 03:10:06 +0000 (20:10 -0700)]
fib_rules: Fix payload calculation
The errant semicolon here results in the final addend getting discarded.
Fixes:
ef5fbba6f8da ("net: core: add UID to flows, rules, and routes")
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Matthias Kaehlcke [Tue, 18 Jun 2019 21:14:40 +0000 (14:14 -0700)]
net/ipv4: fib_trie: Avoid cryptic ternary expressions
empty_child_inc/dec() use the ternary operator for conditional
operations. The conditions involve the post/pre in/decrement
operator and the operation is only performed when the condition
is *not* true. This is hard to parse for humans, use a regular
'if' construct instead and perform the in/decrement separately.
This also fixes two warnings that are emitted about the value
of the ternary expression being unused, when building the kernel
with clang + "kbuild: Remove unnecessary -Wno-unused-value"
(https://lore.kernel.org/patchwork/patch/
1089869/):
CC net/ipv4/fib_trie.o
net/ipv4/fib_trie.c:351:2: error: expression result unused [-Werror,-Wunused-value]
++tn_info(n)->empty_children ? : ++tn_info(n)->full_children;
Fixes:
95f60ea3e99a ("fib_trie: Add collapse() and should_collapse() to resize")
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Acked-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Sultan Alsawaf [Thu, 1 Aug 2019 01:38:18 +0000 (18:38 -0700)]
{chiron,sagit}_defconfig: Panic in schedule() when stack corruption is found
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
[wight554: apply wahoo change on chiron and sagit]
Signed-off-by: Volodymyr Zhdanov <wight554@gmail.com>
Sultan Alsawaf [Thu, 1 Aug 2019 01:37:06 +0000 (18:37 -0700)]
lib: Kconfig.debug: Remove debug dependency from SCHED_STACK_END_CHECK
This is a very useful feature that doesn't have any real dependencies on
DEBUG_KERNEL. Let it be used in the absence of DEBUG_KERNEL.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Sultan Alsawaf [Thu, 1 Aug 2019 01:34:31 +0000 (18:34 -0700)]
ANDROID: sdcardfs: Allocate temporary name buffer on the stack
Since this 4 KiB name buffer is only used temporarily, allocate it on
the stack to improve performance. This is confirmed to be safe according
to runtime stack usage measurements.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Sultan Alsawaf [Thu, 1 Aug 2019 01:27:02 +0000 (18:27 -0700)]
kobject_uevent: Allocate environment buffer on the stack
The environment buffer isn't very big; when it's allocated on the stack,
kobject_uevent_env's stack frame size increases to just over 2 KiB,
which is safe considering that we have a 16 KiB stack.
Allocate the environment buffer on the stack instead of using the slab
allocator in order to improve performance.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Sultan Alsawaf [Thu, 1 Aug 2019 01:02:49 +0000 (18:02 -0700)]
ion: system_heap: Speed up system heap allocations
The system heap allocation process consists of allocating numerous
temporary buffers that can instead be placed on the stack, to an extent;
if the new 4 KiB on-stack buffer runs out, page_info allocations will
fall back to using kmalloc.
Additionally, since system heap allocations are frequent, they can
benefit from the use of a memory pool for allocating the persistent
sg_table structures. These allocations, along with a few others, also
don't need to be zeroed out.
These changes improve system heap allocation performance considerably.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Sultan Alsawaf [Wed, 31 Jul 2019 20:07:35 +0000 (13:07 -0700)]
ANDROID: crypto: heh - Avoid dynamically allocating memory for keys
The derived keys are usually quite small (48 B). We can use a small
on-stack buffer of 1 KiB to dodge dynamic memory allocation, speeding up
heh_setkey.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Sultan Alsawaf [Wed, 31 Jul 2019 20:06:33 +0000 (13:06 -0700)]
ext4: Avoid dynamically allocating memory in ext4_ext_remove_space
Although path depth is unbounded, we can still fulfill many path
allocations here with a 4 KiB stack allocation, thereby improving
performance.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Sultan Alsawaf [Wed, 31 Jul 2019 07:04:01 +0000 (00:04 -0700)]
xattr: Avoid dynamically allocating memory in getxattr
Although the maximum xattr size is too big to fit on the stack (64 KiB),
we can still fulfill most getxattr requests with a 4 KiB stack
allocation, thereby improving performance. Such a large stack allocation
here is confirmed to be safe via stack usage measurements at runtime.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Sultan Alsawaf [Wed, 31 Jul 2019 07:00:01 +0000 (00:00 -0700)]
binfmt_elf: Don't allocate memory dynamically in load_elf_binary
The dynamic memory allocations in load_elf_binary can be replaced by
large stack allocations that bring the total frame size for the function
up to about 4 KiB. We have 16 KiB of stack space, and runtime
measurements confirm that using this much stack memory here is safe.
This improves performance by eliminating the overhead of dynamic memory
allocation.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Sultan Alsawaf [Wed, 31 Jul 2019 06:56:18 +0000 (23:56 -0700)]
staging: sync: Use an on-stack allocation for fence info ioctl
Since the fence info ioctl limits output data length to 4096 bytes, we
can just use a 4096-byte on-stack buffer for it (which is confirmed to
be safe via runtime stack usage measurements). This ioctl is used for
every frame rendered to the display, so eliminating dynamic memory
allocation overhead here improves frame rendering performance.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Sultan Alsawaf [Wed, 31 Jul 2019 06:53:13 +0000 (23:53 -0700)]
media: v4l2-ioctl: Use larger on-stack video copy buffers
We have a 16 KiB stack; buffers of 4 KiB and 512 B work perfectly fine
in place of a small 128-byte buffer and especially no on-stack buffer at
all. This avoids dynamic memory allocation more often, improving
performance, and it's safe according to stack usage measurements at
runtime.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Sultan Alsawaf [Wed, 31 Jul 2019 06:38:19 +0000 (23:38 -0700)]
msm: camera: Optimize memory allocation for small buffers
Try to use an on-stack buffer for memory allocations that are small
enough to not warrant a dynamic allocation, and eliminate dynamic memory
allocation entirely in msm_camera_cci_i2c_read_seq. This improves
performance by skipping latency-prone dynamic memory allocation when it
isn't needed.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Sultan Alsawaf [Wed, 31 Jul 2019 04:35:56 +0000 (21:35 -0700)]
msm: kgsl: Don't allocate memory dynamically for temp command buffers
The temporary command buffer in _set_pagetable_gpu is only the size of a
single page; it is therefore easy to replace the dynamic command buffer
allocation with a static one to improve performance by avoiding the
latency of dynamic memory allocation.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Sultan Alsawaf [Wed, 31 Jul 2019 04:29:13 +0000 (21:29 -0700)]
msm: mdss: Don't allocate memory dynamically for small layer buffers
There's no reason to dynamically allocate memory for a single, small
struct instance (output_layer) when it can be allocated on the stack.
Additionally, layer_list and validate_info_list are limited by the
maximum number of layers allowed, so they can be replaced by stack
allocations.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Sultan Alsawaf [Wed, 31 Jul 2019 04:15:10 +0000 (21:15 -0700)]
ext4 crypto: Use a larger on-stack file name buffer
32 bytes for the on-stack file name buffer is rather small and doesn't
fit many file names, causing dynamic allocation to be used more often
than necessary instead. Increasing the on-stack buffer to 4 KiB is safe
and helps this function avoid dynamic memory allocations far more
frequently.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Sultan Alsawaf [Wed, 31 Jul 2019 04:13:43 +0000 (21:13 -0700)]
selinux: Avoid dynamic memory allocation for small context buffers
Most context buffers are rather small and can fit on the stack,
eliminating the need to allocate them dynamically. Reserve a 4 KiB
stack buffer for this purpose to avoid the overhead of dynamic
memory allocation.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>