Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754790AbbGQDsg (ORCPT ); Thu, 16 Jul 2015 23:48:36 -0400 Received: from mga11.intel.com ([192.55.52.93]:62184 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754200AbbGQDse (ORCPT ); Thu, 16 Jul 2015 23:48:34 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,492,1432623600"; d="scan'208";a="607841819" From: kan.liang@intel.com To: a.p.zijlstra@chello.nl Cc: mingo@redhat.com, acme@kernel.org, eranian@google.com, ak@linux.intel.com, mark.rutland@arm.com, adrian.hunter@intel.com, dsahern@gmail.com, jolsa@kernel.org, namhyung@kernel.org, linux-kernel@vger.kernel.org, Kan Liang Subject: [PATCH 3/9] perf/x86: Add is_hardware_event Date: Thu, 16 Jul 2015 16:33:45 -0400 Message-Id: <1437078831-10152-4-git-send-email-kan.liang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1437078831-10152-1-git-send-email-kan.liang@intel.com> References: <1437078831-10152-1-git-send-email-kan.liang@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2330 Lines: 74 From: Kan Liang Using is_hardware_event to replace !is_software_event to indicate a hardware event. Signed-off-by: Kan Liang --- include/linux/perf_event.h | 7 ++++++- kernel/events/core.c | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 2027809..fea0ddf 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -761,13 +761,18 @@ static inline bool is_sampling_event(struct perf_event *event) } /* - * Return 1 for a software event, 0 for a hardware event + * Return 1 for a software event, 0 for other event */ static inline int is_software_event(struct perf_event *event) { return event->pmu->task_ctx_nr == perf_sw_context; } +static inline int is_hardware_event(struct perf_event *event) +{ + return event->pmu->task_ctx_nr == perf_hw_context; +} + extern struct static_key perf_swevent_enabled[PERF_COUNT_SW_MAX]; extern void ___perf_sw_event(u32, u64, struct pt_regs *, u64); diff --git a/kernel/events/core.c b/kernel/events/core.c index d3dae34..9077867 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -1347,7 +1347,7 @@ static void perf_group_attach(struct perf_event *event) WARN_ON_ONCE(group_leader->ctx != event->ctx); if (group_leader->group_flags & PERF_GROUP_SOFTWARE && - !is_software_event(event)) + is_hardware_event(event)) group_leader->group_flags &= ~PERF_GROUP_SOFTWARE; list_add_tail(&event->group_entry, &group_leader->sibling_list); @@ -1553,7 +1553,7 @@ event_sched_out(struct perf_event *event, event->pmu->del(event, 0); event->oncpu = -1; - if (!is_software_event(event)) + if (is_hardware_event(event)) cpuctx->active_oncpu--; if (!--ctx->nr_active) perf_event_ctx_deactivate(ctx); @@ -1881,7 +1881,7 @@ event_sched_in(struct perf_event *event, goto out; } - if (!is_software_event(event)) + if (is_hardware_event(event)) cpuctx->active_oncpu++; if (!ctx->nr_active++) perf_event_ctx_activate(ctx); -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/