Re: [PATCH RFC v7 07/23] dept: Apply sdt_might_sleep_strong() to wait_for_completion()/complete()

2023-01-18 Thread Thomas Gleixner
On Mon, Jan 09 2023 at 12:33, Byungchul Park wrote:
> Makes Dept able to track dependencies by
> wait_for_completion()/complete().
>
> In order to obtain the meaningful caller points, replace all the
> wait_for_completion*() declarations with macros in the header.

That's just wrong.

> -extern void wait_for_completion(struct completion *);
> +extern void raw_wait_for_completion(struct completion *);

> +#define wait_for_completion(x)   \
> +({   \
> + sdt_might_sleep_strong(NULL);   \
> + raw_wait_for_completion(x); \
> + sdt_might_sleep_finish();   \
> +})

The very same can be achieved with a proper annotation which does not
enforce THIS_IP but allows to use __builtin_return_address($N). That's
what everything else uses too.

Thanks,

tglx


[PATCH RFC v7 07/23] dept: Apply sdt_might_sleep_strong() to wait_for_completion()/complete()

2023-01-08 Thread Byungchul Park
Makes Dept able to track dependencies by
wait_for_completion()/complete().

In order to obtain the meaningful caller points, replace all the
wait_for_completion*() declarations with macros in the header.

Signed-off-by: Byungchul Park 
---
 include/linux/completion.h | 89 +-
 kernel/sched/completion.c  | 60 +++
 2 files changed, 110 insertions(+), 39 deletions(-)

diff --git a/include/linux/completion.h b/include/linux/completion.h
index 62b32b1..0408f6d 100644
--- a/include/linux/completion.h
+++ b/include/linux/completion.h
@@ -10,6 +10,7 @@
  */
 
 #include 
+#include 
 
 /*
  * struct completion - structure used to maintain state for a "completion"
@@ -99,19 +100,89 @@ static inline void reinit_completion(struct completion *x)
x->done = 0;
 }
 
-extern void wait_for_completion(struct completion *);
-extern void wait_for_completion_io(struct completion *);
-extern int wait_for_completion_interruptible(struct completion *x);
-extern int wait_for_completion_killable(struct completion *x);
-extern int wait_for_completion_state(struct completion *x, unsigned int state);
-extern unsigned long wait_for_completion_timeout(struct completion *x,
+extern void raw_wait_for_completion(struct completion *);
+extern void raw_wait_for_completion_io(struct completion *);
+extern int raw_wait_for_completion_interruptible(struct completion *x);
+extern int raw_wait_for_completion_killable(struct completion *x);
+extern int raw_wait_for_completion_state(struct completion *x, unsigned int 
state);
+extern unsigned long raw_wait_for_completion_timeout(struct completion *x,
   unsigned long timeout);
-extern unsigned long wait_for_completion_io_timeout(struct completion *x,
+extern unsigned long raw_wait_for_completion_io_timeout(struct completion *x,
unsigned long timeout);
-extern long wait_for_completion_interruptible_timeout(
+extern long raw_wait_for_completion_interruptible_timeout(
struct completion *x, unsigned long timeout);
-extern long wait_for_completion_killable_timeout(
+extern long raw_wait_for_completion_killable_timeout(
struct completion *x, unsigned long timeout);
+
+#define wait_for_completion(x) \
+({ \
+   sdt_might_sleep_strong(NULL);   \
+   raw_wait_for_completion(x); \
+   sdt_might_sleep_finish();   \
+})
+#define wait_for_completion_io(x)  \
+({ \
+   sdt_might_sleep_strong(NULL);   \
+   raw_wait_for_completion_io(x);  \
+   sdt_might_sleep_finish();   \
+})
+#define wait_for_completion_interruptible(x)   \
+({ \
+   int __ret;  \
+   sdt_might_sleep_strong(NULL);   \
+   __ret = raw_wait_for_completion_interruptible(x);   \
+   sdt_might_sleep_finish();   \
+   __ret;  \
+})
+#define wait_for_completion_killable(x)\
+({ \
+   int __ret;  \
+   sdt_might_sleep_strong(NULL);   \
+   __ret = raw_wait_for_completion_killable(x);\
+   sdt_might_sleep_finish();   \
+   __ret;  \
+})
+#define wait_for_completion_state(x, s)\
+({ \
+   int __ret;  \
+   sdt_might_sleep_strong(NULL);   \
+   __ret = raw_wait_for_completion_state(x, s);\
+   sdt_might_sleep_finish();   \
+   __ret;  \
+})
+#define wait_for_completion_timeout(x, t)  \
+({ \
+   unsigned long __ret;\
+   sdt_might_sleep_strong(NULL);   \
+   __ret = raw_wait_for_completion_timeout(x, t);  \
+   sdt_might_sleep_finish();   \
+   __ret;  \
+})
+#define wait_for_completion_io_timeout(x, t)   \
+({ \
+   unsigned lon