mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	perf/core: Remove pmu linear searching code
Searching for the right pmu by iterating over all pmus is no longer required since all pmus now *must* be present in the 'pmu_idr' list. So, remove linear searching code. Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20230504110003.2548-4-ravi.bangoria@amd.com
This commit is contained in:
		
							parent
							
								
									2fad201fe3
								
							
						
					
					
						commit
						9551fbb64d
					
				
					 1 changed files with 13 additions and 24 deletions
				
			
		| 
						 | 
					@ -11630,38 +11630,27 @@ static struct pmu *perf_init_event(struct perf_event *event)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
again:
 | 
					again:
 | 
				
			||||||
 | 
						ret = -ENOENT;
 | 
				
			||||||
	rcu_read_lock();
 | 
						rcu_read_lock();
 | 
				
			||||||
	pmu = idr_find(&pmu_idr, type);
 | 
						pmu = idr_find(&pmu_idr, type);
 | 
				
			||||||
	rcu_read_unlock();
 | 
						rcu_read_unlock();
 | 
				
			||||||
	if (pmu) {
 | 
						if (!pmu)
 | 
				
			||||||
		if (event->attr.type != type && type != PERF_TYPE_RAW &&
 | 
							goto fail;
 | 
				
			||||||
		    !(pmu->capabilities & PERF_PMU_CAP_EXTENDED_HW_TYPE))
 | 
					 | 
				
			||||||
			goto fail;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ret = perf_try_init_event(pmu, event);
 | 
						if (event->attr.type != type && type != PERF_TYPE_RAW &&
 | 
				
			||||||
		if (ret == -ENOENT && event->attr.type != type && !extended_type) {
 | 
						    !(pmu->capabilities & PERF_PMU_CAP_EXTENDED_HW_TYPE))
 | 
				
			||||||
			type = event->attr.type;
 | 
							goto fail;
 | 
				
			||||||
			goto again;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (ret)
 | 
						ret = perf_try_init_event(pmu, event);
 | 
				
			||||||
			pmu = ERR_PTR(ret);
 | 
						if (ret == -ENOENT && event->attr.type != type && !extended_type) {
 | 
				
			||||||
 | 
							type = event->attr.type;
 | 
				
			||||||
		goto unlock;
 | 
							goto again;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	list_for_each_entry_rcu(pmu, &pmus, entry, lockdep_is_held(&pmus_srcu)) {
 | 
					 | 
				
			||||||
		ret = perf_try_init_event(pmu, event);
 | 
					 | 
				
			||||||
		if (!ret)
 | 
					 | 
				
			||||||
			goto unlock;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (ret != -ENOENT) {
 | 
					 | 
				
			||||||
			pmu = ERR_PTR(ret);
 | 
					 | 
				
			||||||
			goto unlock;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
fail:
 | 
					fail:
 | 
				
			||||||
	pmu = ERR_PTR(-ENOENT);
 | 
						if (ret)
 | 
				
			||||||
 | 
							pmu = ERR_PTR(ret);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
unlock:
 | 
					unlock:
 | 
				
			||||||
	srcu_read_unlock(&pmus_srcu, idx);
 | 
						srcu_read_unlock(&pmus_srcu, idx);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue