Skip to contentSkip to conversation

Add configuration options to disable features not needed on embedded devices

PATCH RESEND In review Thomas Petazzoni 14 participants 65 messages Jul 31, 2008 – Aug 7, 2008

Subsystems (13)
lore
Share & tools
lore
#0 lore raw

cover Add configuration options to disable features not needed on embedded devices

Hi,

This is a resend of the small patch list I sent on July, 29th. I'm resending the patches because they didn't make it to vger lists for some setup problem on my side, and because I've been asked by Adrian Bunk to resend them in order to get proper review.

However, please note that the patches removing ethtool and IGMP have both been nack-ed by David Miller. The resend of these patches is not an intent to workaround these NACKs in any way: I'm resending because I've been asked to do so.

I apologize for the mess, and hope that this time, the mails will reach vger lists.

Changes since previous post:

* Add Matt Mackall's Signed-off-by on all patches
* Make bonding and bridging select ethtool in the ethtool-related patch.

Sincerly,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#1 lore raw

PATCH 1/4 Configure out AIO support

This patchs adds the CONFIG_AIO option which allows to remove support for asynchronous I/O operations, that are not necessarly used by applications, particularly on embedded devices. As this is a size-reduction option, it depends on CONFIG_EMBEDDED. It allows to save ~7 kilobytes of kernel code/data:

text data bss dec hex filename
1115067 119180 217088 1451335 162547 vmlinux
1108025 119048 217088 1444161 160941 vmlinux.new
-7042 -132 0 -7174 -1C06 +/-

This patch has been originally written by Matt Mackall <[email protected]>, and is part of the Linux Tiny project.

---
 fs/Makefile         |    3 ++-
 include/linux/aio.h |    9 +++++++++
 init/Kconfig        |    8 ++++++++
 kernel/sys_ni.c     |    5 +++++
 kernel/sysctl.c     |    2 ++
 5 files changed, 26 insertions(+), 1 deletion(-)
fs/Makefile +2 -1
Index: linuxdev/fs/Makefile
===================================================================
@@ -8,7 +8,7 @@
 obj-y :=	open.o read_write.o file_table.o super.o \
 		char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \
 		ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \
-		attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \
+		attr.o bad_inode.o file.o filesystems.o namespace.o \
 		seq_file.o xattr.o libfs.o fs-writeback.o \
 		pnode.o drop_caches.o splice.o sync.o utimes.o \
 		stack.o
@@ -27,6 +27,7 @@
 obj-$(CONFIG_SIGNALFD)		+= signalfd.o
 obj-$(CONFIG_TIMERFD)		+= timerfd.o
 obj-$(CONFIG_EVENTFD)		+= eventfd.o
+obj-$(CONFIG_AIO)               += aio.o
 obj-$(CONFIG_COMPAT)		+= compat.o compat_ioctl.o
 
 nfsd-$(CONFIG_NFSD)		:= nfsctl.o
include/linux/aio.h +9 -0
Index: linuxdev/include/linux/aio.h
===================================================================
@@ -204,12 +204,21 @@
 /* prototypes */
 extern unsigned aio_max_size;
 
+#ifdef CONFIG_AIO
 extern ssize_t wait_on_sync_kiocb(struct kiocb *iocb);
 extern int aio_put_req(struct kiocb *iocb);
 extern void kick_iocb(struct kiocb *iocb);
 extern int aio_complete(struct kiocb *iocb, long res, long res2);
 struct mm_struct;
 extern void exit_aio(struct mm_struct *mm);
+#else
+static inline ssize_t wait_on_sync_kiocb(struct kiocb *iocb) { return 0; }
+static inline int aio_put_req(struct kiocb *iocb) { return 0; }
+static inline void kick_iocb(struct kiocb *iocb) { }
+static inline int aio_complete(struct kiocb *iocb, long res, long res2) { return 0; }
+struct mm_struct;
+static inline void exit_aio(struct mm_struct *mm) { }
+#endif /* CONFIG_AIO */
 
 #define io_wait_to_kiocb(wait) container_of(wait, struct kiocb, ki_wait)
 
init/Kconfig +8 -0
Index: linuxdev/init/Kconfig
===================================================================
@@ -724,6 +724,14 @@
 	  option replaces shmem and tmpfs with the much simpler ramfs code,
 	  which may be appropriate on small systems without swap.
 
+config AIO
+	bool "Enable AIO support" if EMBEDDED
+	default y
+	help
+	  This option enables POSIX asynchronous I/O which may by used
+          by some high performance threaded applications. Disabling
+          this option saves about 7k.
+
 config VM_EVENT_COUNTERS
 	default y
 	bool "Enable VM event counters for /proc/vmstat" if EMBEDDED
kernel/sys_ni.c +5 -0
Index: linuxdev/kernel/sys_ni.c
===================================================================
@@ -125,6 +125,11 @@
 cond_syscall(sys_vm86);
 cond_syscall(compat_sys_ipc);
 cond_syscall(compat_sys_sysctl);
+cond_syscall(sys_io_setup);
+cond_syscall(sys_io_destroy);
+cond_syscall(sys_io_submit);
+cond_syscall(sys_io_cancel);
+cond_syscall(sys_io_getevents);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);
kernel/sysctl.c +2 -0
Index: linuxdev/kernel/sysctl.c
===================================================================
@@ -1290,6 +1290,7 @@
 		.extra1		= &zero,
 		.extra2		= &two,
 	},
+#ifdef CONFIG_AIO
 	{
 		.procname	= "aio-nr",
 		.data		= &aio_nr,
@@ -1304,6 +1305,7 @@
 		.mode		= 0644,
 		.proc_handler	= &proc_doulongvec_minmax,
 	},
+#endif /* CONFIG_AIO */
 #ifdef CONFIG_INOTIFY_USER
 	{
 		.ctl_name	= FS_INOTIFY,
Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#8 lore raw

PATCH 2/4 Configure out file locking features

In reply to Thomas Petazzoni

This patch adds the CONFIG_FILE_LOCKING option which allows to remove support for advisory locks. With this patch enabled, the flock() system call, the F_GETLK, F_SETLK and F_SETLKW operations of fcntl() and NFS support are disabled. These features are not necessarly needed on embedded systems. It allows to save ~11 Kb of kernel code and data:

text data bss dec hex filename
1125436 118764 212992 1457192 163c28 vmlinux.old
1114299 118564 212992 1445855 160fdf vmlinux
-11137 -200 0 -11337 -2C49 +/-

This patch has originally been written by Matt Mackall <[email protected]>, and is part of the Linux Tiny project.

---
 fs/Kconfig          |    2 +-
 fs/Makefile         |    3 ++-
 fs/proc/proc_misc.c |    4 ++++
 include/linux/fs.h  |   52 +++++++++++++++++++++++++++++++++++++++++++++-------
 init/Kconfig        |    8 ++++++++
 kernel/sys_ni.c     |    1 +
 kernel/sysctl.c     |    6 +++++-
 7 files changed, 66 insertions(+), 10 deletions(-)
fs/Kconfig +1 -1
Index: linuxdev/fs/Kconfig
===================================================================
@@ -1559,7 +1559,7 @@
 
 config NFS_FS
 	tristate "NFS client support"
-	depends on INET
+	depends on INET && FILE_LOCKING
 	select LOCKD
 	select SUNRPC
 	select NFS_ACL_SUPPORT if NFS_V3_ACL
fs/Makefile +2 -1
Index: linuxdev/fs/Makefile
===================================================================
@@ -7,7 +7,7 @@
 
 obj-y :=	open.o read_write.o file_table.o super.o \
 		char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \
-		ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \
+		ioctl.o readdir.o select.o fifo.o dcache.o inode.o \
 		attr.o bad_inode.o file.o filesystems.o namespace.o \
 		seq_file.o xattr.o libfs.o fs-writeback.o \
 		pnode.o drop_caches.o splice.o sync.o utimes.o \
@@ -28,6 +28,7 @@
 obj-$(CONFIG_TIMERFD)		+= timerfd.o
 obj-$(CONFIG_EVENTFD)		+= eventfd.o
 obj-$(CONFIG_AIO)               += aio.o
+obj-$(CONFIG_FILE_LOCKING)      += locks.o
 obj-$(CONFIG_COMPAT)		+= compat.o compat_ioctl.o
 
 nfsd-$(CONFIG_NFSD)		:= nfsctl.o
fs/proc/proc_misc.c +4 -0
Index: linuxdev/fs/proc/proc_misc.c
===================================================================
@@ -677,6 +677,7 @@
 	return proc_calc_metrics(page, start, off, count, eof, len);
 }
 
+#ifdef CONFIG_FILE_LOCKING
 static int locks_open(struct inode *inode, struct file *filp)
 {
 	return seq_open(filp, &locks_seq_operations);
@@ -688,6 +689,7 @@
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
+#endif /* CONFIG_FILE_LOCKING */
 
 static int execdomains_read_proc(char *page, char **start, off_t off,
 				 int count, int *eof, void *data)
@@ -881,7 +883,9 @@
 #ifdef CONFIG_PRINTK
 	proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations);
 #endif
+#ifdef CONFIG_FILE_LOCKING
 	proc_create("locks", 0, NULL, &proc_locks_operations);
+#endif
 	proc_create("devices", 0, NULL, &proc_devinfo_operations);
 	proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations);
 #ifdef CONFIG_BLOCK
include/linux/fs.h +45 -7

94 lines not on this page · raw message

init/Kconfig +8 -0
Index: linuxdev/init/Kconfig
===================================================================
@@ -732,6 +732,14 @@
           by some high performance threaded applications. Disabling
           this option saves about 7k.
 
+config FILE_LOCKING
+	bool "Enable POSIX file locking API" if EMBEDDED
+	default y
+	help
+	  This option enables standard file locking support, required
+          for filesystems like NFS and for the flock() system
+          call. Disabling this option saves about 11k.
+
 config VM_EVENT_COUNTERS
 	default y
 	bool "Enable VM event counters for /proc/vmstat" if EMBEDDED
kernel/sys_ni.c +1 -0
Index: linuxdev/kernel/sys_ni.c
===================================================================
@@ -130,6 +130,7 @@
 cond_syscall(sys_io_submit);
 cond_syscall(sys_io_cancel);
 cond_syscall(sys_io_getevents);
+cond_syscall(sys_flock);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);
kernel/sysctl.c +5 -1
Index: linuxdev/kernel/sysctl.c
===================================================================
@@ -97,7 +97,7 @@
 static int neg_one = -1;
 #endif
 
-#ifdef CONFIG_MMU
+#if defined(CONFIG_MMU) && defined(CONFIG_FILE_LOCKING)
 static int two = 2;
 #endif
 
@@ -1260,6 +1260,7 @@
 		.extra1		= &minolduid,
 		.extra2		= &maxolduid,
 	},
+#ifdef CONFIG_FILE_LOCKING
 	{
 		.ctl_name	= FS_LEASES,
 		.procname	= "leases-enable",
@@ -1268,6 +1269,7 @@
 		.mode		= 0644,
 		.proc_handler	= &proc_dointvec,
 	},
+#endif
 #ifdef CONFIG_DNOTIFY
 	{
 		.ctl_name	= FS_DIR_NOTIFY,
@@ -1279,6 +1281,7 @@
 	},
 #endif
 #ifdef CONFIG_MMU
+#ifdef CONFIG_FILE_LOCKING
 	{
 		.ctl_name	= FS_LEASE_TIME,
 		.procname	= "lease-break-time",
@@ -1290,6 +1293,7 @@
 		.extra1		= &zero,
 		.extra2		= &two,
 	},
+#endif /* CONFIG_FILE_LOCKING */
 #ifdef CONFIG_AIO
 	{
 		.procname	= "aio-nr",
Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#31 lore raw

PATCH 3/4 Configure out ethtool support

In reply to Thomas Petazzoni

This patchs add the CONFIG_ETHTOOL option which allows to remove support for ethtool, not necessarly used on embedded systems. As this is a size-reduction option, it depends on CONFIG_EMBEDDED. It allows to save ~6 kilobytes of kernel code:

text data bss dec hex filename
1258447 123592 212992 1595031 185697 vmlinux
1252147 123592 212992 1588731 183dfb vmlinux.new
-6300 0 0 -6300 -189C +/-

Bonding and bridging both depends on Ethtool functionnality, so ETHTOOL is selected automatically when either bonding and bridging are selected.

Question: should we also remove ethtool-related functions from all network drivers ?

This patch has been originally written by Matt Mackall <[email protected]>, and is part of the Linux Tiny project.

---
 drivers/net/Kconfig     |    1 +
 include/linux/ethtool.h |   16 ++++++++++++++++
 init/Kconfig            |    8 ++++++++
 net/bridge/Kconfig      |    1 +
 net/core/Makefile       |    3 ++-
 net/core/dev.c          |    4 ++++
 6 files changed, 32 insertions(+), 1 deletion(-)
drivers/net/Kconfig +1 -0
Index: linuxdev/drivers/net/Kconfig
===================================================================
@@ -61,6 +61,7 @@
 config BONDING
 	tristate "Bonding driver support"
 	depends on INET
+	select ETHTOOL
 	---help---
 	  Say 'Y' or 'M' if you wish to be able to 'bond' multiple Ethernet
 	  Channels together. This is called 'Etherchannel' by Cisco,
include/linux/ethtool.h +16 -0
Index: linuxdev/include/linux/ethtool.h
===================================================================
@@ -283,6 +283,7 @@
 struct net_device;
 
 /* Some generic methods drivers may use in their ethtool_ops */
+#ifdef CONFIG_ETHTOOL
 u32 ethtool_op_get_link(struct net_device *dev);
 u32 ethtool_op_get_tx_csum(struct net_device *dev);
 int ethtool_op_set_tx_csum(struct net_device *dev, u32 data);
@@ -296,6 +297,21 @@
 int ethtool_op_set_ufo(struct net_device *dev, u32 data);
 u32 ethtool_op_get_flags(struct net_device *dev);
 int ethtool_op_set_flags(struct net_device *dev, u32 data);
+#else
+static inline u32 ethtool_op_get_link(struct net_device *dev) { return 0; }
+static inline u32 ethtool_op_get_tx_csum(struct net_device *dev) { return 0; }
+static inline int ethtool_op_set_tx_csum(struct net_device *dev, u32 data) { return 0; }
+static inline int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data) { return 0; }
+static inline int ethtool_op_set_tx_ipv6_csum(struct net_device *dev, u32 data) { return 0; }
+static inline u32 ethtool_op_get_sg(struct net_device *dev) { return 0; }
+static inline int ethtool_op_set_sg(struct net_device *dev, u32 data) { return 0; }
+static inline u32 ethtool_op_get_tso(struct net_device *dev) { return 0; }
+static inline int ethtool_op_set_tso(struct net_device *dev, u32 data) { return 0; }
+static inline u32 ethtool_op_get_ufo(struct net_device *dev) { return 0; }
+static inline int ethtool_op_set_ufo(struct net_device *dev, u32 data) { return 0; }
+static inline u32 ethtool_op_get_flags(struct net_device *dev) { return 0; }
+static inline int ethtool_op_set_flags(struct net_device *dev, u32 data) { return 0; }
+#endif
 
 /**
  * &ethtool_ops - Alter and report network device settings
init/Kconfig +8 -0
Index: linuxdev/init/Kconfig
===================================================================
@@ -740,6 +740,14 @@
           for filesystems like NFS and for the flock() system
           call. Disabling this option saves about 11k.
 
+config ETHTOOL
+	bool "Enable ethtool support" if EMBEDDED
+	depends on NET
+	default y
+	help
+	  Disabling this option removes support for configuring
+	  ethernet device features via ethtool. Saves about 6k.
+
 config VM_EVENT_COUNTERS
 	default y
 	bool "Enable VM event counters for /proc/vmstat" if EMBEDDED
net/bridge/Kconfig +1 -0
Index: linuxdev/net/bridge/Kconfig
===================================================================
@@ -6,6 +6,7 @@
 	tristate "802.1d Ethernet Bridging"
 	select LLC
 	select STP
+	select ETHTOOL
 	---help---
 	  If you say Y here, then your Linux box will be able to act as an
 	  Ethernet bridge, which means that the different Ethernet segments it
net/core/Makefile +2 -1
Index: linuxdev/net/core/Makefile
===================================================================
@@ -7,10 +7,11 @@
 
 obj-$(CONFIG_SYSCTL) += sysctl_net_core.o
 
-obj-y		     += dev.o ethtool.o dev_mcast.o dst.o netevent.o \
+obj-y		     += dev.o dev_mcast.o dst.o netevent.o \
 			neighbour.o rtnetlink.o utils.o link_watch.o filter.o
 
 obj-$(CONFIG_XFRM) += flow.o
+obj-$(CONFIG_ETHTOOL) += ethtool.o
 obj-y += net-sysfs.o
 obj-$(CONFIG_NET_PKTGEN) += pktgen.o
 obj-$(CONFIG_NETPOLL) += netpoll.o
net/core/dev.c +4 -0
Index: linuxdev/net/core/dev.c
===================================================================
@@ -3669,6 +3669,7 @@
 			return ret;
 
 		case SIOCETHTOOL:
+#ifdef CONFIG_ETHTOOL
 			dev_load(net, ifr.ifr_name);
 			rtnl_lock();
 			ret = dev_ethtool(net, &ifr);
@@ -3681,6 +3682,9 @@
 					ret = -EFAULT;
 			}
 			return ret;
+#else
+			return -EINVAL;
+#endif
 
 		/*
 		 *	These ioctl calls:
Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#44 lore raw

PATCH 4/4 Configure out IGMP support

In reply to Thomas Petazzoni

This patchs adds the CONFIG_IGMP option which allows to remove support for the Internet Group Management Protocol, used in multicast. Multicast is not necessarly used by applications, particularly on embedded devices. As this is a size-reduction option, it depends on CONFIG_EMBEDDED. It allows to save ~10 kilobytes of kernel code/data:

text data bss dec hex filename
1718857 143672 221184 2083713 1fcb81 vmlinux
1708838 143640 221184 2073662 1fa43e vmlinux.new
-10019 -32 0 -10051 -2743 +/-

This patch has been originally written by Matt Mackall <[email protected]>, and is part of the Linux Tiny project.

---
 include/linux/igmp.h       |   20 ++++++++++++++++++++
 init/Kconfig               |    8 ++++++++
 net/ipv4/Makefile          |    3 ++-
 net/ipv4/af_inet.c         |    2 --
 net/ipv4/ip_sockglue.c     |    4 ++++
 net/ipv4/sysctl_net_ipv4.c |    2 ++
 6 files changed, 36 insertions(+), 3 deletions(-)
include/linux/igmp.h +20 -0
Index: linuxdev/include/linux/igmp.h
===================================================================
@@ -215,6 +215,7 @@
 #define IGMPV3_QQIC(value) IGMPV3_EXP(0x80, 4, 3, value)
 #define IGMPV3_MRC(value) IGMPV3_EXP(0x80, 4, 3, value)
 
+#ifdef CONFIG_IGMP
 extern int ip_check_mc(struct in_device *dev, __be32 mc_addr, __be32 src_addr, u16 proto);
 extern int igmp_rcv(struct sk_buff *);
 extern int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr);
@@ -235,6 +236,25 @@
 extern void ip_mc_dec_group(struct in_device *in_dev, __be32 addr);
 extern void ip_mc_inc_group(struct in_device *in_dev, __be32 addr);
 extern void ip_mc_rejoin_group(struct ip_mc_list *im);
+#else /* !CONFIG_IGMP */
+#define ip_check_mc(a, b, c, d) (0)
+#define igmp_rcv(a) (0)
+#define ip_mc_join_group(a, b) (0)
+#define ip_mc_leave_group(a, b) (0)
+#define ip_mc_drop_socket(a)
+#define ip_mc_source(a, b, c, d, e) (0)
+#define ip_mc_msfilter(a, b, c) (0)
+#define ip_mc_msfget(a, b, c, d) (0)
+#define ip_mc_gsfget(a, b, c, d) (0)
+#define ip_mc_sf_allow(a, b, c, d) (0)
+#define ip_mc_init_dev(a)
+#define ip_mc_destroy_dev(a)
+#define ip_mc_up(a)
+#define ip_mc_down(a)
+#define ip_mc_dec_group(a)
+#define ip_mc_inc_group(a)
+#define ip_mc_rejoin_group(a)
+#endif /* CONFIG_IGMP */
 
 #endif
 #endif
init/Kconfig +8 -0
Index: linuxdev/init/Kconfig
===================================================================
@@ -748,6 +748,14 @@
 	  Disabling this option removes support for configuring
 	  ethernet device features via ethtool. Saves about 6k.
 
+config IGMP
+	depends on INET
+	bool "Enable IGMP support" if EMBEDDED && !IP_MULTICAST
+	default y
+	help
+	  Disabling this option removes support for the Internet group
+          management protocol, used for multicast. Saves about 10k.
+
 config VM_EVENT_COUNTERS
 	default y
 	bool "Enable VM event counters for /proc/vmstat" if EMBEDDED
net/ipv4/Makefile +2 -1
Index: linuxdev/net/ipv4/Makefile
===================================================================
@@ -9,13 +9,14 @@
 	     tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \
 	     tcp_minisocks.o tcp_cong.o \
 	     datagram.o raw.o udp.o udplite.o \
-	     arp.o icmp.o devinet.o af_inet.o  igmp.o \
+	     arp.o icmp.o devinet.o af_inet.o \
 	     fib_frontend.o fib_semantics.o \
 	     inet_fragment.o
 
 obj-$(CONFIG_SYSCTL) += sysctl_net_ipv4.o
 obj-$(CONFIG_IP_FIB_HASH) += fib_hash.o
 obj-$(CONFIG_IP_FIB_TRIE) += fib_trie.o
+obj-$(CONFIG_IGMP) += igmp.o
 obj-$(CONFIG_PROC_FS) += proc.o
 obj-$(CONFIG_IP_MULTIPLE_TABLES) += fib_rules.o
 obj-$(CONFIG_IP_MROUTE) += ipmr.o
net/ipv4/af_inet.c +0 -2
Index: linuxdev/net/ipv4/af_inet.c
===================================================================
@@ -115,8 +115,6 @@
 #include <linux/mroute.h>
 #endif
 
-extern void ip_mc_drop_socket(struct sock *sk);
-
 /* The inetsw table contains everything that inet_create needs to
  * build a new socket.
  */
net/ipv4/ip_sockglue.c +4 -0
Index: linuxdev/net/ipv4/ip_sockglue.c
===================================================================
@@ -640,6 +640,7 @@
 			err = ip_mc_leave_group(sk, &mreq);
 		break;
 	}
+#ifdef CONFIG_IGMP
 	case IP_MSFILTER:
 	{
 		extern int sysctl_igmp_max_msf;
@@ -677,6 +678,7 @@
 		kfree(msf);
 		break;
 	}
+#endif
 	case IP_BLOCK_SOURCE:
 	case IP_UNBLOCK_SOURCE:
 	case IP_ADD_SOURCE_MEMBERSHIP:
@@ -794,6 +796,7 @@
 				   greqs.gsr_interface);
 		break;
 	}
+#ifdef CONFIG_IGMP
 	case MCAST_MSFILTER:
 	{
 		extern int sysctl_igmp_max_msf;
@@ -860,6 +863,7 @@
 		kfree(gsf);
 		break;
 	}
+#endif
 	case IP_ROUTER_ALERT:
 		err = ip_ra_control(sk, val ? 1 : 0, NULL);
 		break;
net/ipv4/sysctl_net_ipv4.c +2 -0
Index: linuxdev/net/ipv4/sysctl_net_ipv4.c
===================================================================
@@ -412,6 +412,7 @@
 	},
 
 #endif
+#ifdef CONFIG_IGMP
 	{
 		.ctl_name	= NET_IPV4_IGMP_MAX_MSF,
 		.procname	= "igmp_max_msf",
@@ -420,6 +421,7 @@
 		.mode		= 0644,
 		.proc_handler	= &proc_dointvec
 	},
+#endif
 	{
 		.ctl_name	= NET_IPV4_INET_PEER_THRESHOLD,
 		.procname	= "inet_peer_threshold",
Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
maintainer
#49 lore raw
In reply to Thomas Petazzoni

From: Thomas Petazzoni <[email protected]>
Date: Thu, 31 Jul 2008 11:27:03 +0200

Quoted 5 lines

Changes since previous post:

* Add Matt Mackall's Signed-off-by on all patches
* Make bonding and bridging select ethtool in the ethtool-related patch.

The ethtool config option needs to be selected by CONFIG_INET as well, as per the things I described today. Which erodes it's usefulness tremendously.

I also am keeping my stance that I have no current intention of applying these patches.

#50 lore raw
Quoted 9 lines · David Miller

From: Thomas Petazzoni <[email protected]>
Date: Thu, 31 Jul 2008 11:27:03 +0200

Quoted 5 lines

Changes since previous post:

* Add Matt Mackall's Signed-off-by on all patches
* Make bonding and bridging select ethtool in the ethtool-related patch.

Quoted 6 lines

The ethtool config option needs to be selected by CONFIG_INET as well, as per the things I described today. Which erodes it's usefulness tremendously.

I also am keeping my stance that I have no current intention of applying these patches.

I would very much like you to reconsider, Dave.

We can make them default to 'y' and hide them behind CONFIG_EMBEDDED, and put in a scary help text that tells people _never_ to turn it off -- and hell, you can even make a taint flag for it if you like. But there are a lot of people who really don't need these features and really want the option of leaving them out.

Perhaps we should add a warning printk when one of these features is 'required' but absent. That would help to make it clear when someone has disabled a feature which they shouldn't have disabled.

Refusing to apply the patches just means that either those people will get them from elsewhere, or that their kernel will be more bloated than it needs to be.

Signature · 1 line
dwmw2
maintainer
#51 lore raw

From: David Woodhouse <[email protected]>
Date: Thu, 31 Jul 2008 10:51:52 +0100

Quoted 2 lines

But there are a lot of people who really don't need these features and really want the option of leaving them out.

I'll say it one last time.

If you have ipv4 enabled, you need ETHTOOL.

#52 lore raw
Quoted 9 lines · David Miller

From: David Woodhouse <[email protected]>
Date: Thu, 31 Jul 2008 10:51:52 +0100

Quoted 2 lines

But there are a lot of people who really don't need these features and really want the option of leaving them out.

I'll say it one last time.

If you have ipv4 enabled, you need ETHTOOL.

I have drivers which don't even _have_ ethtool support, and they seem to work fine. But leaving aside the debate on that point, your statement also seemed to be covering the other patches, such as the IGMP one and others which haven't been seen (or perhaps even imagined) yet.

Signature · 1 line
dwmw2
maintainer
#53 lore raw

From: David Woodhouse <[email protected]>
Date: Thu, 31 Jul 2008 10:59:15 +0100

Quoted 4 lines

I have drivers which don't even _have_ ethtool support, and they seem to work fine. But leaving aside the debate on that point, your statement also seemed to be covering the other patches, such as the IGMP one and others which haven't been seen (or perhaps even imagined) yet.

I explained why I didn't want to apply the IGMP one too.

Andrew didn't like my objections, but that doesn't mean I need to defend my position further.

Show me a size reduction patch for networking that actually makes real sense and I'll apply it.

#2 lore raw

Re: [patch 1/4] Configure out AIO support

In reply to Thomas Petazzoni
Quoted 5 lines · Thomas Petazzoni

This patchs adds the CONFIG_AIO option which allows to remove support for asynchronous I/O operations, that are not necessarly used by applications, particularly on embedded devices. As this is a size-reduction option, it depends on CONFIG_EMBEDDED. It allows to save ~7 kilobytes of kernel code/data:

Shouldn't this also make sure not to install aio_abi.h or at least an empty aio_abi.h?

#3 lore raw

Re: [patch 1/4] Configure out AIO support

Quoted 9 lines · Bernhard Fischer
Quoted 5 lines · Thomas Petazzoni

This patchs adds the CONFIG_AIO option which allows to remove support for asynchronous I/O operations, that are not necessarly used by applications, particularly on embedded devices. As this is a size-reduction option, it depends on CONFIG_EMBEDDED. It allows to save ~7 kilobytes of kernel code/data:

Shouldn't this also make sure not to install aio_abi.h or at least an empty aio_abi.h?

The userspace headers are independent of any kernel configuration (except for the architecture).

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#54 lore raw
In reply to David Miller
Quoted 4 lines · David Miller

I explained why I didn't want to apply the IGMP one too.

Andrew didn't like my objections, but that doesn't mean I need to defend my position further.

You said that it was part of the core BSD socket API and "Like TCP and UDP, multicast capabilities are something applications can always depend upon being available".

Andrew's response was that embedded devices have full control over their userspace and that they are in a position to _know_ that they never use multicast, so your argument is bogus. If they _know_ they don't want multicast, it makes a lot of sense for them to turn it off.

While I agree with Andrew's observation, I'd also respectfully submit that your argument is more fundamentally bogus than that. TCP and UDP are _not_ universally available. They go away if you set CONFIG_INET=n.

Signature · 1 line
dwmw2
maintainer
#55 lore raw

From: David Woodhouse <[email protected]>
Date: Thu, 31 Jul 2008 11:15:16 +0100

Quoted 3 lines

While I agree with Andrew's observation, I'd also respectfully submit that your argument is more fundamentally bogus than that. TCP and UDP are _not_ universally available. They go away if you set CONFIG_INET=n.

Like I said, people can locally patch their systems if they really want to rip out fundamental things like multicast support.

Some folks might find it instructive to do a google code search or similar on the multicast socket options this things dikes out of the tree.

Even simple things like NTP will spew failures with this CONFIG_IGMP thing turned off. And that's just the tip of the iceberg.

#32 lore raw

Re: [patch 3/4] Configure out ethtool support

In reply to Thomas Petazzoni

Thomas Petazzoni wrote:
[...]

Quoted 18 lines
include/linux/ethtool.h +5 -0
@@ -283,6 +283,7 @@
 struct net_device;
 
 /* Some generic methods drivers may use in their ethtool_ops */
+#ifdef CONFIG_ETHTOOL
 u32 ethtool_op_get_link(struct net_device *dev);
 u32 ethtool_op_get_tx_csum(struct net_device *dev);
 int ethtool_op_set_tx_csum(struct net_device *dev, u32 data);
@@ -296,6 +297,21 @@
 int ethtool_op_set_ufo(struct net_device *dev, u32 data);
 u32 ethtool_op_get_flags(struct net_device *dev);
 int ethtool_op_set_flags(struct net_device *dev, u32 data);
+#else
+static inline u32 ethtool_op_get_link(struct net_device *dev) { return 0; }
+static inline u32 ethtool_op_get_tx_csum(struct net_device *dev) { return 0; }
+static inline int ethtool_op_set_tx_csum(struct net_device *dev, u32 data) { return 0; }

include/linux/ethtool.h line 313

Quoted 10 lines
include/linux/ethtool.h +10 -0
+static inline int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data) { return 0; }
+static inline int ethtool_op_set_tx_ipv6_csum(struct net_device *dev, u32 data) { return 0; }
+static inline u32 ethtool_op_get_sg(struct net_device *dev) { return 0; }
+static inline int ethtool_op_set_sg(struct net_device *dev, u32 data) { return 0; }
+static inline u32 ethtool_op_get_tso(struct net_device *dev) { return 0; }
+static inline int ethtool_op_set_tso(struct net_device *dev, u32 data) { return 0; }
+static inline u32 ethtool_op_get_ufo(struct net_device *dev) { return 0; }
+static inline int ethtool_op_set_ufo(struct net_device *dev, u32 data) { return 0; }
+static inline u32 ethtool_op_get_flags(struct net_device *dev) { return 0; }
+static inline int ethtool_op_set_flags(struct net_device *dev, u32 data) { return 0; }

The dummy setter functions should return -EOPNOTSUPP. The getter functions just read device feature flags and could be made inline. They have no way of returning failure.

[...]

Quoted 12 lines

===================================================================

net/core/dev.c +1 -0
@@ -3669,6 +3669,7 @@
 			return ret;
 
 		case SIOCETHTOOL:
+#ifdef CONFIG_ETHTOOL
 			dev_load(net, ifr.ifr_name);
 			rtnl_lock();
 			ret = dev_ethtool(net, &ifr);

net/core/dev.c line 3690

Quoted 9 lines
net/core/dev.c +3 -0
@@ -3681,6 +3682,9 @@
 					ret = -EFAULT;
 			}
 			return ret;
+#else
+			return -EINVAL;
+#endif
 
 		/*
 		 *	These ioctl calls:

You also need to conditionalise dev_disable_lro().

Ben.

Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#36 lore raw

Re: [patch 3/4] Configure out ethtool support

In reply to Thomas Petazzoni
Quoted 6 lines · Thomas Petazzoni
include/linux/ethtool.h +5 -0
+#else
+static inline u32 ethtool_op_get_link(struct net_device *dev) { return 0; }
+static inline u32 ethtool_op_get_tx_csum(struct net_device *dev) { return 0; }
+static inline int ethtool_op_set_tx_csum(struct net_device *dev, u32 data) { return 0; }
+static inline int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data) { return 0; }

include/linux/ethtool.h line 314

Quoted 10 lines
include/linux/ethtool.h +10 -0
+static inline int ethtool_op_set_tx_ipv6_csum(struct net_device *dev, u32 data) { return 0; }
+static inline u32 ethtool_op_get_sg(struct net_device *dev) { return 0; }
+static inline int ethtool_op_set_sg(struct net_device *dev, u32 data) { return 0; }
+static inline u32 ethtool_op_get_tso(struct net_device *dev) { return 0; }
+static inline int ethtool_op_set_tso(struct net_device *dev, u32 data) { return 0; }
+static inline u32 ethtool_op_get_ufo(struct net_device *dev) { return 0; }
+static inline int ethtool_op_set_ufo(struct net_device *dev, u32 data) { return 0; }
+static inline u32 ethtool_op_get_flags(struct net_device *dev) { return 0; }
+static inline int ethtool_op_set_flags(struct net_device *dev, u32 data) { return 0; }
+#endif

It's alleged that these functions are called from 'core' network code in some places, although I can't actually see any evidence of that anywhere in Linus' tree except for vlans and bridging.

If that's actually the case, perhaps it makes sense to add a WARN_ON_ONCE() to these empty functions, so that a developer who disables CONFIG_ETHTOOL when they shouldn't will see a nasty warning about it rather than a silent failure?

Btw, I see you've made bridging 'select ETHTOOL'; did you do the same for vlan support?

Signature · 2 lines
David Woodhouse                            Open Source Technology Centre
[email protected]                              Intel Corporation
maintainer
#33 lore raw

Re: [patch 3/4] Configure out ethtool support

In reply to Ben Hutchings

From: Ben Hutchings <[email protected]>
Date: Thu, 31 Jul 2008 11:40:05 +0100

Quoted 1 line

You also need to conditionalise dev_disable_lro().

That can only be done once the CONFIG_ETHTOOL select statement is added for CONFIG_INET.

Which basically makes this CONFIG_ETHTOOL thing completely pointless.

maintainer
#37 lore raw

Re: [patch 3/4] Configure out ethtool support

In reply to David Woodhouse

From: David Woodhouse <[email protected]>
Date: Thu, 31 Jul 2008 11:42:47 +0100

Quoted 11 lines

It's alleged that these functions are called from 'core' network code in some places, although I can't actually see any evidence of that anywhere in Linus' tree except for vlans and bridging.

If that's actually the case, perhaps it makes sense to add a WARN_ON_ONCE() to these empty functions, so that a developer who disables CONFIG_ETHTOOL when they shouldn't will see a nasty warning about it rather than a silent failure?

Btw, I see you've made bridging 'select ETHTOOL'; did you do the same for vlan support?

CONFIG_INET needs it too.

dev_disable_lro() calls the ethtool ops directly.

But it still needs to be conditional, because as I said what I see happening next is this CONFIG_ETHTOOL thing getting jammed into each and every network driver. (in fact, ethtool support code in a single driver probably drarfs the 6K savings this initial patch is giving us).

And at which point you'll have a broken system for drivers that enable LRO and the user enables forwarding.

#34 lore raw

Re: [patch 3/4] Configure out ethtool support

In reply to David Miller
Quoted 9 lines · David Miller

From: Ben Hutchings <[email protected]>
Date: Thu, 31 Jul 2008 11:40:05 +0100

Quoted 1 line

You also need to conditionalise dev_disable_lro().

That can only be done once the CONFIG_ETHTOOL select statement is added for CONFIG_INET.

Which basically makes this CONFIG_ETHTOOL thing completely pointless.

Other potential approaches include not enabling LRO by default if !CONFIG_ETHTOOL. Or having the driver(s) which _do_ enable LRO by default 'select ETHTOOL'.

Signature · 1 line
dwmw2
maintainer
#35 lore raw

Re: [patch 3/4] Configure out ethtool support

From: David Woodhouse <[email protected]>
Date: Thu, 31 Jul 2008 11:54:24 +0100

Quoted 3 lines

Other potential approaches include not enabling LRO by default if !CONFIG_ETHTOOL. Or having the driver(s) which _do_ enable LRO by default 'select ETHTOOL'.

It is possible for us to generically enable LRO for every device, since it is a software algorithm. And likely we will do something like this in the not too distant future.

#38 lore raw

Re: [patch 3/4] Configure out ethtool support

In reply to David Miller
Quoted 3 lines · David Miller

CONFIG_INET needs it too.

dev_disable_lro() calls the ethtool ops directly.

Ah, right. That's why it didn't show up in my grep.

There are solutions to that, as I said. Either we could 'select ETHTOOL' in those drivers which enable LRO by default, or we could just make sure they _don't_ enable LRO by default when CONFIG_ETHTOOL isn't set.

And if we end up doing LRO generically in software where the hardware doesn't handle it, presumably we can do that without having to use ethtool to change the hardware behaviour?

Quoted 5 lines

But it still needs to be conditional, because as I said what I see happening next is this CONFIG_ETHTOOL thing getting jammed into each and every network driver. (in fact, ethtool support code in a single driver probably drarfs the 6K savings this initial patch is giving us).

I think we can avoid that. If the actual functions and the struct ethtool_ops are static, and if we have something like...

#ifdef CONFIG_ETHTOOL
#define dev_set_ethtool_ops(dev, ops) dev->ethtool_ops = ops #else
#define dev_set_ethtool_ops(dev, ops) (void)ops #endif

... then it should all fall out silently. (Yeah, those definitions would need 'hardening' but they're a proof of concept).

Quoted 2 lines

And at which point you'll have a broken system for drivers that enable LRO and the user enables forwarding.

Obviously that needs avoiding. Thanks for the technical feedback.

After an offline discussion, I understand that if we can sort out the actual technical issues, you'll carry this in the net tree. Thanks.

Signature · 2 lines
David Woodhouse                            Open Source Technology Centre
[email protected]                              Intel Corporation
maintainer
#39 lore raw

Re: [patch 3/4] Configure out ethtool support

From: David Woodhouse <[email protected]>
Date: Thu, 31 Jul 2008 12:29:30 +0100

Quoted 2 lines

After an offline discussion, I understand that if we can sort out the actual technical issues, you'll carry this in the net tree. Thanks.

I will, but only because you threatened to bypass me and send them directly to Linus. And frankly fighting someone willing to do things like that is simply not worth my time, so I'll just merge them blindly. You just let me know when you think they are ready for inclusion.

#40 lore raw

Re: [patch 3/4] Configure out ethtool support

Quoted 10 lines · David Miller

From: David Woodhouse <[email protected]>
Date: Thu, 31 Jul 2008 12:29:30 +0100

Quoted 2 lines

After an offline discussion, I understand that if we can sort out the actual technical issues, you'll carry this in the net tree. Thanks.

I will, but only because you threatened to bypass me and send them directly to Linus. And frankly fighting someone willing to do things like that is simply not worth my time, so I'll just merge them blindly.

That doesn't make a lot of sense, Dave. Just because I _submit_ them to Linus, that doesn't mean he automatically takes them.

I only said I'd submit them directly to Linus because I _think_ he'd agree with Andrew and I, and take them despite your objections. And because I think that's the right thing for him to do.

I wasn't going to hack hera and just put them into his tree by myself.

But don't let me talk you out of taking the patches... :)

Quoted 1 line

You just let me know when you think they are ready for inclusion.

I'll do that; thanks.

Signature · 1 line
dwmw2
maintainer
#41 lore raw

Re: [patch 3/4] Configure out ethtool support

From: David Woodhouse <[email protected]>
Date: Thu, 31 Jul 2008 12:46:41 +0100

Quoted 3 lines

I only said I'd submit them directly to Linus because I _think_ he'd agree with Andrew and I, and take them despite your objections. And because I think that's the right thing for him to do.

I guess Linus is unable to participate in the discussion, voice his opinion, and sort this out with the rest of us unless you submit the patches directly to him for inclusion, right?

Can you at least begin to see why your doing that might irritate me?

Quoted 3 lines
Quoted 1 line

You just let me know when you think they are ready for inclusion.

I'll do that; thanks.

No problem.

#9 lore raw

Re: [patch 2/4] Configure out file locking features

In reply to Thomas Petazzoni
Quoted 6 lines · Thomas Petazzoni

This patch adds the CONFIG_FILE_LOCKING option which allows to remove support for advisory locks. With this patch enabled, the flock() system call, the F_GETLK, F_SETLK and F_SETLKW operations of fcntl() and NFS support are disabled. These features are not necessarly needed on embedded systems. It allows to save ~11 Kb of kernel code and data:

Quoted 8 lines

text data bss dec hex filename
1125436 118764 212992 1457192 163c28 vmlinux.old
1114299 118564 212992 1445855 160fdf vmlinux
-11137 -200 0 -11337 -2C49 +/-

This patch has originally been written by Matt Mackall <[email protected]>, and is part of the Linux Tiny project.
...

As I've already said in the past I'm personally not a huge fan of these patches, but if it brings advantages in real-life situations it's hard to argue against it.

In which use cases can users safely disable this option, and on what devices have you verified that CONFIG_FILE_LOCKING=n kernels actually work in practice?

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#10 lore raw

Re: [patch 2/4] Configure out file locking features

Le Thu, 31 Jul 2008 16:53:19 +0300,
Adrian Bunk <[email protected]> a écrit :

Quoted 3 lines

As I've already said in the past I'm personally not a huge fan of these patches, but if it brings advantages in real-life situations it's hard to argue against it.

Yes, I've seen your points about that kind of patches on linux-embedded, and I understand them. I agree that adding dozens and dozens of configuration items for small features doesn't look like something sustainable on the long run. However, the kernel keeps growing and this isn't sustainable either on the long run for *some* embedded users. So, what should we do ? (That's a real question)

Some numbers about a bootable x86 allnoconfig kernel with ELF, ext2 and IDE support :

text data bss dec hex filename
1110389 119468 217088 1446945 161421 vmlinux.2.6.26
1134606 118840 212992 1466438 166046 vmlinux.2.6.27-rc1
24217 -628 -4096 19493 4C25 +/-

(The only configuration change between the two kernels is CONFIG_FW_LOADER n->y, which pulls drivers/base/firmware_class.o, 3k).

Quoted 3 lines

In which use cases can users safely disable this option, and on what devices have you verified that CONFIG_FILE_LOCKING=n kernels actually work in practice?

As long as they don't use NFS (realistic in many production environments) and that the applications do not rely on advisory locking (flock() and fnctl() F_GETLK and F_SETLK), file locking can be disabled. In practice, I only tested a CONFIG_FILE_LOCKING=n kernel with a basic Busybox under Qemu.

Sincerly,

Thomas

Signature · 8 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#11 lore raw

Re: [patch 2/4] Configure out file locking features

Quoted 7 lines · Thomas Petazzoni

Le Thu, 31 Jul 2008 16:53:19 +0300,
Adrian Bunk <[email protected]> a écrit :

Quoted 3 lines

As I've already said in the past I'm personally not a huge fan of these patches, but if it brings advantages in real-life situations it's hard to argue against it.

Quoted 6 lines

Yes, I've seen your points about that kind of patches on linux-embedded, and I understand them. I agree that adding dozens and dozens of configuration items for small features doesn't look like something sustainable on the long run. However, the kernel keeps growing and this isn't sustainable either on the long run for *some* embedded users. So, what should we do ? (That's a real question)

I'm not against making the kernel smaller.

I'm just not a fan of adding config options for each few kB of code - we have to maintain them and the more complex the configuration becomes the more often it breaks.

Quoted 7 lines

Some numbers about a bootable x86 allnoconfig kernel with ELF, ext2 and IDE support :

text data bss dec hex filename
1110389 119468 217088 1446945 161421 vmlinux.2.6.26
1134606 118840 212992 1466438 166046 vmlinux.2.6.27-rc1
24217 -628 -4096 19493 4C25 +/-

What became bigger was most likely not related to the patches you sent.

Where and why did the kernel become bigger?

Quoted 2 lines

(The only configuration change between the two kernels is CONFIG_FW_LOADER n->y, which pulls drivers/base/firmware_class.o, 3k).

Why did CONFIG_FW_LOADER get enabled?
Due to alnoconfig disabling CONFIG_EMBEDDED?

Quoted 8 lines
Quoted 3 lines

In which use cases can users safely disable this option, and on what devices have you verified that CONFIG_FILE_LOCKING=n kernels actually work in practice?

As long as they don't use NFS (realistic in many production environments) and that the applications do not rely on advisory locking (flock() and fnctl() F_GETLK and F_SETLK), file locking can be disabled.

But what does that mean in practice?

A user will ask:
I'm using $applications with $libraries, can I safely disable this option?

And e.g. according to a quick grep through the sources uClibc's updwtmp() seems to cease working without flock().

It costs us maintainance of the option and the #ifdef's and gives users one way more to shoot themselves into the foot in nontrivial to detect ways.

Quoted 6 lines

In practice, I only tested a CONFIG_FILE_LOCKING=n kernel with a basic Busybox under Qemu.

Sincerly,

Thomas

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#42 lore raw

Re: [patch 3/4] Configure out ethtool support

In reply to David Woodhouse
Quoted 12 lines · David Woodhouse
Quoted 10 lines · David Miller

From: David Woodhouse <[email protected]>
Date: Thu, 31 Jul 2008 12:29:30 +0100

Quoted 2 lines

After an offline discussion, I understand that if we can sort out the actual technical issues, you'll carry this in the net tree. Thanks.

I will, but only because you threatened to bypass me and send them directly to Linus. And frankly fighting someone willing to do things like that is simply not worth my time, so I'll just merge them blindly.

Quoted 7 lines

That doesn't make a lot of sense, Dave. Just because I _submit_ them to Linus, that doesn't mean he automatically takes them.

I only said I'd submit them directly to Linus because I _think_ he'd agree with Andrew and I, and take them despite your objections. And because I think that's the right thing for him to do.
...

I'm sure we can find simpler and less controversial ways to save 6 kB in the network stack. E.g. Ilpo's past work on making inline functions in the network stack out-of-line had far bigger effects than the patch in this discussion. And as a bonus, his work brings benefits to everyone.

It might have also made more sense to spend some of the energy used in this discussion instead on checking where the global 24 kB size increase Thomas reported for 2.6.27-rc1 compared to 2.6.26 comes from.

It's kinda silly to spend time on creating and arguing about non-trivial patches that might save a few kB for very few people while noone seems to work on reducing the continuous size increase of the kernel that affects everyone...

Quoted 1 line

dwmw2

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#12 lore raw

Re: [patch 2/4] Configure out file locking features

In reply to Adrian Bunk

Le Thu, 31 Jul 2008 18:37:57 +0300,
Adrian Bunk <[email protected]> a écrit :

Quoted 3 lines

I'm just not a fan of adding config options for each few kB of code - we have to maintain them and the more complex the configuration becomes the more often it breaks.

I'm not a fan of these too, but are there other solutions ?

Quoted 2 lines

What became bigger was most likely not related to the patches you sent.

No, it is not.

Quoted 1 line

Where and why did the kernel become bigger?

It's not up-to-date with 2.6.26 and 2.6.27-rc1, but Bloatwatch
<http://www.selenic.com/bloatwatch/>, by Matt Mackall, is here to answer these questions. I haven't made the analysis for 2.6.26->2.6.27-rc1.

Quoted 2 lines

Why did CONFIG_FW_LOADER get enabled?
Due to alnoconfig disabling CONFIG_EMBEDDED?

I don't know. Haven't made the analysis for now.

Quoted 3 lines

A user will ask:
I'm using $applications with $libraries, can I safely disable this option?

Hard to tell in the general case.

Quoted 2 lines

And e.g. according to a quick grep through the sources uClibc's updwtmp() seems to cease working without flock().

Correct. But on many embedded systems, we don't care about logging past user logins. We might even not care about logins at all.

Quoted 3 lines

It costs us maintainance of the option and the #ifdef's and gives users one way more to shoot themselves into the foot in nontrivial to detect ways.

That's correct, and as I said previously, I fully understand the maintainance problem of all these new configuration options. I must admit that I do not really have more objective technical arguments that would help us deciding whether the code size reduction vs. code maintainance choice should be made in one direction or the other.

Sincerly,

Thomas

Signature · 8 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#43 lore raw

Re: [patch 3/4] Configure out ethtool support

In reply to Adrian Bunk

Le Thu, 31 Jul 2008 18:58:20 +0300,
Adrian Bunk <[email protected]> a écrit :

Quoted 3 lines

It might have also made more sense to spend some of the energy used in this discussion instead on checking where the global 24 kB size increase Thomas reported for 2.6.27-rc1 compared to 2.6.26 comes from.

I agree. This is something I'm working on. I hope to have results soon. But I *fear* that the results will be: the size growth is 10 bytes here, 22 bytes there, 35 bytes here, spread over hundreds of patches. Something we can do anything against.

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#63 lore raw
In reply to David Miller
Quoted 9 lines · David Miller

From: David Woodhouse <[email protected]>
Date: Thu, 31 Jul 2008 10:51:52 +0100

Quoted 2 lines

But there are a lot of people who really don't need these features and really want the option of leaving them out.

I'll say it one last time.

If you have ipv4 enabled, you need ETHTOOL.

I've been using and administering Linux for 16 years, and using it successfully in embedded projects for 10. Until I stumbled upon this patch in Linux-tiny, I had never heard of ethtool. Sony has shipped hundreds of thousands of products with ETHTOOL turned off.

It sounds like you don't want to talk about it any more, but could you please give me the 30-second overview of why ETHTOOL is required for proper ipv4 operation?

If Sony is shipping network-buggy products I certainly want to know about it.

Sorry if I missed an earlier explanation.

Thanks,
-- Tim

=============================
Tim Bird
Architecture Group Chair, CE Linux Forum Senior Staff Engineer, Sony Corporation of America
=============================

#13 lore raw

Re: [patch 2/4] Configure out file locking features

In reply to Thomas Petazzoni
Quoted 8 lines · Thomas Petazzoni

Le Thu, 31 Jul 2008 18:37:57 +0300,
Adrian Bunk <[email protected]> a écrit :

Quoted 3 lines

I'm just not a fan of adding config options for each few kB of code - we have to maintain them and the more complex the configuration becomes the more often it breaks.

I'm not a fan of these too, but are there other solutions ?

There are many things that can be done to reduce the kernel size or try to minimize the growth of the kernel.

E.g. working on --combine -fwhole-program (where David once had preliminary patches for the per-module approach) might be better.

Quoted 11 lines
Quoted 2 lines

What became bigger was most likely not related to the patches you sent.

No, it is not.

Quoted 1 line

Where and why did the kernel become bigger?

It's not up-to-date with 2.6.26 and 2.6.27-rc1, but Bloatwatch
<http://www.selenic.com/bloatwatch/>, by Matt Mackall, is here to answer these questions. I haven't made the analysis for 2.6.26->2.6.27-rc1.

It can only give some hints where to start searching.

But it tracks a defconfig, and e.g. the nearly doubled size between 2.6.18 and 2.6.19 is both expected and not a problem for embedded systems.

The real work is to figure out in which areas that are relevant for embedded systems the kernel became bigger.

Quoted 9 lines
Quoted 2 lines

Why did CONFIG_FW_LOADER get enabled?
Due to alnoconfig disabling CONFIG_EMBEDDED?

I don't know. Haven't made the analysis for now.

Quoted 3 lines

A user will ask:
I'm using $applications with $libraries, can I safely disable this option?

Quoted 7 lines

Hard to tell in the general case.

Quoted 2 lines

And e.g. according to a quick grep through the sources uClibc's updwtmp() seems to cease working without flock().

Correct. But on many embedded systems, we don't care about logging past user logins. We might even not care about logins at all.

And for embedded systems with which applications is it 100% safe to disable this option?

And don't answer "doesn't use flock()", I want a real-life example of a device where you could guarantee a developer that disabling this option in his product would be safe.

Quoted 9 lines
Quoted 3 lines

It costs us maintainance of the option and the #ifdef's and gives users one way more to shoot themselves into the foot in nontrivial to detect ways.

That's correct, and as I said previously, I fully understand the maintainance problem of all these new configuration options. I must admit that I do not really have more objective technical arguments that would help us deciding whether the code size reduction vs. code maintainance choice should be made in one direction or the other.

My personal criteron for this patch is still how many real-life systems can safely disable it.

Quoted 3 lines

Sincerly,

Thomas

cu
Adrian

Signature · 9 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#14 lore raw

Re: [patch 2/4] Configure out file locking features

Quoted 8 lines · Adrian Bunk
Quoted 7 lines · Thomas Petazzoni

Le Thu, 31 Jul 2008 18:37:57 +0300,
Adrian Bunk <[email protected]> a écrit :

Quoted 3 lines

I'm just not a fan of adding config options for each few kB of code - we have to maintain them and the more complex the configuration becomes the more often it breaks.

Quoted 7 lines
Quoted 1 line

I'm not a fan of these too, but are there other solutions ?

There are many things that can be done to reduce the kernel size or try to minimize the growth of the kernel.

E.g. working on --combine -fwhole-program (where David once had preliminary patches for the per-module approach) might be better.

Yeah, I'm planning to dig that out again and play with it some time soon. The Kbuild issues were too scary at the time, but I'm less frightened of it these days...

Segher has also been looking at it, and reported quite a useful win when he used it to combine arch/$ARCH/mm and mm/, and arch/$ARCH/kernel and kernel/.

Signature · 2 lines
David Woodhouse                            Open Source Technology Centre
[email protected]                              Intel Corporation
#64 lore raw
In reply to Tim Bird
Quoted 3 lines · Tim Bird

It sounds like you don't want to talk about it any more, but could you please give me the 30-second overview of why ETHTOOL is required for proper ipv4 operation?

...

Quoted 1 line

Sorry if I missed an earlier explanation.

Never mind. I hadn't read the whole thread yet.

=============================
Tim Bird
Architecture Group Chair, CE Linux Forum Senior Staff Engineer, Sony Corporation of America
=============================

#15 lore raw

Re: [patch 2/4] Configure out file locking features

In reply to Adrian Bunk
Quoted 2 lines · Adrian Bunk

And for embedded systems with which applications is it 100% safe to disable this option?

Sony's digital cameras.

This option *is* disabled in the kernel for (most) Sony digital cameras. Those digital cameras have the kernel, busybox, a custom C library,
and one proprietary application. The application does not use
flock() (or AIO, or ethtool or multi-cast)

These cameras were heavily tested, and are shipping now. I can't make any guarantees for other developers, but those of us who are careful about our application development would like the option to eliminate completely unused features from the kernel. (And the C library, but that's a different issue.)

Quoted 3 lines

And don't answer "doesn't use flock()", I want a real-life example of a device where you could guarantee a developer that disabling this option in his product would be safe.

I'm not sure why a guarantee is required that other developers use this option safely. Maybe this is a point of disconnect between embedded folks and non-embedded folks. We're accustomed to making tradeoff decisions that only affect our product, and which we take full responsibility for testing.

If warnings or support avoidance for the general population using such config options is the issue, I think that David Woodhouse's suggestion that such things could taint the kernel is an interesting idea. Maybe have we could have an "unsafe-config" taint flag?

I should add that I am sympathetic with the larger issue you raise about nibbling at the bottom with patches that only address a few KB of the problem, while the size continues to build (to an even greater degree) with each release. My response is that I agree with you on the nibbling bit, but probably just at a different level of KB savings.

That is, I presume you'd be OK with something that saved 100K or even 20K, but balk at bit at these patches, which save 10k or less. My threshold is lower (probably down to about 5K, so these are pretty close to the bubble), but even I wouldn't recommend applying anything much below that. We've already started considering to drop some linux-tiny patches that just don't save enough to warrant continued maintenance.
-- Tim

=============================
Tim Bird
Architecture Group Chair, CE Linux Forum Senior Staff Engineer, Sony Corporation of America
=============================

#56 lore raw
In reply to David Miller
Quoted 6 lines · David Miller

Some folks might find it instructive to do a google code search or similar on the multicast socket options this things dikes out of the tree.

Even simple things like NTP will spew failures with this CONFIG_IGMP thing turned off. And that's just the tip of the iceberg.

I don't know of any embedded products that ship with NTP turned on. It's best to assume, with embedded, that we're not shipping ANY of the desktop or server applications you are familiar with. Absent those, does something break in the kernel with multicast support when IGMP is turned off?
-- Tim

=============================
Tim Bird
Architecture Group Chair, CE Linux Forum Senior Staff Engineer, Sony Corporation of America
=============================

#16 lore raw

Re: [patch 2/4] Configure out file locking features

In reply to Tim Bird
Quoted 4 lines · Tim Bird
Quoted 2 lines

And for embedded systems with which applications is it 100% safe to disable this option?

Sony's digital cameras.

We have also several very small automation & measurement devices in the field which run a very dedicated more or less single application which can be carefully audited.

In the OSADL safety working group, people are discussing about Linux for safety critical applications. If we want to achieve such scenarios, stripped-down systems are an absolute must.

Although increasing processor power even in embedded applications lead to more and more standard-line kernels plus normal userspace components (i.e. glibc instead of uclibc), there are still applications where the final product consists only of the kernel plus the app, whereas during development time, the system has a full-blown configuration.

rsc

Signature · 5 lines
 Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry
   Handelsregister:  Amtsgericht Hildesheim, HRA 2686
     Hannoversche Str. 2, 31134 Hildesheim, Germany
   Phone: +49-5121-206917-0 |  Fax: +49-5121-206917-9
#57 lore raw

Re: [patch 0/4] [resend] Add configuration options to disable features

In reply to Tim Bird

Hi,

Quoted 2 lines

I don't know of any embedded products that ship with NTP turned on.

Well, I do. To be exact, I've developed parts of it. But it's numbers are only into the thousands, so that makes it insignificant ;-)

Quoted 4 lines

It's best to assume, with embedded, that we're not shipping ANY of the desktop or server applications you are familiar with. Absent those, does something break in the kernel with multicast support when IGMP is turned off?

I do not think of NTP as desktop or server application, but that's probably just me,

CU,
Uli

Signature · 3 lines
Dipl. Inf. Ulrich Teichert|e-mail: [email protected] | Listening to:
Stormweg 24               |Pale Bride (The Von Bondies), No Time (Statues),
24539 Neumuenster, Germany|Am Strand (Smoke Blow), Sacred Decay (The Estranged)
#19 lore raw

Re: [patch 2/4] Configure out file locking features

In reply to Tim Bird
Quoted 21 lines · Tim Bird
Quoted 2 lines · Adrian Bunk

And for embedded systems with which applications is it 100% safe to disable this option?

Sony's digital cameras.

This option *is* disabled in the kernel for (most) Sony digital cameras. Those digital cameras have the kernel, busybox, a custom C library,
and one proprietary application. The application does not use
flock() (or AIO, or ethtool or multi-cast)

These cameras were heavily tested, and are shipping now. I can't make any guarantees for other developers, but those of us who are careful about our application development would like the option to eliminate completely unused features from the kernel. (And the C library, but that's a different issue.)

Quoted 3 lines

And don't answer "doesn't use flock()", I want a real-life example of a device where you could guarantee a developer that disabling this option in his product would be safe.

Quoted 5 lines

I'm not sure why a guarantee is required that other developers use this option safely. Maybe this is a point of disconnect between embedded folks and non-embedded folks. We're accustomed to making tradeoff decisions that only affect our product, and which we take full responsibility for testing.

Thanks. That's quite different from Thomas' "In practice, I only tested a CONFIG_FILE_LOCKING=n kernel with a basic Busybox under Qemu." and addresses my concerns.

In case I didn't express myself clearly:
I was not interested in guarantees for random developers but in seeing some reasonable use case for a real device.

Quoted 4 lines

If warnings or support avoidance for the general population using such config options is the issue, I think that David Woodhouse's suggestion that such things could taint the kernel is an interesting idea. Maybe have we could have an "unsafe-config" taint flag?

A CONFIG_EMBEDDED=y flag?

Quoted 7 lines

I should add that I am sympathetic with the larger issue you raise about nibbling at the bottom with patches that only address a few KB of the problem, while the size continues to build (to an even greater degree) with each release. My response is that I agree with you on the nibbling bit, but probably just at a different level of KB savings.

Quoted 7 lines

That is, I presume you'd be OK with something that saved 100K or even 20K, but balk at bit at these patches, which save 10k or less. My threshold is lower (probably down to about 5K, so these are pretty close to the bubble), but even I wouldn't recommend applying anything much below that. We've already started considering to drop some linux-tiny patches that just don't save enough to warrant continued maintenance.

It's not only about limits, I also have a general dislike for the "add more config options" approach.

I get your point why it brings advantages in some cases, but if you are looking for a cheerleader it won't be me. ;-)

Quoted 1 line

-- Tim

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#17 lore raw

Re: [patch 2/4] Configure out file locking features

In reply to Robert Schwebel
Quoted 6 lines · Robert Schwebel
Quoted 4 lines · Tim Bird
Quoted 2 lines

And for embedded systems with which applications is it 100% safe to disable this option?

Sony's digital cameras.

Quoted 8 lines

We have also several very small automation & measurement devices in the field which run a very dedicated more or less single application which can be carefully audited.

In the OSADL safety working group, people are discussing about Linux for safety critical applications. If we want to achieve such scenarios, stripped-down systems are an absolute must.
...

My first reaction is that as soon as you enable CONFIG_EMBEDDED you can easily enter codepaths noone else has used for a while and that got unnoticed broken.

Quoted 1 line

rsc

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#58 lore raw

Re: [patch 0/4] [resend] Add configuration options to disable features

In reply to Ulrich Teichert
Quoted 8 lines · Ulrich Teichert

Hi,

Quoted 2 lines

I don't know of any embedded products that ship with NTP turned on.

Well, I do. To be exact, I've developed parts of it. But it's numbers are only into the thousands, so that makes it insignificant ;-)

Quoted 7 lines
Quoted 4 lines

It's best to assume, with embedded, that we're not shipping ANY of the desktop or server applications you are familiar with. Absent those, does something break in the kernel with multicast support when IGMP is turned off?

I do not think of NTP as desktop or server application, but that's probably just me,

No, it's not just you. NTP is useful in cases where things do care about time but hardware designers were too cheap to put an RTC on the board.

I will admit that it's use in embedded products is probably very limited though.

josh

#59 lore raw

Re: [patch 0/4] [resend] Add configuration options to disable features

Quoted 17 lines · Josh Boyer
Quoted 8 lines · Ulrich Teichert

Hi,

Quoted 2 lines

I don't know of any embedded products that ship with NTP turned on.

Well, I do. To be exact, I've developed parts of it. But it's numbers are only into the thousands, so that makes it insignificant ;-)

Quoted 7 lines
Quoted 4 lines

It's best to assume, with embedded, that we're not shipping ANY of the desktop or server applications you are familiar with. Absent those, does something break in the kernel with multicast support when IGMP is turned off?

I do not think of NTP as desktop or server application, but that's probably just me,

Quoted 6 lines

No, it's not just you. NTP is useful in cases where things do care about time but hardware designers were too cheap to put an RTC on the board.

I will admit that it's use in embedded products is probably very limited though.

NTP is a red herring. It has a check for multicast support in its configure script and wraps it all in #ifdef MCAST anyway.

So even if it _does_ crap out when I build my standard distro kernel with !CONFIG_IGMP and use the standard distro build of ntpd, that still isn't particularly relevant to the kind of application where someone would built a kernel without IGMP support and build their own ntpd to match.

Signature · 1 line
dwmw2
#20 lore raw

Re: [patch 2/4] Configure out file locking features

In reply to Adrian Bunk
Quoted 7 lines · Adrian Bunk
Quoted 4 lines · Tim Bird

If warnings or support avoidance for the general population using such config options is the issue, I think that David Woodhouse's suggestion that such things could taint the kernel is an interesting idea. Maybe have we could have an "unsafe-config" taint flag?

A CONFIG_EMBEDDED=y flag?

If this is sufficient, it works for me!

Quoted 5 lines

It's not only about limits, I also have a general dislike for the "add more config options" approach.

I get your point why it brings advantages in some cases, but if you are looking for a cheerleader it won't be me. ;-)

Understood. I promise not to send you any pom-poms. ;-)
-- Tim

=============================
Tim Bird
Architecture Group Chair, CE Linux Forum Senior Staff Engineer, Sony Corporation of America
=============================

#4 lore raw

Re: [patch 1/4] Configure out AIO support

In reply to Adrian Bunk
Quoted 8 lines · Adrian Bunk
Quoted 7 lines · Bernhard Fischer
Quoted 5 lines · Thomas Petazzoni

This patchs adds the CONFIG_AIO option which allows to remove support for asynchronous I/O operations, that are not necessarly used by applications, particularly on embedded devices. As this is a size-reduction option, it depends on CONFIG_EMBEDDED. It allows to save ~7 kilobytes of kernel code/data:

Quoted 5 lines
Quoted 2 lines

Shouldn't this also make sure not to install aio_abi.h or at least an empty aio_abi.h?

The userspace headers are independent of any kernel configuration (except for the architecture).

I beg to disagree:
internals as exposed by e.g. aio_abi.h are impl dependent. Noone except the impl and it's users are interrested in it.

If a per package feature, independent of arch, is off, all respective features stuff should be off for that particular installation.

I.e. if I, for subsequent installations, choose to turn on feature, the requested feature-stuff will be installed properly. If I, OTOH, choose to (keep to) turn off feature, then all feature-related stuff should -- and has to be and stay -- turned off.

In the particular case of the kernel exposing unwanted API extensions that are off, all such API reminiscences should be off, thus not installed to my staging dir at all since i explicitely asked for doing away with all of the API.

From a libc POV i'd agree, but from an inherently broken userspace POV installing willingly broken stuff is just wrong and misleading, imo.

#60 lore raw

Re: [patch 0/4] [resend] Add configuration options to disable features

In reply to Josh Boyer
Quoted 6 lines · Josh Boyer
Quoted 2 lines

I do not think of NTP as desktop or server application, but that's probably just me,

No, it's not just you. NTP is useful in cases where things do care about time but hardware designers were too cheap to put an RTC on the board.

Yes, we also have such customer systems, i.e. one which is used in a Telemetry application where you can have hundrets of PXA270 data concentrators that collect data from FPGAs and push them to a PC via ethernet. As the system does not work without the PC, the hardware designers decided that they can save hundrets of RTCs.

Or another autonomous data collection system where only one system of several tens has an RTC...

We used chrony in these cases, as the standard ntputils seem to be optimized for scenarios where you have permanent network connection, which is often not the case in embedded applications.

rsc

Signature · 5 lines
 Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry
   Handelsregister:  Amtsgericht Hildesheim, HRA 2686
     Hannoversche Str. 2, 31134 Hildesheim, Germany
   Phone: +49-5121-206917-0 |  Fax: +49-5121-206917-9
#18 lore raw

Re: [patch 2/4] Configure out file locking features

In reply to Adrian Bunk
Quoted 8 lines · Adrian Bunk
Quoted 4 lines

In the OSADL safety working group, people are discussing about Linux for safety critical applications. If we want to achieve such scenarios, stripped-down systems are an absolute must.
...

My first reaction is that as soon as you enable CONFIG_EMBEDDED you can easily enter codepaths noone else has used for a while and that got unnoticed broken.

That may be no problem; if we ever come to a safety kernel, it will have to be audited and carefully tested anyway.

rsc

Signature · 5 lines
 Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry
   Handelsregister:  Amtsgericht Hildesheim, HRA 2686
     Hannoversche Str. 2, 31134 Hildesheim, Germany
   Phone: +49-5121-206917-0 |  Fax: +49-5121-206917-9
#61 lore raw

Re: [patch 0/4] [resend] Add configuration options to disable features

In reply to Josh Boyer
Quoted 8 lines · Josh Boyer
Quoted 3 lines · Ulrich Teichert

I do not think of NTP as desktop or server application, but that's probably just me,

No, it's not just you. NTP is useful in cases where things do care about time but hardware designers were too cheap to put an RTC on the board.

In fact, didn't one of the netgear firewall/switch/routers end up being famous for overloading some NTP service exactly because all the _millions_ of routers ended up using the same (incorrect) NTP host?

So NTP is very definitely an embedded thing too.

Linus

#45 lore raw

Re: [patch 4/4] Configure out IGMP support

In reply to Thomas Petazzoni
Quoted 6 lines · Thomas Petazzoni

This patchs adds the CONFIG_IGMP option which allows to remove support for the Internet Group Management Protocol, used in multicast. Multicast is not necessarly used by applications, particularly on embedded devices. As this is a size-reduction option, it depends on CONFIG_EMBEDDED. It allows to save ~10 kilobytes of kernel code/data:

The config option probably lives in net/Kconfig, not init/Kconfig.

And please could you make it clear how this interacts with IP_MULTICAST?

We already have a CONFIG_IP_MULTICAST option, for which the help text says "For more people, it's safe to say N'. And I think it defaults to that too. What more does CONFIG_IGMP remove? It's not made clear by the help text.

Signature · 1 line
dwmw2
#62 lore raw

Re: [patch 0/4] [resend] Add configuration options to disable features

In reply to Linus Torvalds
Quoted 11 lines · Linus Torvalds
Quoted 8 lines · Josh Boyer
Quoted 3 lines · Ulrich Teichert

I do not think of NTP as desktop or server application, but that's probably just me,

No, it's not just you. NTP is useful in cases where things do care about time but hardware designers were too cheap to put an RTC on the board.

Quoted 5 lines

In fact, didn't one of the netgear firewall/switch/routers end up being famous for overloading some NTP service exactly because all the _millions_ of routers ended up using the same (incorrect) NTP host?

So NTP is very definitely an embedded thing too.

And it's _still_ a red herring.

I just booted a !CONFIG_IGMP kernel on my workstation and NTP is running just fine (as is IPv6).

Even though ntpd has a configure test for multicast and can be built without multicast support at all, it isn't even necessary to build it that way -- the stock Fedora build of it works just fine.

(Actually, I never managed to get ntpd to work _with_ multicast, but that's a different issue... :)

Signature · 1 line
dwmw2
#21 lore raw

Re: [patch 2/4] Configure out file locking features

In reply to Thomas Petazzoni
Quoted 5 lines · Thomas Petazzoni

This patch adds the CONFIG_FILE_LOCKING option which allows to remove support for advisory locks. With this patch enabled, the flock() system call, the F_GETLK, F_SETLK and F_SETLKW operations of fcntl() and NFS support are disabled. These features are not necessarly needed on embedded systems. It allows to save ~11 Kb of kernel code and data:

Out of curiosity, why does the nfs client need disabling, but not nfsd, gfs2, fuse, etc.?

--b.

Quoted 280 lines

text data bss dec hex filename
1125436 118764 212992 1457192 163c28 vmlinux.old
1114299 118564 212992 1445855 160fdf vmlinux
-11137 -200 0 -11337 -2C49 +/-

This patch has originally been written by Matt Mackall <[email protected]>, and is part of the Linux Tiny project.

---
 fs/Kconfig          |    2 +-
 fs/Makefile         |    3 ++-
 fs/proc/proc_misc.c |    4 ++++
 include/linux/fs.h  |   52 +++++++++++++++++++++++++++++++++++++++++++++-------
 init/Kconfig        |    8 ++++++++
 kernel/sys_ni.c     |    1 +
 kernel/sysctl.c     |    6 +++++-
 7 files changed, 66 insertions(+), 10 deletions(-)

Index: linuxdev/fs/Kconfig
===================================================================

fs/Kconfig +1 -1
@@ -1559,7 +1559,7 @@
 
 config NFS_FS
 	tristate "NFS client support"
-	depends on INET
+	depends on INET && FILE_LOCKING
 	select LOCKD
 	select SUNRPC
 	select NFS_ACL_SUPPORT if NFS_V3_ACL

Index: linuxdev/fs/Makefile
===================================================================

fs/Makefile +2 -1
@@ -7,7 +7,7 @@
 
 obj-y :=	open.o read_write.o file_table.o super.o \
 		char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \
-		ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \
+		ioctl.o readdir.o select.o fifo.o dcache.o inode.o \
 		attr.o bad_inode.o file.o filesystems.o namespace.o \
 		seq_file.o xattr.o libfs.o fs-writeback.o \
 		pnode.o drop_caches.o splice.o sync.o utimes.o \
@@ -28,6 +28,7 @@
 obj-$(CONFIG_TIMERFD)		+= timerfd.o
 obj-$(CONFIG_EVENTFD)		+= eventfd.o
 obj-$(CONFIG_AIO)               += aio.o
+obj-$(CONFIG_FILE_LOCKING)      += locks.o
 obj-$(CONFIG_COMPAT)		+= compat.o compat_ioctl.o
 
 nfsd-$(CONFIG_NFSD)		:= nfsctl.o

Index: linuxdev/fs/proc/proc_misc.c
===================================================================

fs/proc/proc_misc.c +4 -0
@@ -677,6 +677,7 @@
 	return proc_calc_metrics(page, start, off, count, eof, len);
 }
 
+#ifdef CONFIG_FILE_LOCKING
 static int locks_open(struct inode *inode, struct file *filp)
 {
 	return seq_open(filp, &locks_seq_operations);
@@ -688,6 +689,7 @@
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
+#endif /* CONFIG_FILE_LOCKING */
 
 static int execdomains_read_proc(char *page, char **start, off_t off,
 				 int count, int *eof, void *data)
@@ -881,7 +883,9 @@
 #ifdef CONFIG_PRINTK
 	proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations);
 #endif
+#ifdef CONFIG_FILE_LOCKING
 	proc_create("locks", 0, NULL, &proc_locks_operations);
+#endif
 	proc_create("devices", 0, NULL, &proc_devinfo_operations);
 	proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations);
 #ifdef CONFIG_BLOCK

Index: linuxdev/include/linux/fs.h
===================================================================

include/linux/fs.h +45 -7
@@ -983,6 +983,13 @@
 
 #include <linux/fcntl.h>
 
+extern void send_sigio(struct fown_struct *fown, int fd, int band);
+
+/* fs/sync.c */
+extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
+			loff_t endbyte, unsigned int flags);
+
+#ifdef CONFIG_FILE_LOCKING
 extern int fcntl_getlk(struct file *, struct flock __user *);
 extern int fcntl_setlk(unsigned int, struct file *, unsigned int,
 			struct flock __user *);
@@ -993,14 +1000,9 @@
 			struct flock64 __user *);
 #endif
 
-extern void send_sigio(struct fown_struct *fown, int fd, int band);
 extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
 extern int fcntl_getlease(struct file *filp);
 
-/* fs/sync.c */
-extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
-			loff_t endbyte, unsigned int flags);
-
 /* fs/locks.c */
 extern void locks_init_lock(struct file_lock *);
 extern void locks_copy_lock(struct file_lock *, struct file_lock *);
@@ -1023,6 +1025,33 @@
 extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
 extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
 extern struct seq_operations locks_seq_operations;
+#else /* !CONFIG_FILE_LOCKING */
+#define fcntl_getlk(a, b) (-EINVAL)
+#define fcntl_setlk(a, b, c, d) (-EACCES)
+#if BITS_PER_LONG == 32
+#define fcntl_getlk64(a, b) (-EINVAL)
+#define fcntl_setlk64(a, b, c, d) (-EACCES)
+#endif
+#define fcntl_setlease(a, b, c) (0)
+#define fcntl_getlease(a) (0)
+#define locks_init_lock(a)
+#define locks_copy_lock(a, b)
+#define locks_remove_posix(a, b)
+#define locks_remove_flock(a)
+#define posix_test_lock(a, b) (0)
+#define posix_lock_file(a, b) (-ENOLCK)
+#define posix_lock_file_wait(a, b) (-ENOLCK)
+#define posix_unblock_lock(a, b) (-ENOENT)
+#define vfs_test_lock(a, b) (0)
+#define vfs_lock_file(a, b, c, d) (-ENOLCK)
+#define vfs_cancel_lock(a, b) (0)
+#define flock_lock_file_wait(a, b) (-ENOLCK)
+#define __break_lease(a, b) (0)
+#define lease_get_mtime(a, b)
+#define lock_may_read(a, b, c) (1)
+#define lock_may_write(a, b, c) (1)
+#endif /* !CONFIG_FILE_LOCKING */
+
 
 struct fasync_struct {
 	int	magic;
@@ -1554,9 +1583,12 @@
 /* /sys/fs */
 extern struct kobject *fs_kobj;
 
+extern int rw_verify_area(int, struct file *, loff_t *, size_t);
+
 #define FLOCK_VERIFY_READ  1
 #define FLOCK_VERIFY_WRITE 2
 
+#ifdef CONFIG_FILE_LOCKING
 extern int locks_mandatory_locked(struct inode *);
 extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
 
@@ -1587,8 +1619,6 @@
 	return 0;
 }
 
-extern int rw_verify_area(int, struct file *, loff_t *, size_t);
-
 static inline int locks_verify_truncate(struct inode *inode,
 				    struct file *filp,
 				    loff_t size)
@@ -1609,6 +1639,14 @@
 		return __break_lease(inode, mode);
 	return 0;
 }
+#else /* !CONFIG_FILE_LOCKING */
+#define locks_mandatory_locked(a) (0)
+#define locks_mandatory_area(a, b, c, d, e) (0)
+#define mandatory_lock(a) (0)
+#define locks_verify_locked(a) (0)
+#define locks_verify_truncate(a, b, c) (0)
+#define break_lease(a, b) (0)
+#endif /* CONFIG_FILE_LOCKING */
 
 /* fs/open.c */
 

Index: linuxdev/init/Kconfig
===================================================================

init/Kconfig +8 -0
@@ -732,6 +732,14 @@
           by some high performance threaded applications. Disabling
           this option saves about 7k.
 
+config FILE_LOCKING
+	bool "Enable POSIX file locking API" if EMBEDDED
+	default y
+	help
+	  This option enables standard file locking support, required
+          for filesystems like NFS and for the flock() system
+          call. Disabling this option saves about 11k.
+
 config VM_EVENT_COUNTERS
 	default y
 	bool "Enable VM event counters for /proc/vmstat" if EMBEDDED

Index: linuxdev/kernel/sys_ni.c
===================================================================

kernel/sys_ni.c +1 -0
@@ -130,6 +130,7 @@
 cond_syscall(sys_io_submit);
 cond_syscall(sys_io_cancel);
 cond_syscall(sys_io_getevents);
+cond_syscall(sys_flock);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);

Index: linuxdev/kernel/sysctl.c
===================================================================

kernel/sysctl.c +5 -1
@@ -97,7 +97,7 @@
 static int neg_one = -1;
 #endif
 
-#ifdef CONFIG_MMU
+#if defined(CONFIG_MMU) && defined(CONFIG_FILE_LOCKING)
 static int two = 2;
 #endif
 
@@ -1260,6 +1260,7 @@
 		.extra1		= &minolduid,
 		.extra2		= &maxolduid,
 	},
+#ifdef CONFIG_FILE_LOCKING
 	{
 		.ctl_name	= FS_LEASES,
 		.procname	= "leases-enable",
@@ -1268,6 +1269,7 @@
 		.mode		= 0644,
 		.proc_handler	= &proc_dointvec,
 	},
+#endif
 #ifdef CONFIG_DNOTIFY
 	{
 		.ctl_name	= FS_DIR_NOTIFY,
@@ -1279,6 +1281,7 @@
 	},
 #endif
 #ifdef CONFIG_MMU
+#ifdef CONFIG_FILE_LOCKING
 	{
 		.ctl_name	= FS_LEASE_TIME,
 		.procname	= "lease-break-time",
@@ -1290,6 +1293,7 @@
 		.extra1		= &zero,
 		.extra2		= &two,
 	},
+#endif /* CONFIG_FILE_LOCKING */
 #ifdef CONFIG_AIO
 	{
 		.procname	= "aio-nr",
Signature · 9 lines
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#46 lore raw

Re: [patch 4/4] Configure out IGMP support

In reply to David Woodhouse

Le Fri, 01 Aug 2008 20:41:55 +0100,
David Woodhouse <[email protected]> a écrit :

Quoted 1 line

The config option probably lives in net/Kconfig, not init/Kconfig.

Yes, it could. But AFAIK, until now, all CONFIG_EMBEDDED-related options have been put in init/Kconfig. But if it's preferred, I can of course change the patch to move the config option to net/Kconfig.

Quoted 7 lines

And please could you make it clear how this interacts with IP_MULTICAST?

We already have a CONFIG_IP_MULTICAST option, for which the help text says "For more people, it's safe to say N'. And I think it defaults to that too. What more does CONFIG_IGMP remove? It's not made clear by the help text.

The interaction of IGMP support with CONFIG_IP_MULTICAST is fairly unclear to me.

A large portion of igmp.c is already under #ifdef CONFIG_IP_MULTICAST:
all the igmp_*() functions, amongst which is igmp_rcv(), referenced in igmp_protocol in net/ipv4/af_inet.c, which is compiled-out when !CONFIG_IP_MULTICAST.

All the proc-related code at the end of the file is only conditionnaly compiled on CONFIG_PROC_FS, but seems to in fact be only used if both CONFIG_IP_MULTICAST and CONFIG_PROC_FS are selected:
igmp_mc_proc_init() in net/ipv4/ip_output.c is only called when CONFIG_IP_MULTICAST and CONFIG_PROC_FS are selected.

Besides that, it's unclear to me why the ip_mc_*() functions are useful when !CONFIG_IP_MULTICAST, but I'm probably missing something. They are used to implement setsockopt-operations related to multicast, hooks for the routing code to handle multicast-related traffic, etc.

Sincerly,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#47 lore raw

Re: [patch 4/4] Configure out IGMP support

Quoted 8 lines · Thomas Petazzoni

Le Fri, 01 Aug 2008 20:41:55 +0100,
David Woodhouse <[email protected]> a écrit :

Quoted 1 line

The config option probably lives in net/Kconfig, not init/Kconfig.

Yes, it could. But AFAIK, until now, all CONFIG_EMBEDDED-related options have been put in init/Kconfig.
...

No, the vast majority is actually outside of init/Kconfig.

Quoted 3 lines

Sincerly,

Thomas

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#22 lore raw

Re: [patch 2/4] Configure out file locking features

In reply to J. Bruce Fields

Le Sat, 2 Aug 2008 12:38:48 -0400,
"J. Bruce Fields" <[email protected]> a écrit :

Quoted 2 lines

Out of curiosity, why does the nfs client need disabling, but not nfsd, gfs2, fuse, etc.?

Then also need disabling. Updated patch below.

Thanks!

Thomas

---

Configure out file locking features

This patch adds the CONFIG_FILE_LOCKING option which allows to remove support for advisory locks. With this patch enabled, the flock() system call, the F_GETLK, F_SETLK and F_SETLKW operations of fcntl() and NFS support are disabled. These features are not necessarly needed on embedded systems. It allows to save ~11 Kb of kernel code and data:

text data bss dec hex filename
1125436 118764 212992 1457192 163c28 vmlinux.old
1114299 118564 212992 1445855 160fdf vmlinux
-11137 -200 0 -11337 -2C49 +/-

This patch has originally been written by Matt Mackall <[email protected]>, and is part of the Linux Tiny project.

---
 fs/Kconfig          |   15 ++++++++++++++-
 fs/Makefile         |    3 ++-
 fs/dlm/Kconfig      |    1 +
 fs/gfs2/Kconfig     |    1 +
 fs/proc/proc_misc.c |    4 ++++
 include/linux/fs.h  |   52 +++++++++++++++++++++++++++++++++++++++++++++-------
 kernel/sys_ni.c     |    1 +
 kernel/sysctl.c     |    6 +++++-
 8 files changed, 73 insertions(+), 10 deletions(-)
fs/Kconfig +14 -1
Index: linuxdev/fs/Kconfig
===================================================================
@@ -427,12 +427,21 @@
 	bool
 	default n
 
+config FILE_LOCKING
+	bool "Enable POSIX file locking API" if EMBEDDED
+	default y
+	help
+	  This option enables standard file locking support, required
+          for filesystems like NFS and for the flock() system
+          call. Disabling this option saves about 11k.
+
 source "fs/xfs/Kconfig"
 source "fs/gfs2/Kconfig"
 
 config OCFS2_FS
 	tristate "OCFS2 file system support"
 	depends on NET && SYSFS
+	depends on FILE_LOCKING
 	select CONFIGFS_FS
 	select JBD
 	select CRC32
@@ -642,6 +651,7 @@
 
 config FUSE_FS
 	tristate "Filesystem in Userspace support"
+	depends on FILE_LOCKING
 	help
 	  With FUSE it is possible to implement a fully functional filesystem
 	  in a userspace program.
@@ -1567,7 +1577,7 @@
 
 config NFS_FS
 	tristate "NFS client support"
-	depends on INET
+	depends on INET && FILE_LOCKING
 	select LOCKD
 	select SUNRPC
 	select NFS_ACL_SUPPORT if NFS_V3_ACL
@@ -1735,6 +1745,7 @@
 
 config LOCKD
 	tristate
+	depends on FILE_LOCKING
 
 config LOCKD_V4
 	bool
@@ -1870,6 +1881,7 @@
 config CIFS
 	tristate "CIFS support (advanced network filesystem, SMBFS successor)"
 	depends on INET
+	depends on FILE_LOCKING
 	select NLS
 	help
 	  This is the client VFS module for the Common Internet File System
@@ -2059,6 +2071,7 @@
 config AFS_FS
 	tristate "Andrew File System support (AFS) (EXPERIMENTAL)"
 	depends on INET && EXPERIMENTAL
+	depends on FILE_LOCKING
 	select AF_RXRPC
 	help
 	  If you say Y here, you will get an experimental Andrew File System
fs/Makefile +2 -1
Index: linuxdev/fs/Makefile
===================================================================
@@ -7,7 +7,7 @@
 
 obj-y :=	open.o read_write.o file_table.o super.o \
 		char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \
-		ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \
+		ioctl.o readdir.o select.o fifo.o dcache.o inode.o \
 		attr.o bad_inode.o file.o filesystems.o namespace.o \
 		seq_file.o xattr.o libfs.o fs-writeback.o \
 		pnode.o drop_caches.o splice.o sync.o utimes.o \
@@ -28,6 +28,7 @@
 obj-$(CONFIG_TIMERFD)		+= timerfd.o
 obj-$(CONFIG_EVENTFD)		+= eventfd.o
 obj-$(CONFIG_AIO)               += aio.o
+obj-$(CONFIG_FILE_LOCKING)      += locks.o
 obj-$(CONFIG_COMPAT)		+= compat.o compat_ioctl.o
 
 nfsd-$(CONFIG_NFSD)		:= nfsctl.o
fs/dlm/Kconfig +1 -0
Index: linuxdev/fs/dlm/Kconfig
===================================================================
@@ -2,6 +2,7 @@
 	tristate "Distributed Lock Manager (DLM)"
 	depends on EXPERIMENTAL && INET
 	depends on SYSFS && (IPV6 || IPV6=n)
+	depends on FILE_LOCKING
 	select CONFIGFS_FS
 	select IP_SCTP
 	help
fs/gfs2/Kconfig +1 -0
Index: linuxdev/fs/gfs2/Kconfig
===================================================================
@@ -1,6 +1,7 @@
 config GFS2_FS
 	tristate "GFS2 file system support"
 	depends on EXPERIMENTAL && (64BIT || (LSF && LBD))
+	depends on FILE_LOCKING
 	select FS_POSIX_ACL
 	select CRC32
 	help
fs/proc/proc_misc.c +4 -0
Index: linuxdev/fs/proc/proc_misc.c
===================================================================
@@ -677,6 +677,7 @@
 	return proc_calc_metrics(page, start, off, count, eof, len);
 }
 
+#ifdef CONFIG_FILE_LOCKING
 static int locks_open(struct inode *inode, struct file *filp)
 {
 	return seq_open(filp, &locks_seq_operations);
@@ -688,6 +689,7 @@
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
+#endif /* CONFIG_FILE_LOCKING */
 
 static int execdomains_read_proc(char *page, char **start, off_t off,
 				 int count, int *eof, void *data)
@@ -881,7 +883,9 @@
 #ifdef CONFIG_PRINTK
 	proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations);
 #endif
+#ifdef CONFIG_FILE_LOCKING
 	proc_create("locks", 0, NULL, &proc_locks_operations);
+#endif
 	proc_create("devices", 0, NULL, &proc_devinfo_operations);
 	proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations);
 #ifdef CONFIG_BLOCK
include/linux/fs.h +45 -7

94 lines not on this page · raw message

kernel/sys_ni.c +1 -0
Index: linuxdev/kernel/sys_ni.c
===================================================================
@@ -130,6 +130,7 @@
 cond_syscall(sys_io_submit);
 cond_syscall(sys_io_cancel);
 cond_syscall(sys_io_getevents);
+cond_syscall(sys_flock);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);
kernel/sysctl.c +5 -1
Index: linuxdev/kernel/sysctl.c
===================================================================
@@ -97,7 +97,7 @@
 static int neg_one = -1;
 #endif
 
-#ifdef CONFIG_MMU
+#if defined(CONFIG_MMU) && defined(CONFIG_FILE_LOCKING)
 static int two = 2;
 #endif
 
@@ -1260,6 +1260,7 @@
 		.extra1		= &minolduid,
 		.extra2		= &maxolduid,
 	},
+#ifdef CONFIG_FILE_LOCKING
 	{
 		.ctl_name	= FS_LEASES,
 		.procname	= "leases-enable",
@@ -1268,6 +1269,7 @@
 		.mode		= 0644,
 		.proc_handler	= &proc_dointvec,
 	},
+#endif
 #ifdef CONFIG_DNOTIFY
 	{
 		.ctl_name	= FS_DIR_NOTIFY,
@@ -1279,6 +1281,7 @@
 	},
 #endif
 #ifdef CONFIG_MMU
+#ifdef CONFIG_FILE_LOCKING
 	{
 		.ctl_name	= FS_LEASE_TIME,
 		.procname	= "lease-break-time",
@@ -1290,6 +1293,7 @@
 		.extra1		= &zero,
 		.extra2		= &two,
 	},
+#endif /* CONFIG_FILE_LOCKING */
 #ifdef CONFIG_AIO
 	{
 		.procname	= "aio-nr",
Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#48 lore raw

Re: [patch 4/4] Configure out IGMP support

In reply to Thomas Petazzoni
Quoted 8 lines · Thomas Petazzoni

Le Fri, 01 Aug 2008 20:41:55 +0100,
David Woodhouse <[email protected]> a écrit :

Quoted 1 line

The config option probably lives in net/Kconfig, not init/Kconfig.

Yes, it could. But AFAIK, until now, all CONFIG_EMBEDDED-related options have been put in init/Kconfig. But if it's preferred, I can of course change the patch to move the config option to net/Kconfig.

It clearly lives in net/Kconfig.

Quoted 16 lines
Quoted 7 lines

And please could you make it clear how this interacts with IP_MULTICAST?

We already have a CONFIG_IP_MULTICAST option, for which the help text says "For more people, it's safe to say N'. And I think it defaults to that too. What more does CONFIG_IGMP remove? It's not made clear by the help text.

The interaction of IGMP support with CONFIG_IP_MULTICAST is fairly unclear to me.

A large portion of igmp.c is already under #ifdef CONFIG_IP_MULTICAST:
all the igmp_*() functions, amongst which is igmp_rcv(), referenced in igmp_protocol in net/ipv4/af_inet.c, which is compiled-out when !CONFIG_IP_MULTICAST.

Quoted 8 lines

All the proc-related code at the end of the file is only conditionnaly compiled on CONFIG_PROC_FS, but seems to in fact be only used if both CONFIG_IP_MULTICAST and CONFIG_PROC_FS are selected:
igmp_mc_proc_init() in net/ipv4/ip_output.c is only called when CONFIG_IP_MULTICAST and CONFIG_PROC_FS are selected.

Besides that, it's unclear to me why the ip_mc_*() functions are useful when !CONFIG_IP_MULTICAST, but I'm probably missing something.

Most of them aren't, as far as I can tell.

Quoted 2 lines

They are used to implement setsockopt-operations related to multicast, hooks for the routing code to handle multicast-related traffic, etc.

I wonder if those options should return errors now, rather than silently failing but returning zero. Or maybe that _would_ cause a stock build of ntpd to fail? Not that it really matters if it _does_, though.

It sounds like 'CONFIG_IGMP' is a bad name for the option, too -- and the help text is similarly misleading. I think you need to work out how it all fits together with CONFIG_IP_MULTICAST, fix it up, and resubmit it.

Signature · 2 lines
David Woodhouse                            Open Source Technology Centre
[email protected]                              Intel Corporation
#23 lore raw

Re: [patch 2/4] Configure out file locking features

In reply to Thomas Petazzoni
Quoted 7 lines · Thomas Petazzoni

Le Sat, 2 Aug 2008 12:38:48 -0400,
"J. Bruce Fields" <[email protected]> a écrit :

Quoted 2 lines

Out of curiosity, why does the nfs client need disabling, but not nfsd, gfs2, fuse, etc.?

Then also need disabling.

OK by me, but again, why exactly? Since you're replacing the locking calls they used by stubs that just return errors, in theory nfs, nfsd, gfs2, and the rest should still compile and run, just without locking support, right?

I don't have a strong opinion either way, just curious.

--b.

Quoted 352 lines

Updated patch below.

Thanks!

Thomas

---

Configure out file locking features

This patch adds the CONFIG_FILE_LOCKING option which allows to remove support for advisory locks. With this patch enabled, the flock() system call, the F_GETLK, F_SETLK and F_SETLKW operations of fcntl() and NFS support are disabled. These features are not necessarly needed on embedded systems. It allows to save ~11 Kb of kernel code and data:

text data bss dec hex filename
1125436 118764 212992 1457192 163c28 vmlinux.old
1114299 118564 212992 1445855 160fdf vmlinux
-11137 -200 0 -11337 -2C49 +/-

This patch has originally been written by Matt Mackall <[email protected]>, and is part of the Linux Tiny project.

---
 fs/Kconfig          |   15 ++++++++++++++-
 fs/Makefile         |    3 ++-
 fs/dlm/Kconfig      |    1 +
 fs/gfs2/Kconfig     |    1 +
 fs/proc/proc_misc.c |    4 ++++
 include/linux/fs.h  |   52 +++++++++++++++++++++++++++++++++++++++++++++-------
 kernel/sys_ni.c     |    1 +
 kernel/sysctl.c     |    6 +++++-
 8 files changed, 73 insertions(+), 10 deletions(-)

Index: linuxdev/fs/Kconfig
===================================================================

fs/Kconfig +14 -1
@@ -427,12 +427,21 @@
 	bool
 	default n
 
+config FILE_LOCKING
+	bool "Enable POSIX file locking API" if EMBEDDED
+	default y
+	help
+	  This option enables standard file locking support, required
+          for filesystems like NFS and for the flock() system
+          call. Disabling this option saves about 11k.
+
 source "fs/xfs/Kconfig"
 source "fs/gfs2/Kconfig"
 
 config OCFS2_FS
 	tristate "OCFS2 file system support"
 	depends on NET && SYSFS
+	depends on FILE_LOCKING
 	select CONFIGFS_FS
 	select JBD
 	select CRC32
@@ -642,6 +651,7 @@
 
 config FUSE_FS
 	tristate "Filesystem in Userspace support"
+	depends on FILE_LOCKING
 	help
 	  With FUSE it is possible to implement a fully functional filesystem
 	  in a userspace program.
@@ -1567,7 +1577,7 @@
 
 config NFS_FS
 	tristate "NFS client support"
-	depends on INET
+	depends on INET && FILE_LOCKING
 	select LOCKD
 	select SUNRPC
 	select NFS_ACL_SUPPORT if NFS_V3_ACL
@@ -1735,6 +1745,7 @@
 
 config LOCKD
 	tristate
+	depends on FILE_LOCKING
 
 config LOCKD_V4
 	bool
@@ -1870,6 +1881,7 @@
 config CIFS
 	tristate "CIFS support (advanced network filesystem, SMBFS successor)"
 	depends on INET
+	depends on FILE_LOCKING
 	select NLS
 	help
 	  This is the client VFS module for the Common Internet File System
@@ -2059,6 +2071,7 @@
 config AFS_FS
 	tristate "Andrew File System support (AFS) (EXPERIMENTAL)"
 	depends on INET && EXPERIMENTAL
+	depends on FILE_LOCKING
 	select AF_RXRPC
 	help
 	  If you say Y here, you will get an experimental Andrew File System

Index: linuxdev/fs/Makefile
===================================================================

fs/Makefile +2 -1
@@ -7,7 +7,7 @@
 
 obj-y :=	open.o read_write.o file_table.o super.o \
 		char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \
-		ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \
+		ioctl.o readdir.o select.o fifo.o dcache.o inode.o \
 		attr.o bad_inode.o file.o filesystems.o namespace.o \
 		seq_file.o xattr.o libfs.o fs-writeback.o \
 		pnode.o drop_caches.o splice.o sync.o utimes.o \
@@ -28,6 +28,7 @@
 obj-$(CONFIG_TIMERFD)		+= timerfd.o
 obj-$(CONFIG_EVENTFD)		+= eventfd.o
 obj-$(CONFIG_AIO)               += aio.o
+obj-$(CONFIG_FILE_LOCKING)      += locks.o
 obj-$(CONFIG_COMPAT)		+= compat.o compat_ioctl.o
 
 nfsd-$(CONFIG_NFSD)		:= nfsctl.o

Index: linuxdev/fs/dlm/Kconfig
===================================================================

fs/dlm/Kconfig +1 -0
@@ -2,6 +2,7 @@
 	tristate "Distributed Lock Manager (DLM)"
 	depends on EXPERIMENTAL && INET
 	depends on SYSFS && (IPV6 || IPV6=n)
+	depends on FILE_LOCKING
 	select CONFIGFS_FS
 	select IP_SCTP
 	help

Index: linuxdev/fs/gfs2/Kconfig
===================================================================

fs/gfs2/Kconfig +1 -0
@@ -1,6 +1,7 @@
 config GFS2_FS
 	tristate "GFS2 file system support"
 	depends on EXPERIMENTAL && (64BIT || (LSF && LBD))
+	depends on FILE_LOCKING
 	select FS_POSIX_ACL
 	select CRC32
 	help

Index: linuxdev/fs/proc/proc_misc.c
===================================================================

fs/proc/proc_misc.c +4 -0
@@ -677,6 +677,7 @@
 	return proc_calc_metrics(page, start, off, count, eof, len);
 }
 
+#ifdef CONFIG_FILE_LOCKING
 static int locks_open(struct inode *inode, struct file *filp)
 {
 	return seq_open(filp, &locks_seq_operations);
@@ -688,6 +689,7 @@
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
+#endif /* CONFIG_FILE_LOCKING */
 
 static int execdomains_read_proc(char *page, char **start, off_t off,
 				 int count, int *eof, void *data)
@@ -881,7 +883,9 @@
 #ifdef CONFIG_PRINTK
 	proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations);
 #endif
+#ifdef CONFIG_FILE_LOCKING
 	proc_create("locks", 0, NULL, &proc_locks_operations);
+#endif
 	proc_create("devices", 0, NULL, &proc_devinfo_operations);
 	proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations);
 #ifdef CONFIG_BLOCK

Index: linuxdev/include/linux/fs.h
===================================================================

include/linux/fs.h +45 -7
@@ -983,6 +983,13 @@
 
 #include <linux/fcntl.h>
 
+extern void send_sigio(struct fown_struct *fown, int fd, int band);
+
+/* fs/sync.c */
+extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
+			loff_t endbyte, unsigned int flags);
+
+#ifdef CONFIG_FILE_LOCKING
 extern int fcntl_getlk(struct file *, struct flock __user *);
 extern int fcntl_setlk(unsigned int, struct file *, unsigned int,
 			struct flock __user *);
@@ -993,14 +1000,9 @@
 			struct flock64 __user *);
 #endif
 
-extern void send_sigio(struct fown_struct *fown, int fd, int band);
 extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
 extern int fcntl_getlease(struct file *filp);
 
-/* fs/sync.c */
-extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
-			loff_t endbyte, unsigned int flags);
-
 /* fs/locks.c */
 extern void locks_init_lock(struct file_lock *);
 extern void locks_copy_lock(struct file_lock *, struct file_lock *);
@@ -1023,6 +1025,33 @@
 extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
 extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
 extern struct seq_operations locks_seq_operations;
+#else /* !CONFIG_FILE_LOCKING */
+#define fcntl_getlk(a, b) (-EINVAL)
+#define fcntl_setlk(a, b, c, d) (-EACCES)
+#if BITS_PER_LONG == 32
+#define fcntl_getlk64(a, b) (-EINVAL)
+#define fcntl_setlk64(a, b, c, d) (-EACCES)
+#endif
+#define fcntl_setlease(a, b, c) (0)
+#define fcntl_getlease(a) (0)
+#define locks_init_lock(a)
+#define locks_copy_lock(a, b)
+#define locks_remove_posix(a, b)
+#define locks_remove_flock(a)
+#define posix_test_lock(a, b) (0)
+#define posix_lock_file(a, b) (-ENOLCK)
+#define posix_lock_file_wait(a, b) (-ENOLCK)
+#define posix_unblock_lock(a, b) (-ENOENT)
+#define vfs_test_lock(a, b) (0)
+#define vfs_lock_file(a, b, c, d) (-ENOLCK)
+#define vfs_cancel_lock(a, b) (0)
+#define flock_lock_file_wait(a, b) (-ENOLCK)
+#define __break_lease(a, b) (0)
+#define lease_get_mtime(a, b)
+#define lock_may_read(a, b, c) (1)
+#define lock_may_write(a, b, c) (1)
+#endif /* !CONFIG_FILE_LOCKING */
+
 
 struct fasync_struct {
 	int	magic;
@@ -1554,9 +1583,12 @@
 /* /sys/fs */
 extern struct kobject *fs_kobj;
 
+extern int rw_verify_area(int, struct file *, loff_t *, size_t);
+
 #define FLOCK_VERIFY_READ  1
 #define FLOCK_VERIFY_WRITE 2
 
+#ifdef CONFIG_FILE_LOCKING
 extern int locks_mandatory_locked(struct inode *);
 extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
 
@@ -1587,8 +1619,6 @@
 	return 0;
 }
 
-extern int rw_verify_area(int, struct file *, loff_t *, size_t);
-
 static inline int locks_verify_truncate(struct inode *inode,
 				    struct file *filp,
 				    loff_t size)
@@ -1609,6 +1639,14 @@
 		return __break_lease(inode, mode);
 	return 0;
 }
+#else /* !CONFIG_FILE_LOCKING */
+#define locks_mandatory_locked(a) (0)
+#define locks_mandatory_area(a, b, c, d, e) (0)
+#define mandatory_lock(a) (0)
+#define locks_verify_locked(a) (0)
+#define locks_verify_truncate(a, b, c) (0)
+#define break_lease(a, b) (0)
+#endif /* CONFIG_FILE_LOCKING */
 
 /* fs/open.c */
 

Index: linuxdev/kernel/sys_ni.c
===================================================================

kernel/sys_ni.c +1 -0
@@ -130,6 +130,7 @@
 cond_syscall(sys_io_submit);
 cond_syscall(sys_io_cancel);
 cond_syscall(sys_io_getevents);
+cond_syscall(sys_flock);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);

Index: linuxdev/kernel/sysctl.c
===================================================================

kernel/sysctl.c +5 -1
@@ -97,7 +97,7 @@
 static int neg_one = -1;
 #endif
 
-#ifdef CONFIG_MMU
+#if defined(CONFIG_MMU) && defined(CONFIG_FILE_LOCKING)
 static int two = 2;
 #endif
 
@@ -1260,6 +1260,7 @@
 		.extra1		= &minolduid,
 		.extra2		= &maxolduid,
 	},
+#ifdef CONFIG_FILE_LOCKING
 	{
 		.ctl_name	= FS_LEASES,
 		.procname	= "leases-enable",
@@ -1268,6 +1269,7 @@
 		.mode		= 0644,
 		.proc_handler	= &proc_dointvec,
 	},
+#endif
 #ifdef CONFIG_DNOTIFY
 	{
 		.ctl_name	= FS_DIR_NOTIFY,
@@ -1279,6 +1281,7 @@
 	},
 #endif
 #ifdef CONFIG_MMU
+#ifdef CONFIG_FILE_LOCKING
 	{
 		.ctl_name	= FS_LEASE_TIME,
 		.procname	= "lease-break-time",
@@ -1290,6 +1293,7 @@
 		.extra1		= &zero,
 		.extra2		= &two,
 	},
+#endif /* CONFIG_FILE_LOCKING */
 #ifdef CONFIG_AIO
 	{
 		.procname	= "aio-nr",
Signature · 5 lines
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#24 lore raw

Re: [patch 2/4] Configure out file locking features

Quoted 4 lines · J. Bruce Fields
Quoted 3 lines · Thomas Petazzoni

Le Sat, 2 Aug 2008 12:38:48 -0400,
"J. Bruce Fields" <[email protected]> a écrit :

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

Out of curiosity, why does the nfs client need disabling, but not nfsd, gfs2, fuse, etc.?

Then also need disabling.

OK by me, but again, why exactly? Since you're replacing the locking calls they used by stubs that just return errors, in theory nfs, nfsd, gfs2, and the rest should still compile and run, just without locking support, right?

I think so, but haven't tested this myself.

However, I would still be inclined to NOT add the extra config dependencies. Just my 2 cents.
-- Tim

=============================
Tim Bird
Architecture Group Chair, CE Linux Forum Senior Staff Engineer, Sony Corporation of America
=============================

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#25 lore raw

Re: [patch 2/4] Configure out file locking features

Quoted 14 lines · Tim Bird
Quoted 4 lines · J. Bruce Fields
Quoted 3 lines · Thomas Petazzoni

Le Sat, 2 Aug 2008 12:38:48 -0400,
"J. Bruce Fields" <[email protected]> a écrit :

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

Out of curiosity, why does the nfs client need disabling, but not nfsd, gfs2, fuse, etc.?

Then also need disabling.

OK by me, but again, why exactly? Since you're replacing the locking calls they used by stubs that just return errors, in theory nfs, nfsd, gfs2, and the rest should still compile and run, just without locking support, right?

Quoted 4 lines

I think so, but haven't tested this myself.

However, I would still be inclined to NOT add the extra config dependencies. Just my 2 cents.

OK. My fear was that there was some good reason that the nfs dependency was added in the first place, and that it's since been lost....

--b.
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#26 lore raw

Re: [patch 2/4] Configure out file locking features

Quoted 15 lines · J. Bruce Fields
Quoted 14 lines · Tim Bird
Quoted 12 lines · J. Bruce Fields
Quoted 6 lines · Thomas Petazzoni

Le Sat, 2 Aug 2008 12:38:48 -0400,
"J. Bruce Fields" <[email protected]> a écrit :

Quoted 2 lines

Out of curiosity, why does the nfs client need disabling, but not nfsd, gfs2, fuse, etc.?

Then also need disabling.

OK by me, but again, why exactly? Since you're replacing the locking calls they used by stubs that just return errors, in theory nfs, nfsd, gfs2, and the rest should still compile and run, just without locking support, right?

Quoted 7 lines
Quoted 4 lines

I think so, but haven't tested this myself.

However, I would still be inclined to NOT add the extra config dependencies. Just my 2 cents.

OK. My fear was that there was some good reason that the nfs dependency was added in the first place, and that it's since been lost....

I vaguely remember there was some compile issue here, but that would have been back in the 2.6.10 era.

Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#27 lore raw

Re: [patch 2/4] Configure out file locking features

Quoted 19 lines · Matt Mackall
Quoted 17 lines · J. Bruce Fields
Quoted 16 lines · Tim Bird
Quoted 4 lines · J. Bruce Fields
Quoted 3 lines · Thomas Petazzoni

Le Sat, 2 Aug 2008 12:38:48 -0400,
"J. Bruce Fields" <[email protected]> a écrit :

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

Out of curiosity, why does the nfs client need disabling, but not nfsd, gfs2, fuse, etc.?

Then also need disabling.

OK by me, but again, why exactly? Since you're replacing the locking calls they used by stubs that just return errors, in theory nfs, nfsd, gfs2, and the rest should still compile and run, just without locking support, right?

I think so, but haven't tested this myself.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

However, I would still be inclined to NOT add the extra config dependencies. Just my 2 cents.

OK. My fear was that there was some good reason that the nfs dependency was added in the first place, and that it's since been lost....

I vaguely remember there was some compile issue here, but that would have been back in the 2.6.10 era.

Sounds plausible. I've got no objection to the patch either way, but if we could at least just add a comment documenting the issue (if it exists), that might be helpful.

--b.
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#28 lore raw

Re: [patch 2/4] Configure out file locking features

In reply to J. Bruce Fields
Quoted 13 lines · J. Bruce Fields
Quoted 12 lines · Tim Bird
Quoted 11 lines · J. Bruce Fields
Quoted 6 lines · Thomas Petazzoni
Quoted 2 lines · J. Bruce Fields

Out of curiosity, why does the nfs client need disabling, but not nfsd, gfs2, fuse, etc.?

Then also need disabling.

OK by me, but again, why exactly? Since you're replacing the locking calls they used by stubs that just return errors, in theory nfs, nfsd, gfs2, and the rest should still compile and run, just without locking support, right?

Quoted 7 lines
Quoted 4 lines

I think so, but haven't tested this myself.

However, I would still be inclined to NOT add the extra config dependencies. Just my 2 cents.

OK. My fear was that there was some good reason that the nfs dependency was added in the first place, and that it's since been lost....

For general information, I just ran a test with the NFS dependency on file locking turned off, and with the NFS auto-enable of CONFIG_LOCKD removed.

It got me about a 16K savings, and I was able to successfully boot a target with an NFS-mounted root file system. I haven't run extensive tests, so I don't know what apps might break in this configuration, but at least in this test, it ran well enough to boot the machine.

Below is the patch I used, which is only provided for information. This should NOT be applied - it consists of quick hacks to test this configuration only (that is, to test NFS with CONFIG_FILE_LOCKING=n).

BTW - this is on a 2.6.23 kernel, so even the regular FILE_LOCKING bits may be different from the current no-file-locking patch.

---
 fs/Kconfig         |    3 +--
 fs/nfs/client.c    |    6 ++++++
 fs/nfs/nfs3proc.c  |    4 ++++
 fs/nfs/proc.c      |    4 ++++
 fs/read_write.c    |    2 ++
 include/linux/fs.h |   13 +++++++------
 6 files changed, 24 insertions(+), 8 deletions(-)
fs/Kconfig +1 -2
@@ -1701,8 +1701,7 @@ menu "Network File Systems"
 
 config NFS_FS
 	tristate "NFS file system support"
-	depends on INET && FILE_LOCKING
-	select LOCKD
+	depends on INET
 	select SUNRPC
 	select NFS_ACL_SUPPORT if NFS_V3_ACL
 	help
fs/nfs/client.c +6 -0
@@ -414,6 +414,7 @@ static void nfs_destroy_server(struct nf
 		lockd_down();	/* release rpc.lockd */
 }
 
+#ifdef LOCKD
 /*
  * Version 2 or 3 lockd setup
  */
@@ -434,6 +435,7 @@ static int nfs_start_lockd(struct nfs_se
 out:
 	return error;
 }
+#endif
 
 /*
  * Initialise an NFSv3 ACL client connection
@@ -577,9 +579,11 @@ static int nfs_init_server(struct nfs_se
 	server->acdirmax = data->acdirmax * HZ;
 
 	/* Start lockd here, before we might error out */
+#ifdef LOCKD
 	error = nfs_start_lockd(server);
 	if (error < 0)
 		goto error;
+#endif
 
 	error = nfs_init_server_rpcclient(server, data->pseudoflavor);
 	if (error < 0)
@@ -1128,9 +1132,11 @@ struct nfs_server *nfs_clone_server(stru
 		(unsigned long long) server->fsid.major,
 		(unsigned long long) server->fsid.minor);
 
+#ifdef LOCKD
 	error = nfs_start_lockd(server);
 	if (error < 0)
 		goto out_free_server;
+#endif
 
 	spin_lock(&nfs_client_lock);
 	list_add_tail(&server->client_link, &server->nfs_client->cl_superblocks);
fs/nfs/nfs3proc.c +4 -0
@@ -795,7 +795,11 @@ static void nfs3_proc_commit_setup(struc
 static int
 nfs3_proc_lock(struct file *filp, int cmd, struct file_lock *fl)
 {
+#ifdef LOCKD
 	return nlmclnt_proc(filp->f_path.dentry->d_inode, cmd, fl);
+#else
+	return -ENOLCK;
+#endif
 }
 
 const struct nfs_rpc_ops nfs_v3_clientops = {
fs/nfs/proc.c +4 -0
@@ -605,7 +605,11 @@ nfs_proc_commit_setup(struct nfs_write_d
 static int
 nfs_proc_lock(struct file *filp, int cmd, struct file_lock *fl)
 {
+#ifdef LOCKD
 	return nlmclnt_proc(filp->f_path.dentry->d_inode, cmd, fl);
+#else
+	return -ENOLCK;
+#endif
 }
 
 
fs/read_write.c +2 -0
@@ -211,6 +211,7 @@ int rw_verify_area(int read_write, struc
 	if (unlikely((pos < 0) || (loff_t) (pos + count) < 0))
 		goto Einval;
 
+#ifdef FILE_LOCKING
 	if (unlikely(inode->i_flock && MANDATORY_LOCK(inode))) {
 		int retval = locks_mandatory_area(
 			read_write == READ ? FLOCK_VERIFY_READ : FLOCK_VERIFY_WRITE,
@@ -218,6 +219,7 @@ int rw_verify_area(int read_write, struc
 		if (retval < 0)
 			return retval;
 	}
+#endif
 	return count > MAX_RW_COUNT ? MAX_RW_COUNT : count;
 
 Einval:
include/linux/fs.h +7 -6
@@ -863,10 +863,6 @@ extern int fcntl_setlk64(unsigned int, s
 extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
 extern int fcntl_getlease(struct file *filp);
 
-/* fs/sync.c */
-extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
-			loff_t endbyte, unsigned int flags);
-
 /* fs/locks.c */
 extern void locks_init_lock(struct file_lock *);
 extern void locks_copy_lock(struct file_lock *, struct file_lock *);
@@ -918,6 +914,10 @@ extern int lock_may_write(struct inode *
 #define steal_locks(a)
 #endif /* !CONFIG_FILE_LOCKING */
 
+/* fs/sync.c */
+extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
+			loff_t endbyte, unsigned int flags);
+
 struct fasync_struct {
 	int	magic;
 	int	fa_fd;
@@ -1424,8 +1424,6 @@ static inline int locks_verify_locked(st
 	return 0;
 }
 
-extern int rw_verify_area(int, struct file *, loff_t *, size_t);
-
 static inline int locks_verify_truncate(struct inode *inode,
 				    struct file *filp,
 				    loff_t size)
@@ -1459,6 +1457,9 @@ static inline int break_lease(struct ino
 
 #endif /* !CONFIG_FILE_LOCKING */
 
+extern int rw_verify_area(int, struct file *, loff_t *, size_t);
+
+
 /* fs/open.c */
 
 extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,

=============================
Tim Bird
Architecture Group Chair, CE Linux Forum Senior Staff Engineer, Sony Corporation of America
=============================

#5 lore raw

Re: [patch 1/4] Configure out AIO support

In reply to Bernhard Fischer
Quoted 12 lines · Bernhard Fischer
Quoted 11 lines · Adrian Bunk
Quoted 9 lines · Bernhard Fischer
Quoted 5 lines · Thomas Petazzoni

This patchs adds the CONFIG_AIO option which allows to remove support for asynchronous I/O operations, that are not necessarly used by applications, particularly on embedded devices. As this is a size-reduction option, it depends on CONFIG_EMBEDDED. It allows to save ~7 kilobytes of kernel code/data:

Shouldn't this also make sure not to install aio_abi.h or at least an empty aio_abi.h?

Quoted 7 lines
Quoted 2 lines

The userspace headers are independent of any kernel configuration (except for the architecture).

I beg to disagree:
internals as exposed by e.g. aio_abi.h are impl dependent. Noone except the impl and it's users are interrested in it.
...

That's utter bullshit.

The contents of aio_abi.h is a kernel<->userspace ABI that mustn't ever change. [1]

cu
Adrian

[1] there are some exceptions like adding stuff (but not in existing structs), but basically the contents of aio_abi.h is cast in stone

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#6 lore raw

Re: [patch 1/4] Configure out AIO support

Quoted 21 lines · Adrian Bunk
Quoted 12 lines · Bernhard Fischer
Quoted 11 lines · Adrian Bunk
Quoted 9 lines · Bernhard Fischer
Quoted 5 lines · Thomas Petazzoni

This patchs adds the CONFIG_AIO option which allows to remove support for asynchronous I/O operations, that are not necessarly used by applications, particularly on embedded devices. As this is a size-reduction option, it depends on CONFIG_EMBEDDED. It allows to save ~7 kilobytes of kernel code/data:

Shouldn't this also make sure not to install aio_abi.h or at least an empty aio_abi.h?

Quoted 7 lines
Quoted 2 lines

The userspace headers are independent of any kernel configuration (except for the architecture).

I beg to disagree:
internals as exposed by e.g. aio_abi.h are impl dependent. Noone except the impl and it's users are interrested in it.
...

Quoted 4 lines

That's utter bullshit.

The contents of aio_abi.h is a kernel<->userspace ABI that mustn't ever change. [1]

Case in point:

I want to be able to compile an application for embedded Linux which *can use* Linux-AIO, but can also run on a kernel which has Linux-AIO removed by this patch.

I still want to compile the application with that capability, in case it's run on another kernel with it enabled.

I shouldn't have to have a separate, special kernel with all options enabled, just to compile applications that run on multiple kernels and use run-time features when available.

Just like all the other kernel<->userspace interfaces, the header files (including their presence) shouldn't depend on kernel configuration at all.

-- Jamie

#7 lore raw

Re: [patch 1/4] Configure out AIO support

Quoted 22 lines · Jamie Lokier
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

The userspace headers are independent of any kernel configuration (except for the architecture).

I beg to disagree:
internals as exposed by e.g. aio_abi.h are impl dependent. Noone except the impl and it's users are interrested in it.
...

Quoted 4 lines

That's utter bullshit.

The contents of aio_abi.h is a kernel<->userspace ABI that mustn't ever change. [1]

Case in point:

I want to be able to compile an application for embedded Linux which *can use* Linux-AIO, but can also run on a kernel which has Linux-AIO removed by this patch.

I still want to compile the application with that capability, in case it's run on another kernel with it enabled.

Quoted 7 lines

I shouldn't have to have a separate, special kernel with all options enabled, just to compile applications that run on multiple kernels and use run-time features when available.

Just like all the other kernel<->userspace interfaces, the header files (including their presence) shouldn't depend on kernel configuration at all.

alright, makes perfect sense. I must have been playing too much with libc recently, i guess.

thanks,

#29 lore raw

Re: [patch 2/4] Configure out file locking features

In reply to J. Bruce Fields

Le Mon, 4 Aug 2008 14:16:41 -0400,
"J. Bruce Fields" <[email protected]> a écrit :

Quoted 4 lines

OK by me, but again, why exactly? Since you're replacing the locking calls they used by stubs that just return errors, in theory nfs, nfsd, gfs2, and the rest should still compile and run, just without locking support, right?

You're right, that was stupid. Either should I add the Kconfig dependencies *OR* add the function stubs, not both. The following patch implements the second solution. I've checked that NFS, CIFS, GFS2, OCFS2, AFS and FUSE compile correctly. I've tested NFS only, though.

Here is the new patch. Comments and suggestions welcome.

Sincerly,

Thomas

---

Configure out file locking features

This patch adds the CONFIG_FILE_LOCKING option which allows to remove support for advisory locks. With this patch enabled, the flock() system call, the F_GETLK, F_SETLK and F_SETLKW operations of fcntl() and NFS support are disabled. These features are not necessarly needed on embedded systems. It allows to save ~11 Kb of kernel code and data:

text data bss dec hex filename
1125436 118764 212992 1457192 163c28 vmlinux.old
1114299 118564 212992 1445855 160fdf vmlinux
-11137 -200 0 -11337 -2C49 +/-

This patch has originally been written by Matt Mackall <[email protected]>, and is part of the Linux Tiny project.

---
 fs/Kconfig          |    8 +++++++
 fs/Makefile         |    3 +-
 fs/proc/proc_misc.c |    4 +++
 include/linux/fs.h  |   55 +++++++++++++++++++++++++++++++++++++++++++++-------
 kernel/sys_ni.c     |    1 
 kernel/sysctl.c     |    6 ++++-
 6 files changed, 68 insertions(+), 9 deletions(-)
fs/Kconfig +8 -0
Index: linuxdev/fs/Kconfig
===================================================================
@@ -419,6 +419,14 @@
 	bool
 	default n
 
+config FILE_LOCKING
+	bool "Enable POSIX file locking API" if EMBEDDED
+	default y
+	help
+	  This option enables standard file locking support, required
+          for filesystems like NFS and for the flock() system
+          call. Disabling this option saves about 11k.
+
 source "fs/xfs/Kconfig"
 source "fs/gfs2/Kconfig"
 
fs/Makefile +2 -1
Index: linuxdev/fs/Makefile
===================================================================
@@ -7,7 +7,7 @@
 
 obj-y :=	open.o read_write.o file_table.o super.o \
 		char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \
-		ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \
+		ioctl.o readdir.o select.o fifo.o dcache.o inode.o \
 		attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \
 		seq_file.o xattr.o libfs.o fs-writeback.o \
 		pnode.o drop_caches.o splice.o sync.o utimes.o \
@@ -27,6 +27,7 @@
 obj-$(CONFIG_SIGNALFD)		+= signalfd.o
 obj-$(CONFIG_TIMERFD)		+= timerfd.o
 obj-$(CONFIG_EVENTFD)		+= eventfd.o
+obj-$(CONFIG_FILE_LOCKING)      += locks.o
 obj-$(CONFIG_COMPAT)		+= compat.o compat_ioctl.o
 
 nfsd-$(CONFIG_NFSD)		:= nfsctl.o
fs/proc/proc_misc.c +4 -0
Index: linuxdev/fs/proc/proc_misc.c
===================================================================
@@ -677,6 +677,7 @@
 	return proc_calc_metrics(page, start, off, count, eof, len);
 }
 
+#ifdef CONFIG_FILE_LOCKING
 static int locks_open(struct inode *inode, struct file *filp)
 {
 	return seq_open(filp, &locks_seq_operations);
@@ -688,6 +689,7 @@
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
+#endif /* CONFIG_FILE_LOCKING */
 
 static int execdomains_read_proc(char *page, char **start, off_t off,
 				 int count, int *eof, void *data)
@@ -881,7 +883,9 @@
 #ifdef CONFIG_PRINTK
 	proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations);
 #endif
+#ifdef CONFIG_FILE_LOCKING
 	proc_create("locks", 0, NULL, &proc_locks_operations);
+#endif
 	proc_create("devices", 0, NULL, &proc_devinfo_operations);
 	proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations);
 #ifdef CONFIG_BLOCK
include/linux/fs.h +48 -7

97 lines not on this page · raw message

kernel/sys_ni.c +1 -0
Index: linuxdev/kernel/sys_ni.c
===================================================================
@@ -125,6 +125,7 @@
 cond_syscall(sys_vm86);
 cond_syscall(compat_sys_ipc);
 cond_syscall(compat_sys_sysctl);
+cond_syscall(sys_flock);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);
kernel/sysctl.c +5 -1
Index: linuxdev/kernel/sysctl.c
===================================================================
@@ -97,7 +97,7 @@
 static int neg_one = -1;
 #endif
 
-#ifdef CONFIG_MMU
+#if defined(CONFIG_MMU) && defined(CONFIG_FILE_LOCKING)
 static int two = 2;
 #endif
 
@@ -1260,6 +1260,7 @@
 		.extra1		= &minolduid,
 		.extra2		= &maxolduid,
 	},
+#ifdef CONFIG_FILE_LOCKING
 	{
 		.ctl_name	= FS_LEASES,
 		.procname	= "leases-enable",
@@ -1268,6 +1269,7 @@
 		.mode		= 0644,
 		.proc_handler	= &proc_dointvec,
 	},
+#endif
 #ifdef CONFIG_DNOTIFY
 	{
 		.ctl_name	= FS_DIR_NOTIFY,
@@ -1279,6 +1281,7 @@
 	},
 #endif
 #ifdef CONFIG_MMU
+#ifdef CONFIG_FILE_LOCKING
 	{
 		.ctl_name	= FS_LEASE_TIME,
 		.procname	= "lease-break-time",
@@ -1290,6 +1293,7 @@
 		.extra1		= &zero,
 		.extra2		= &two,
 	},
+#endif
 	{
 		.procname	= "aio-nr",
 		.data		= &aio_nr,
Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#30 lore raw

Re: [patch 2/4] Configure out file locking features

Quoted 8 lines · Thomas Petazzoni

Le Mon, 4 Aug 2008 14:16:41 -0400,
"J. Bruce Fields" <[email protected]> a écrit :

Quoted 4 lines

OK by me, but again, why exactly? Since you're replacing the locking calls they used by stubs that just return errors, in theory nfs, nfsd, gfs2, and the rest should still compile and run, just without locking support, right?

Quoted 6 lines

You're right, that was stupid. Either should I add the Kconfig dependencies *OR* add the function stubs, not both. The following patch implements the second solution. I've checked that NFS, CIFS, GFS2, OCFS2, AFS and FUSE compile correctly. I've tested NFS only, though.

Here is the new patch. Comments and suggestions welcome.

Seems fine to me, thanks! I can queue it up in my tree for 2.6.28 if there's no objections.

(But, basic mail question: so I give this message to git-am and it complains because of all this =3D=20 stuff, which google tells me is quoted-printable encoding. Fine, I fixed it up by hand, but a) there must be some less boring way to deal with it, and b) there must have been some easy way to avoid it in the first place, either on my side or yours? Enlightenment welcome.)

--b.

Quoted 280 lines

Sincerly,

Thomas

---

Configure out file locking features

This patch adds the CONFIG_FILE_LOCKING option which allows to remove support for advisory locks. With this patch enabled, the flock() system call, the F_GETLK, F_SETLK and F_SETLKW operations of fcntl() and NFS support are disabled. These features are not necessarly needed on embedded systems. It allows to save ~11 Kb of kernel code and data:

text data bss dec hex filename
1125436 118764 212992 1457192 163c28 vmlinux.old
1114299 118564 212992 1445855 160fdf vmlinux
-11137 -200 0 -11337 -2C49 +/-

This patch has originally been written by Matt Mackall <[email protected]>, and is part of the Linux Tiny project.

---
 fs/Kconfig          |    8 +++++++
 fs/Makefile         |    3 +-
 fs/proc/proc_misc.c |    4 +++
 include/linux/fs.h  |   55 +++++++++++++++++++++++++++++++++++++++++++++-------
 kernel/sys_ni.c     |    1 
 kernel/sysctl.c     |    6 ++++-
 6 files changed, 68 insertions(+), 9 deletions(-)

Index: linuxdev/fs/Kconfig
===================================================================

fs/Kconfig +8 -0
@@ -419,6 +419,14 @@
 	bool
 	default n
 
+config FILE_LOCKING
+	bool "Enable POSIX file locking API" if EMBEDDED
+	default y
+	help
+	  This option enables standard file locking support, required
+          for filesystems like NFS and for the flock() system
+          call. Disabling this option saves about 11k.
+
 source "fs/xfs/Kconfig"
 source "fs/gfs2/Kconfig"
 

Index: linuxdev/fs/Makefile
===================================================================

fs/Makefile +2 -1
@@ -7,7 +7,7 @@
 
 obj-y :=	open.o read_write.o file_table.o super.o \
 		char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \
-		ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \
+		ioctl.o readdir.o select.o fifo.o dcache.o inode.o \
 		attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \
 		seq_file.o xattr.o libfs.o fs-writeback.o \
 		pnode.o drop_caches.o splice.o sync.o utimes.o \
@@ -27,6 +27,7 @@
 obj-$(CONFIG_SIGNALFD)		+= signalfd.o
 obj-$(CONFIG_TIMERFD)		+= timerfd.o
 obj-$(CONFIG_EVENTFD)		+= eventfd.o
+obj-$(CONFIG_FILE_LOCKING)      += locks.o
 obj-$(CONFIG_COMPAT)		+= compat.o compat_ioctl.o
 
 nfsd-$(CONFIG_NFSD)		:= nfsctl.o

Index: linuxdev/fs/proc/proc_misc.c
===================================================================

fs/proc/proc_misc.c +4 -0
@@ -677,6 +677,7 @@
 	return proc_calc_metrics(page, start, off, count, eof, len);
 }
 
+#ifdef CONFIG_FILE_LOCKING
 static int locks_open(struct inode *inode, struct file *filp)
 {
 	return seq_open(filp, &locks_seq_operations);
@@ -688,6 +689,7 @@
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
+#endif /* CONFIG_FILE_LOCKING */
 
 static int execdomains_read_proc(char *page, char **start, off_t off,
 				 int count, int *eof, void *data)
@@ -881,7 +883,9 @@
 #ifdef CONFIG_PRINTK
 	proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations);
 #endif
+#ifdef CONFIG_FILE_LOCKING
 	proc_create("locks", 0, NULL, &proc_locks_operations);
+#endif
 	proc_create("devices", 0, NULL, &proc_devinfo_operations);
 	proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations);
 #ifdef CONFIG_BLOCK

Index: linuxdev/include/linux/fs.h
===================================================================

include/linux/fs.h +48 -7
@@ -983,6 +983,13 @@
 
 #include <linux/fcntl.h>
 
+extern void send_sigio(struct fown_struct *fown, int fd, int band);
+
+/* fs/sync.c */
+extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
+			loff_t endbyte, unsigned int flags);
+
+#ifdef CONFIG_FILE_LOCKING
 extern int fcntl_getlk(struct file *, struct flock __user *);
 extern int fcntl_setlk(unsigned int, struct file *, unsigned int,
 			struct flock __user *);
@@ -993,14 +1000,9 @@
 			struct flock64 __user *);
 #endif
 
-extern void send_sigio(struct fown_struct *fown, int fd, int band);
 extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
 extern int fcntl_getlease(struct file *filp);
 
-/* fs/sync.c */
-extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
-			loff_t endbyte, unsigned int flags);
-
 /* fs/locks.c */
 extern void locks_init_lock(struct file_lock *);
 extern void locks_copy_lock(struct file_lock *, struct file_lock *);
@@ -1023,6 +1025,35 @@
 extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
 extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
 extern struct seq_operations locks_seq_operations;
+#else /* !CONFIG_FILE_LOCKING */
+#define fcntl_getlk(a, b) ({ -EINVAL; })
+#define fcntl_setlk(a, b, c, d) ({ -EACCES; })
+#if BITS_PER_LONG == 32
+#define fcntl_getlk64(a, b) ({ -EINVAL; })
+#define fcntl_setlk64(a, b, c, d) ({ -EACCES; })
+#endif
+#define fcntl_setlease(a, b, c) ({ 0; })
+#define fcntl_getlease(a) ({ 0; })
+#define locks_init_lock(a) ({ })
+#define __locks_copy_lock(a, b) ({ })
+#define locks_copy_lock(a, b) ({ })
+#define locks_remove_posix(a, b) ({ })
+#define locks_remove_flock(a) ({ })
+#define posix_test_lock(a, b) ({ 0; })
+#define posix_lock_file(a, b, c) ({ -ENOLCK; })
+#define posix_lock_file_wait(a, b) ({ -ENOLCK; })
+#define posix_unblock_lock(a, b) (-ENOENT)
+#define vfs_test_lock(a, b) ({ 0; })
+#define vfs_lock_file(a, b, c, d) (-ENOLCK)
+#define vfs_cancel_lock(a, b) ({ 0; })
+#define flock_lock_file_wait(a, b) ({ -ENOLCK; })
+#define __break_lease(a, b) ({ 0; })
+#define lease_get_mtime(a, b) ({ })
+#define generic_setlease(a, b, c) ({ -EINVAL; })
+#define lock_may_read(a, b, c) ({ 1; })
+#define lock_may_write(a, b, c) ({ 1; })
+#endif /* !CONFIG_FILE_LOCKING */
+
 
 struct fasync_struct {
 	int	magic;
@@ -1554,9 +1585,12 @@
 /* /sys/fs */
 extern struct kobject *fs_kobj;
 
+extern int rw_verify_area(int, struct file *, loff_t *, size_t);
+
 #define FLOCK_VERIFY_READ  1
 #define FLOCK_VERIFY_WRITE 2
 
+#ifdef CONFIG_FILE_LOCKING
 extern int locks_mandatory_locked(struct inode *);
 extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
 
@@ -1587,8 +1621,6 @@
 	return 0;
 }
 
-extern int rw_verify_area(int, struct file *, loff_t *, size_t);
-
 static inline int locks_verify_truncate(struct inode *inode,
 				    struct file *filp,
 				    loff_t size)
@@ -1609,6 +1641,15 @@
 		return __break_lease(inode, mode);
 	return 0;
 }
+#else /* !CONFIG_FILE_LOCKING */
+#define locks_mandatory_locked(a) ({ 0; })
+#define locks_mandatory_area(a, b, c, d, e) ({ 0; })
+#define __mandatory_lock(a) ({ 0; })
+#define mandatory_lock(a) ({ 0; })
+#define locks_verify_locked(a) ({ 0; })
+#define locks_verify_truncate(a, b, c) ({ 0; })
+#define break_lease(a, b) ({ 0; })
+#endif /* CONFIG_FILE_LOCKING */
 
 /* fs/open.c */
 

Index: linuxdev/kernel/sys_ni.c
===================================================================

kernel/sys_ni.c +1 -0
@@ -125,6 +125,7 @@
 cond_syscall(sys_vm86);
 cond_syscall(compat_sys_ipc);
 cond_syscall(compat_sys_sysctl);
+cond_syscall(sys_flock);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);

Index: linuxdev/kernel/sysctl.c
===================================================================

kernel/sysctl.c +5 -1
@@ -97,7 +97,7 @@
 static int neg_one = -1;
 #endif
 
-#ifdef CONFIG_MMU
+#if defined(CONFIG_MMU) && defined(CONFIG_FILE_LOCKING)
 static int two = 2;
 #endif
 
@@ -1260,6 +1260,7 @@
 		.extra1		= &minolduid,
 		.extra2		= &maxolduid,
 	},
+#ifdef CONFIG_FILE_LOCKING
 	{
 		.ctl_name	= FS_LEASES,
 		.procname	= "leases-enable",
@@ -1268,6 +1269,7 @@
 		.mode		= 0644,
 		.proc_handler	= &proc_dointvec,
 	},
+#endif
 #ifdef CONFIG_DNOTIFY
 	{
 		.ctl_name	= FS_DIR_NOTIFY,
@@ -1279,6 +1281,7 @@
 	},
 #endif
 #ifdef CONFIG_MMU
+#ifdef CONFIG_FILE_LOCKING
 	{
 		.ctl_name	= FS_LEASE_TIME,
 		.procname	= "lease-break-time",
@@ -1290,6 +1293,7 @@
 		.extra1		= &zero,
 		.extra2		= &two,
 	},
+#endif
 	{
 		.procname	= "aio-nr",
 		.data		= &aio_nr,
Signature · 5 lines
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com