Re: [patch 02/21] perfmon2 minimal: generic headers

From: Arnd Bergmann
Date: Thu Jun 12 2008 - 16:53:19 EST


On Wednesday 11 June 2008, stephane eranian wrote:
> > I'm very nervous when seeing something like this in userspace headers;
> > you need to assume that the app has been compiled with a very different
> > version of the headers than the currently running kernel.... either the
> > version of perfmon doesn't matter, in which case these don't belong
> > here, or it does and it should be a runtime query.
> >
> I think you bring up a good point. There is indeed a way of querying the version
> via /sysfs.
>
> However the question is how does an application know which API version
> it was compiled
> for, so it can compare with what it finds in /sysfs? That ought to be
> somewhere in the
> public headers that the application was compiled with.
>

The normal way for an application is to just use a syscall or file
interface, and check for -ENOENT or -ENOSYS error codes in order to
find kernels that are too old. If older kernels had a different way
of doing things, the application can fall back on that mechanism.
An example for this would be pselect() which you can replace with
select(), but only in a racy way that the user should avoid.

When the kernel changes an interface, it must only do that in a
backwards compatible way, so that old binaries do not break. Ever.

Arnd <><
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/