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

 



The following patch implements the new features from Linux 3.10 as well
as properly sets up the new features from 3.7 that were only 
half-implemented before.

Signed-off-by: Vince Weaver <vincent.weaver@xxxxxxxxx>

diff --git a/syscalls/perf_event_open.c b/syscalls/perf_event_open.c
index 5127231..d1d59ec 100644
--- a/syscalls/perf_event_open.c
+++ b/syscalls/perf_event_open.c
@@ -785,6 +785,10 @@ static long long random_sample_type(void)
 		sample_type |= PERF_SAMPLE_REGS_USER;
 	if (rand_bool())
 		sample_type |= PERF_SAMPLE_STACK_USER;
+	if (rand_bool())
+		sample_type |= PERF_SAMPLE_WEIGHT;
+	if (rand_bool())
+		sample_type |= PERF_SAMPLE_DATA_SRC;
 
 	return sample_type;
 }
@@ -837,6 +841,34 @@ static int random_attr_size(void) {
 	return size;
 }
 
+static long long random_branch_sample_type(void)
+{
+
+	long long branch_sample = 0;
+
+	if (rand() % 2)
+		return rand64();
+
+	if (rand_bool())
+		branch_sample |= PERF_SAMPLE_BRANCH_USER;
+	if (rand_bool())
+		branch_sample |= PERF_SAMPLE_BRANCH_KERNEL;
+	if (rand_bool())
+		branch_sample |= PERF_SAMPLE_BRANCH_HV;
+
+	if (rand_bool())
+		branch_sample |= PERF_SAMPLE_BRANCH_ANY;
+	if (rand_bool())
+		branch_sample |= PERF_SAMPLE_BRANCH_ANY_CALL;
+	if (rand_bool())
+		branch_sample |= PERF_SAMPLE_BRANCH_ANY_RETURN;
+	if (rand_bool())
+		branch_sample |= PERF_SAMPLE_BRANCH_IND_CALL;
+
+	return branch_sample;
+}
+
+
 static void create_mostly_valid_counting_event(struct perf_event_attr *attr,
 						int group_leader)
 {
@@ -886,6 +918,11 @@ static void create_mostly_valid_counting_event(struct perf_event_attr *attr,
 		/* leave config2 alone for now */
 	}
 
+	/* branch_sample_type not relevant if not sampling */
+
+	/* sample_regs_user not relevant if not sampling */
+
+	/* sample_stack_user not relevant if not sampling */
 }
 
 static void create_mostly_valid_sampling_event(struct perf_event_attr *attr,
@@ -940,6 +977,26 @@ static void create_mostly_valid_sampling_event(struct perf_event_attr *attr,
 		/* config1 set earlier */
 	}
 
+	attr->branch_sample_type = random_branch_sample_type();
+
+	/* sample_regs_user is a bitmask of CPU registers to record.     */
+	/* The values come from arch/ARCH/include/uapi/asm/perf_regs.h   */
+	/* Most architectures have fewer than 64 registers...            */
+	switch(rand()%3) {
+		case 0:		attr->sample_regs_user = rand()%16;
+				break;
+		case 1:		attr->sample_regs_user = rand()%64;
+				break;
+		case 2:		attr->sample_regs_user = rand64();
+				break;
+		default:
+				break;
+	}
+
+	/* sample_stack_user is the size of user stack backtrace we want  */
+	/* if we pick too large of a value the kernel in theory truncates */
+	attr->sample_stack_user = rand32();
+
 }
 
 /* Creates a completely random event, unlikely to be valid */
--
To unsubscribe from this list: send the line "unsubscribe trinity" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




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

  Powered by Linux