From owner-svn-src-all@freebsd.org Fri Feb 22 23:15:34 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0C34914FDE7A; Fri, 22 Feb 2019 23:15:34 +0000 (UTC) (envelope-from mmacy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9C3BC8C834; Fri, 22 Feb 2019 23:15:33 +0000 (UTC) (envelope-from mmacy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 46AFEC57D; Fri, 22 Feb 2019 23:15:33 +0000 (UTC) (envelope-from mmacy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x1MNFXpI090307; Fri, 22 Feb 2019 23:15:33 GMT (envelope-from mmacy@FreeBSD.org) Received: (from mmacy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x1MNFWrZ090303; Fri, 22 Feb 2019 23:15:32 GMT (envelope-from mmacy@FreeBSD.org) Message-Id: <201902222315.x1MNFWrZ090303@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmacy set sender to mmacy@FreeBSD.org using -f From: Matt Macy Date: Fri, 22 Feb 2019 23:15:32 +0000 (UTC) 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 X-SVN-Group: head X-SVN-Commit-Author: mmacy X-SVN-Commit-Paths: in head/sys: compat/linuxkpi/common/include/linux compat/linuxkpi/common/src kern sys X-SVN-Commit-Revision: 344478 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9C3BC8C834 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.976,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Feb 2019 23:15:34 -0000 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()