lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 17 Jul 2015 15:03:36 +0000
From:	"Liang, Kan" <kan.liang@...el.com>
To:	Mark Rutland <mark.rutland@....com>
CC:	"a.p.zijlstra@...llo.nl" <a.p.zijlstra@...llo.nl>,
	"mingo@...hat.com" <mingo@...hat.com>,
	"acme@...nel.org" <acme@...nel.org>,
	"eranian@...gle.com" <eranian@...gle.com>,
	"ak@...ux.intel.com" <ak@...ux.intel.com>,
	"Hunter, Adrian" <adrian.hunter@...el.com>,
	"dsahern@...il.com" <dsahern@...il.com>,
	"jolsa@...nel.org" <jolsa@...nel.org>,
	"namhyung@...nel.org" <namhyung@...nel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH 3/9] perf/x86: Add is_hardware_event

> 
> On Thu, Jul 16, 2015 at 09:33:45PM +0100, kan.liang@...el.com wrote:
> > From: Kan Liang <kan.liang@...el.com>
> >
> > Using is_hardware_event to replace !is_software_event to indicate a
> > hardware event.
> 
> Why...?

First, the comments of is_software_event is not correct. 
0 or !is_software_event is not for a hardware event.
is_hardware_event is for a hardware event.

Also, the following patch make mix core_misc event be part of hw/sw
event, !is_software_event could be either hw event or core_misc event.
We need an accurate definition here.

> 
> For an uncore event e, is_hardware_event(e) != !is_software_event(e),
> so this will be a change of behaviour...

Uncore event cannot be part of hw/sw event group. So it doesn't change the behavior. 

> 
> >
> > Signed-off-by: Kan Liang <kan.liang@...el.com>
> > ---
> >  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);
> 
> ... whereby we won't accuont uncore events as active, and thereforef will
> never perform throttling.
> 
> That doesn't sound right.

I think active_oncpu should only impact if the group is exclusive.
The changes will make pure perf_invalid_context event group never exclusive.
If that's a problem, I will change this part back.

Thanks,
Kan

> 
> Mark.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ