mirror of
https://github.com/hardkernel/linux.git
synced 2026-04-02 03:03:00 +09:00
PD#SWPL-1773 Problem: After adding optimization of vmap stack, we can found stack usage of each functions when handle vmap fault. From test log we see some functions using large stack size which over 256bytes. Especially common call path from fs. We need to optimize stack usage of these functions to reduce stack fault probability and save stack memory usage. Solution: 1. remove CONFIG_CC_STACKPROTECTOR_STRONG and set STACKPROTECTOR to NONE. This can save stack usage add by compiler for most functions. Kernel code size can also save over 1MB. 2. Add some noinline functions for android_fs_data rw trace calls. In these trace call it allcated a 256 bytes local buffer. 3. Add a wrap function for mem abort handler. By default, it defined a siginfo struct(size over 100 bytes) in local but only used when fault can't be handled. 4. reduce cached page size for vmap stack since probability of page fault caused by stack overflow is reduced after function stack usage optimized. Monkey test show real stack usage ratio compared with 1st vmap implementation reduced from 35% ~ 38% to 26 ~ 27%. Which is very close to 25%, theory limit. Verify: P212 Change-Id: I5505cacc1cab51f88654052902852fd648b6a036 Signed-off-by: tao zeng <tao.zeng@amlogic.com>
72 lines
2.1 KiB
C
72 lines
2.1 KiB
C
#undef TRACE_SYSTEM
|
|
#define TRACE_SYSTEM android_fs
|
|
|
|
#if !defined(_TRACE_ANDROID_FS_H) || defined(TRACE_HEADER_MULTI_READ)
|
|
#define _TRACE_ANDROID_FS_H
|
|
|
|
#include <linux/tracepoint.h>
|
|
#include <trace/events/android_fs_template.h>
|
|
|
|
DEFINE_EVENT(android_fs_data_start_template, android_fs_dataread_start,
|
|
TP_PROTO(struct inode *inode, loff_t offset, int bytes,
|
|
pid_t pid, char *pathname, char *command),
|
|
TP_ARGS(inode, offset, bytes, pid, pathname, command));
|
|
|
|
DEFINE_EVENT(android_fs_data_end_template, android_fs_dataread_end,
|
|
TP_PROTO(struct inode *inode, loff_t offset, int bytes),
|
|
TP_ARGS(inode, offset, bytes));
|
|
|
|
DEFINE_EVENT(android_fs_data_start_template, android_fs_datawrite_start,
|
|
TP_PROTO(struct inode *inode, loff_t offset, int bytes,
|
|
pid_t pid, char *pathname, char *command),
|
|
TP_ARGS(inode, offset, bytes, pid, pathname, command));
|
|
|
|
DEFINE_EVENT(android_fs_data_end_template, android_fs_datawrite_end,
|
|
TP_PROTO(struct inode *inode, loff_t offset, int bytes),
|
|
TP_ARGS(inode, offset, bytes));
|
|
|
|
#endif /* _TRACE_ANDROID_FS_H */
|
|
|
|
/* This part must be outside protection */
|
|
#include <trace/define_trace.h>
|
|
|
|
#ifndef ANDROID_FSTRACE_GET_PATHNAME
|
|
#define ANDROID_FSTRACE_GET_PATHNAME
|
|
|
|
/* Sizes an on-stack array, so careful if sizing this up ! */
|
|
#define MAX_TRACE_PATHBUF_LEN 256
|
|
|
|
static inline char *
|
|
android_fstrace_get_pathname(char *buf, int buflen, struct inode *inode)
|
|
{
|
|
char *path;
|
|
struct dentry *d;
|
|
|
|
/*
|
|
* d_obtain_alias() will either iput() if it locates an existing
|
|
* dentry or transfer the reference to the new dentry created.
|
|
* So get an extra reference here.
|
|
*/
|
|
ihold(inode);
|
|
d = d_obtain_alias(inode);
|
|
if (likely(!IS_ERR(d))) {
|
|
path = dentry_path_raw(d, buf, buflen);
|
|
if (unlikely(IS_ERR(path))) {
|
|
strcpy(buf, "ERROR");
|
|
path = buf;
|
|
}
|
|
dput(d);
|
|
} else {
|
|
strcpy(buf, "ERROR");
|
|
path = buf;
|
|
}
|
|
return path;
|
|
}
|
|
#endif
|
|
#ifdef CONFIG_AMLOGIC_VMAP
|
|
extern void trace_android_fs_datawrite_wrap(struct inode *inode,
|
|
loff_t pos, unsigned int len);
|
|
extern void trace_android_fs_dataread_wrap(struct inode *inode,
|
|
loff_t pos, unsigned int len);
|
|
#endif
|