From: Tom Keiser Date: Tue, 10 Apr 2012 20:26:42 +0000 (-0400) Subject: libafs: use kthread_run when available X-Git-Tag: upstream/1.6.2_pre2^2~65 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=cd91bbac7647f768107a2e5c9524d7df23f9cddc;p=packages%2Fo%2Fopenafs.git libafs: use kthread_run when available Use the kthread_run interface on linux to create kernel threads. This interface allows all the cpus to schedule afsd threads, instead of just inheriting the cpu affinity of the main afsd thread. Written by Tom Keiser. Reviewed-on: http://gerrit.openafs.org/7915 Reviewed-by: Derrick Brashear Tested-by: BuildBot (cherry picked from commit b440d8ffcbb0ac58ecaa34a9c60fe27a0fc91026) Change-Id: Id05360309db01ac13b8d887b1ef19596ed86b63a Reviewed-on: http://gerrit.openafs.org/8604 Reviewed-by: Marc Dionne Reviewed-by: Michael Meffie Reviewed-by: Paul Smeddle Reviewed-by: Stephan Wiesand Tested-by: BuildBot --- diff --git a/acinclude.m4 b/acinclude.m4 index 11a30b3a2..003b0d9de 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -911,6 +911,10 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) AC_CHECK_LINUX_FUNC([noop_fsync], [#include ], [void *address = &noop_fsync; printk("%p\n", address)];) + AC_CHECK_LINUX_FUNC([kthread_run], + [#include + #include ], + [kthread_run(NULL, NULL, "test");]) dnl Consequences - things which get set as a result of the dnl above tests diff --git a/src/afs/afs_call.c b/src/afs/afs_call.c index 3d184b5d6..1b615174d 100644 --- a/src/afs/afs_call.c +++ b/src/afs/afs_call.c @@ -15,14 +15,19 @@ #include "afsincludes.h" /* Afs-based standard headers */ #include "afs/afs_stats.h" #include "rx/rx_globals.h" -#if !defined(UKERNEL) && !defined(AFS_LINUX20_ENV) -#include "net/if.h" -#ifdef AFS_SGI62_ENV -#include "h/hashing.h" -#endif -#if !defined(AFS_HPUX110_ENV) && !defined(AFS_DARWIN_ENV) -#include "netinet/in_var.h" -#endif +#if !defined(UKERNEL) +# if !defined(AFS_LINUX20_ENV) +# include "net/if.h" +# ifdef AFS_SGI62_ENV +# include "h/hashing.h" +# endif +# if !defined(AFS_HPUX110_ENV) && !defined(AFS_DARWIN_ENV) +# include "netinet/in_var.h" +# endif +# endif +# ifdef HAVE_LINUX_KTHREAD_RUN +# include "h/kthread.h" +# endif #endif /* !defined(UKERNEL) */ #ifdef AFS_SUN510_ENV #include "h/ksynch.h" @@ -293,11 +298,13 @@ afsd_thread(void *rock) # ifdef SYS_SETPRIORITY_EXPORTED int (*sys_setpriority) (int, int, int) = sys_call_table[__NR_setpriority]; # endif -# if defined(AFS_LINUX26_ENV) +# if !defined(HAVE_LINUX_KTHREAD_RUN) +# if defined(AFS_LINUX26_ENV) daemonize("afsd"); -# else +# else daemonize(); -# endif +# endif +# endif /* !HAVE_LINUX_KTHREAD_RUN */ /* doesn't do much, since we were forked from keventd, but * does call mm_release, which wakes up our parent (since it * used CLONE_VFORK) */ @@ -430,8 +437,14 @@ afsd_launcher(void *rock) struct afsd_thread_info *rock = container_of(work, struct afsd_thread_info, tq); # endif +# if defined(HAVE_LINUX_KTHREAD_RUN) + if (IS_ERR(kthread_run(afsd_thread, (void *)rock, "afsd"))) { + afs_warn("kthread_run failed; afs startup will not complete\n"); + } +# else /* !HAVE_LINUX_KTHREAD_RUN */ if (!kernel_thread(afsd_thread, (void *)rock, CLONE_VFORK | SIGCHLD)) afs_warn("kernel_thread failed. afs startup will not complete\n"); +# endif /* !HAVE_LINUX_KTHREAD_RUN */ } void