Skip to content

Commit 6e855cd

Browse files
virtuosoIngo Molnar
authored andcommitted
perf/core: Let userspace know if the PMU supports address filters
Export an additional common attribute for PMUs that support address range filtering to let the perf userspace identify such PMUs in a uniform way. Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Mathieu Poirier <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vince Weaver <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/1461771888-10409-8-git-send-email-alexander.shishkin@linux.intel.com Signed-off-by: Ingo Molnar <[email protected]>
1 parent eadf48c commit 6e855cd

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

kernel/events/core.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8273,6 +8273,20 @@ static void free_pmu_context(struct pmu *pmu)
82738273
out:
82748274
mutex_unlock(&pmus_lock);
82758275
}
8276+
8277+
/*
8278+
* Let userspace know that this PMU supports address range filtering:
8279+
*/
8280+
static ssize_t nr_addr_filters_show(struct device *dev,
8281+
struct device_attribute *attr,
8282+
char *page)
8283+
{
8284+
struct pmu *pmu = dev_get_drvdata(dev);
8285+
8286+
return snprintf(page, PAGE_SIZE - 1, "%d\n", pmu->nr_addr_filters);
8287+
}
8288+
DEVICE_ATTR_RO(nr_addr_filters);
8289+
82768290
static struct idr pmu_idr;
82778291

82788292
static ssize_t
@@ -8374,9 +8388,19 @@ static int pmu_dev_alloc(struct pmu *pmu)
83748388
if (ret)
83758389
goto free_dev;
83768390

8391+
/* For PMUs with address filters, throw in an extra attribute: */
8392+
if (pmu->nr_addr_filters)
8393+
ret = device_create_file(pmu->dev, &dev_attr_nr_addr_filters);
8394+
8395+
if (ret)
8396+
goto del_dev;
8397+
83778398
out:
83788399
return ret;
83798400

8401+
del_dev:
8402+
device_del(pmu->dev);
8403+
83808404
free_dev:
83818405
put_device(pmu->dev);
83828406
goto out;
@@ -8512,6 +8536,8 @@ void perf_pmu_unregister(struct pmu *pmu)
85128536
free_percpu(pmu->pmu_disable_count);
85138537
if (pmu->type >= PERF_TYPE_MAX)
85148538
idr_remove(&pmu_idr, pmu->type);
8539+
if (pmu->nr_addr_filters)
8540+
device_remove_file(pmu->dev, &dev_attr_nr_addr_filters);
85158541
device_del(pmu->dev);
85168542
put_device(pmu->dev);
85178543
free_pmu_context(pmu);

0 commit comments

Comments
 (0)