From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30771 invoked by alias); 25 Jul 2011 19:22:01 -0000 Received: (qmail 30758 invoked by uid 22791); 25 Jul 2011 19:22:00 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 25 Jul 2011 19:21:46 +0000 Received: (qmail 12686 invoked from network); 25 Jul 2011 19:21:45 -0000 Received: from unknown (HELO scottsdale.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 25 Jul 2011 19:21:45 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [RFC][patch] Make DCACHE_LINE runtime-settable Date: Mon, 25 Jul 2011 19:32:00 -0000 User-Agent: KMail/1.13.6 (Linux/2.6.38-8-generic; KDE/4.6.2; x86_64; ; ) Cc: Paul Pluzhnikov , Tom Tromey References: <20110722222025.ED9B6190B14@elbrus2.mtv.corp.google.com> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201107252021.39702.pedro@codesourcery.com> 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: 2011-07/txt/msg00705.txt.bz2 Hi Paul, On Monday 25 July 2011 19:32:51, Paul Pluzhnikov wrote: > > -/* The size of a cache line. Smaller values reduce the time taken to > +/* The default size of a cache line. Smaller values reduce the time taken to > read a single byte and make the cache more granular, but increase > overhead and reduce the effectiveness of the cache as a prefetcher. */ > -#define LINE_SIZE_POWER 6 > -#define LINE_SIZE (1 << LINE_SIZE_POWER) > +#define DCACHE_DEFAULT_LINE_SIZE 64 > +static unsigned dcache_line_size = DCACHE_DEFAULT_LINE_SIZE; > > /* Each cache block holds LINE_SIZE bytes of data > starting at a multiple-of-LINE_SIZE address. */ > > -#define LINE_SIZE_MASK ((LINE_SIZE - 1)) > -#define XFORM(x) ((x) & LINE_SIZE_MASK) > -#define MASK(x) ((x) & ~LINE_SIZE_MASK) > +#define LINE_SIZE_MASK(dcache) ((dcache->line_size - 1)) > +#define XFORM(dcache, x) ((x) & LINE_SIZE_MASK(dcache)) > +#define MASK(dcache, x) ((x) & ~LINE_SIZE_MASK(dcache)) Missing space after LINE_SIZE_MASK and before `('. > > struct dcache_block > { > @@ -93,8 +98,8 @@ struct dcache_block > struct dcache_block *next; > > CORE_ADDR addr; /* address of data */ > - gdb_byte data[LINE_SIZE]; /* bytes at given address */ > int refs; /* # hits */ > + gdb_byte data[0]; /* line_size bytes at given address */ Arrays of 0 length are not valid C90. Please make that `gdb_byte data[1]' and adjust allocation accordingly (using offsetof (..., data) instead of sizeof, or just subtracting 1). > +/* BLOCK_FUNC routine for dcache_free. */ > + > +static void > +free_block (struct dcache_block *block, void *param) > +{ > + free (block); xfree. > > +static void > +set_dcache_size (char *args, int from_tty, > + struct cmd_list_element *c) > +{ > + if (dcache_size <= 0) Given: > +static unsigned dcache_size = DCACHE_DEFAULT_SIZE; That < 0 can't ever return true. > + { > + unsigned d = dcache_size; > + dcache_size = DCACHE_DEFAULT_SIZE; > + error (_("Invalid dcache size: %u (must be positive)."), d); If you meant to support negatives in the setting, is printing the number as unsigned your intention? I think it'll look confusing? > + add_setshow_uinteger_cmd ("line-size", class_obscure, > + &dcache_line_size, _("\ > +Set dcache line size in bytes (must be power of 2)."), _("\ > +Show dcache line size."), > + NULL, > + set_dcache_line_size, > + NULL, > + &dcache_set_list, &dcache_show_list); > + add_setshow_uinteger_cmd ("size", class_obscure, ... you've registered the command as ..._uinteger... so it all looks like the "must be positive" bits are dead, and you just want to forbit 0. -- Pedro Alves