From 808a6b83de7f3f06327c8db6e801302084651bd8 Mon Sep 17 00:00:00 2001 From: Artem Savkov Date: Fri, 6 Apr 2018 13:27:20 +0200 Subject: [PATCH] patch-author-guide: sleeping locks in callbacks Add a note about dealing with sleeping locks in callbacks. --- doc/patch-author-guide.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/patch-author-guide.md b/doc/patch-author-guide.md index fa9cb68..15f4562 100644 --- a/doc/patch-author-guide.md +++ b/doc/patch-author-guide.md @@ -193,7 +193,10 @@ static void kpatch_post_unpatch_tcp_send_challenge_ack(patch_object *obj) +KPATCH_POST_UNPATCH_CALLBACK(kpatch_post_unpatch_tcp_send_challenge_ack); ``` -Don't forget to protect access to the data as needed. +Don't forget to protect access to the data as needed. Please note that mutexes +and other sleeping locks can't be used from stop_machine context, so you will +have to check if any locks protecting the data are already held and if so +return an error from your callback function. Also be careful when upgrading. If patch A has a pre/post-patch callback which writes to X, and then you load patch B which is a superset of A, in some cases