Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751635AbaDYOwK (ORCPT ); Fri, 25 Apr 2014 10:52:10 -0400 Received: from casper.infradead.org ([85.118.1.10]:42771 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751061AbaDYOwI (ORCPT ); Fri, 25 Apr 2014 10:52:08 -0400 Date: Fri, 25 Apr 2014 16:52:05 +0200 From: Peter Zijlstra To: Robert Richter Cc: Jean Pihet , Borislav Petkov , Ingo Molnar , Arnaldo Carvalho de Melo , Jiri Olsa , linux-kernel@vger.kernel.org, Al Viro Subject: Re: [PATCH 04/16] perf, mmap: Factor out perf_get_fd() Message-ID: <20140425145205.GV13658@twins.programming.kicks-ass.net> References: <1396883078-25320-1-git-send-email-jean.pihet@linaro.org> <1396883078-25320-5-git-send-email-jean.pihet@linaro.org> <20140422142759.GM11182@twins.programming.kicks-ass.net> <20140425135413.GE32718@rric.localhost> <20140425144301.GI11096@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140425144301.GI11096@twins.programming.kicks-ass.net> 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 Fri, Apr 25, 2014 at 04:43:01PM +0200, Peter Zijlstra wrote: > On Fri, Apr 25, 2014 at 03:54:13PM +0200, Robert Richter wrote: > > I guess its this patch from Al you referring to: > > > > ea635c6 Fix racy use of anon_inode_getfd() in perf_event.c > > > > I think we do not introduce it back due to: > > > > a6fa941 perf_event: Switch to internal refcount, fix race with close() > > > > which removes the user of event_file. > > linux-2.6# git show a6fa941 > error: short SHA1 a6fa941 is ambiguous. > error: short SHA1 a6fa941 is ambiguous. > fatal: ambiguous argument 'a6fa941': unknown revision or path not in the working tree. > > Which is I think why Linus makes us use 12 chars instead of the git > default of 8. > > Of course its also entirely useless of git to not list the full IDs for > those it did find to be ambiguous. ok, so its a6fa941d94b4. But no, I don't think that helps, its still true that the moment you get a fd another thread can immediately close(). That would drop the last ref and free it, meanwhile perf_event_open() is happily poking at it. Now I think you could cure this by adding an extra ref before calling your perf_get_fd() and dropping that extra ref at the end, where we used to have fd_install(). -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/