From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2454 invoked by alias); 12 Nov 2009 00:06:45 -0000 Received: (qmail 2445 invoked by uid 22791); 12 Nov 2009 00:06:45 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from smtp-outbound-1.vmware.com (HELO smtp-outbound-1.vmware.com) (65.115.85.69) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 12 Nov 2009 00:06:39 +0000 Received: from jupiter.vmware.com (mailhost5.vmware.com [10.16.68.131]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 1499D13B4D; Wed, 11 Nov 2009 16:06:36 -0800 (PST) Received: from [10.20.94.141] (msnyder-server.eng.vmware.com [10.20.94.141]) by jupiter.vmware.com (Postfix) with ESMTP id 08795DC05D; Wed, 11 Nov 2009 16:06:36 -0800 (PST) Message-ID: <4AFB512D.1050900@vmware.com> Date: Thu, 12 Nov 2009 00:06:00 -0000 From: Michael Snyder User-Agent: Thunderbird 1.5.0.12 (X11/20090624) MIME-Version: 1.0 To: Doug Evans CC: "gdb-patches@sourceware.org" Subject: Re: [RFA] dcache invalidate fix References: <4AF9DC39.7030207@vmware.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-11/txt/msg00271.txt.bz2 Doug Evans wrote: > On Tue, Nov 10, 2009 at 1:33 PM, Michael Snyder wrote: >> Doug, I'm vague about this, but it seems right and it fixes the >> bug that I'm running into. >> >> It seems like dcache_invalidate_line needs to remove the block >> from the in use list at the same time as adding it to the freed >> list. >> >> The problem that bit me was getting the two lists cross-linked, >> which eventually led to an infinite loop behavior in dcache_invalidate. >> >> >> 2009-11-10 Michael Snyder >> >> * dcache.c (dcache_invalidate_line): Remove block from used list >> when adding it to freed list. >> >> Index: dcache.c >> =================================================================== >> RCS file: /cvs/src/src/gdb/dcache.c,v >> retrieving revision 1.37 >> diff -u -p -r1.37 dcache.c >> --- dcache.c 10 Nov 2009 18:36:50 -0000 1.37 >> +++ dcache.c 10 Nov 2009 21:31:03 -0000 >> @@ -167,10 +167,18 @@ dcache_invalidate_line (DCACHE *dcache, >> >> if (db) >> { >> + struct dcache_block *db2; >> splay_tree_remove (dcache->tree, (splay_tree_key) db->addr); >> db->newer = dcache->freelist; >> dcache->freelist = db; >> --dcache->size; >> + /* Remove db from dcache in-use chain. */ >> + for (db2 = dcache->oldest; db2; db2 = db2->newer) >> + if (db2->newer == db) >> + { >> + dcache->newest = db2; >> + db2->newer = NULL; >> + } >> } >> } > > Blech. Thanks for catching this. > > The list will contain 4096 elements at this point so I think we need > to do something different. > The following comes to mind. > > I'll check it in in a few days if there are no objections. FYI, this fixes the problem that caused me to look into it. Thanks, Michael > 2009-11-11 Doug Evans > > * dcache.c (dcache_block): Replace member newer with next,prev. > (dcache_struct): Delete member newest. > (block_func): New typedef. > (append_block, remove_block, for_each_block): New functions. > (invalidate_block, free_block): New functions. > (dcache_invalidate): Update > (dcache_invalidate_line, dcache_alloc): Update to use new list > accessors. > (dcache_free): Ditto. Fix memory leak.