Re: [PATCH dwarves v3 2/4] dwarf_loader: Prepare and pass per-thread data to worker threads.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jan 25, 2022 at 8:07 PM Kui-Feng Lee <kuifeng@xxxxxx> wrote:
>
> Add interfaces to allow users of dwarf_loader to prepare and pass
> per-thread data to steal-functions running on worker threads.
>
> Signed-off-by: Kui-Feng Lee <kuifeng@xxxxxx>
> ---

Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx>

>  dwarf_loader.c | 58 +++++++++++++++++++++++++++++++++++++++-----------
>  dwarves.h      |  4 ++++
>  2 files changed, 49 insertions(+), 13 deletions(-)
>

[...]

>  static int dwarf_cus__threaded_process_cus(struct dwarf_cus *dcus)
>  {
>         pthread_t threads[dcus->conf->nr_jobs];
> +       struct dwarf_thread dthr[dcus->conf->nr_jobs];
> +       void *thread_data[dcus->conf->nr_jobs];
> +       int res;
>         int i;
>
> +       if (dcus->conf->threads_prepare) {
> +               res = dcus->conf->threads_prepare(dcus->conf, dcus->conf->nr_jobs, thread_data);
> +               if (res != 0)
> +                       return res;
> +       } else
> +               memset(thread_data, 0, sizeof(void *) * dcus->conf->nr_jobs);

at least in kernel code style, if one branch of if/else has {}, the
other has to have {} as well, even if it's a single-line statement

> +
>         for (i = 0; i < dcus->conf->nr_jobs; ++i) {
> -               dcus->error = pthread_create(&threads[i], NULL, dwarf_cus__process_cu_thread, dcus);
> +               dthr[i].dcus = dcus;
> +               dthr[i].data = thread_data[i];
> +
> +               dcus->error = pthread_create(&threads[i], NULL,
> +                                            dwarf_cus__process_cu_thread,
> +                                            &dthr[i]);
>                 if (dcus->error)
>                         goto out_join;
>         }

[...]



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux