Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Feb 2019 23:15:32 +0000 (UTC)
From:      Matt Macy <mmacy@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r344478 - in head/sys: compat/linuxkpi/common/include/linux compat/linuxkpi/common/src kern sys
Message-ID:  <201902222315.x1MNFWrZ090303@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mmacy
Date: Fri Feb 22 23:15:32 2019
New Revision: 344478
URL: https://svnweb.freebsd.org/changeset/base/344478

Log:
  lkpi: allow late binding of linux_alloc_current
  
  Some consumers may be loosely coupled with the lkpi.
  This allows them to call linux_alloc_current without
  having a static dependency.
  
  Reviewed by:	hps@
  MFC after:	1 week
  Sponsored by:	iX Systems
  Differential Revision:	https://reviews.freebsd.org/D19257

Modified:
  head/sys/compat/linuxkpi/common/include/linux/compat.h
  head/sys/compat/linuxkpi/common/src/linux_current.c
  head/sys/kern/init_main.c
  head/sys/sys/systm.h

Modified: head/sys/compat/linuxkpi/common/include/linux/compat.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/compat.h	Fri Feb 22 21:57:27 2019	(r344477)
+++ head/sys/compat/linuxkpi/common/include/linux/compat.h	Fri Feb 22 23:15:32 2019	(r344478)
@@ -41,18 +41,19 @@ struct task_struct;
 extern int linux_alloc_current(struct thread *, int flags);
 extern void linux_free_current(struct task_struct *);
 
+
 static inline void
 linux_set_current(struct thread *td)
 {
 	if (__predict_false(td->td_lkpi_task == NULL))
-		linux_alloc_current(td, M_WAITOK);
+		lkpi_alloc_current(td, M_WAITOK);
 }
 
 static inline int
 linux_set_current_flags(struct thread *td, int flags)
 {
 	if (__predict_false(td->td_lkpi_task == NULL))
-		return (linux_alloc_current(td, flags));
+		return (lkpi_alloc_current(td, flags));
 	return (0);
 }
 

Modified: head/sys/compat/linuxkpi/common/src/linux_current.c
==============================================================================
--- head/sys/compat/linuxkpi/common/src/linux_current.c	Fri Feb 22 21:57:27 2019	(r344477)
+++ head/sys/compat/linuxkpi/common/src/linux_current.c	Fri Feb 22 23:15:32 2019	(r344478)
@@ -218,6 +218,7 @@ linux_get_pid_task(pid_t pid)
 static void
 linux_current_init(void *arg __unused)
 {
+	lkpi_alloc_current = linux_alloc_current;
 	linuxkpi_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor,
 	    linuxkpi_thread_dtor, NULL, EVENTHANDLER_PRI_ANY);
 }
@@ -242,7 +243,7 @@ linux_current_uninit(void *arg __unused)
 		PROC_UNLOCK(p);
 	}
 	sx_sunlock(&allproc_lock);
-
 	EVENTHANDLER_DEREGISTER(thread_dtor, linuxkpi_thread_dtor_tag);
+	lkpi_alloc_current = linux_alloc_current_noop;
 }
 SYSUNINIT(linux_current, SI_SUB_EVENTHANDLER, SI_ORDER_SECOND, linux_current_uninit, NULL);

Modified: head/sys/kern/init_main.c
==============================================================================
--- head/sys/kern/init_main.c	Fri Feb 22 21:57:27 2019	(r344477)
+++ head/sys/kern/init_main.c	Fri Feb 22 23:15:32 2019	(r344478)
@@ -107,6 +107,14 @@ struct thread0_storage thread0_st __aligned(32);
 struct	vmspace vmspace0;
 struct	proc *initproc;
 
+int
+linux_alloc_current_noop(struct thread *td __unused, int flags __unused)
+{
+	return (0);
+}
+int (*lkpi_alloc_current)(struct thread *, int) = linux_alloc_current_noop;
+
+
 #ifndef BOOTHOWTO
 #define	BOOTHOWTO	0
 #endif
@@ -454,7 +462,7 @@ proc0_init(void *dummy __unused)
 	GIANT_REQUIRED;
 	p = &proc0;
 	td = &thread0;
-	
+
 	/*
 	 * Initialize magic number and osrel.
 	 */

Modified: head/sys/sys/systm.h
==============================================================================
--- head/sys/sys/systm.h	Fri Feb 22 21:57:27 2019	(r344477)
+++ head/sys/sys/systm.h	Fri Feb 22 23:15:32 2019	(r344478)
@@ -237,6 +237,13 @@ void	init_param2(long physpages);
 void	init_static_kenv(char *, size_t);
 void	tablefull(const char *);
 
+/*
+ * Allocate per-thread "current" state in the linuxkpi
+ */
+extern int (*lkpi_alloc_current)(struct thread *, int);
+int linux_alloc_current_noop(struct thread *, int);
+
+
 #if defined(KLD_MODULE) || defined(KTR_CRITICAL) || !defined(_KERNEL) || defined(GENOFFSET)
 #define critical_enter() critical_enter_KBI()
 #define critical_exit() critical_exit_KBI()



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902222315.x1MNFWrZ090303>