On 04/03/2016 19:50, Markus Armbruster wrote:
> There's another one in ivshmem_server.c, functionally identical and
> wrapped in CONFIG_LINUX.
Not quite identical, since it returns -1 for non-hugetlbfs. It should
return getpagesize().
> Here's exec.c's:
>
> #define HUGETLBFS_MAGIC 0x958458f6
>
> static long gethugepagesize(const char *path, Error **errp)
> {
> struct statfs fs;
> int ret;
>
> do {
> ret = statfs(path, &fs);
> } while (ret != 0 && errno == EINTR);
>
> if (ret != 0) {
> error_setg_errno(errp, errno, "failed to get page size of file
> %s",
> path);
> return 0;
> }
>
> return fs.f_bsize;
> }
>
> Before commit bfc2a1a, it additionally had
>
> if (fs.f_type != HUGETLBFS_MAGIC)
> fprintf(stderr, "Warning: path not on HugeTLBFS: %s\n", path);
>
> Note the lack of "if not hugetlbfs, use getpagesize()" logic.
>
> Here's util/mmap-alloc.c's:
>
> #define HUGETLBFS_MAGIC 0x958458f6
>
> #ifdef CONFIG_LINUX
> #include <sys/vfs.h>
> #endif
>
> size_t qemu_fd_getpagesize(int fd)
> {
> #ifdef CONFIG_LINUX
> struct statfs fs;
> int ret;
>
> if (fd != -1) {
> do {
> ret = fstatfs(fd, &fs);
> } while (ret != 0 && errno == EINTR);
>
> if (ret == 0 && fs.f_type == HUGETLBFS_MAGIC) {
> return fs.f_bsize;
> }
> }
> #endif
>
> return getpagesize();
> }
>
> Would you like me to convert the others users to this one and drop the
> dupes?
That would be great, since all of them really should use fstatfs instead
of statfs.
Paolo