[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090908204853.GC2641@redhat.com>
Date: Tue, 8 Sep 2009 16:48:54 -0400
From: Jason Baron <jbaron@...hat.com>
To: Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>
Cc: linux-kernel@...r.kernel.org, roland@...hat.com, rth@...hat.com,
mingo@...e.hu
Subject: Re: [PATCH 0/4] RFC: jump label - (tracepoint optimizations)
On Mon, Sep 07, 2009 at 11:48:24AM -0400, Mathieu Desnoyers wrote:
> > ".pushsection __jump_table, \"a\" \n\t" \
> > _ASM_PTR "1b, %l[" #label "], %c0 \n\t" \
> > ".popsection \n\t" \
> > : : "i" (__sjstrtab_##tag) : : label)
> >
>
> Supporting multiple labels to create a real jump table would be a
> nice-to-have as future enhancement too. This could be called
> STATIC_JUMP_TABLE(). Actually, the STATIC_JUMP_IF could probably be
> implemented in terms of STATIC_JUMP_TABLE.
>
> > #else
> >
> > #define STATIC_JUMP_IF(tag, label, cond) \
> > if (unlikely(cond)) \
> > goto label;
> >
>
> Hrm, however, it's not clear to me how the STATIC_JUMP_TABLE() fallback
> would look like. In the case of STATIC_JUMP_IF, it's a simple if (),
> which makes support of compilers lacking static jump support easy. We
> could probably use a switch statement to replace the STATIC_JUMP_TABLE
> though.
>
right - if we have more labels passed into STATIC_JUMP_TABLE(), we can
probably do a case statement with a 'goto' to the correct label.
> > #endif /* !HAVE_STATIC_JUMP */
> >
> >
> > which can be used as:
> >
> > STATIC_JUMP_IF(trace, trace_label, jump_enabled);
> > printk("not doing tracing\n");
> > if (0) {
> > trace_label:
> > printk("doing tracing: %d\n", file);
> > }
> >
>
> Hrm. Is there any way to make this a bit prettier ? Given modifications
> are made to gcc anyway...
>
> Maybe:
>
> static_jump_if (trace, jump_enabled) {
> ...
>
> } else {
> ...
> }
>
> And for the jump table:
>
> static_jump_table (trace, jump_select) {
> case 0: ...
> break;
> case 1: ...
> break;
> default:
> ...
> }
>
hmmm...yes, I agree it would be nice if the code looked a little prettier.
However, short of additional gcc changes i'm not sure how to do that.
perhaps, somebody has some better ideas? Note also, that the
'STATIC_JUMP_IF()' as defined implements both:
if () { }
and:
if () { } else { }
I'm not sure the code is that hideous as proposed. However, I definitely
would be interested it other opinions? Also, in this case note that the
STATIC_JUMP_IF() is only added to 1 place in the code, and doesn't
affect any of the normal tracepoint API.
>
> > ---------------------------------------
> >
> > Thus, if 'HAVE_STATIC_JUMP' is defined (which will depend ultimately on the
> > existence of 'asm goto' in the compiler version), we simply have a no-op
> > followed by a jump around the dormant (disabled) tracing code.
>
> Hrm, why don't we collapse that into a single 5-bytes jump instruction
> instead ?
that might be nice, but would require more complex compiler support. I'm
not sure if the extra complexity is worth the 2-byte i-cache savings?
That is, I think we're getting the majority of the savings with the
proposed solution.
thanks,
-Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists