Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756811AbdGLLse (ORCPT ); Wed, 12 Jul 2017 07:48:34 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:34055 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756401AbdGLLsc (ORCPT ); Wed, 12 Jul 2017 07:48:32 -0400 Date: Wed, 12 Jul 2017 13:48:29 +0200 From: Peter Zijlstra To: "Naveen N. Rao" Cc: Arnaldo Carvalho de Melo , Jiri Olsa , Ingo Molnar , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] kernel/events: Add option to enable counting sideband events in wakeup_events Message-ID: <20170712114829.v2tbvk37xdkkwqme@hirez.programming.kicks-ass.net> References: <3e1d5fea814758906c64b01e1eed186daaf2c9ed.1497881378.git.naveen.n.rao@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3e1d5fea814758906c64b01e1eed186daaf2c9ed.1497881378.git.naveen.n.rao@linux.vnet.ibm.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 957 Lines: 28 On Mon, Jun 19, 2017 at 08:01:08PM +0530, Naveen N. Rao wrote: > diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c > index 4e7c728569a8..f43a6081141f 100644 > --- a/kernel/events/ring_buffer.c > +++ b/kernel/events/ring_buffer.c > @@ -197,6 +197,19 @@ __perf_output_begin(struct perf_output_handle *handle, > * none of the data stores below can be lifted up by the compiler. > */ > > + if (event->attr.count_sb_events && !event->attr.watermark) { > + int wakeup_events = event->attr.wakeup_events; > + > + if (wakeup_events) { > + int events = local_inc_return(&rb->events); > + > + if (events >= wakeup_events) { > + local_sub(wakeup_events, &rb->events); > + local_inc(&rb->wakeup); > + } > + } > + } > + > if (unlikely(head - local_read(&rb->wakeup) > rb->watermark)) > local_add(rb->watermark, &rb->wakeup); > So this is a very performance sensitive function; not at all happy to add bits here ... :/