This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH v3] Consolidate Linux readahead() implementations
- From: Yury Norov <ynorov at caviumnetworks dot com>
- To: <libc-alpha at sourceware dot org>
- Cc: Yury Norov <ynorov at caviumnetworks dot com>, Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, Florian Weimer <fw at deneb dot enyo dot de>
- Date: Tue, 27 Sep 2016 02:12:03 +0300
- Subject: [PATCH v3] Consolidate Linux readahead() implementations
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Yuri dot Norov at caviumnetworks dot com;
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
There are 4 different implementations of readahead() in glibc:
- arm and mips32 use one located under sysdeps/unix/sysv/linux/arm;
- powerpc32 and wordsize64 has 2 another implementations in their
syscalls.list;
- and there's generic implementation under sysdeps/unix/sysv/linux for
other ports.
With the [1] it's possible to consolidate all of them except tile32
under sysdeps/unix/sysv/linux. Tile32 like other 32-bit ports passes
offset in a pair of registers, but doesn't need register alignment,
though has __ASSUME_ALIGNED_REGISTER_PAIRS enabled. So it should be
handled exceptionally. Here new __ASSUME_READAHEAD_NO_ALIGN option is
introduced in kernel-features.h, and is enabled only for tile.
[1] https://sourceware.org/ml/libc-alpha/2016-09/msg00452.html
v3:
- option is restored, and exceptional implementation is dropped
to avoid warning due to multiple inclusion of sysdep.h
v2:
- remove powerpc and wordsize64 implementations;
- remove __ASSUME_READAHEAD_ALIGN option;
- add exception for tile32.
v1: https://sourceware.org/ml/libc-alpha/2016-09/msg00469.html
2016-09-27: Yury Norov <ynorov@caviumnetworks.com>
* sysdeps/unix/sysv/linux/arm/readahead.c: Delete.
* sysdeps/unix/sysv/linux/mips/mips32/readahead.c: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list: Delete
readahead generation.
* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/readahead.c: Consolidate implementation.
* sysdeps/unix/sysv/linux/kernel-features.h: New
__ASSUME_READAHEAD_NO_ALIGN option.
* sysdeps/unix/sysv/linux/tile/kernel-features.h: Likewise.
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
CC: Adhemerval Zanella <adhemerval.zanella@linaro.org>
CC: Florian Weimer <fw@deneb.enyo.de>
---
sysdeps/unix/sysv/linux/arm/readahead.c | 37 ----------------------
sysdeps/unix/sysv/linux/kernel-features.h | 4 +++
sysdeps/unix/sysv/linux/mips/mips32/readahead.c | 1 -
.../sysv/linux/powerpc/powerpc32/syscalls.list | 3 --
sysdeps/unix/sysv/linux/readahead.c | 13 +++++---
sysdeps/unix/sysv/linux/tile/kernel-features.h | 5 +--
sysdeps/unix/sysv/linux/wordsize-64/syscalls.list | 1 -
7 files changed, 15 insertions(+), 49 deletions(-)
delete mode 100644 sysdeps/unix/sysv/linux/arm/readahead.c
delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/readahead.c
diff --git a/sysdeps/unix/sysv/linux/arm/readahead.c b/sysdeps/unix/sysv/linux/arm/readahead.c
deleted file mode 100644
index 9824e6f..0000000
--- a/sysdeps/unix/sysv/linux/arm/readahead.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Provide kernel hint to read ahead.
- Copyright (C) 2002-2016 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library. If not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <endian.h>
-
-#include <sysdep.h>
-#include <sys/syscall.h>
-
-
-ssize_t
-__readahead (int fd, off64_t offset, size_t count)
-{
- return INLINE_SYSCALL (readahead, 5, fd, 0,
- __LONG_LONG_PAIR ((off_t) (offset >> 32),
- (off_t) (offset & 0xffffffff)),
- count);
-}
-
-weak_alias (__readahead, readahead)
diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
index 71ce57a..683c958 100644
--- a/sysdeps/unix/sysv/linux/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/kernel-features.h
@@ -144,6 +144,10 @@
# define __ASSUME_SENDMMSG 1
#endif
+#ifndef __ASSUME_READAHEAD_NO_ALIGN
+# define __ASSUME_READAHEAD_NO_ALIGN 0
+#endif
+
/* On most architectures, most socket syscalls are supported for all
supported kernel versions, but on some socketcall architectures
separate syscalls were only added later. */
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/readahead.c b/sysdeps/unix/sysv/linux/mips/mips32/readahead.c
deleted file mode 100644
index 80170c3..0000000
--- a/sysdeps/unix/sysv/linux/mips/mips32/readahead.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/arm/readahead.c>
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list
index 451d508..487bdd0 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list
@@ -7,8 +7,5 @@ lchown - lchown i:sii __lchown lchown@@GLIBC_2.0 chown@GLIBC_2.0
oldgetrlimit EXTRA getrlimit i:ip __old_getrlimit getrlimit@GLIBC_2.0
setrlimit - setrlimit i:ip __setrlimit setrlimit@GLIBC_2.0 setrlimit@@GLIBC_2.2
-# Due to 64bit alignment there is a dummy second parameter
-readahead - readahead i:iiiii __readahead readahead
-
prlimit64 EXTRA prlimit64 i:iipp prlimit64
fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
diff --git a/sysdeps/unix/sysv/linux/readahead.c b/sysdeps/unix/sysv/linux/readahead.c
index 92e5428..cb49906 100644
--- a/sysdeps/unix/sysv/linux/readahead.c
+++ b/sysdeps/unix/sysv/linux/readahead.c
@@ -22,17 +22,20 @@
#include <sysdep.h>
#include <sys/syscall.h>
-
+#include <kernel-features.h>
#ifdef __NR_readahead
+#if __ASSUME_READAHEAD_NO_ALIGN
+# undef __ALIGNMENT_ARG
+# define __ALIGNMENT_ARG
+#endif
+
ssize_t
__readahead (int fd, off64_t offset, size_t count)
{
- return INLINE_SYSCALL (readahead, 4, fd,
- __LONG_LONG_PAIR ((off_t) (offset >> 32),
- (off_t) (offset & 0xffffffff)),
- count);
+ return INLINE_SYSCALL_CALL (readahead, fd, __ALIGNMENT_ARG
+ SYSCALL_LL64 (offset), count);
}
#else
ssize_t
diff --git a/sysdeps/unix/sysv/linux/tile/kernel-features.h b/sysdeps/unix/sysv/linux/tile/kernel-features.h
index ded0e43..84d1011 100644
--- a/sysdeps/unix/sysv/linux/tile/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/tile/kernel-features.h
@@ -17,11 +17,12 @@
<http://www.gnu.org/licenses/>. */
-#include_next <kernel-features.h>
-
/* Define this if your 32-bit syscall API requires 64-bit register
pairs to start with an even-number register. */
#ifndef _LP64
# define __ASSUME_ALIGNED_REGISTER_PAIRS 1
# define __ASSUME_FADVISE64_64_NO_ALIGN 1
+# define __ASSUME_READAHEAD_NO_ALIGN 1
#endif
+
+#include_next <kernel-features.h>
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
index 3f3569f..1040e70 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
@@ -7,7 +7,6 @@ ftruncate - ftruncate i:ii __ftruncate ftruncate ftruncate64 __ftruncate64
truncate - truncate i:si truncate truncate64
getrlimit - getrlimit i:ip __getrlimit getrlimit getrlimit64 __getrlimit64
setrlimit - setrlimit i:ip __setrlimit setrlimit setrlimit64
-readahead - readahead i:iii __readahead readahead
sendfile - sendfile i:iipi sendfile sendfile64
sync_file_range - sync_file_range Ci:iiii sync_file_range
creat - creat Ci:si creat creat64
--
2.7.4