[PATCH/RFC] don't store struct sysent::native_scno member if we aren't using it.

Denys Vlasenko dvlasenk at redhat.com
Tue Feb 7 11:23:24 UTC 2012


Hi Dmitry.

I noticed that this structure member is used only if
we have more than one personality.

I tried removing it and on i386, ~1800 bytes are saved:
    text	   data	    bss	    dec	    hex	filename
  239234	    668	  19044	 258946	  3f382	strace.before
  237422	    668	  19044	 257134	  3ec6e	strace

The patch is below. It's fairly self-explanatory...

To convert all architectures, a follow-on patch is needed
which replaces all { ... } with SE( ... )
in every syscallent*.h file. This patch is not sent since
it's huge but trivial.

Please let me know whether you are ok with this change...
-- 
vda



diff -d -urpN strace.4/defs.h strace.5/defs.h
--- strace.4/defs.h	2012-01-29 00:44:34.991058101 +0100
+++ strace.5/defs.h	2012-02-07 11:21:12.163006996 +0100
@@ -762,7 +762,9 @@ struct sysent {
  	int	sys_flags;
  	int	(*sys_func)();
  	const char *sys_name;
+#if SUPPORTED_PERSONALITIES > 1
  	long	native_scno;	/* Match against SYS_* constants.  */
+#endif
  };

  struct ioctlent {
diff -d -urpN strace.4/linux/i386/syscallent.h strace.5/linux/i386/syscallent.h
--- strace.4/linux/i386/syscallent.h	2012-01-28 01:44:11.967408054 +0100
+++ strace.5/linux/i386/syscallent.h	2012-02-07 11:27:43.043954108 +0100
@@ -29,17 +29,17 @@
   */

  	{ 0,	0,	sys_restart_syscall,	"restart_syscall" }, /* 0 */
-	{ 1,	TP,	sys_exit,		"_exit", SYS_exit }, /* 1 */
-	{ 0,	TP,	sys_fork,		"fork", SYS_fork }, /* 2 */
-	{ 3,	TD,	sys_read,		"read", SYS_read }, /* 3 */
-	{ 3,	TD,	sys_write,		"write", SYS_write }, /* 4 */
+SE	( 1,	TP,	sys_exit,		"_exit", SYS_exit ), /* 1 */
+SE	( 0,	TP,	sys_fork,		"fork", SYS_fork ), /* 2 */
+SE	( 3,	TD,	sys_read,		"read", SYS_read ), /* 3 */
+SE	( 3,	TD,	sys_write,		"write", SYS_write ), /* 4 */
  	{ 3,	TD|TF,	sys_open,		"open"		}, /* 5 */
  	{ 1,	TD,	sys_close,		"close"		}, /* 6 */
-	{ 3,	TP,	sys_waitpid,		"waitpid", SYS_wait4 }, /* 7 */
+SE	( 3,	TP,	sys_waitpid,		"waitpid", SYS_wait4 ), /* 7 */
  	{ 2,	TD|TF,	sys_creat,		"creat"		}, /* 8 */
  	{ 2,	TF,	sys_link,		"link"		}, /* 9 */
  	{ 1,	TF,	sys_unlink,		"unlink"	}, /* 10 */
-	{ 3,	TF|TP,	sys_execve,		"execve", SYS_execve }, /* 11 */
+SE	( 3,	TF|TP,	sys_execve,		"execve", SYS_execve ), /* 11 */
  	{ 1,	TF,	sys_chdir,		"chdir"		}, /* 12 */
  	{ 1,	0,	sys_time,		"time"		}, /* 13 */
  	{ 3,	TF,	sys_mknod,		"mknod"		}, /* 14 */
@@ -130,7 +130,7 @@
  	{ 2,	TF,	sys_statfs,		"statfs"	}, /* 99 */
  	{ 2,	TD,	sys_fstatfs,		"fstatfs"	}, /* 100 */
  	{ 3,	0,	sys_ioperm,		"ioperm"	}, /* 101 */
-	{ 2,	TD,	sys_socketcall,		"socketcall", SYS_socketcall }, /* 102 */
+SE	( 2,	TD,	sys_socketcall,		"socketcall", SYS_socketcall ), /* 102 */
  	{ 3,	0,	sys_syslog,		"syslog"	}, /* 103 */
  	{ 3,	0,	sys_setitimer,		"setitimer"	}, /* 104 */
  	{ 2,	0,	sys_getitimer,		"getitimer"	}, /* 105 */
@@ -142,13 +142,13 @@
  	{ 0,	0,	sys_vhangup,		"vhangup"	}, /* 111 */
  	{ 0,	0,	sys_idle,		"idle"		}, /* 112 */
  	{ 1,	0,	sys_vm86old,		"vm86old"	}, /* 113 */
-	{ 4,	TP,	sys_wait4,		"wait4", SYS_wait4 }, /* 114 */
+SE	( 4,	TP,	sys_wait4,		"wait4", SYS_wait4 ), /* 114 */
  	{ 1,	TF,	sys_swapoff,		"swapoff"	}, /* 115 */
  	{ 1,	0,	sys_sysinfo,		"sysinfo"	}, /* 116 */
-	{ 6,	TI,	sys_ipc,		"ipc", SYS_ipc }, /* 117 */
+SE	( 6,	TI,	sys_ipc,		"ipc", SYS_ipc  ), /* 117 */
  	{ 1,	TD,	sys_fsync,		"fsync"		}, /* 118 */
  	{ 0,	TS,	sys_sigreturn,		"sigreturn"	}, /* 119 */
-	{ 5,	TP,	sys_clone,		"clone", SYS_clone }, /* 120 */
+SE	( 5,	TP,	sys_clone,		"clone", SYS_clone ), /* 120 */
  	{ 2,	0,	sys_setdomainname,	"setdomainname"	}, /* 121 */
  	{ 1,	0,	sys_uname,		"uname"		}, /* 122 */
  	{ 3,	0,	sys_modify_ldt,		"modify_ldt"	}, /* 123 */
@@ -163,7 +163,7 @@
  	{ 1,	0,	sys_getpgid,		"getpgid"	}, /* 132 */
  	{ 1,	TD,	sys_fchdir,		"fchdir"	}, /* 133 */
  	{ 0,	0,	sys_bdflush,		"bdflush"	}, /* 134 */
-	{ 3,	0,	sys_sysfs,		"sysfs", SYS_sysfs }, /* 135 */
+SE	( 3,	0,	sys_sysfs,		"sysfs", SYS_sysfs ), /* 135 */
  	{ 1,	0,	sys_personality,	"personality"	}, /* 136 */
  	{ 5,	0,	sys_afs_syscall,	"afs_syscall"	}, /* 137 */
  	{ 1,	NF,	sys_setfsuid,		"setfsuid"	}, /* 138 */
@@ -173,8 +173,8 @@
  	{ 5,	TD,	sys_select,		"select"	}, /* 142 */
  	{ 2,	TD,	sys_flock,		"flock"		}, /* 143 */
  	{ 3,	0,	sys_msync,		"msync"		}, /* 144 */
-	{ 3,	TD,	sys_readv,		"readv", SYS_readv }, /* 145 */
-	{ 3,	TD,	sys_writev,		"writev", SYS_writev }, /* 146 */
+SE	( 3,	TD,	sys_readv,		"readv", SYS_readv ), /* 145 */
+SE	( 3,	TD,	sys_writev,		"writev", SYS_writev ), /* 146 */
  	{ 1,	0,	sys_getsid,		"getsid"	}, /* 147 */
  	{ 1,	TD,	sys_fdatasync,		"fdatasync"	}, /* 148 */
  	{ 1,	0,	sys_sysctl,		"_sysctl"	}, /* 149 */
@@ -209,8 +209,8 @@
  	{ 3,	TS,	sys_rt_sigqueueinfo,    "rt_sigqueueinfo"}, /* 178 */
  	{ 2,	TS,	sys_rt_sigsuspend,	"rt_sigsuspend"	}, /* 179 */

-	{ 5,	TD,	sys_pread,		"pread64", SYS_read }, /* 180 */
-	{ 5,	TD,	sys_pwrite,		"pwrite64", SYS_write }, /* 181 */
+SE	( 5,	TD,	sys_pread,		"pread64", SYS_read ), /* 180 */
+SE	( 5,	TD,	sys_pwrite,		"pwrite64", SYS_write ), /* 181 */
  	{ 3,	TF,	sys_chown,		"chown"		}, /* 182 */
  	{ 2,	TF,	sys_getcwd,		"getcwd"	}, /* 183 */
  	{ 2,	0,	sys_capget,		"capget"	}, /* 184 */
@@ -219,7 +219,7 @@
  	{ 4,	TD|TN,	sys_sendfile,		"sendfile"	}, /* 187 */
  	{ 5,	0,	sys_getpmsg,		"getpmsg"	}, /* 188 */
  	{ 5,	0,	sys_putpmsg,		"putpmsg"	}, /* 189 */
-	{ 0,	TP,	sys_vfork,		"vfork", SYS_vfork }, /* 190 */
+SE	( 0,	TP,	sys_vfork,		"vfork", SYS_vfork ), /* 190 */
  	{ 2,	0,	sys_getrlimit,		"getrlimit"	}, /* 191 */
  	{ 6,	TD,	sys_mmap,		"mmap2"		}, /* 192 */
  	{ 3,	TF,	sys_truncate64,		"truncate64"	}, /* 193 */
@@ -282,7 +282,7 @@
  	{ 3,	0,	sys_io_cancel,		"io_cancel"	}, /* 249 */
  	{ 5,	TD,	sys_fadvise64,		"fadvise64"	}, /* 250 */
  	{ 6,	0,	printargs,		"SYS_251"	}, /* 251 */
-	{ 1,	TP,	sys_exit,		"exit_group", __NR_exit_group }, /* 252 */
+SE	( 1,	TP,	sys_exit,		"exit_group", __NR_exit_group ), /* 252 */
  	{ 4,	0,	sys_lookup_dcookie,	"lookup_dcookie"}, /* 253 */
  	{ 1,	TD,	sys_epoll_create,	"epoll_create"	}, /* 254 */
  	{ 4,	TD,	sys_epoll_ctl,		"epoll_ctl"	}, /* 255 */
@@ -314,7 +314,7 @@
  	{ 2,	0,	sys_mq_notify,		"mq_notify"	}, /* 281 */
  	{ 3,	0,	sys_mq_getsetattr,	"mq_getsetattr"	}, /* 282 */
  	{ 4,	0,	sys_kexec_load,		"kexec_load"	}, /* 283 */
-	{ 5,	TP,	sys_waitid,		"waitid", SYS_waitid }, /* 284 */
+SE	( 5,	TP,	sys_waitid,		"waitid", SYS_waitid ), /* 284 */
  	{ 6,	0,	printargs,		"SYS_285"	}, /* 285 */
  	{ 5,	0,	sys_add_key,		"add_key"	}, /* 286 */
  	{ 4,	0,	sys_request_key,	"request_key"	}, /* 287 */
@@ -443,10 +443,10 @@
  	{ 3,	TN,	sys_getsockname,	"getsockname"	}, /* 406 */
  	{ 3,	TN,	sys_getpeername,	"getpeername"	}, /* 407 */
  	{ 4,	TN,	sys_socketpair,		"socketpair"	}, /* 408 */
-	{ 4,	TN,	sys_send,		"send", SYS_sub_send }, /* 409 */
-	{ 4,	TN,	sys_recv,		"recv", SYS_sub_recv }, /* 410 */
-	{ 6,	TN,	sys_sendto,		"sendto", SYS_sub_sendto }, /* 411 */
-	{ 6,	TN,	sys_recvfrom,		"recvfrom", SYS_sub_recvfrom }, /* 412 */
+SE	( 4,	TN,	sys_send,		"send", SYS_sub_send ), /* 409 */
+SE	( 4,	TN,	sys_recv,		"recv", SYS_sub_recv ), /* 410 */
+SE	( 6,	TN,	sys_sendto,		"sendto", SYS_sub_sendto ), /* 411 */
+SE	( 6,	TN,	sys_recvfrom,		"recvfrom", SYS_sub_recvfrom ), /* 412 */
  	{ 2,	TN,	sys_shutdown,		"shutdown"	}, /* 413 */
  	{ 5,	TN,	sys_setsockopt,		"setsockopt"	}, /* 414 */
  	{ 5,	TN,	sys_getsockopt,		"getsockopt"	}, /* 415 */
diff -d -urpN strace.4/syscall.c strace.5/syscall.c
--- strace.4/syscall.c	2012-01-29 01:12:51.110642083 +0100
+++ strace.5/syscall.c	2012-02-07 11:47:00.465648666 +0100
@@ -114,6 +114,13 @@
  #define NF SYSCALL_NEVER_FAILS
  #define MA MAX_ARGS

+#if SUPPORTED_PERSONALITIES > 1
+# define SE(nargs, sys_flags, sys_func, sys_name, ...) { nargs, sys_flags, sys_func, sys_name, __VA_ARGS__ }
+#else
+/* Remove last arg (native_scno), it's unused */
+# define SE(nargs, sys_flags, sys_func, sys_name, ...) { nargs, sys_flags, sys_func, sys_name }
+#endif
+
  static const struct sysent sysent0[] = {
  #include "syscallent.h"
  };
diff -d -urpN strace.4/syscallent.sh strace.5/syscallent.sh
--- strace.4/syscallent.sh	2012-01-27 17:28:32.996173811 +0100
+++ strace.5/syscallent.sh	2012-02-07 11:37:13.964535256 +0100
@@ -63,12 +63,12 @@ s/^#[ ]*define[ ][ ]*__NR_\([^ ]*\)[ ]*[
  		while (++call < limit) {
  			f = "printargs"
  			n = "SYS_" call
-			s = "\t{ MA,\t0,\t"
+			s = "SE( MA,\t0,\t"
  			s = s f ","
  			s = s substr(tabs, 1, 24/8 - int((length(f) + 1)/8))
  			s = s "\"" n "\""
  			s = s substr(tabs, 1, 16/8 - int((length(n) + 2)/8))
-			s = s "}, /* " call " */"
+			s = s "), /* " call " */"
  			print s
  		}
  	}




More information about the Strace-devel mailing list