Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755285AbbGQSB5 (ORCPT ); Fri, 17 Jul 2015 14:01:57 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:32962 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752941AbbGQSBt (ORCPT ); Fri, 17 Jul 2015 14:01:49 -0400 Message-ID: <55A94303.5040805@roeck-us.net> Date: Fri, 17 Jul 2015 11:01:39 -0700 From: Guenter Roeck User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: "Odzioba, Lukasz" , Jean Delvare CC: "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 References: <1436976253-4810-1-git-send-email-lukasz.odzioba@intel.com> <20150715230734.76347af2@endymion.delvare> <55A93365.4000702@roeck-us.net> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated_sender: linux@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: linux@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2281 Lines: 51 On 07/17/2015 10:28 AM, Odzioba, Lukasz wrote: > From: Guenter Roeck [mailto:linux@roeck-us.net] > On Friday, July 17, 2015 6:55 PM Guenter Roeck wrote: > >> You don't really explain why your approach would be better than >> allocating an array of pointers to struct temp_data and increasing >> its size using krealloc if needed. > > Let's consider two cases of such implementation: > a) we use array of pointers with O(n) access algorithm > b) we use array of pointers with O(1) access algorithm > > In both cases an array will have greater memory footprint unless > we implement reallocation ourselves when cpus are disabled which will > make code harder to maintain. 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. > Case b) does not handle huge core ids and sparse enumeration well - > it is still to discuss whether we really need it since there is no > such hardware yet. > "yet" is a key term here. Presumably you have insider information. Unless you can share this information, I don't see the point of replacing an O(1) algorithm with O(n), especially since there is a relatively simple alternative available to support more CPUs. > I am not saying that my solution is the best of possible ones. > I am saying that "the best" can vary depending on which criteria do you > choose from (time, memory, clean code...). Some may say that O(n) is > fine unless we have thousands of cores and this code is not on hot path, > others may be concerned more about memory on small/old devices. > I don't see holy grail here, If you see one please let me know. > Unless you clarify that Intel will introduce CPU IDs which can not be used as array index because they are too sparse, I don't really see how the list solution would consume less memory than an array of pointers, even if the array is somewhat sparse. After all, a list consumes at least two pointers per entry. Thanks, Guenter -- 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/