From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754118AbYKMRVT (ORCPT ); Thu, 13 Nov 2008 12:21:19 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751684AbYKMRVF (ORCPT ); Thu, 13 Nov 2008 12:21:05 -0500 Received: from hrndva-omtalb.mail.rr.com ([71.74.56.125]:37327 "EHLO hrndva-omtalb.mail.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751608AbYKMRVE (ORCPT ); Thu, 13 Nov 2008 12:21:04 -0500 Date: Thu, 13 Nov 2008 12:21:00 -0500 (EST) From: Steven Rostedt X-X-Sender: rostedt@gandalf.stny.rr.com To: Andi Kleen cc: =?ISO-8859-15?Q?Fr=E9d=E9ric_Weisbecker?= , Ingo Molnar , Linux Kernel Subject: Re: [PATCH 1/2] tracing/function-return-tracer: Make the function return tracer lockless In-Reply-To: <20081113171220.GX3810@one.firstfloor.org> Message-ID: References: <491B4F0A.3080901@gmail.com> <87od0jd6ds.fsf@basil.nowhere.org> <20081113171220.GX3810@one.firstfloor.org> User-Agent: Alpine 1.10 (DEB 962 2008-03-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 13 Nov 2008, Andi Kleen wrote: > > > local register i > > > i = index; > > > write to index'ed array using i > > > <--------- interrupt here would overwrite data > > > ... > > > index = i + 1; > > > > > > Yes in the common case that would be a danger. But here, if an > > interrupt is raised, it will increment > > the counter and then decrement it at return time without dropping the > > cpu. So after the interrupt, the > > value will remain the same... > > The buffer contents will not be necessarily > the same. See the scenario above. The interrupt would use the > same i as the current function and would overwrite the > partially written entry. So the answer to this is: i = index++; barrier(); write to index i (not index); -- Steve