Recent changes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The following changes since commit 271067a6e278dafd62649257fe99ce536acfe7bb:

  Fix bug in smalloc size calculation (2011-08-15 15:18:03 +0200)

are available in the git repository at:
  git://git.kernel.dk/fio.git master

Eric Gouriou (1):
      stats: fix io_u_plat out-of-bound accesses (round 2)

Jens Axboe (3):
      Fixup bad style in plat code
      Add simple stest smalloc tester
      Improve Makefile for t/ test code

 Makefile  |    9 ++++++-
 fio.h     |    2 +-
 stat.c    |   46 +++++++++++++++++++++-----------
 t/stest.c |   84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 123 insertions(+), 18 deletions(-)
 create mode 100644 t/stest.c

---

Diff of recent changes:

diff --git a/Makefile b/Makefile
index 40d47d5..85942a0 100644
--- a/Makefile
+++ b/Makefile
@@ -63,6 +63,10 @@ endif
 
 OBJS = $(SOURCE:.c=.o)
 
+T_OBJS = t/stest.o
+T_OBJS += mutex.o smalloc.o
+T_PROGS = t/stest
+
 ifneq ($(findstring $(MAKEFLAGS),s),s)
 ifndef V
 	QUIET_CC	= @echo '   ' CC $@;
@@ -80,6 +84,9 @@ all: .depend $(PROGS) $(SCRIPTS)
 .c.o: .depend
 	$(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $<
 
+t/stest: $(T_OBJS)
+	$(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_OBJS) $(LIBS) $(LDFLAGS)
+
 fio: $(OBJS)
 	$(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
 
@@ -89,7 +96,7 @@ fio: $(OBJS)
 $(PROGS): .depend
 
 clean:
-	-rm -f .depend $(OBJS) $(PROGS) core.* core
+	-rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core
 
 cscope:
 	@cscope -b -R
diff --git a/fio.h b/fio.h
index c741162..6c57496 100644
--- a/fio.h
+++ b/fio.h
@@ -217,7 +217,7 @@ struct thread_stat {
 	unsigned int io_u_complete[FIO_IO_U_MAP_NR];
 	unsigned int io_u_lat_u[FIO_IO_U_LAT_U_NR];
 	unsigned int io_u_lat_m[FIO_IO_U_LAT_M_NR];
-	unsigned int io_u_plat[3][FIO_IO_U_PLAT_NR];
+	unsigned int io_u_plat[2][FIO_IO_U_PLAT_NR];
 	unsigned long total_io_u[3];
 	unsigned long short_io_u[3];
 	unsigned long total_submit;
diff --git a/stat.c b/stat.c
index ee6ee51..d2cc775 100644
--- a/stat.c
+++ b/stat.c
@@ -47,8 +47,10 @@ static unsigned int plat_val_to_idx(unsigned int val)
 	else
 		msb = (sizeof(val)*8) - __builtin_clz(val) - 1;
 
-	/* MSB <= (FIO_IO_U_PLAT_BITS-1), cannot be rounded off. Use
-	 * all bits of the sample as index */
+	/*
+	 * MSB <= (FIO_IO_U_PLAT_BITS-1), cannot be rounded off. Use
+	 * all bits of the sample as index
+	 */
 	if (msb <= FIO_IO_U_PLAT_BITS)
 		return val;
 
@@ -58,8 +60,10 @@ static unsigned int plat_val_to_idx(unsigned int val)
 	/* Compute the number of buckets before the group */
 	base = (error_bits + 1) << FIO_IO_U_PLAT_BITS;
 
-	/* Discard the error bits and apply the mask to find the
-         * index for the buckets in the group */
+	/*
+	 * Discard the error bits and apply the mask to find the
+         * index for the buckets in the group
+	 */
 	offset = (FIO_IO_U_PLAT_VAL - 1) & (val >> error_bits);
 
 	/* Make sure the index does not exceed (array size - 1) */
@@ -117,28 +121,36 @@ static void show_clat_percentiles(unsigned int* io_u_plat, unsigned long nr,
 {
 	unsigned long sum = 0;
 	unsigned int len, i, j = 0;
+	const double *plist;
+	int is_last = 0;
 	static const double def_list[FIO_IO_U_LIST_MAX_LEN] = {
 			1.0, 5.0, 10.0, 20.0, 30.0,
 			40.0, 50.0, 60.0, 70.0, 80.0,
 			90.0, 95.0, 99.0, 99.5, 99.9};
 
-	const double* plist = user_list? user_list: def_list;
-	for (len = 0; len <FIO_IO_U_LIST_MAX_LEN && plist[len] != 0; len++) {}
+	plist = user_list;
+	if (!plist)
+		plist = def_list;
+
+	for (len = 0; len <FIO_IO_U_LIST_MAX_LEN && plist[len] != 0; len++)
+		;
 
-	/* Sort the user-specified list. Note that this does not work
-	   for NaN values */
+	/*
+	 * Sort the user-specified list. Note that this does not work
+	 * for NaN values
+	 */
 	if (user_list && len > 1)
 		qsort((void*)user_list, len, sizeof(user_list[0]), double_cmp);
 
-	int is_last = 0;
 	log_info("    clat percentiles (usec) :");
 
-	for (i = 0; i <FIO_IO_U_PLAT_NR && !is_last; i++) {
+	for (i = 0; i < FIO_IO_U_PLAT_NR && !is_last; i++) {
 		sum += io_u_plat[i];
-		while (sum >= (plist[j]/100 * nr)) {
+		while (sum >= (plist[j] / 100 * nr)) {
 			assert(plist[j] <= 100.0);
 
-			if (j!=0 && (j%4) == 0)	/* for formatting */
+			/* for formatting */
+			if (j != 0 && (j % 4) == 0)
 				log_info("                             ");
 
 			/* end of the list */
@@ -147,9 +159,10 @@ static void show_clat_percentiles(unsigned int* io_u_plat, unsigned long nr,
 			log_info(" %2.2fth=%u%c", plist[j], plat_idx_to_val(i),
 				 (is_last? '\n' : ','));
 
-			if (is_last) break;
+			if (is_last)
+				break;
 
-			if (j%4 == 3)	/* for formatting */
+			if (j % 4 == 3)	/* for formatting */
 				log_info("\n");
 			j++;
 		}
@@ -773,11 +786,12 @@ void show_run_stats(void)
 
 
 		for (k = 0; k <= 2; k++) {
-			int m;
-
 			ts->total_io_u[k] += td->ts.total_io_u[k];
 			ts->short_io_u[k] += td->ts.short_io_u[k];
+		}
 
+		for (k = 0; k <= DDIR_WRITE; k++) {
+			int m;
 			for (m = 0; m < FIO_IO_U_PLAT_NR; m++)
 				ts->io_u_plat[k][m] += td->ts.io_u_plat[k][m];
 		}
diff --git a/t/stest.c b/t/stest.c
new file mode 100644
index 0000000..c179484
--- /dev/null
+++ b/t/stest.c
@@ -0,0 +1,84 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#include "../smalloc.h"
+#include "../flist.h"
+
+FILE *f_err;
+
+#define MAGIC1	0xa9b1c8d2
+#define MAGIC2	0xf0a1e9b3
+
+#define LOOPS	32
+
+struct elem {
+	unsigned int magic1;
+	struct flist_head list;
+	unsigned int magic2;
+};
+
+FLIST_HEAD(list);
+
+static int do_rand_allocs(void)
+{
+	unsigned int size, nr, rounds = 0;
+	unsigned long total;
+	struct elem *e;
+
+	while (rounds++ < LOOPS) {
+#ifdef STEST_SEED
+		srand(MAGIC1);
+#endif
+		nr = total = 0;
+		while (total < 128*1024*1024UL) {
+			size = 8 * sizeof(struct elem) + (int) (999.0 * (rand() / (RAND_MAX + 1.0)));
+			e = smalloc(size);
+			if (!e) {
+				printf("fail at %lu, size %u\n", total, size);
+				break;
+			}
+			e->magic1 = MAGIC1;
+			e->magic2 = MAGIC2;
+			total += size;
+			flist_add_tail(&e->list, &list);
+			nr++;
+		}
+
+		printf("Got items: %u\n", nr);
+
+		while (!flist_empty(&list)) {
+			e = flist_entry(list.next, struct elem, list);
+			assert(e->magic1 == MAGIC1);
+			assert(e->magic2 == MAGIC2);
+			flist_del(&e->list);
+			sfree(e);
+		}
+	}
+
+	return 0;
+}
+
+static int do_specific_alloc(unsigned long size)
+{
+	void *ptr;
+
+	ptr = smalloc(size);
+	sfree(ptr);
+	return 0;
+}
+
+int main(int argc, char *argv[])
+{
+	f_err = stderr;
+
+	sinit();
+
+	do_rand_allocs();
+
+	/* smalloc bug, commit 271067a6 */
+	do_specific_alloc(671386584);
+
+	scleanup();
+	return 0;
+}
--
To unsubscribe from this list: send the line "unsubscribe fio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux