On 2022/10/27 3:03, Luis Chamberlain wrote: > On Wed, Oct 26, 2022 at 02:44:36PM +0800, Leizhen (ThunderTown) wrote: >> On 2022/10/26 1:53, Luis Chamberlain wrote: >>> This answers how we don't use a hash table, the question was *should* we >>> use one? >> >> I'm not the original author, and I can only answer now based on my understanding. Maybe >> the original author didn't think of the hash method, or he has weighed it out. >> >> Hash is a good solution if only performance is required and memory overhead is not >> considered. Using hash will increase the memory size by up to "4 * kallsyms_num_syms + >> 4 * ARRAY_SIZE(hashtable)" bytes, kallsyms_num_syms is about 1-2 million. >> >> Because I don't know what hash algorithm will be used, the cost of generating the >> hash value corresponding to the symbol name is unknown now. But I think it's gonna >> be small. But it definitely needs a simpler algorithm, the tool needs to implement >> the same hash algorithm. > > For instance, you can look at evaluating if alloc_large_system_hash() would help. OK, I found the right hash function. In this way, the tool does not need to consider the byte order. include/linux/stringhash.h /* * Version 1: one byte at a time. Example of use: * * unsigned long hash = init_name_hash; * while (*p) * hash = partial_name_hash(tolower(*p++), hash); * hash = end_name_hash(hash); > > Luis > . > -- Regards, Zhen Lei