-
-
Save agentzh/84e937cd50238c5b96ba75d46a3f85a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/runtime/print_flush.c b/runtime/print_flush.c | |
index 18b3e8f62..a0fa71b48 100644 | |
--- a/runtime/print_flush.c | |
+++ b/runtime/print_flush.c | |
@@ -111,6 +111,13 @@ void stp_print_flush(_stp_pbuf *pb) | |
struct context* __restrict__ c = NULL; | |
char *bufp = pb->buf; | |
+#if defined(__KERNEL__) | |
+ int locked; | |
+ struct rchan_buf *buf; | |
+ struct inode *inode; | |
+ int i; | |
+#endif | |
+ | |
/* Prevent probe reentrancy on _stp_print_lock. | |
* | |
* Since stp_print_flush may be called from probe context, we | |
@@ -131,6 +138,25 @@ void stp_print_flush(_stp_pbuf *pb) | |
dbug_trans(1, "calling _stp_data_write...\n"); | |
stp_spin_lock_irqsave(&_stp_print_lock, flags); | |
+ | |
+#if defined(__KERNEL__) | |
+ buf = _stp_get_rchan_subbuf(_stp_relay_data.rchan->buf, | |
+ smp_processor_id()); | |
+ | |
+ inode = buf->dentry->d_inode; | |
+ | |
+ /* emulate a spin lock here */ | |
+ for (i = 0; i < 200; i++) { | |
+ locked = down_write_trylock(&inode->i_rwsem); | |
+ if (locked) | |
+ break; | |
+ } | |
+ | |
+#ifdef DEBUG_TRANS | |
+ if (!locked) | |
+ dbug_trans(0, "failed to lock the relay file inode"); | |
+#endif | |
+#endif /* defined(__KERNEL__) */ | |
+ | |
while (len > 0) { | |
size_t bytes_reserved; | |
@@ -147,6 +173,12 @@ void stp_print_flush(_stp_pbuf *pb) | |
break; | |
} | |
} | |
+ | |
+#if defined(__KERNEL__) | |
+ if (locked) | |
+ up_write(&inode->i_rwsem); | |
+#endif | |
+ | |
stp_spin_unlock_irqrestore(&_stp_print_lock, flags); | |
_stp_runtime_entryfn_put_context(c); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment