int ret = 0;
        struct evsel *first_wildcard_match = NULL;
 
-       while ((pmu = perf_pmus__scan(pmu)) != NULL) {
+       while ((pmu = perf_pmus__scan_for_event(pmu, name)) != NULL) {
                LIST_HEAD(config_terms);
                struct perf_event_attr attr;
 
 
        INIT_LIST_HEAD(list);
 
-       while ((pmu = perf_pmus__scan(pmu)) != NULL) {
+       while ((pmu = perf_pmus__scan_for_event(pmu, event_name)) != NULL) {
+
                if (parse_events__filter_pmu(parse_state, pmu))
                        continue;
 
 
        pmu = NULL;
        /* Failed to add, try wildcard expansion of event_or_pmu as a PMU name. */
-       while ((pmu = perf_pmus__scan(pmu)) != NULL) {
-               if (!parse_events__filter_pmu(parse_state, pmu) &&
-                   perf_pmu__wildcard_match(pmu, event_or_pmu)) {
-                       if (!parse_events_add_pmu(parse_state, *listp, pmu,
-                                                 const_parsed_terms,
-                                                 first_wildcard_match,
-                                                 /*alternate_hw_config=*/PERF_COUNT_HW_MAX)) {
-                               ok++;
-                               parse_state->wild_card_pmus = true;
-                       }
-                       if (first_wildcard_match == NULL)
-                               first_wildcard_match =
-                                       container_of((*listp)->prev, struct evsel, core.node);
+       while ((pmu = perf_pmus__scan_matching_wildcard(pmu, event_or_pmu)) != NULL) {
+
+               if (parse_events__filter_pmu(parse_state, pmu))
+                       continue;
+
+               if (!parse_events_add_pmu(parse_state, *listp, pmu,
+                                         const_parsed_terms,
+                                         first_wildcard_match,
+                                         /*alternate_hw_config=*/PERF_COUNT_HW_MAX)) {
+                       ok++;
+                       parse_state->wild_card_pmus = true;
+               }
+               if (first_wildcard_match == NULL) {
+                       first_wildcard_match =
+                               container_of((*listp)->prev, struct evsel, core.node);
                }
        }
        if (ok)
 
 #include "tool_pmu.h"
 #include "print-events.h"
 #include "strbuf.h"
+#include "string2.h"
 
 /*
  * core_pmus:  A PMU belongs to core_pmus if it's name is "cpu" or it's sysfs
        return NULL;
 }
 
+struct perf_pmu *perf_pmus__scan_for_event(struct perf_pmu *pmu, const char *event)
+{
+       bool use_core_pmus = !pmu || pmu->is_core;
+
+       if (!pmu) {
+               /* Hwmon filename values that aren't used. */
+               enum hwmon_type type;
+               int number;
+               /*
+                * Core PMUs, other sysfs PMUs and tool PMU can take all event
+                * types or aren't wother optimizing for.
+                */
+               unsigned int to_read_pmus =  PERF_TOOL_PMU_TYPE_PE_CORE_MASK |
+                       PERF_TOOL_PMU_TYPE_PE_OTHER_MASK |
+                       PERF_TOOL_PMU_TYPE_TOOL_MASK;
+
+               /* Could the event be a hwmon event? */
+               if (parse_hwmon_filename(event, &type, &number, /*item=*/NULL, /*alarm=*/NULL))
+                       to_read_pmus |= PERF_TOOL_PMU_TYPE_HWMON_MASK;
+
+               pmu_read_sysfs(to_read_pmus);
+               pmu = list_prepare_entry(pmu, &core_pmus, list);
+       }
+       if (use_core_pmus) {
+               list_for_each_entry_continue(pmu, &core_pmus, list)
+                       return pmu;
+
+               pmu = NULL;
+               pmu = list_prepare_entry(pmu, &other_pmus, list);
+       }
+       list_for_each_entry_continue(pmu, &other_pmus, list)
+               return pmu;
+       return NULL;
+}
+
+struct perf_pmu *perf_pmus__scan_matching_wildcard(struct perf_pmu *pmu, const char *wildcard)
+{
+       bool use_core_pmus = !pmu || pmu->is_core;
+
+       if (!pmu) {
+               /*
+                * Core PMUs, other sysfs PMUs and tool PMU can have any name or
+                * aren't wother optimizing for.
+                */
+               unsigned int to_read_pmus =  PERF_TOOL_PMU_TYPE_PE_CORE_MASK |
+                       PERF_TOOL_PMU_TYPE_PE_OTHER_MASK |
+                       PERF_TOOL_PMU_TYPE_TOOL_MASK;
+
+               /*
+                * Hwmon PMUs have an alias from a sysfs name like hwmon0,
+                * hwmon1, etc. or have a name of hwmon_<name>. They therefore
+                * can only have a wildcard match if the wildcard begins with
+                * "hwmon".
+                */
+               if (strisglob(wildcard) ||
+                   (strlen(wildcard) >= 5 && strncmp("hwmon", wildcard, 5) == 0))
+                       to_read_pmus |= PERF_TOOL_PMU_TYPE_HWMON_MASK;
+
+               pmu_read_sysfs(to_read_pmus);
+               pmu = list_prepare_entry(pmu, &core_pmus, list);
+       }
+       if (use_core_pmus) {
+               list_for_each_entry_continue(pmu, &core_pmus, list) {
+                       if (perf_pmu__wildcard_match(pmu, wildcard))
+                               return pmu;
+               }
+               pmu = NULL;
+               pmu = list_prepare_entry(pmu, &other_pmus, list);
+       }
+       list_for_each_entry_continue(pmu, &other_pmus, list) {
+               if (perf_pmu__wildcard_match(pmu, wildcard))
+                       return pmu;
+       }
+       return NULL;
+}
+
 static struct perf_pmu *perf_pmus__scan_skip_duplicates(struct perf_pmu *pmu)
 {
        bool use_core_pmus = !pmu || pmu->is_core;