Older blog entries for acme (starting at number 150)

Kill-a-hole: Reorganizing struct layouts

Say a project has this struct:

struct cheese {
char name[52];
char a;
int b;
char c;
int d;
short e;
};

And we want to see how the layout looks like more precisely:

[acme@filo examples]$ pahole swiss_cheese cheese
/* <11b> /home/acme/git/pahole/examples/swiss_cheese.c:3 */
struct cheese {
char name[52]; /* 0 52 */
char a; /* 52 1 */

/* XXX 3 bytes hole, try to pack */

int b; /* 56 4 */
char c; /* 60 1 */

/* XXX 3 bytes hole, try to pack */

/* — cacheline 1 boundary (64 bytes) — */
int d; /* 64 4 */
short int e; /* 68 2 */
}; /* size: 72, cachelines: 2 */
/* sum members: 64, holes: 2, sum holes: 6 */
/* padding: 2 */
/* last cacheline: 8 bytes */
[acme@filo examples]$

Heck, what a swiss cheese! Surely we can do better, huh? Lets ask pahole for a little help:

[acme@filo examples]$ pahole -kV swiss_cheese cheese
/* moving c(size=1) to after a(offset=52, size=1, hole=3) */
/* moving e(size=2) to after c(offset=53, size=1, hole=2) */

/* <11b> /home/acme/git/pahole/examples/swiss_cheese.c:3 */
struct cheese {
char name[52]; /* 0 52 */
char a; /* 52 1 */
char c; /* 53 1 */
short int e; /* 54 2 */
int b; /* 56 4 */
int d; /* 60 4 */
/* — cacheline 1 boundary (64 bytes) — */
}; /* size: 64, cachelines: 1 */
/* saved 8 bytes and 1 cacheline! */
[acme@filo examples]$

Much better now, no?

Ok, lets try something more interesting, like some Linux kernel structs, the output is big, so here are some links for some structs that spent some jiffies on pahole’s spa:

Type demotion of bigger than needed bitfields will help getting more saved :-)

Syndicated 2007-01-30 15:20:26 from Arnaldo's Ramblings

Unfolding structs

Check the git cset comment! New rpms are available at the usual place with this new feature, for the curious, here is struct task_struct unfolded.

Syndicated 2007-01-29 15:17:02 from Arnaldo's Ramblings

ctracer made easy

Make sure you have the kernel-debuginfo package installed!

rpm -ivh http://oops.ghostprotocols.net:81/acme/dwarves/rpm/libdwarves1-0-9.i386.rpm http://oops.ghostprotocols.net:81/acme/dwarves/rpm/dwarves-0-9.i386.rpm
mkdir foo
cd foo
ln -s /usr/lib/ctracer/Makefile .
ln -s /usr/lib/ctracer/ctracer_jprobe.c .
make CLASS=sock
insmod ctracer.ko
# do some networking activity or just move the mouse :-)
dmesg # or tail /var/log/messages
rmmod ctracer

Now to work on kahole, kill a hole, a tool that will reorganize structs to kill holes and that will provide the bits needed for struct “views”, i.e. to specify a list of fields in a struct that are of interest for collection at each probe point and that will also be used to create a userspace utility that will read the relay channel (/sys/kernel/ctracer0) and generate what ostra-cg, the callgraph tool from the OSTRA days needs to generate things such as this session collecting struct task_struct methods calls in the Linux kernel, ah, ostra-cg also produces this methods statistics and from this page you get plottings such as this one for sched_
fork calls
, workload is forgotten right now, but as soon as I get my new test machine we’ll have more interesting graphics :-)

Syndicated 2007-01-27 21:20:21 from Arnaldo's Ramblings

libdwarves (mostly) explained

In response to a comment I’ve added comments to the ctracer tool source code in an attempt to help people interested in helping improving these tools, check it out!

Syndicated 2007-01-20 15:04:30 from Arnaldo's Ramblings

How many functions receive as a parameter a pointer to a struct?

Implemented a new command line option in pahole: –nr_members, look here for the result using a kernel built for qemu.

Syndicated 2007-01-13 16:04:08 from Arnaldo's Ramblings

Support for more C++ tags

Added support for DW_TAG_reference and DW_AT_specification, still have to work on DW_TAG_namespace and rework the list of tags to make classes within classes to properly be shown in the tools, nowadays its just a flat namespace, which has not been a problem for the tools written so far, but for pdwtags, the dwarf I’m working on now, that will do a complete dump of all tags it is a must.

Syndicated 2007-01-13 13:51:47 from Arnaldo's Ramblings

connection_sock work going on nicely, today sent patches for lots of network families, tomorrow, finally, will try to test the ax25/netrom/rose big patch with bpqether and the ax25 utilities, if all goes well, send the patches to Dave and turn the chainsaw to net/bluetooth/, that will be interesting with all the internal proto infrastructure it has, lets see if we can take advantage of its approach in other protos or if getting what the net/ipv4/ has for a similar purpose is better.

Added my TODO list to this page.

WOW, it has been a long time, and since I'm lazy as hell to use my ghostprotocols.net to create some webpage, diary, etc I'll continue using this nice infrastructure provided by the fine folks at advogato.org :-)

Today I submitted a proposal for OLS 2005 "DCCP on Linux", for those, like a friend who said for some seconds he thought I was going to talk about KDE, no, its not DCOP, its a new internet transport protocol, interested people can take a look at the RFCs drafts at http://www.icir.org/kohler/dcp/.

The proposal is just an attempt to get me from procastrinating and get back to work on this thing, that fits very nicely in my work on TCPfying the poor cousins, i.e. factoring out code from the rich cousins (TCP, yeah) and into the linux kernel core networking code.

OK, lets see how long it takes for me to write another diary entry 8-)

net-exp quiet for a while, but getting good reviews from the friends that have looked at it, if it passes Al Viro's eyes then I'll just chunk it into sensible changesets and start feeding davem, won't be fun tho, over 10K lines of patches for net/ in 2.6.early...
Just got very happy that a serious stab at a 2.6-tiny kernel tree is being maintained by Matt Mackall, have already come up with several ideas from my long nights in net/ land, booting up the kernel with mem=4m on the command line again is sooooooo nice... :) lilliput net here we go :P

141 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!