From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755835Ab3KLPex (ORCPT ); Tue, 12 Nov 2013 10:34:53 -0500 Received: from merlin.infradead.org ([205.233.59.134]:34217 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753960Ab3KLPet (ORCPT ); Tue, 12 Nov 2013 10:34:49 -0500 Date: Tue, 12 Nov 2013 16:34:40 +0100 From: Peter Zijlstra To: David Ahern Cc: Ingo Molnar , acme@ghostprotocols.net, linux-kernel@vger.kernel.org, Frederic Weisbecker , Jiri Olsa , Namhyung Kim , Mike Galbraith , Stephane Eranian Subject: Re: [PATCH] perf record: Delete file if a failure occurs writing the perf data file Message-ID: <20131112153440.GZ5056@laptop.programming.kicks-ass.net> References: <1383928906-31470-1-git-send-email-dsahern@gmail.com> <20131111093747.GA14810@gmail.com> <5280ECFF.10103@gmail.com> <52824064.4060100@gmail.com> <20131112150410.GW5056@laptop.programming.kicks-ass.net> <5282484E.9010206@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5282484E.9010206@gmail.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 12, 2013 at 08:25:02AM -0700, David Ahern wrote: > On 11/12/13, 8:04 AM, Peter Zijlstra wrote: > >On Tue, Nov 12, 2013 at 07:51:16AM -0700, David Ahern wrote: > >>> From man mmap: > >>> SIGBUS Attempted access to a portion of the buffer that > >>> does not correspond to the file (for example, beyond > >>> the end of the file, ... > > > >SIGBUS is basically the std fail for any fault; there's a ton more > >reasons than listed in that manpage. > > > >Failing to dirty a page due to -ENOSPACE is one reason we'll > >trigger SIGBUS -- as you already found in that memcpy to mmap() instead > >of write() patch. > > Sure. Lots of mmaps flying around, so to make sure we are on the same page > in this case we are talking about perf-report reading a file via mmap. > > If the file creation (be it memcpy to mmap() or write()) has a failure due > to lack of space, then only a partial event is in the file -- e.g., > perf-header only. Trying to read the rest of the event leads to perf-report > terminating due to SIGBUS. How should that condition be handled? > > The patch in this thread deletes the file. Another option is to rewind the > file to the last known good write (ie., length after last successful call to > write_output). I'd report a warning and continue with all events that you could read upto that point.