All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: Jason Baron <jbaron@redhat.com>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu,
	mathieu.desnoyers@polymtl.ca, hpa@zytor.com, tglx@linutronix.de,
	rostedt@goodmis.org, andi@firstfloor.org, roland@redhat.com,
	rth@redhat.com, mhiramat@redhat.com, fweisbec@gmail.com,
	avi@redhat.com, "Eric W. Biederman" <ebiederm@xmission.com>
Subject: Re: [PATCH 7/9] jump label: sort jump table at build-time
Date: Fri, 9 Apr 2010 17:24:25 -0400	[thread overview]
Message-ID: <20100409212425.GB8219@redhat.com> (raw)
In-Reply-To: <9cd6a0307ac55f2090c5b75a26ee9ca6a167cc8d.1270839564.git.jbaron@redhat.com>

On Fri, Apr 09, 2010 at 03:49:57PM -0400, Jason Baron wrote:
> The jump label table is more optimal accessed if the entries are continguous.
> Sorting the table accomplishes this. Do the sort at build-time. Adds a '-j'
> option to 'modpost' which replaces the vmlinux, with a sorted jump label
> section vmlinux. I've tested this on x86 with relocatable and it works fine
> there as well. Note that I have not sorted the jump label table in modules.
> This is b/c the jump label names can be exported by the core kernel, and thus
> I don't have them available at buildtime. This could be solved by either
> finding the correct ones in the vmlinux, or by embedding the name of the jump
> label in the module tables (and not just a pointer), but the module tables
> tend to be smaller, and thus their is less value to this kind of change
> anyway. The kernel continues to do the sort, just in case, but at least for
> the vmlinux, this is just a verfication that the jump label table has
> already been sorted.
> 
> Signed-off-by: Jason Baron <jbaron@redhat.com>
> ---

[ CCing Eric ]

[..]
> +static void swap_jump_label_entries(struct jump_entry *previous, struct jump_entry *next)
> +{
> +	struct jump_entry tmp;
> +
> +	tmp = *next;
> +	*next = *previous;
> +	*previous = tmp;
> +}
> +
> +static void sort_jump_label_table(struct elf_info *info, Elf_Ehdr *hdr)
> +{
> +	int swapped = 0;
> +	struct jump_entry *iter, *iter_next;
> +	char *name, *next_name;
> +	Elf_Shdr *sechdrs = info->sechdrs;
> +	unsigned long jump_table, jump_table_end;
> +	unsigned long jump_strings, jump_strings_addr;
> +
> +	if ((info->jump_sec == 0) && (info->jump_strings_sec == 0))
> +		return;
> +
> +	jump_table = (unsigned long)hdr + sechdrs[info->jump_sec].sh_offset;
> +	jump_table_end = jump_table + sechdrs[info->jump_sec].sh_size;
> +	jump_strings = (unsigned long)hdr +
> +				sechdrs[info->jump_strings_sec].sh_offset;
> +	jump_strings_addr = sechdrs[info->jump_strings_sec].sh_addr;
> +
> +	do {
> +		swapped = 0;
> +		iter = iter_next = (struct jump_entry *)jump_table;
> +		iter_next++;
> +		for (; iter_next < (struct jump_entry *)jump_table_end;
> +							iter++, iter_next++) {
> +			name = jump_strings + (iter->name - jump_strings_addr);
> +			next_name = jump_strings +
> +					(iter_next->name - jump_strings_addr);
> +			if (strcmp(name, next_name) > 0) {
> +				swap_jump_label_entries(iter, iter_next);
> +				swapped = 1;


Jason,

As we were chatting about this, it looks like you are modifying vmlinux
section outside the knowledge of compiler. So theoritically associated
relocation section knowledge is no more valid and it can be a problem during
i386 relocatable kernels where we read the section's relocation inforamtion
and perform the relocations at runtime.

I know you have tested this on i386 and it works for you. I guess it works
because all the entries in the section are same and we apply same relocation
offset to all entries so even changing the order of entries is not impacting.

But conceptually, changing the vmlinux section outside knowledge of compiler
and assuming that we don't have to change the associated relocation section
probably is not the best thing.

I am not sure how to fix it. May be rely back on boot time sorting, or if
there is a way to relink sections after sorting etc. I just wanted to raise
a concern. May be other people (Eric, hpa) have ideas whether it is a valid
concern or not or how to handle it better.

Thanks
Vivek

  reply	other threads:[~2010-04-09 21:24 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-09 19:49 [PATCH 0/9] jump label v6 Jason Baron
2010-04-09 19:49 ` [PATCH 1/9] jump label: notifier atomic call chain notrace Jason Baron
2010-04-09 19:49 ` [PATCH 2/9] jump label: base patch Jason Baron
2010-04-09 19:49 ` [PATCH 3/9] jump label: x86 support Jason Baron
2010-04-09 19:49 ` [PATCH 4/9] jump label: tracepoint support Jason Baron
2010-04-09 19:49 ` [PATCH 5/9] jump label: add module support Jason Baron
2010-04-09 19:49 ` [PATCH 6/9] jump label: move ftrace_dyn_arch_init to common code Jason Baron
2010-04-09 19:49 ` [PATCH 7/9] jump label: sort jump table at build-time Jason Baron
2010-04-09 21:24   ` Vivek Goyal [this message]
2010-04-09 21:32     ` Roland McGrath
2010-04-09 19:50 ` [PATCH 8/9] jump label: initialize workqueue tracepoints *before* they are registered Jason Baron
2010-04-09 19:50 ` [PATCH 9/9] jump label: jump_label_text_reserved() to reserve our jump points Jason Baron
2010-04-09 21:09   ` Masami Hiramatsu
2010-04-09 20:36 ` [PATCH 0/9] jump label v6 Masami Hiramatsu
2010-04-09 21:37   ` Jason Baron
2010-04-09 21:58     ` Masami Hiramatsu
2010-04-10  6:16 ` David Miller
2010-04-10  6:22   ` H. Peter Anvin
2010-04-13 16:56 ` Mathieu Desnoyers
2010-04-14 19:34   ` Jason Baron

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=20100409212425.GB8219@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=andi@firstfloor.org \
    --cc=avi@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jbaron@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@polymtl.ca \
    --cc=mhiramat@redhat.com \
    --cc=mingo@elte.hu \
    --cc=roland@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=rth@redhat.com \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.