Date: Sun, 8 Oct 2017 07:20:47 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324408 - stable/11/usr.sbin/diskinfo Message-ID: <201710080720.v987Kll8034460@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Sun Oct 8 07:20:47 2017 New Revision: 324408 URL: https://svnweb.freebsd.org/changeset/base/324408 Log: MFC r324172: Align test I/O buffer to page boundary. This is more alike to typical kernel behavior, that can be useful from benchmarking point of view. Modified: stable/11/usr.sbin/diskinfo/diskinfo.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/diskinfo/diskinfo.c ============================================================================== --- stable/11/usr.sbin/diskinfo/diskinfo.c Sun Oct 8 07:19:59 2017 (r324407) +++ stable/11/usr.sbin/diskinfo/diskinfo.c Sun Oct 8 07:20:47 2017 (r324408) @@ -50,6 +50,8 @@ #include <sys/time.h> #define NAIO 128 +#define MAXTX (8*1024*1024) +#define MEGATX (1024*1024) static void usage(void) @@ -67,12 +69,14 @@ static void slogbench(int fd, int isreg, off_t mediasi static int zonecheck(int fd, uint32_t *zone_mode, char *zone_str, size_t zone_str_len); +static uint8_t *buf; + int main(int argc, char **argv) { struct stat sb; int i, ch, fd, error, exitval = 0; - char buf[BUFSIZ], ident[DISK_IDENT_SIZE], physpath[MAXPATHLEN]; + char tstr[BUFSIZ], ident[DISK_IDENT_SIZE], physpath[MAXPATHLEN]; char zone_desc[64]; struct diocgattr_arg arg; off_t mediasize, stripesize, stripeoffset; @@ -129,11 +133,13 @@ main(int argc, char **argv) usage(); } + if (posix_memalign((void **)&buf, PAGE_SIZE, MAXTX)) + errx(1, "Can't allocate memory buffer"); for (i = 0; i < argc; i++) { fd = open(argv[i], (opt_w ? O_RDWR : O_RDONLY) | O_DIRECT); if (fd < 0 && errno == ENOENT && *argv[i] != '/') { - snprintf(buf, BUFSIZ, "%s%s", _PATH_DEV, argv[i]); - fd = open(buf, O_RDONLY); + snprintf(tstr, sizeof(tstr), "%s%s", _PATH_DEV, argv[i]); + fd = open(tstr, O_RDONLY); } if (fd < 0) { warn("%s", argv[i]); @@ -216,12 +222,12 @@ main(int argc, char **argv) printf("\t%u", fwsectors); } } else { - humanize_number(buf, 5, (int64_t)mediasize, "", + humanize_number(tstr, 5, (int64_t)mediasize, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); printf("%s\n", argv[i]); printf("\t%-12u\t# sectorsize\n", sectorsize); printf("\t%-12jd\t# mediasize in bytes (%s)\n", - (intmax_t)mediasize, buf); + (intmax_t)mediasize, tstr); printf("\t%-12jd\t# mediasize in sectors\n", (intmax_t)mediasize/sectorsize); printf("\t%-12jd\t# stripesize\n", stripesize); @@ -255,12 +261,9 @@ main(int argc, char **argv) out: close(fd); } + free(buf); exit (exitval); } - -#define MAXTX (8*1024*1024) -#define MEGATX (1024*1024) -static uint8_t buf[MAXTX]; static void rdsect(int fd, off_t blockno, u_int sectorsize)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201710080720.v987Kll8034460>