Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932347AbWBUUYX (ORCPT ); Tue, 21 Feb 2006 15:24:23 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932322AbWBUUYW (ORCPT ); Tue, 21 Feb 2006 15:24:22 -0500 Received: from mtagate4.de.ibm.com ([195.212.29.153]:24050 "EHLO mtagate4.de.ibm.com") by vger.kernel.org with ESMTP id S932347AbWBUUYW (ORCPT ); Tue, 21 Feb 2006 15:24:22 -0500 Message-ID: <43FB76EF.9080406@de.ibm.com> Date: Tue, 21 Feb 2006 21:24:15 +0100 From: Martin Peschke User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: linux-kernel@vger.kernel.org Subject: How to allocate per-cpu data for online CPUs only (and safely)? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1356 Lines: 37 I am trying to optimize the memory footprint of some code of mine. It's been using per-cpu data and alloc_percpu() so far. The latter has the disadvantage of getting hold of memory for CPU's which aren't there (yet). I could imagine using CPU-hotplug notifications as triggers for additional allocations or for cleaning up unneeded memory. But alloc_percpu() appears to conflict with that idea. I was briefly tempted to derive some code from alloc_percpu() more to my liking, until I was scared off by this comment in alloc_percpu(): /* * Cannot use for_each_online_cpu since a cpu may come online * and we have no way of figuring out how to fix the array * that we have allocated then.... */ Well, and then there is kernel/profile.c, for example, which boldly ignors alloc_percpu()'s qualms and allocates and releases per-cpu data as needed. Is that the way to go? If so, why alloc_percpu()'s reservations? Or, does that comment imply that the exploiter isn't expected to take care of CPU hotplug events? Am I missing anything? Thank you. Martin - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/