Call direct system calls for socket operations

Explicit system calls for the socket operations were added in Linux kernel
in commit 86250b9d12ca for powerpc. This patch make use of those instead of
calling socketcall to save number of cycles on networking syscalls.

2015-08-25  Rajalakshmi Srinivasaraghavan  <raji@linux.vnet.ibm.com>

	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h: Define new macros.
	* sysdeps/unix/sysv/linux/accept.c: Call direct system call.
	* sysdeps/unix/sysv/linux/bind.c: Call direct system call.
	* sysdeps/unix/sysv/linux/connect.c: Call direct system call.
	* sysdeps/unix/sysv/linux/getpeername.c: Call direct system call.
	* sysdeps/unix/sysv/linux/getsockname.c: Call direct system call.
	* sysdeps/unix/sysv/linux/getsockopt.c: Call direct system call.
	* sysdeps/unix/sysv/linux/listen.c: Call direct system call.
	* sysdeps/unix/sysv/linux/recv.c: Call direct system call.
	* sysdeps/unix/sysv/linux/recvfrom.c: Call direct system call.
	* sysdeps/unix/sysv/linux/recvmsg.c: Call direct system call.
	* sysdeps/unix/sysv/linux/send.c: Call direct system call.
	* sysdeps/unix/sysv/linux/sendmsg.c: Call direct system call.
	* sysdeps/unix/sysv/linux/sendto.c: Call direct system call.
	* sysdeps/unix/sysv/linux/setsockopt.c: Call direct system call.
	* sysdeps/unix/sysv/linux/shutdown.c: Call direct system call.
	* sysdeps/unix/sysv/linux/socket.c: Call direct system call.
	* sysdeps/unix/sysv/linux/socketpair.c: Call direct system call.
This commit is contained in:
Rajalakshmi Srinivasaraghavan 2015-08-25 10:23:47 -03:00 committed by Tulio Magno Quites Machado Filho
parent 18173559a2
commit f4491417cc
19 changed files with 146 additions and 0 deletions

View File

@ -1,3 +1,24 @@
2015-08-25 Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
* sysdeps/unix/sysv/linux/powerpc/kernel-features.h: Define new macros.
* sysdeps/unix/sysv/linux/accept.c: Call direct system call.
* sysdeps/unix/sysv/linux/bind.c: Call direct system call.
* sysdeps/unix/sysv/linux/connect.c: Call direct system call.
* sysdeps/unix/sysv/linux/getpeername.c: Call direct system call.
* sysdeps/unix/sysv/linux/getsockname.c: Call direct system call.
* sysdeps/unix/sysv/linux/getsockopt.c: Call direct system call.
* sysdeps/unix/sysv/linux/listen.c: Call direct system call.
* sysdeps/unix/sysv/linux/recv.c: Call direct system call.
* sysdeps/unix/sysv/linux/recvfrom.c: Call direct system call.
* sysdeps/unix/sysv/linux/recvmsg.c: Call direct system call.
* sysdeps/unix/sysv/linux/send.c: Call direct system call.
* sysdeps/unix/sysv/linux/sendmsg.c: Call direct system call.
* sysdeps/unix/sysv/linux/sendto.c: Call direct system call.
* sysdeps/unix/sysv/linux/setsockopt.c: Call direct system call.
* sysdeps/unix/sysv/linux/shutdown.c: Call direct system call.
* sysdeps/unix/sysv/linux/socket.c: Call direct system call.
* sysdeps/unix/sysv/linux/socketpair.c: Call direct system call.
2015-08-25 Paul E. Murphy <murphyp@linux.vnet.ibm.com>
* sysdeps/powerpc/powerpc32/sysdep.h (ABORT_TRANSACTION): Use

View File

@ -21,11 +21,17 @@
#include <sysdep-cancel.h>
#include <socketcall.h>
#include <sys/syscall.h>
#include <kernel-features.h>
int
__libc_accept (int fd, __SOCKADDR_ARG addr, socklen_t *len)
{
#ifdef __ASSUME_ACCEPT_SYSCALL
return SYSCALL_CANCEL (accept, fd, addr.__sockaddr__, len);
#else
return SOCKETCALL_CANCEL (accept, fd, addr.__sockaddr__, len);
#endif
}
weak_alias (__libc_accept, accept)
libc_hidden_def (accept)

View File

@ -20,10 +20,16 @@
#include <sys/socket.h>
#include <socketcall.h>
#include <kernel-features.h>
#include <sys/syscall.h>
int
__bind (int fd, __CONST_SOCKADDR_ARG addr, socklen_t len)
{
#ifdef __ASSUME_BIND_SYSCALL
return INLINE_SYSCALL (bind, 3, fd, addr.__sockaddr__, len);
#else
return SOCKETCALL (bind, fd, addr.__sockaddr__, len, 0, 0, 0);
#endif
}
weak_alias (__bind, bind)

View File

@ -21,11 +21,17 @@
#include <sysdep-cancel.h>
#include <socketcall.h>
#include <kernel-features.h>
#include <sys/syscall.h>
int
__libc_connect (int fd, __CONST_SOCKADDR_ARG addr, socklen_t len)
{
#ifdef __ASSUME_CONNECT_SYSCALL
return SYSCALL_CANCEL (connect, fd, addr.__sockaddr__, len);
#else
return SOCKETCALL_CANCEL (connect, fd, addr.__sockaddr__, len);
#endif
}
weak_alias (__libc_connect, connect)
weak_alias (__libc_connect, __connect)

View File

@ -20,10 +20,16 @@
#include <sys/socket.h>
#include <socketcall.h>
#include <kernel-features.h>
#include <sys/syscall.h>
int
__getpeername (int fd, __SOCKADDR_ARG addr, socklen_t *len)
{
#ifdef __ASSUME_GETPEERNAME_SYSCALL
return INLINE_SYSCALL (getpeername, 3, fd, addr.__sockaddr__, len);
#else
return SOCKETCALL (getpeername, fd, addr.__sockaddr__, len);
#endif
}
weak_alias (__getpeername, getpeername)

View File

@ -20,10 +20,16 @@
#include <sys/socket.h>
#include <socketcall.h>
#include <kernel-features.h>
#include <sys/syscall.h>
int
__getsockname (int fd, __SOCKADDR_ARG addr, socklen_t *len)
{
#ifdef __ASSUME_GETSOCKNAME_SYSCALL
return INLINE_SYSCALL (getsockname, 3, fd, addr.__sockaddr__, len);
#else
return SOCKETCALL (getsockname, fd, addr.__sockaddr__, len);
#endif
}
weak_alias (__getsockname, getsockname)

View File

@ -20,10 +20,16 @@
#include <sys/socket.h>
#include <socketcall.h>
#include <kernel-features.h>
#include <sys/syscall.h>
int
__getsockopt (int fd, int level, int optname, void *optval, socklen_t *len)
{
#ifdef __ASSUME_GETSOCKOPT_SYSCALL
return INLINE_SYSCALL (getsockopt, 5, fd, level, optname, optval, len);
#else
return SOCKETCALL (getsockopt, fd, level, optname, optval, len);
#endif
}
weak_alias (__getsockopt, getsockopt)

View File

@ -20,10 +20,16 @@
#include <sys/socket.h>
#include <socketcall.h>
#include <kernel-features.h>
#include <sys/syscall.h>
int
listen (int fd, int backlog)
{
#ifdef __ASSUME_LISTEN_SYSCALL
return INLINE_SYSCALL (listen, 2, fd, backlog);
#else
return SOCKETCALL (listen, fd, backlog);
#endif
}
weak_alias (listen, __listen);

View File

@ -30,6 +30,27 @@
# define __ASSUME_RECVMMSG_SYSCALL 1
#endif
/* New syscalls added for PowerPC in 2.6.37. */
#if __LINUX_KERNEL_VERSION >= 0x020625
# define __ASSUME_SOCKET_SYSCALL 1
# define __ASSUME_BIND_SYSCALL 1
# define __ASSUME_CONNECT_SYSCALL 1
# define __ASSUME_LISTEN_SYSCALL 1
# define __ASSUME_ACCEPT_SYSCALL 1
# define __ASSUME_GETSOCKNAME_SYSCALL 1
# define __ASSUME_GETPEERNAME_SYSCALL 1
# define __ASSUME_SOCKETPAIR_SYSCALL 1
# define __ASSUME_SEND_SYSCALL 1
# define __ASSUME_SENDTO_SYSCALL 1
# define __ASSUME_RECV_SYSCALL 1
# define __ASSUME_RECVFROM_SYSCALL 1
# define __ASSUME_SHUTDOWN_SYSCALL 1
# define __ASSUME_GETSOCKOPT_SYSCALL 1
# define __ASSUME_SETSOCKOPT_SYSCALL 1
# define __ASSUME_SENDMSG_SYSCALL 1
# define __ASSUME_RECVMSG_SYSCALL 1
#endif
/* The sendmmsg syscall was added for PowerPC in 3.0. */
#if __LINUX_KERNEL_VERSION >= 0x030000
# define __ASSUME_SENDMMSG_SYSCALL 1

View File

@ -21,11 +21,17 @@
#include <sysdep-cancel.h>
#include <socketcall.h>
#include <kernel-features.h>
#include <sys/syscall.h>
ssize_t
__libc_recv (int fd, void *buf, size_t len, int flags)
{
#ifdef __ASSUME_RECV_SYSCALL
return SYSCALL_CANCEL (recv, fd, buf, len, flags);
#else
return SOCKETCALL_CANCEL (recv, fd, buf, len, flags);
#endif
}
weak_alias (__libc_recv, recv)
weak_alias (__libc_recv, __recv)

View File

@ -21,13 +21,20 @@
#include <sysdep-cancel.h>
#include <socketcall.h>
#include <kernel-features.h>
#include <sys/syscall.h>
ssize_t
__libc_recvfrom (int fd, void *buf, size_t len, int flags,
__SOCKADDR_ARG addr, socklen_t *addrlen)
{
#ifdef __ASSUME_RECVFROM_SYSCALL
return SYSCALL_CANCEL (recvfrom, fd, buf, len, flags, addr.__sockaddr__,
addrlen);
#else
return SOCKETCALL_CANCEL (recvfrom, fd, buf, len, flags, addr.__sockaddr__,
addrlen);
#endif
}
weak_alias (__libc_recvfrom, recvfrom)
weak_alias (__libc_recvfrom, __recvfrom)

View File

@ -21,11 +21,17 @@
#include <sysdep-cancel.h>
#include <socketcall.h>
#include <kernel-features.h>
#include <sys/syscall.h>
ssize_t
__libc_recvmsg (int fd, struct msghdr *msg, int flags)
{
#ifdef __ASSUME_RECVMSG_SYSCALL
return SYSCALL_CANCEL (recvmsg, fd, msg, flags);
#else
return SOCKETCALL_CANCEL (recvmsg, fd, msg, flags);
#endif
}
weak_alias (__libc_recvmsg, recvmsg)
weak_alias (__libc_recvmsg, __recvmsg)

View File

@ -21,11 +21,17 @@
#include <sysdep-cancel.h>
#include <socketcall.h>
#include <kernel-features.h>
#include <sys/syscall.h>
ssize_t
__libc_send (int fd, const void *buf, size_t len, int flags)
{
#ifdef __ASSUME_SEND_SYSCALL
return SYSCALL_CANCEL (send, fd, buf, len, flags);
#else
return SOCKETCALL_CANCEL (send, fd, buf, len, flags);
#endif
}
weak_alias (__libc_send, send)
weak_alias (__libc_send, __send)

View File

@ -21,11 +21,17 @@
#include <sysdep-cancel.h>
#include <socketcall.h>
#include <kernel-features.h>
#include <sys/syscall.h>
ssize_t
__libc_sendmsg (int fd, const struct msghdr *msg, int flags)
{
#ifdef __ASSUME_SENDMSG_SYSCALL
return SYSCALL_CANCEL (sendmsg, fd, msg, flags);
#else
return SOCKETCALL_CANCEL (sendmsg, fd, msg, flags);
#endif
}
weak_alias (__libc_sendmsg, sendmsg)
weak_alias (__libc_sendmsg, __sendmsg)

View File

@ -21,13 +21,20 @@
#include <sysdep-cancel.h>
#include <socketcall.h>
#include <kernel-features.h>
#include <sys/syscall.h>
ssize_t
__libc_sendto (int fd, const void *buf, size_t len, int flags,
__CONST_SOCKADDR_ARG addr, socklen_t addrlen)
{
#ifdef __ASSUME_SENDTO_SYSCALL
return SYSCALL_CANCEL (sendto, fd, buf, len, flags, addr.__sockaddr__,
addrlen);
#else
return SOCKETCALL_CANCEL (sendto, fd, buf, len, flags, addr.__sockaddr__,
addrlen);
#endif
}
weak_alias (__libc_sendto, sendto)
weak_alias (__libc_sendto, __sendto)

View File

@ -20,10 +20,16 @@
#include <sys/socket.h>
#include <socketcall.h>
#include <kernel-features.h>
#include <sys/syscall.h>
int
setsockopt (int fd, int level, int optname, const void *optval, socklen_t len)
{
#ifdef __ASSUME_SETSOCKOPT_SYSCALL
return INLINE_SYSCALL (setsockopt, 5, fd, level, optname, optval, len);
#else
return SOCKETCALL (setsockopt, fd, level, optname, optval, len);
#endif
}
weak_alias (setsockopt, __setsockopt)

View File

@ -20,10 +20,16 @@
#include <sys/socket.h>
#include <socketcall.h>
#include <kernel-features.h>
#include <sys/syscall.h>
int
__shutdown (int fd, int how)
{
#ifdef __ASSUME_SHUTDOWN_SYSCALL
return INLINE_SYSCALL (shutdown, 2, fd, how);
#else
return SOCKETCALL (shutdown, fd, how);
#endif
}
weak_alias (__shutdown, shutdown)

View File

@ -20,11 +20,17 @@
#include <sys/socket.h>
#include <socketcall.h>
#include <kernel-features.h>
#include <sys/syscall.h>
int
__socket (int fd, int type, int domain)
{
#ifdef __ASSUME_SOCKET_SYSCALL
return INLINE_SYSCALL (socket, 3, fd, type, domain);
#else
return SOCKETCALL (socket, fd, type, domain);
#endif
}
libc_hidden_def (__socket)
weak_alias (__socket, socket)

View File

@ -20,10 +20,16 @@
#include <sys/socket.h>
#include <socketcall.h>
#include <kernel-features.h>
#include <sys/syscall.h>
int
__socketpair (int domain, int type, int protocol, int sv[2])
{
#ifdef __ASSUME_SOCKETPAIR_SYSCALL
return INLINE_SYSCALL (socketpair, 4, domain, type, protocol, sv);
#else
return SOCKETCALL (socketpair, domain, type, protocol, sv);
#endif
}
weak_alias (__socketpair, socketpair)