Subject: MIPS bus_space macros vs functions
To: None <port-mips@netbsd.org>
From: Simon Burge <simonb@wasabisystems.com>
List: port-mips
Date: 11/26/2005 01:06:40
In light of the recent talk about macros, I had a little play with
converting the macros in <mips/bus_space.h> to functions in a new
file (mips/mips/bus_space.c).
To pick on example, in <mips/bus_space.h> instead of:
#define bus_space_read_1(t, h, o) \
__bs_rs(1,uint8_t,(t),(h),(o))
there's now:
u_int8_t bus_space_read_1(bus_space_tag_t, \
bus_space_handle_t, bus_size_t);
(line wraps for this email) and bus_space.c has:
u_int8_t
bus_space_read_1(bus_space_tag_t space,
bus_space_handle_t handle, bus_size_t offset)
{
return __bs_rs(1,uint8_t,space,handle,offset);
}
For an evbmips/malta kernel, the old and new kernels are:
text data bss dec hex filename
1948008 177488 61732 2187228 215fdc netbsd.old
1913432 177488 61732 2152652 20d8cc netbsd.new
For an evbmips/pb1000 kernel, the savings are a bit less since there's
fewer drivers that use bus_space functions:
text data bss dec hex filename
2304760 210736 74536 2590032 278550 netbsd.old
2292904 210736 74536 2578176 275700 netbsd.new
To pick a benchmark at random, building tcsh over NFS on an pb1500 board
(which uses bus_space functions in it's ethernet driver) before took:
350.520u 44.351s 6:58.84 94.2% 0+0k 0+0io 185pf+0w
349.663u 44.458s 6:59.13 94.0% 0+0k 0+0io 7pf+0w
349.797u 44.109s 6:56.85 94.4% 0+0k 0+0io 7pf+0w
and after took:
351.099u 44.318s 6:58.40 94.5% 0+0k 0+0io 112pf+0w
351.480u 43.919s 6:57.58 94.6% 0+0k 0+0io 7pf+0w
351.205u 44.174s 6:54.45 95.3% 0+0k 0+0io 7pf+0w
So we've saved about 35kB of text for one kernel, about 12kB for another
and any performance changes are statistical noise. Obviously including
more bus_space aware drivers in a kernel is going to increase any more
space savings too.
Diffs for this are at
ftp://ftp.NetBSD.org/pub/NetBSD/misc/simonb/mips.bus_space.diff
I can't think of a reason not to apply this patch. Can anyone else?
Simon.
--
Simon Burge <simonb@wasabisystems.com>
NetBSD Development, Support and Service: http://www.wasabisystems.com/