Re: [PATCH 08/17] tracing/probes: Split [ku]probes_fetch_type_table

From: Namhyung Kim
Date: Mon Dec 02 2013 - 21:24:25 EST


Hi Oleg,

On Mon, 2 Dec 2013 18:09:52 +0100, Oleg Nesterov wrote:
> On 12/02, Oleg Nesterov wrote:
>>
>> On 11/27, Namhyung Kim wrote:
>> >
>> > Use separate fetch_type_table for kprobes and uprobes. It currently
>> > shares all fetch methods but some of them will be implemented
>> > differently later.
>>
>> Hmm. This looks wrong, afaics...
>>
>> > static int parse_probe_arg(char *arg, const struct fetch_type *t,
>> > struct fetch_param *f, bool is_return, bool is_kprobe)
>> > {
>> > + const struct fetch_type *ftbl;
>> > unsigned long param;
>> > long offset;
>> > char *tmp;
>> > - int ret;
>> > + int ret = 0;
>> >
>> > - ret = 0;
>> > + ftbl = is_kprobe ? kprobes_fetch_type_table : uprobes_fetch_type_table;
>>
>> OK, but what if, say, CONFIG_KPROBE_EVENT && !CONFIG_UPROBE_EVENT ?
>> The kernel won't compile in this case?
>
> Ah, wait, probably I was wrong. I didn't noticee that this patch
> does
>
> extern __weak const struct fetch_type kprobes_fetch_type_table[];
> extern __weak const struct fetch_type uprobes_fetch_type_table[];
>
> Is it the reason for "weak" ?

Exactly!

>
> If yes, perhaps this deserves a comment or at least a note in the changelog.
> Or is there another reason?

Nope. I'll add a comment and a note in the changelog too. Please see the
new version below.

>
> I am wondering if this should always work, with any toolchain. I simply
> do not know what is the documented behaviour if a "weak" symbol is never
> defined.

It's something like a weak reference - if it couldn't find a definition
the ref would have value of 0 instead of error. I'm not sure this is a
standard or documented behavior but it worked for a long time AFAIK so I
guess it's pretty compatible.

Btw I found this:

http://gcc.gnu.org/ml/gcc/1999-02n/msg01219.html

Thanks,
Namhyung