Skip to contentSkip to conversation

kthread: export park/unpark facility

PATCH In review Jean Tourrilhes 3 participants 7 messages Jul 9, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kthread: export park/unpark facility

	Hi,

	The kthread park/unpark facility is not used in the kernel, so

one would assume that it's made for kernel modules. This patch should definitely help most modules.
Patch untested, at your own risks...
Regards,

Jean

kernel/kthread.c renamed from kernel/kthread.j2.c +4 -0
diff -u -p linux-3.18.17/kernel/kthread.j2.c linux-3.18.17/kernel/kthread.c
@@ -97,6 +97,7 @@ bool kthread_should_park(void)
 {
 	return test_bit(KTHREAD_SHOULD_PARK, &to_kthread(current)->flags);
 }
+EXPORT_SYMBOL(kthread_should_park);
 
 /**
  * kthread_freezable_should_stop - should this freezable kthread return now?
@@ -171,6 +172,7 @@ void kthread_parkme(void)
 {
 	__kthread_parkme(to_kthread(current));
 }
+EXPORT_SYMBOL(kthread_parkme);
 
 static int kthread(void *_create)
 {
@@ -411,6 +413,7 @@ void kthread_unpark(struct task_struct *
 	if (kthread)
 		__kthread_unpark(k, kthread);
 }
+EXPORT_SYMBOL(kthread_unpark);
 
 /**
  * kthread_park - park a thread created by kthread_create().
@@ -441,6 +444,7 @@ int kthread_park(struct task_struct *k)
 	}
 	return ret;
 }
+EXPORT_SYMBOL(kthread_park);
 
 /**
  * kthread_stop - stop a thread created by kthread_create().
#1 lore raw
Quoted 3 lines · Jean Tourrilhes
	Hi,

	The kthread park/unpark facility is not used in the kernel

kernel/smpboot.c ?

Quoted 44 lines

, so one would assume that it's made for kernel modules. This patch should definitely help most modules.
Patch untested, at your own risks...
Regards,

Jean

diff -u -p linux-3.18.17/kernel/kthread.j2.c linux-3.18.17/kernel/kthread.c

kernel/kthread.c renamed from kernel/kthread.j2.c +4 -0
@@ -97,6 +97,7 @@ bool kthread_should_park(void)
 {
 	return test_bit(KTHREAD_SHOULD_PARK, &to_kthread(current)->flags);
 }
+EXPORT_SYMBOL(kthread_should_park);
 
 /**
  * kthread_freezable_should_stop - should this freezable kthread return now?
@@ -171,6 +172,7 @@ void kthread_parkme(void)
 {
 	__kthread_parkme(to_kthread(current));
 }
+EXPORT_SYMBOL(kthread_parkme);
 
 static int kthread(void *_create)
 {
@@ -411,6 +413,7 @@ void kthread_unpark(struct task_struct *
 	if (kthread)
 		__kthread_unpark(k, kthread);
 }
+EXPORT_SYMBOL(kthread_unpark);
 
 /**
  * kthread_park - park a thread created by kthread_create().
@@ -441,6 +444,7 @@ int kthread_park(struct task_struct *k)
 	}
 	return ret;
 }
+EXPORT_SYMBOL(kthread_park);
 
 /**
  * kthread_stop - stop a thread created by kthread_create().
#2 lore raw
Quoted 6 lines · Peter Hurley
Quoted 3 lines · Jean Tourrilhes
	Hi,

	The kthread park/unpark facility is not used in the kernel

kernel/smpboot.c ?

Got me, I should have said hardly used.
Sorry for the gross exageration ;-)

Jean

#3 lore raw
In reply to Jean Tourrilhes
Quoted 1 line · Jean Tourrilhes

The kthread park/unpark facility is not used in the kernel, so

git grep kthread.*park tells a different story

Quoted 1 line

one would assume that it's made for kernel modules.

Certainly not.

Quoted 1 line

This patch should definitely help most modules.

And how exactly would this help modules?

Thanks,

tglx

#4 lore raw
Quoted 4 lines · Thomas Gleixner
Quoted 2 lines

This patch should definitely help most modules.

And how exactly would this help modules?

Putting kthread to sleep and waking them up later is slightly
tricky :

		http://www.linuxjournal.com/article/8144

	The park and unpark API encapsulate this functionality in

a pretty nice and clean API, and avoid duplicating this code in various modules. I'm all for sharing the joy ;-)

Quoted 3 lines

Thanks,

tglx

Regards,

Jean

#5 lore raw
Quoted 6 lines · Jean Tourrilhes
Quoted 4 lines · Thomas Gleixner
Quoted 2 lines

This patch should definitely help most modules.

And how exactly would this help modules?

Quoted 7 lines

Putting kthread to sleep and waking them up later is slightly
tricky :

		http://www.linuxjournal.com/article/8144

	The park and unpark API encapsulate this functionality in

a pretty nice and clean API, and avoid duplicating this code in various modules. I'm all for sharing the joy ;-)

If you can come up with a proper use case, i.e. patch for a module, then we can certainly talk about the exports. But without a user it does not make any sense.

Thanks,

tglx

#6 lore raw
Quoted 4 lines · Thomas Gleixner

If you can come up with a proper use case, i.e. patch for a module, then we can certainly talk about the exports. But without a user it does not make any sense.

My module is currently out of the tree, so obviously it does
not count.
Regards,

Jean