Re: [PATCH 2/3] scripts/sorttable: Build orc fast lookup table via sorttable tool

From: changhuaixin
Date: Sun Jul 26 2020 - 22:19:25 EST




> On Jul 24, 2020, at 9:53 PM, Ingo Molnar <mingo@xxxxxxxxxx> wrote:
>
>
> * Huaixin Chang <changhuaixin@xxxxxxxxxxxxxxxxx> wrote:
>
>> Since orc tables are already sorted by sorttable tool, let us move
>> building of fast lookup table into sorttable tool too. This saves us
>> 6380us from boot time under Intel(R) Xeon(R) CPU E5-2682 v4 @ 2.50GHz
>> with 64 cores.
>
> Neat!
>
>> +struct orc_sort_param {
>> + size_t lookup_table_size;
>> + unsigned int *orc_lookup_table;
>> + unsigned long start_ip;
>> + size_t text_size;
>> + unsigned int orc_num_entries;
>> +};
>
>>
>> +#define LOOKUP_BLOCK_ORDER 8
>> +#define LOOKUP_BLOCK_SIZE (1 << LOOKUP_BLOCK_ORDER)
>> +
>> + for (i = 0; i < lookup_num_blocks-1; i++) {
>> + orc = __orc_find(g_orc_ip_table, g_orc_table,
>> + num_entries,
>> + lookup_start_ip + (LOOKUP_BLOCK_SIZE * i));
>> + if (!orc) {
>> + snprintf(g_err, ERRSTR_MAXSZ,
>> + "Corrupt .orc_unwind table\n");
>> + pthread_exit(g_err);
>> + }
>> +
>> + orc_lookup[i] = orc - g_orc_table;
>> + }
>> +
>> + /* Initialize the ending block: */
>> + orc = __orc_find(g_orc_ip_table, g_orc_table, num_entries,
>> + lookup_stop_ip);
>> + if (!orc) {
>> + snprintf(g_err, ERRSTR_MAXSZ, "Corrupt .orc_unwind table\n");
>> + pthread_exit(g_err);
>> + }
>> + orc_lookup[lookup_num_blocks-1] = orc - g_orc_table;
>
> Yeah, so now this definition of LOOKUP_BLOCK_* basicaly duplicates the
> arch/x86/include/asm/orc_lookup.h size, with no obvious link between
> the two. This is asking for trouble.
>
> <asm/orc_lookup.h> looks simple enough - can we include it in
> scripts/sorttable.h?
>
> Or better yet, please move these two defines into <asm/orc_types.h>,
> which is already included in sorttable.h.
>
Thanks!
Moving these two into <asm/orc_types.h> and capitalized spelling will be done in the following patches.

Huaixin

> BTW., please update your patches to spell 'ORC' in a capitalized
> fashion, like most of the existing code does:
>
>> /* create thread to sort ORC unwind tables concurrently */
>
> Thanks,
>
> Ingo