x86info glibc backwards compatibility.

Uncategorized

Sometimes, backwards compatibility gets really ugly.
Today I got a mail from someone who failed to compile x86info on some old system, because it had an old glibc.
x86info uses the affinity system calls to bind processes to specific CPUs. I had forgotten all about it, but earlier versions of the interface in glibc were a little unstable.
Quoting the sched_getaffinity manpage:

VERSIONS
The CPU affinity system calls were introduced in Linux kernel 2.5.8. The library interfaces were introduced in glibc 2.3. Initially, the glibc interfaces included a cpusetsize argument, typed as unsigned int. In glibc 2.3.3, the cpusetsize argument was removed, but was then restored in glibc 2.3.4, with type size_t.

The email I got was kind enough to include a patch that made it work on all possible combinations of the glibc, by using plpa. It’s neat that this rube goldberg machine can make it work with anything, but damn is it ever ugly.

I settled for a simpler “fix”

It’s a controversial answer, but sometimes, compatibility just isn’t worth it.

Related posts:

  1. x86info processor topology parsing. Today was my last working day of the year, as...

Related posts brought to you by Yet Another Related Posts Plugin.

2 Comments

2 Comments

  1. ntl  •  Jan 22, 2009 @19:16

    Yeah, I decided to not even try to support glibc 2.3 in my own project because of this. By the way, thought I’d point out that the way x86info uses the sched affinity APIs limits it to 1024 CPUs (the number of bits in a single cpu_set_t). You can discover the cpumask size used by the kernel at runtime and dynamically allocate your cpu_set_t’s but it’s a bit awkward — libtopology can help with that (topology_sizeof_cpumask). Likely this is not a pressing issue for x86info but maybe in a few years… :-)

  2. davej  •  Jan 22, 2009 @20:07

    heh, when we come to supporting >1k CPUs, we’ll probably have to rethink a number of things in x86info. I’m not sure the default output scrolling by would be too useful.
    It’s already a little cumbersome at 16 CPUs as I recently found out. I think I’m going to work on this sometime soon to print a header like .. “Found 16 CPUs like this …”
    rather than print the details out 16 times. Where it gets tricky is if there are differences between processors. (Which has already happened, and not just in weirdo asymmetric combinations of CPUs).



  • huaglahglah huaglahglah