Sukadev Bhattiprolu [suka...@linux.vnet.ibm.com] wrote:
| Miscellaenous fixes for perf and 24x7 counters in powerpc.
| 
| Patches 1,3,4 were submitted earlier as a part of the parametrized
| events for 24x7 counters. But they are not directly related to the
| parametrized events.
| 
| Patch 2 simplifies and fixes a bug in catalog_read() which causes the
| catalog file to not read first page.
| 
| Changelog[v3]
|       [Michael Ellerman] Cleanup patches 1 and 2 and fix a bug
|       Add patch 5/5 to update contact info for 24x7 and GPCI counters
| 
| Changelog[v2]
|       Rebase to perf/core tree.
| 
| Cody P Schafer (3):
|   powerpc/perf/hv-24x7: use kmem_cache instead of aligned stack
|     allocations
|   perf Documentation: sysfs events/ interfaces
|   perf Documentation: remove duplicated docs for powerpc cpu specific
|     events

Per Michael Ellerman's suggestion, attaching an informal test case to
demonstrate the bug and the fix.

Sukadev
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <sys/stat.h>

/*
 * Usage: cp-catalog <read_size>
 *
 * Read the catalog from beginning to end. Read 'read_size' bytes
 * on each read.
 *
 * To ensure that a bug in catalog_read() in the kernel code is fixed.
 * 	cp-catalog 5 > /tmp/catalog-5
 * 	cp-catalog  > /tmp/catalog-4096
 * 	diff /tmp/catalog-5 /tmp/catalog-4096
 *
 * If both files are identical and size is about 256K, the bug is fixed.
 */
#define CATALOG	"/sys/bus/event_source/devices/hv_24x7/interface/catalog"
#define TMP_CATALOG	"/tmp/catalog"

main(int argc, char *argv[])
{
	int read_size, rfd, wfd, rc;
	struct stat stat_buf;
	char *input_file;
	char buf[4096];
	char output_file[256];

	read_size = 4096;
	if (argc > 1)
		read_size = atoi(argv[1]);

	if (read_size > sizeof(buf))
		read_size = sizeof(buf);

	input_file = CATALOG;
	sprintf(output_file, "%s-%d", TMP_CATALOG, read_size);

	rfd = open(input_file, O_RDONLY);
	if (rfd < 0) {
		perror(input_file);
		_Exit(1);
	}

	wfd  = open(output_file, O_WRONLY|O_CREAT|O_TRUNC);
	if (wfd < 0) {
		perror(output_file);
		_Exit(1);
	}

	while(1) {
		memset(buf, 0, sizeof(buf));
		rc = read(rfd, buf, read_size);
		if (rc <= 0)
			break;
		if (write(wfd, buf, rc) != rc) {
			perror("write()");
			break;
		}
	}
	if (fstat(wfd, &stat_buf) < 0) {
		perror("fstat()");
		_Exit(1);
	}
	printf("catalog size %zd\n", stat_buf.st_size);
}
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Reply via email to