Re: [Patch][RFC] Disabling per-tgid stats on task exit in taskstats

From: Andrew Morton
Date: Fri Jun 30 2006 - 23:50:55 EST


On Fri, 30 Jun 2006 23:37:10 -0400
Shailabh Nagar <nagar@xxxxxxxxxxxxxx> wrote:

> >Set aside the implementation details and ask "what is a good design"?
> >
> >A kernel-wide constant, whether determined at build-time or by a /proc poke
> >isn't a nice design.
> >
> >Can we permit userspace to send in a netlink message describing a cpumask?
> >That's back-compatible.
> >
> >
> Yes, that should be doable. And passing in a cpumask is much better
> since we no longer
> have to maintain mappings.
>
> So the strawman is:
> Listener bind()s to genetlink using its real pid.
> Sends a separate "registration" message with cpumask to listen to.
> Kernel stores (real) pid and cpumask.
> During task exit, kernel goes through each registered listener (small
> list) and decides which
> one needs to get this exit data and calls a genetlink_unicast to each
> one that does need it.
>
> If number of listeners is small, the lookups should be swift enough. If
> it grows large, we
> can consider a fancier lookup (but there I go again, delving into
> implementation too early :-)

We'll need a map.

1024 CPUs, 1024 listeners, 1000 exits/sec/CPU and we're up to a million
operations per second per CPU. Meltdown.

But it's a pretty simple map. A per-cpu array of pointers to the head of a
linked list. One lock for each CPU's list.
-
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/