mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	perf: Use sample_flags for addr
Use the new sample_flags to indicate whether the addr field is filled by the PMU driver. As most PMU drivers pass 0, it can set the flag only if it has a non-zero value. And use 0 in perf_sample_output() if it's not filled already. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20220921220032.2858517-1-namhyung@kernel.org
This commit is contained in:
		
							parent
							
								
									dca6344d7a
								
							
						
					
					
						commit
						7b08463015
					
				
					 3 changed files with 17 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -1621,8 +1621,10 @@ static void setup_pebs_fixed_sample_data(struct perf_event *event,
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
	if ((sample_type & PERF_SAMPLE_ADDR_TYPE) &&
 | 
			
		||||
	    x86_pmu.intel_cap.pebs_format >= 1)
 | 
			
		||||
	    x86_pmu.intel_cap.pebs_format >= 1) {
 | 
			
		||||
		data->addr = pebs->dla;
 | 
			
		||||
		data->sample_flags |= PERF_SAMPLE_ADDR;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (x86_pmu.intel_cap.pebs_format >= 2) {
 | 
			
		||||
		/* Only set the TSX weight when no memory weight. */
 | 
			
		||||
| 
						 | 
				
			
			@ -1783,8 +1785,10 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event,
 | 
			
		|||
			data->sample_flags |= PERF_SAMPLE_DATA_SRC;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (sample_type & PERF_SAMPLE_ADDR_TYPE)
 | 
			
		||||
		if (sample_type & PERF_SAMPLE_ADDR_TYPE) {
 | 
			
		||||
			data->addr = meminfo->address;
 | 
			
		||||
			data->sample_flags |= PERF_SAMPLE_ADDR;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (sample_type & PERF_SAMPLE_TRANSACTION) {
 | 
			
		||||
			data->txn = intel_get_tsx_transaction(meminfo->tsx_tuning,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1028,7 +1028,6 @@ struct perf_sample_data {
 | 
			
		|||
	 * minimize the cachelines touched.
 | 
			
		||||
	 */
 | 
			
		||||
	u64				sample_flags;
 | 
			
		||||
	u64				addr;
 | 
			
		||||
	struct perf_raw_record		*raw;
 | 
			
		||||
	u64				period;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1040,6 +1039,7 @@ struct perf_sample_data {
 | 
			
		|||
	union perf_sample_weight	weight;
 | 
			
		||||
	union  perf_mem_data_src	data_src;
 | 
			
		||||
	u64				txn;
 | 
			
		||||
	u64				addr;
 | 
			
		||||
 | 
			
		||||
	u64				type;
 | 
			
		||||
	u64				ip;
 | 
			
		||||
| 
						 | 
				
			
			@ -1079,9 +1079,13 @@ static inline void perf_sample_data_init(struct perf_sample_data *data,
 | 
			
		|||
{
 | 
			
		||||
	/* remaining struct members initialized in perf_prepare_sample() */
 | 
			
		||||
	data->sample_flags = 0;
 | 
			
		||||
	data->addr = addr;
 | 
			
		||||
	data->raw  = NULL;
 | 
			
		||||
	data->period = period;
 | 
			
		||||
 | 
			
		||||
	if (addr) {
 | 
			
		||||
		data->addr = addr;
 | 
			
		||||
		data->sample_flags |= PERF_SAMPLE_ADDR;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7414,6 +7414,11 @@ void perf_prepare_sample(struct perf_event_header *header,
 | 
			
		|||
	if (filtered_sample_type & PERF_SAMPLE_TRANSACTION)
 | 
			
		||||
		data->txn = 0;
 | 
			
		||||
 | 
			
		||||
	if (sample_type & (PERF_SAMPLE_ADDR | PERF_SAMPLE_PHYS_ADDR | PERF_SAMPLE_DATA_PAGE_SIZE)) {
 | 
			
		||||
		if (filtered_sample_type & PERF_SAMPLE_ADDR)
 | 
			
		||||
			data->addr = 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (sample_type & PERF_SAMPLE_REGS_INTR) {
 | 
			
		||||
		/* regs dump ABI info */
 | 
			
		||||
		int size = sizeof(u64);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue