Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751864AbdHDSNX (ORCPT ); Fri, 4 Aug 2017 14:13:23 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:54238 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751281AbdHDSNW (ORCPT ); Fri, 4 Aug 2017 14:13:22 -0400 Date: Fri, 4 Aug 2017 23:43:08 +0530 From: "Naveen N. Rao" To: Peter Zijlstra Cc: Jiri Olsa , Arnaldo Carvalho de Melo , Ingo Molnar , Vince Weaver , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] kernel/events: Add option to enable counting sideband events in wakeup_events References: <3e7dabc8a4762aad3836244661f843dda689588b.1501576497.git.naveen.n.rao@linux.vnet.ibm.com> <20170804105922.uaxuj3ote263ofec@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170804105922.uaxuj3ote263ofec@hirez.programming.kicks-ass.net> User-Agent: NeoMutt/20170714 (1.8.3) X-TM-AS-MML: disable x-cbid: 17080418-0012-0000-0000-00000258845B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17080418-0013-0000-0000-000007732734 Message-Id: <20170804181308.z7efoyqm7bcnmut4@naverao1-tp.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-08-04_10:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1708040281 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1677 Lines: 51 On 2017/08/04 12:59PM, Peter Zijlstra wrote: > On Tue, Aug 01, 2017 at 08:14:04PM +0530, Naveen N. Rao wrote: > > @@ -5974,19 +5976,8 @@ void perf_output_sample(struct perf_output_handle *handle, > > } > > } > > > > + if (!event->attr.count_sb_events) > > + rb_handle_wakeup_events(event, handle->rb); > > } > > > +void __always_inline > > +rb_handle_wakeup_events(struct perf_event *event, struct ring_buffer *rb) > > +{ > > + int wakeup_events = event->attr.wakeup_events; > > + > > + if (!event->attr.watermark && wakeup_events) { > > + int events = local_inc_return(&rb->events); > > + > > + if (events >= wakeup_events) { > > + local_sub(wakeup_events, &rb->events); > > + local_inc(&rb->wakeup); > > + } > > + } > > +} > > + > > static int __always_inline > > __perf_output_begin(struct perf_output_handle *handle, > > struct perf_event *event, unsigned int size, > > @@ -197,6 +212,9 @@ __perf_output_begin(struct perf_output_handle *handle, > > * none of the data stores below can be lifted up by the compiler. > > */ > > > > + if (unlikely(event->attr.count_sb_events)) > > + rb_handle_wakeup_events(event, rb); > > + > > if (unlikely(head - local_read(&rb->wakeup) > rb->watermark)) > > local_add(rb->watermark, &rb->wakeup); > > > > I'm still slightly uneasy over this.. Yes most of our events are > samples, so we'd pay the overhead already. But could you still look at > performance of this, see for example this commit: > > 9ecda41acb97 ("perf/core: Add ::write_backward attribute to perf event") > > we went through a lot of variants to not hurt performance. Sure. I'll run the tests and get back. Thanks, Naveen