From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755235Ab0EQMDp (ORCPT ); Mon, 17 May 2010 08:03:45 -0400 Received: from smtp-out.google.com ([74.125.121.35]:46695 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755185Ab0EQMDn (ORCPT ); Mon, 17 May 2010 08:03:43 -0400 DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=message-id:from:date:to:reply-to:cc:subject:x-system-of-record; b=jKSh9V6H/Zqc7bp9cEpOQyueWyTyoy5VXPkkKtuiFcueu+MO3eSWfOGtiHHi5Lgua ZLUqRzRM3wN2+cLopgvSw== Message-ID: <4bf13099.698fd80a.503a.ffffacd5@mx.google.com> From: Stephane Eranian Date: Mon, 17 May 2010 12:46:01 +0200 To: linux-kernel@vger.kernel.org Reply-to: eranian@google.com Cc: peterz@infradead.org, mingo@elte.hu, paulus@samba.org, davem@davemloft.net, fweisbec@gmail.com, acme@infradead.org, perfmon2-devel@lists.sf.net, eranian@gmail.com, eranian@google.com, jkacur@redhat.com Subject: [PATCH] perf_events: fix errors path in perf_output_begin() (take 2) X-System-Of-Record: true Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case the sampling buffer has no "payload" pages, nr_pages is 0. The problem is that the error path in perf_output_begin() skips to a label which assumes perf_output_lock() has been issued which is not the case. That triggers a WARN_ON() is perf_output_unlock(). This patch fixes the problem by skipping perf_output_unlock() in case data->nr_pages is 0 while maintaining the accounting for data->lost. Signed-off-by: Stephane Eranian -- diff --git a/kernel/perf_event.c b/kernel/perf_event.c index a4fa381..95137b6 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c @@ -3035,8 +3035,10 @@ int perf_output_begin(struct perf_output_handle *handle, handle->nmi = nmi; handle->sample = sample; - if (!data->nr_pages) - goto fail; + if (!data->nr_pages) { + atomic_inc(&data->lost); + goto out; + } have_lost = atomic_read(&data->lost); if (have_lost)