Skip to contentSkip to conversation

uprobes: register/unregister probes.

DISCUSSION Srikar Dronamraju 2 participants 7 messages Nov 24, 2011 6 messages not in the archive Memory management

lore
Share & tools
lore
#4 lore raw
In reply to a message not in the archive
Quoted 9 lines · Srikar Dronamraju

Review

Quoted 5 lines
(quoted diff) +5 -0
+#define UPROBES_HASH_SZ        13
+/* serialize (un)register */
+static struct mutex uprobes_mutex[UPROBES_HASH_SZ];
+#define uprobes_hash(v)        (&uprobes_mutex[((unsigned long)(v)) %\
+                                               UPROBES_HASH_SZ])

Was there any reason to for using this hasing scheme, say over hash.h?

There is no specific reason for choosing this hashing scheme over the current. I just say ext4_aio_mutex in fs/ext4/ext4.h and did something similar.

Signature · 9 lines
Thanks and Regards
Srikar

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#7 lore raw
In reply to a message not in the archive
Quoted 7 lines · Srikar Dronamraju
Quoted 6 lines
(quoted diff) +6 -0
+int register_uprobe(struct inode *inode, loff_t offset,
+                               struct uprobe_consumer *consumer)
+{
+       struct uprobe *uprobe;
+       int ret = -EINVAL;
+
Quoted 9 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+       if (!consumer || consumer->next)
+               return ret;
+
+       inode = igrab(inode);

So why are you dealing with !consumer but not with !inode? and why does
it make sense to allow !consumer at all?

I am not sure if I got your comment correctly.

I do check for inode just after the igrab.

I am actually not dealing with !consumer.
If the consumer is NULL, then we dont have any handler to run so why would we want to register such a probe?

Also if consumer->next is Non-NULL, that means that this consumer was already used. Reusing the consumer, can result in consumers list getting broken into two.

If you meant something else please clarify.

Signature · 9 lines
Thanks and Regards
Srikar

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#8 lore raw
Quoted 18 lines · Srikar Dronamraju
Quoted 7 lines · Srikar Dronamraju
Quoted 6 lines
(quoted diff) +6 -0
+int register_uprobe(struct inode *inode, loff_t offset,
+                               struct uprobe_consumer *consumer)
+{
+       struct uprobe *uprobe;
+       int ret = -EINVAL;
+
Quoted 9 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+       if (!consumer || consumer->next)
+               return ret;
+
+       inode = igrab(inode);

So why are you dealing with !consumer but not with !inode? and why does
it make sense to allow !consumer at all?

Quoted 3 lines

I am not sure if I got your comment correctly.

I do check for inode just after the igrab.

No you don't, you check the return value of igrab(), but you crash hard when someone calls register_uprobe(.inode=NULL).

Quoted 3 lines

I am actually not dealing with !consumer.
If the consumer is NULL, then we dont have any handler to run so why would we want to register such a probe?

Why allow someone calling register_uprobe(.consumer=NULL) to begin with? That doesn't make any sense.

Quoted 3 lines

Also if consumer->next is Non-NULL, that means that this consumer was already used. Reusing the consumer, can result in consumers list getting broken into two.

Yeah, although at that point why be nice about it? Just but a WARN_ON() in or so.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#11 lore raw
In reply to a message not in the archive
Quoted 11 lines

Review

Quoted 8 lines
(quoted diff) +8 -0
+
+       mutex_unlock(uprobes_hash(inode));
+       put_uprobe(uprobe);
+
+reg_out:
+       iput(inode);
+       return ret;
+}

So if this function returns an error the caller is responsible for cleaning up consumer, otherwise we take responsibility.

The caller is always responsible to cleanup the consumer. The only field we touch in the consumer is the next; thats because we use to link up the consumers.

Signature · 9 lines
Thanks and Regards
Srikar

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#9 lore raw
In reply to Peter Zijlstra
Quoted 19 lines · Peter Zijlstra
Quoted 18 lines · Srikar Dronamraju
Quoted 16 lines · Srikar Dronamraju

Review

Quoted 10 lines
(quoted diff) +10 -0
+int register_uprobe(struct inode *inode, loff_t offset,
+                               struct uprobe_consumer *consumer)
+{
+       struct uprobe *uprobe;
+       int ret = -EINVAL;
+
+       if (!consumer || consumer->next)
+               return ret;
+
+       inode = igrab(inode);

So why are you dealing with !consumer but not with !inode? and why does
it make sense to allow !consumer at all?

Quoted 7 lines
Quoted 3 lines

I am not sure if I got your comment correctly.

I do check for inode just after the igrab.

No you don't, you check the return value of igrab(), but you crash hard when someone calls register_uprobe(.inode=NULL).

Okay. will add a check for inode before we do the igrab.

Quoted 7 lines
Quoted 3 lines

I am actually not dealing with !consumer.
If the consumer is NULL, then we dont have any handler to run so why would we want to register such a probe?

Why allow someone calling register_uprobe(.consumer=NULL) to begin with? That doesn't make any sense.

Quoted 7 lines
Quoted 3 lines

Also if consumer->next is Non-NULL, that means that this consumer was already used. Reusing the consumer, can result in consumers list getting broken into two.

Yeah, although at that point why be nice about it? Just but a WARN_ON() in or so.

I thought you werent happy with prints and WARN_ON/BUG_ON unless it was really really necessary. If we were to have a WARN_ON for a wrong consumer passed, then we would need a warn_On for NULL inode too.

So I think we should leave this as is.

Unless I have commented, I agree to your comments sent in other threads and will resolve them accordingly.

Signature · 2 lines
Thanks and Regards
Srikar
#10 lore raw
Quoted 5 lines · Srikar Dronamraju
Quoted 3 lines

No you don't, you check the return value of igrab(), but you crash hard when someone calls register_uprobe(.inode=NULL).

Okay. will add a check for inode before we do the igrab.

No!!! its fcking pointless calling this function without a valid inode argument, don't mess about and try and deal with it.

Same with the consumer thing, if you call it with a NULL consumer you're an idiot, try memcpy(NULL, foo, size), does that return -EINVAL?

Also, what's the point of all this igrab() nonsense? We don't need extra references on the inode, the caller of these functions had better made sure the inode is stable and good to use, otherwise it could be freed before we do igrab() and we'd still crash.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>