Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753620AbbGQVdm (ORCPT ); Fri, 17 Jul 2015 17:33:42 -0400 Received: from cantor2.suse.de ([195.135.220.15]:55094 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751890AbbGQVdl (ORCPT ); Fri, 17 Jul 2015 17:33:41 -0400 Date: Fri, 17 Jul 2015 23:33:38 +0200 From: Jean Delvare To: "Odzioba, Lukasz" Cc: Guenter Roeck , "Yu, Fenghua" , lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] hwmon: coretemp: use list instead of fixed size array for temp data Message-ID: <20150717233338.0ae52805@endymion.delvare> In-Reply-To: References: <1436976253-4810-1-git-send-email-lukasz.odzioba@intel.com> <20150715230734.76347af2@endymion.delvare> <55A93365.4000702@roeck-us.net> <55A94303.5040805@roeck-us.net> Organization: SUSE Linux X-Mailer: Claws Mail 3.10.1 (GTK+ 2.24.23; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1655 Lines: 38 Hi Lukasz, On Fri, 17 Jul 2015 19:23:44 +0000, Odzioba, Lukasz wrote: > On Friday, July 17, 2015 8:02 PM Guenter Roeck wrote: > > Please explain why krealloc() won't work, why using krealloc(() would > > result in a larger memory footprint than using lists, and why disabling > > CPUs would require any action in the first place. > > It will work, but it can use more memory for cpus with many cores. > If you have just one core visible to the kernel with id 59 > (i.e. the rest are disabled by hardware) out of 60-core cpu then you > have to allocate an array of 60 pointers instead of just one element of Arrays of pointers are cheap. You can fit 512 pointers in a single memory page. > the list. Of course you can say that for cpu with just one core list will > use 3x the memory needed by array and that's true. I see no point in > arguing which case is more important, let's move on. I see the point in arguing: the example above is just silly and does not match any real-world application. Nobody buys a 60-core CPU to run it with a single core enabled. When you have two or more alternative implementations possible, thinking in terms of the most common cases is a key to make the right decision. Thinking about servers with a lots of CPU cores versus embedded devices with few cores and tight memory constraints, that is useful. Making up corner cases is not. -- Jean Delvare SUSE L3 Support -- 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/