linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Shile Zhang <shile.zhang@linux.alibaba.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Michal Marek <michal.lkml@markovi.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	x86@kernel.org, "H . Peter Anvin" <hpa@zytor.com>,
	linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org
Subject: Re: [RFC PATCH v3 6/7] scripts/sorttable: Add ORC unwind tables sort concurrently
Date: Fri, 15 Nov 2019 10:19:45 +0100	[thread overview]
Message-ID: <20191115091945.GT4114@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20191115064750.47888-7-shile.zhang@linux.alibaba.com>

On Fri, Nov 15, 2019 at 02:47:49PM +0800, Shile Zhang wrote:

> @@ -141,21 +306,44 @@ static int do_sort(Elf_Ehdr *ehdr,
>  		if (r(&s->sh_type) == SHT_SYMTAB_SHNDX)
>  			symtab_shndx = (Elf32_Word *)((const char *)ehdr +
>  						      _r(&s->sh_offset));
> -	}
>  
> +#if defined(SORTTABLE_64) && defined(UNWINDER_ORC_ENABLED)
> +		/* locate the ORC unwind tables */
> +		if (!strcmp(secstrings + idx, ".orc_unwind_ip")) {
> +			orctable.orc_ip_size = s->sh_size;
> +			g_orc_ip_table = (int *)((void *)ehdr +
> +						   s->sh_offset);
> +		}
> +		if (!strcmp(secstrings + idx, ".orc_unwind")) {
> +			orctable.orc_size = s->sh_size;
> +			g_orc_table = (struct orc_entry *)((void *)ehdr +
> +							     s->sh_offset);
> +		}
> +#endif
> +	} /* for loop */
> +
> +#if defined(SORTTABLE_64) && defined(UNWINDER_ORC_ENABLED)

Maybe something like:

	if (g_orc_table && g_orc_ip_table) {
		 if (pthread_create(...))
		...
	} else if (g_orc_table || g_orc_up_table) {
		fprintf(stderr, "incomplete ORC tables...\n");
	}

> +	/* create thread to sort ORC unwind tables concurrently */
> +	if (pthread_create(&orc_sort_thread, NULL, sort_orctable, &orctable)) {
> +		fprintf(stderr,
> +			"pthread_create orc_sort_thread failed '%s': %s\n",
> +			strerror(errno), fname);
> +		goto out;
> +	}
> +#endif
>  	if (!extab_sec) {
>  		fprintf(stderr,	"no __ex_table in file: %s\n", fname);
> -		return -1;
> +		goto out;
>  	}
>  
>  	if (!symtab_sec) {
>  		fprintf(stderr,	"no .symtab in file: %s\n", fname);
> -		return -1;
> +		goto out;
>  	}
>  
>  	if (!strtab_sec) {
>  		fprintf(stderr,	"no .strtab in file: %s\n", fname);
> -		return -1;
> +		goto out;
>  	}
>  
>  	extab_image = (void *)ehdr + _r(&extab_sec->sh_offset);
> @@ -192,7 +380,7 @@ static int do_sort(Elf_Ehdr *ehdr,
>  		fprintf(stderr,
>  			"no main_extable_sort_needed symbol in file: %s\n",
>  			fname);
> -		return -1;
> +		goto out;
>  	}
>  
>  	sort_needed_sec = &shdr[get_secindex(r2(&sym->st_shndx),
> @@ -205,6 +393,20 @@ static int do_sort(Elf_Ehdr *ehdr,
>  
>  	/* extable has been sorted, clear the flag */
>  	w(0, sort_needed_loc);
> +	rc = 0;
>  
> -	return 0;
> +out:
> +#if defined(SORTTABLE_64) && defined(UNWINDER_ORC_ENABLED)
> +	{ /* to avoid gcc warning about declaration */
> +	void *retval = NULL;

and then here:

	if (orc_sort_thread) {
		void *retval = NULL;
		pthread_join(...);
		...
	}

> +
> +	/* wait for ORC tables sort done */
> +	pthread_join(orc_sort_thread, &retval);
> +	if (retval) {
> +		fprintf(stderr, "%s in file: %s\n", (char *)retval, fname);
> +		rc = -1;
> +	}
> +	}
> +#endif
> +	return rc;
>  }

  parent reply	other threads:[~2019-11-15  9:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-15  6:47 [RFC PATCH v3 0/7] Speed booting by sorting ORC unwind tables at build time Shile Zhang
2019-11-15  6:47 ` [RFC PATCH v3 1/7] scripts/sortextable: Rewrite error/success handling Shile Zhang
2019-11-15  6:47 ` [RFC PATCH v3 2/7] scripts/sortextable: kernel coding style formating Shile Zhang
2019-11-15  6:47 ` [RFC PATCH v3 3/7] scripts/sortextable: Remove dead code Shile Zhang
2019-11-15  6:47 ` [RFC PATCH v3 4/7] scripts/sortextable: refactor do_func() function Shile Zhang
2019-11-15  6:47 ` [RFC PATCH v3 5/7] scripts/sorttable: rename sortextable to sorttable Shile Zhang
2019-11-15  6:47 ` [RFC PATCH v3 6/7] scripts/sorttable: Add ORC unwind tables sort concurrently Shile Zhang
2019-11-15  9:07   ` Peter Zijlstra
2019-11-15  9:43     ` Shile Zhang
2019-11-15 10:33       ` Peter Zijlstra
2019-11-15 17:24       ` Andy Lutomirski
2019-11-18 11:43         ` Shile Zhang
2019-11-15  9:19   ` Peter Zijlstra [this message]
2019-11-15  9:45     ` Shile Zhang
2019-11-15  6:47 ` [RFC PATCH v3 7/7] x86/unwind/orc: remove run-time ORC unwind tables sort Shile Zhang
2019-11-15 16:51   ` David Laight
2019-11-15 17:46     ` Josh Poimboeuf
2019-11-18 10:05       ` David Laight
2019-11-18 10:50         ` Shile Zhang
2019-11-18 14:41         ` Josh Poimboeuf
2019-11-15  7:25 ` [RFC PATCH v3 0/7] Speed booting by sorting ORC unwind tables at build time Ingo Molnar
2019-11-15  8:24   ` Shile Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191115091945.GT4114@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=mingo@redhat.com \
    --cc=shile.zhang@linux.alibaba.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).