From: Felix Fietkau Date: Mon, 17 Dec 2012 15:11:39 +0000 (+0000) Subject: kernel: add some debloat patches, strip down procfs and make O_DIRECT support optiona... X-Git-Tag: reboot~11926 X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=2bda7a5b4106e4e8eb0e073bd4627db14ca81008;p=openwrt%2Fstaging%2Fchunkeey.git kernel: add some debloat patches, strip down procfs and make O_DIRECT support optional, saves ~15K after lzma on MIPS SVN-Revision: 34737 --- diff --git a/target/linux/generic/config-3.6 b/target/linux/generic/config-3.6 index d442f69e67..99e5bdb014 100644 --- a/target/linux/generic/config-3.6 +++ b/target/linux/generic/config-3.6 @@ -607,6 +607,7 @@ CONFIG_DEVPORT=y # CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set # CONFIG_DEVTMPFS is not set # CONFIG_DEVTMPFS_MOUNT is not set +# CONFIG_DIRECT_IO is not set # CONFIG_DISCONTIGMEM_MANUAL is not set # CONFIG_DISPLAY_SUPPORT is not set # CONFIG_DL2K is not set @@ -2279,6 +2280,7 @@ CONFIG_PRINT_STACK_DEPTH=64 CONFIG_PROC_FS=y # CONFIG_PROC_KCORE is not set # CONFIG_PROC_PAGE_MONITOR is not set +CONFIG_PROC_STRIPPED=y CONFIG_PROC_SYSCTL=y # CONFIG_PROFILE_ALL_BRANCHES is not set # CONFIG_PROFILE_ANNOTATED_BRANCHES is not set diff --git a/target/linux/generic/config-3.7 b/target/linux/generic/config-3.7 index b572515163..c5b6115228 100644 --- a/target/linux/generic/config-3.7 +++ b/target/linux/generic/config-3.7 @@ -616,6 +616,7 @@ CONFIG_DEVPORT=y # CONFIG_DEVTMPFS is not set # CONFIG_DEVTMPFS_MOUNT is not set # CONFIG_DGRP is not set +# CONFIG_DIRECT_IO is not set # CONFIG_DISCONTIGMEM_MANUAL is not set # CONFIG_DISPLAY_SUPPORT is not set # CONFIG_DL2K is not set @@ -2309,6 +2310,7 @@ CONFIG_PRINT_STACK_DEPTH=64 CONFIG_PROC_FS=y # CONFIG_PROC_KCORE is not set # CONFIG_PROC_PAGE_MONITOR is not set +CONFIG_PROC_STRIPPED=y CONFIG_PROC_SYSCTL=y # CONFIG_PROFILE_ALL_BRANCHES is not set # CONFIG_PROFILE_ANNOTATED_BRANCHES is not set diff --git a/target/linux/generic/patches-3.6/901-debloat_sock_diag.patch b/target/linux/generic/patches-3.6/901-debloat_sock_diag.patch new file mode 100644 index 0000000000..8f161ba1a3 --- /dev/null +++ b/target/linux/generic/patches-3.6/901-debloat_sock_diag.patch @@ -0,0 +1,46 @@ +--- a/net/Kconfig ++++ b/net/Kconfig +@@ -85,6 +85,9 @@ source "net/netlabel/Kconfig" + + endif # if INET + ++config SOCK_DIAG ++ bool ++ + config NETWORK_SECMARK + bool "Security Marking" + help +--- a/net/core/Makefile ++++ b/net/core/Makefile +@@ -8,9 +8,9 @@ obj-y := sock.o request_sock.o skbuff.o + obj-$(CONFIG_SYSCTL) += sysctl_net_core.o + + obj-y += dev.o ethtool.o dev_addr_lists.o dst.o netevent.o \ +- neighbour.o rtnetlink.o utils.o link_watch.o filter.o \ +- sock_diag.o ++ neighbour.o rtnetlink.o utils.o link_watch.o filter.o + ++obj-$(CONFIG_SOCK_DIAG) += sock_diag.o + obj-$(CONFIG_XFRM) += flow.o + obj-y += net-sysfs.o + obj-$(CONFIG_NET_PKTGEN) += pktgen.o +--- a/net/ipv4/Kconfig ++++ b/net/ipv4/Kconfig +@@ -404,6 +404,7 @@ config INET_LRO + + config INET_DIAG + tristate "INET: socket monitoring interface" ++ select SOCK_DIAG + default y + ---help--- + Support for INET (TCP, DCCP, etc) socket monitoring interface used by +--- a/net/unix/Kconfig ++++ b/net/unix/Kconfig +@@ -22,6 +22,7 @@ config UNIX + config UNIX_DIAG + tristate "UNIX: socket monitoring interface" + depends on UNIX ++ select SOCK_DIAG + default n + ---help--- + Support for UNIX socket monitoring interface used by the ss tool. diff --git a/target/linux/generic/patches-3.6/902-debloat_proc.patch b/target/linux/generic/patches-3.6/902-debloat_proc.patch new file mode 100644 index 0000000000..a8ff00cfe3 --- /dev/null +++ b/target/linux/generic/patches-3.6/902-debloat_proc.patch @@ -0,0 +1,351 @@ +--- a/fs/locks.c ++++ b/fs/locks.c +@@ -2269,6 +2269,8 @@ static const struct file_operations proc + + static int __init proc_locks_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; + proc_create("locks", 0, NULL, &proc_locks_operations); + return 0; + } +--- a/fs/proc/Kconfig ++++ b/fs/proc/Kconfig +@@ -67,3 +67,8 @@ config PROC_PAGE_MONITOR + /proc/pid/smaps, /proc/pid/clear_refs, /proc/pid/pagemap, + /proc/kpagecount, and /proc/kpageflags. Disabling these + interfaces will reduce the size of the kernel by approximately 4kb. ++ ++config PROC_STRIPPED ++ default n ++ depends on EXPERT ++ bool "Strip non-essential /proc functionality to reduce code size" +--- a/fs/proc/consoles.c ++++ b/fs/proc/consoles.c +@@ -108,6 +108,9 @@ static const struct file_operations proc + + static int __init proc_consoles_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; ++ + proc_create("consoles", 0, NULL, &proc_consoles_operations); + return 0; + } +--- a/fs/proc/proc_tty.c ++++ b/fs/proc/proc_tty.c +@@ -143,7 +143,10 @@ static const struct file_operations proc + void proc_tty_register_driver(struct tty_driver *driver) + { + struct proc_dir_entry *ent; +- ++ ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + if (!driver->driver_name || driver->proc_entry || + !driver->ops->proc_fops) + return; +@@ -160,6 +163,9 @@ void proc_tty_unregister_driver(struct t + { + struct proc_dir_entry *ent; + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + ent = driver->proc_entry; + if (!ent) + return; +@@ -174,6 +180,9 @@ void proc_tty_unregister_driver(struct t + */ + void __init proc_tty_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + if (!proc_mkdir("tty", NULL)) + return; + proc_tty_ldisc = proc_mkdir("tty/ldisc", NULL); +--- a/kernel/exec_domain.c ++++ b/kernel/exec_domain.c +@@ -173,6 +173,8 @@ static const struct file_operations exec + + static int __init proc_execdomains_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; + proc_create("execdomains", 0, NULL, &execdomains_proc_fops); + return 0; + } +--- a/kernel/irq/proc.c ++++ b/kernel/irq/proc.c +@@ -311,6 +311,9 @@ void register_irq_proc(unsigned int irq, + { + char name [MAX_NAMELEN]; + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + if (!root_irq_dir || (desc->irq_data.chip == &no_irq_chip) || desc->dir) + return; + +@@ -347,6 +350,9 @@ void unregister_irq_proc(unsigned int ir + { + char name [MAX_NAMELEN]; + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + if (!root_irq_dir || !desc->dir) + return; + #ifdef CONFIG_SMP +@@ -386,6 +392,9 @@ void init_irq_proc(void) + unsigned int irq; + struct irq_desc *desc; + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + /* create /proc/irq */ + root_irq_dir = proc_mkdir("irq", NULL); + if (!root_irq_dir) +--- a/kernel/time/timer_list.c ++++ b/kernel/time/timer_list.c +@@ -293,6 +293,8 @@ static int __init init_timer_list_procfs + { + struct proc_dir_entry *pe; + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; + pe = proc_create("timer_list", 0444, NULL, &timer_list_fops); + if (!pe) + return -ENOMEM; +--- a/mm/vmalloc.c ++++ b/mm/vmalloc.c +@@ -2641,6 +2641,8 @@ static const struct file_operations proc + + static int __init proc_vmalloc_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; + proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations); + return 0; + } +--- a/mm/vmstat.c ++++ b/mm/vmstat.c +@@ -1212,10 +1212,12 @@ static int __init setup_vmstat(void) + start_cpu_timer(cpu); + #endif + #ifdef CONFIG_PROC_FS +- proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations); +- proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops); ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) { ++ proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations); ++ proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops); ++ proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations); ++ } + proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations); +- proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations); + #endif + return 0; + } +--- a/net/8021q/vlanproc.c ++++ b/net/8021q/vlanproc.c +@@ -127,6 +127,9 @@ void vlan_proc_cleanup(struct net *net) + { + struct vlan_net *vn = net_generic(net, vlan_net_id); + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + if (vn->proc_vlan_conf) + remove_proc_entry(name_conf, vn->proc_vlan_dir); + +@@ -146,6 +149,9 @@ int __net_init vlan_proc_init(struct net + { + struct vlan_net *vn = net_generic(net, vlan_net_id); + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; ++ + vn->proc_vlan_dir = proc_net_mkdir(net, name_root, net->proc_net); + if (!vn->proc_vlan_dir) + goto err; +--- a/net/core/dev.c ++++ b/net/core/dev.c +@@ -4425,9 +4425,11 @@ static int __net_init dev_proc_net_init( + + if (!proc_net_fops_create(net, "dev", S_IRUGO, &dev_seq_fops)) + goto out; +- if (!proc_net_fops_create(net, "softnet_stat", S_IRUGO, &softnet_seq_fops)) ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED) && ++ !proc_net_fops_create(net, "softnet_stat", S_IRUGO, &softnet_seq_fops)) + goto out_dev; +- if (!proc_net_fops_create(net, "ptype", S_IRUGO, &ptype_seq_fops)) ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED) && ++ !proc_net_fops_create(net, "ptype", S_IRUGO, &ptype_seq_fops)) + goto out_softnet; + + if (wext_proc_init(net)) +@@ -4436,9 +4438,11 @@ static int __net_init dev_proc_net_init( + out: + return rc; + out_ptype: +- proc_net_remove(net, "ptype"); ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ proc_net_remove(net, "ptype"); + out_softnet: +- proc_net_remove(net, "softnet_stat"); ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ proc_net_remove(net, "softnet_stat"); + out_dev: + proc_net_remove(net, "dev"); + goto out; +@@ -4448,8 +4452,10 @@ static void __net_exit dev_proc_net_exit + { + wext_proc_exit(net); + +- proc_net_remove(net, "ptype"); +- proc_net_remove(net, "softnet_stat"); ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) { ++ proc_net_remove(net, "ptype"); ++ proc_net_remove(net, "softnet_stat"); ++ } + proc_net_remove(net, "dev"); + } + +--- a/net/core/sock.c ++++ b/net/core/sock.c +@@ -2748,6 +2748,8 @@ static __net_initdata struct pernet_oper + + static int __init proto_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; + return register_pernet_subsys(&proto_net_ops); + } + +--- a/net/ipv4/fib_trie.c ++++ b/net/ipv4/fib_trie.c +@@ -2604,10 +2604,12 @@ static const struct file_operations fib_ + + int __net_init fib_proc_init(struct net *net) + { +- if (!proc_net_fops_create(net, "fib_trie", S_IRUGO, &fib_trie_fops)) ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED) && ++ !proc_net_fops_create(net, "fib_trie", S_IRUGO, &fib_trie_fops)) + goto out1; + +- if (!proc_net_fops_create(net, "fib_triestat", S_IRUGO, ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED) && ++ !proc_net_fops_create(net, "fib_triestat", S_IRUGO, + &fib_triestat_fops)) + goto out2; + +@@ -2626,8 +2628,10 @@ out1: + + void __net_exit fib_proc_exit(struct net *net) + { +- proc_net_remove(net, "fib_trie"); +- proc_net_remove(net, "fib_triestat"); ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) { ++ proc_net_remove(net, "fib_trie"); ++ proc_net_remove(net, "fib_triestat"); ++ } + proc_net_remove(net, "route"); + } + +--- a/net/ipv4/igmp.c ++++ b/net/ipv4/igmp.c +@@ -2661,6 +2661,8 @@ static struct pernet_operations igmp_net + + int __init igmp_mc_proc_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; + return register_pernet_subsys(&igmp_net_ops); + } + #endif +--- a/net/ipv4/ipmr.c ++++ b/net/ipv4/ipmr.c +@@ -70,6 +70,10 @@ + #define CONFIG_IP_PIMSM 1 + #endif + ++#ifdef CONFIG_PROC_STRIPPED ++#undef CONFIG_PROC_FS ++#endif ++ + struct mr_table { + struct list_head list; + #ifdef CONFIG_NET_NS +--- a/net/ipv4/proc.c ++++ b/net/ipv4/proc.c +@@ -498,6 +498,9 @@ static __net_initdata struct pernet_oper + + int __init ip_misc_proc_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; ++ + return register_pernet_subsys(&ip_proc_ops); + } + +--- a/net/ipv4/route.c ++++ b/net/ipv4/route.c +@@ -427,6 +427,9 @@ static struct pernet_operations ip_rt_pr + + static int __init ip_rt_proc_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; ++ + return register_pernet_subsys(&ip_rt_proc_ops); + } + +--- a/ipc/msg.c ++++ b/ipc/msg.c +@@ -135,6 +135,9 @@ void __init msg_init(void) + printk(KERN_INFO "msgmni has been set to %d\n", + init_ipc_ns.msg_ctlmni); + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + ipc_init_proc_interface("sysvipc/msg", + " key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime\n", + IPC_MSG_IDS, sysvipc_msg_proc_show); +--- a/ipc/sem.c ++++ b/ipc/sem.c +@@ -185,6 +185,8 @@ void sem_exit_ns(struct ipc_namespace *n + void __init sem_init (void) + { + sem_init_ns(&init_ipc_ns); ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; + ipc_init_proc_interface("sysvipc/sem", + " key semid perms nsems uid gid cuid cgid otime ctime\n", + IPC_SEM_IDS, sysvipc_sem_proc_show); +--- a/ipc/shm.c ++++ b/ipc/shm.c +@@ -115,6 +115,8 @@ pure_initcall(ipc_ns_init); + + void __init shm_init (void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; + ipc_init_proc_interface("sysvipc/shm", + #if BITS_PER_LONG <= 32 + " key shmid perms size cpid lpid nattch uid gid cuid cgid atime dtime ctime rss swap\n", +--- a/ipc/util.c ++++ b/ipc/util.c +@@ -148,6 +148,9 @@ void __init ipc_init_proc_interface(cons + struct proc_dir_entry *pde; + struct ipc_proc_iface *iface; + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + iface = kmalloc(sizeof(*iface), GFP_KERNEL); + if (!iface) + return; diff --git a/target/linux/generic/patches-3.6/903-debloat_direct_io.patch b/target/linux/generic/patches-3.6/903-debloat_direct_io.patch new file mode 100644 index 0000000000..4af6728439 --- /dev/null +++ b/target/linux/generic/patches-3.6/903-debloat_direct_io.patch @@ -0,0 +1,94 @@ +--- a/fs/Kconfig ++++ b/fs/Kconfig +@@ -62,6 +62,11 @@ config FILE_LOCKING + for filesystems like NFS and for the flock() system + call. Disabling this option saves about 11k. + ++config DIRECT_IO ++ bool "Enable O_DIRECT support" if EXPERT ++ depends on BLOCK ++ default y ++ + source "fs/notify/Kconfig" + + source "fs/quota/Kconfig" +--- a/fs/Makefile ++++ b/fs/Makefile +@@ -14,7 +14,8 @@ obj-y := open.o read_write.o file_table. + stack.o fs_struct.o statfs.o + + ifeq ($(CONFIG_BLOCK),y) +-obj-y += buffer.o bio.o block_dev.o direct-io.o mpage.o ioprio.o ++obj-y += buffer.o bio.o block_dev.o mpage.o ioprio.o ++obj-$(CONFIG_DIRECT_IO) += direct-io.o + else + obj-y += no-block.o + endif +--- a/include/linux/fs.h ++++ b/include/linux/fs.h +@@ -2632,20 +2632,36 @@ enum { + DIO_SKIP_HOLES = 0x02, + }; + ++#ifdef CONFIG_DIRECT_IO + void dio_end_io(struct bio *bio, int error); + + ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, + struct block_device *bdev, const struct iovec *iov, loff_t offset, + unsigned long nr_segs, get_block_t get_block, dio_iodone_t end_io, + dio_submit_t submit_io, int flags); ++#else ++static inline void dio_end_io(struct bio *bio, int error) ++{ ++} ++static inline ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, ++ struct block_device *bdev, const struct iovec *iov, loff_t offset, ++ unsigned long nr_segs, get_block_t get_block, dio_iodone_t end_io, ++ dio_submit_t submit_io, int flags) ++{ ++ return -EOPNOTSUPP; ++} ++#endif ++ + + static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb, + struct inode *inode, const struct iovec *iov, loff_t offset, + unsigned long nr_segs, get_block_t get_block) + { ++#ifdef CONFIG_DIRECT_IO + return __blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov, + offset, nr_segs, get_block, NULL, NULL, + DIO_LOCKING | DIO_SKIP_HOLES); ++#endif + } + #endif + +--- a/fs/fcntl.c ++++ b/fs/fcntl.c +@@ -169,8 +169,10 @@ static int setfl(int fd, struct file * f + arg |= O_NONBLOCK; + + if (arg & O_DIRECT) { ++#ifdef CONFIG_DIRECT_IO + if (!filp->f_mapping || !filp->f_mapping->a_ops || + !filp->f_mapping->a_ops->direct_IO) ++#endif + return -EINVAL; + } + +--- a/fs/open.c ++++ b/fs/open.c +@@ -636,9 +636,12 @@ int open_check_o_direct(struct file *f) + { + /* NB: we're sure to have correct a_ops only after f_op->open */ + if (f->f_flags & O_DIRECT) { ++#ifdef CONFIG_DIRECT_IO + if (!f->f_mapping->a_ops || + ((!f->f_mapping->a_ops->direct_IO) && +- (!f->f_mapping->a_ops->get_xip_mem))) { ++ (!f->f_mapping->a_ops->get_xip_mem))) ++#endif ++ { + return -EINVAL; + } + } diff --git a/target/linux/generic/patches-3.7/901-debloat_sock_diag.patch b/target/linux/generic/patches-3.7/901-debloat_sock_diag.patch new file mode 100644 index 0000000000..119760648d --- /dev/null +++ b/target/linux/generic/patches-3.7/901-debloat_sock_diag.patch @@ -0,0 +1,46 @@ +--- a/net/Kconfig ++++ b/net/Kconfig +@@ -87,6 +87,9 @@ source "net/netlabel/Kconfig" + + endif # if INET + ++config SOCK_DIAG ++ bool ++ + config NETWORK_SECMARK + bool "Security Marking" + help +--- a/net/core/Makefile ++++ b/net/core/Makefile +@@ -8,9 +8,9 @@ obj-y := sock.o request_sock.o skbuff.o + obj-$(CONFIG_SYSCTL) += sysctl_net_core.o + + obj-y += dev.o ethtool.o dev_addr_lists.o dst.o netevent.o \ +- neighbour.o rtnetlink.o utils.o link_watch.o filter.o \ +- sock_diag.o ++ neighbour.o rtnetlink.o utils.o link_watch.o filter.o + ++obj-$(CONFIG_SOCK_DIAG) += sock_diag.o + obj-$(CONFIG_XFRM) += flow.o + obj-y += net-sysfs.o + obj-$(CONFIG_NET_PKTGEN) += pktgen.o +--- a/net/ipv4/Kconfig ++++ b/net/ipv4/Kconfig +@@ -404,6 +404,7 @@ config INET_LRO + + config INET_DIAG + tristate "INET: socket monitoring interface" ++ select SOCK_DIAG + default y + ---help--- + Support for INET (TCP, DCCP, etc) socket monitoring interface used by +--- a/net/unix/Kconfig ++++ b/net/unix/Kconfig +@@ -22,6 +22,7 @@ config UNIX + config UNIX_DIAG + tristate "UNIX: socket monitoring interface" + depends on UNIX ++ select SOCK_DIAG + default n + ---help--- + Support for UNIX socket monitoring interface used by the ss tool. diff --git a/target/linux/generic/patches-3.7/902-debloat_proc.patch b/target/linux/generic/patches-3.7/902-debloat_proc.patch new file mode 100644 index 0000000000..30512de956 --- /dev/null +++ b/target/linux/generic/patches-3.7/902-debloat_proc.patch @@ -0,0 +1,351 @@ +--- a/fs/locks.c ++++ b/fs/locks.c +@@ -2267,6 +2267,8 @@ static const struct file_operations proc + + static int __init proc_locks_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; + proc_create("locks", 0, NULL, &proc_locks_operations); + return 0; + } +--- a/fs/proc/Kconfig ++++ b/fs/proc/Kconfig +@@ -67,3 +67,8 @@ config PROC_PAGE_MONITOR + /proc/pid/smaps, /proc/pid/clear_refs, /proc/pid/pagemap, + /proc/kpagecount, and /proc/kpageflags. Disabling these + interfaces will reduce the size of the kernel by approximately 4kb. ++ ++config PROC_STRIPPED ++ default n ++ depends on EXPERT ++ bool "Strip non-essential /proc functionality to reduce code size" +--- a/fs/proc/consoles.c ++++ b/fs/proc/consoles.c +@@ -108,6 +108,9 @@ static const struct file_operations proc + + static int __init proc_consoles_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; ++ + proc_create("consoles", 0, NULL, &proc_consoles_operations); + return 0; + } +--- a/fs/proc/proc_tty.c ++++ b/fs/proc/proc_tty.c +@@ -143,7 +143,10 @@ static const struct file_operations proc + void proc_tty_register_driver(struct tty_driver *driver) + { + struct proc_dir_entry *ent; +- ++ ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + if (!driver->driver_name || driver->proc_entry || + !driver->ops->proc_fops) + return; +@@ -160,6 +163,9 @@ void proc_tty_unregister_driver(struct t + { + struct proc_dir_entry *ent; + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + ent = driver->proc_entry; + if (!ent) + return; +@@ -174,6 +180,9 @@ void proc_tty_unregister_driver(struct t + */ + void __init proc_tty_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + if (!proc_mkdir("tty", NULL)) + return; + proc_tty_ldisc = proc_mkdir("tty/ldisc", NULL); +--- a/kernel/exec_domain.c ++++ b/kernel/exec_domain.c +@@ -173,6 +173,8 @@ static const struct file_operations exec + + static int __init proc_execdomains_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; + proc_create("execdomains", 0, NULL, &execdomains_proc_fops); + return 0; + } +--- a/kernel/irq/proc.c ++++ b/kernel/irq/proc.c +@@ -311,6 +311,9 @@ void register_irq_proc(unsigned int irq, + { + char name [MAX_NAMELEN]; + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + if (!root_irq_dir || (desc->irq_data.chip == &no_irq_chip) || desc->dir) + return; + +@@ -347,6 +350,9 @@ void unregister_irq_proc(unsigned int ir + { + char name [MAX_NAMELEN]; + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + if (!root_irq_dir || !desc->dir) + return; + #ifdef CONFIG_SMP +@@ -386,6 +392,9 @@ void init_irq_proc(void) + unsigned int irq; + struct irq_desc *desc; + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + /* create /proc/irq */ + root_irq_dir = proc_mkdir("irq", NULL); + if (!root_irq_dir) +--- a/kernel/time/timer_list.c ++++ b/kernel/time/timer_list.c +@@ -293,6 +293,8 @@ static int __init init_timer_list_procfs + { + struct proc_dir_entry *pe; + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; + pe = proc_create("timer_list", 0444, NULL, &timer_list_fops); + if (!pe) + return -ENOMEM; +--- a/mm/vmalloc.c ++++ b/mm/vmalloc.c +@@ -2638,6 +2638,8 @@ static const struct file_operations proc + + static int __init proc_vmalloc_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; + proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations); + return 0; + } +--- a/mm/vmstat.c ++++ b/mm/vmstat.c +@@ -1224,10 +1224,12 @@ static int __init setup_vmstat(void) + start_cpu_timer(cpu); + #endif + #ifdef CONFIG_PROC_FS +- proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations); +- proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops); ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) { ++ proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations); ++ proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops); ++ proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations); ++ } + proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations); +- proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations); + #endif + return 0; + } +--- a/net/8021q/vlanproc.c ++++ b/net/8021q/vlanproc.c +@@ -127,6 +127,9 @@ void vlan_proc_cleanup(struct net *net) + { + struct vlan_net *vn = net_generic(net, vlan_net_id); + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + if (vn->proc_vlan_conf) + remove_proc_entry(name_conf, vn->proc_vlan_dir); + +@@ -146,6 +149,9 @@ int __net_init vlan_proc_init(struct net + { + struct vlan_net *vn = net_generic(net, vlan_net_id); + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; ++ + vn->proc_vlan_dir = proc_net_mkdir(net, name_root, net->proc_net); + if (!vn->proc_vlan_dir) + goto err; +--- a/net/core/dev.c ++++ b/net/core/dev.c +@@ -4478,9 +4478,11 @@ static int __net_init dev_proc_net_init( + + if (!proc_net_fops_create(net, "dev", S_IRUGO, &dev_seq_fops)) + goto out; +- if (!proc_net_fops_create(net, "softnet_stat", S_IRUGO, &softnet_seq_fops)) ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED) && ++ !proc_net_fops_create(net, "softnet_stat", S_IRUGO, &softnet_seq_fops)) + goto out_dev; +- if (!proc_net_fops_create(net, "ptype", S_IRUGO, &ptype_seq_fops)) ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED) && ++ !proc_net_fops_create(net, "ptype", S_IRUGO, &ptype_seq_fops)) + goto out_softnet; + + if (wext_proc_init(net)) +@@ -4489,9 +4491,11 @@ static int __net_init dev_proc_net_init( + out: + return rc; + out_ptype: +- proc_net_remove(net, "ptype"); ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ proc_net_remove(net, "ptype"); + out_softnet: +- proc_net_remove(net, "softnet_stat"); ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ proc_net_remove(net, "softnet_stat"); + out_dev: + proc_net_remove(net, "dev"); + goto out; +@@ -4501,8 +4505,10 @@ static void __net_exit dev_proc_net_exit + { + wext_proc_exit(net); + +- proc_net_remove(net, "ptype"); +- proc_net_remove(net, "softnet_stat"); ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) { ++ proc_net_remove(net, "ptype"); ++ proc_net_remove(net, "softnet_stat"); ++ } + proc_net_remove(net, "dev"); + } + +--- a/net/core/sock.c ++++ b/net/core/sock.c +@@ -2773,6 +2773,8 @@ static __net_initdata struct pernet_oper + + static int __init proto_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; + return register_pernet_subsys(&proto_net_ops); + } + +--- a/net/ipv4/fib_trie.c ++++ b/net/ipv4/fib_trie.c +@@ -2607,10 +2607,12 @@ static const struct file_operations fib_ + + int __net_init fib_proc_init(struct net *net) + { +- if (!proc_net_fops_create(net, "fib_trie", S_IRUGO, &fib_trie_fops)) ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED) && ++ !proc_net_fops_create(net, "fib_trie", S_IRUGO, &fib_trie_fops)) + goto out1; + +- if (!proc_net_fops_create(net, "fib_triestat", S_IRUGO, ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED) && ++ !proc_net_fops_create(net, "fib_triestat", S_IRUGO, + &fib_triestat_fops)) + goto out2; + +@@ -2629,8 +2631,10 @@ out1: + + void __net_exit fib_proc_exit(struct net *net) + { +- proc_net_remove(net, "fib_trie"); +- proc_net_remove(net, "fib_triestat"); ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) { ++ proc_net_remove(net, "fib_trie"); ++ proc_net_remove(net, "fib_triestat"); ++ } + proc_net_remove(net, "route"); + } + +--- a/net/ipv4/igmp.c ++++ b/net/ipv4/igmp.c +@@ -2673,6 +2673,8 @@ static struct pernet_operations igmp_net + + int __init igmp_mc_proc_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; + return register_pernet_subsys(&igmp_net_ops); + } + #endif +--- a/net/ipv4/ipmr.c ++++ b/net/ipv4/ipmr.c +@@ -70,6 +70,10 @@ + #define CONFIG_IP_PIMSM 1 + #endif + ++#ifdef CONFIG_PROC_STRIPPED ++#undef CONFIG_PROC_FS ++#endif ++ + struct mr_table { + struct list_head list; + #ifdef CONFIG_NET_NS +--- a/net/ipv4/proc.c ++++ b/net/ipv4/proc.c +@@ -502,6 +502,9 @@ static __net_initdata struct pernet_oper + + int __init ip_misc_proc_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; ++ + return register_pernet_subsys(&ip_proc_ops); + } + +--- a/net/ipv4/route.c ++++ b/net/ipv4/route.c +@@ -427,6 +427,9 @@ static struct pernet_operations ip_rt_pr + + static int __init ip_rt_proc_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; ++ + return register_pernet_subsys(&ip_rt_proc_ops); + } + +--- a/ipc/msg.c ++++ b/ipc/msg.c +@@ -135,6 +135,9 @@ void __init msg_init(void) + printk(KERN_INFO "msgmni has been set to %d\n", + init_ipc_ns.msg_ctlmni); + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + ipc_init_proc_interface("sysvipc/msg", + " key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime\n", + IPC_MSG_IDS, sysvipc_msg_proc_show); +--- a/ipc/sem.c ++++ b/ipc/sem.c +@@ -185,6 +185,8 @@ void sem_exit_ns(struct ipc_namespace *n + void __init sem_init (void) + { + sem_init_ns(&init_ipc_ns); ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; + ipc_init_proc_interface("sysvipc/sem", + " key semid perms nsems uid gid cuid cgid otime ctime\n", + IPC_SEM_IDS, sysvipc_sem_proc_show); +--- a/ipc/shm.c ++++ b/ipc/shm.c +@@ -115,6 +115,8 @@ pure_initcall(ipc_ns_init); + + void __init shm_init (void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; + ipc_init_proc_interface("sysvipc/shm", + #if BITS_PER_LONG <= 32 + " key shmid perms size cpid lpid nattch uid gid cuid cgid atime dtime ctime rss swap\n", +--- a/ipc/util.c ++++ b/ipc/util.c +@@ -148,6 +148,9 @@ void __init ipc_init_proc_interface(cons + struct proc_dir_entry *pde; + struct ipc_proc_iface *iface; + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + iface = kmalloc(sizeof(*iface), GFP_KERNEL); + if (!iface) + return; diff --git a/target/linux/generic/patches-3.7/903-debloat_direct_io.patch b/target/linux/generic/patches-3.7/903-debloat_direct_io.patch new file mode 100644 index 0000000000..20b2423af1 --- /dev/null +++ b/target/linux/generic/patches-3.7/903-debloat_direct_io.patch @@ -0,0 +1,94 @@ +--- a/fs/Kconfig ++++ b/fs/Kconfig +@@ -62,6 +62,11 @@ config FILE_LOCKING + for filesystems like NFS and for the flock() system + call. Disabling this option saves about 11k. + ++config DIRECT_IO ++ bool "Enable O_DIRECT support" if EXPERT ++ depends on BLOCK ++ default y ++ + source "fs/notify/Kconfig" + + source "fs/quota/Kconfig" +--- a/fs/Makefile ++++ b/fs/Makefile +@@ -14,7 +14,8 @@ obj-y := open.o read_write.o file_table. + stack.o fs_struct.o statfs.o + + ifeq ($(CONFIG_BLOCK),y) +-obj-y += buffer.o bio.o block_dev.o direct-io.o mpage.o ioprio.o ++obj-y += buffer.o bio.o block_dev.o mpage.o ioprio.o ++obj-$(CONFIG_DIRECT_IO) += direct-io.o + else + obj-y += no-block.o + endif +--- a/include/linux/fs.h ++++ b/include/linux/fs.h +@@ -2444,20 +2444,36 @@ enum { + DIO_SKIP_HOLES = 0x02, + }; + ++#ifdef CONFIG_DIRECT_IO + void dio_end_io(struct bio *bio, int error); + + ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, + struct block_device *bdev, const struct iovec *iov, loff_t offset, + unsigned long nr_segs, get_block_t get_block, dio_iodone_t end_io, + dio_submit_t submit_io, int flags); ++#else ++static inline void dio_end_io(struct bio *bio, int error) ++{ ++} ++static inline ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, ++ struct block_device *bdev, const struct iovec *iov, loff_t offset, ++ unsigned long nr_segs, get_block_t get_block, dio_iodone_t end_io, ++ dio_submit_t submit_io, int flags) ++{ ++ return -EOPNOTSUPP; ++} ++#endif ++ + + static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb, + struct inode *inode, const struct iovec *iov, loff_t offset, + unsigned long nr_segs, get_block_t get_block) + { ++#ifdef CONFIG_DIRECT_IO + return __blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov, + offset, nr_segs, get_block, NULL, NULL, + DIO_LOCKING | DIO_SKIP_HOLES); ++#endif + } + #endif + +--- a/fs/fcntl.c ++++ b/fs/fcntl.c +@@ -51,8 +51,10 @@ static int setfl(int fd, struct file * f + arg |= O_NONBLOCK; + + if (arg & O_DIRECT) { ++#ifdef CONFIG_DIRECT_IO + if (!filp->f_mapping || !filp->f_mapping->a_ops || + !filp->f_mapping->a_ops->direct_IO) ++#endif + return -EINVAL; + } + +--- a/fs/open.c ++++ b/fs/open.c +@@ -630,9 +630,12 @@ int open_check_o_direct(struct file *f) + { + /* NB: we're sure to have correct a_ops only after f_op->open */ + if (f->f_flags & O_DIRECT) { ++#ifdef CONFIG_DIRECT_IO + if (!f->f_mapping->a_ops || + ((!f->f_mapping->a_ops->direct_IO) && +- (!f->f_mapping->a_ops->get_xip_mem))) { ++ (!f->f_mapping->a_ops->get_xip_mem))) ++#endif ++ { + return -EINVAL; + } + }