Re: dev_lock() question
On Thursday 29 September 2005 03:36 pm, Poul-Henning Kamp wrote: In message [EMAIL PROTECTED], John Baldwin writes: On Thursday 29 September 2005 02:14 pm, Poul-Henning Kamp wrote: In message [EMAIL PROTECTED], John Baldwin writes: Actually, you would think that it could be initialized either via an early SYSINIT() or in the init_mutexes() function in kern_mutex.c and thus not need the early check and avoid penalizing dev_lock(). phk, how early his dev_lock needed? Far too early due to console madness (in syscons I belive). So would mutex_init() work? Havn't tried. It basically has to work right before the copyright is printed. Actually, mutexes won't work until after mutex_init() anyway, so it had better work. :) I'll try it out. Patch is below for reference: --- //depot/vendor/freebsd/src/sys/kern/kern_conf.c 2005/09/19 20:01:08 +++ //depot/projects/smpng/sys/kern/kern_conf.c 2005/09/30 12:57:36 @@ -57,8 +57,7 @@ void dev_lock(void) { - if (!mtx_initialized(devmtx)) - mtx_init(devmtx, cdev, NULL, MTX_DEF); + mtx_lock(devmtx); } --- //depot/vendor/freebsd/src/sys/kern/kern_mutex.c2005/09/02 20:25:20 +++ //depot/projects/smpng/sys/kern/kern_mutex.c2005/09/30 12:57:36 @@ -900,5 +935,6 @@ mtx_init(Giant, Giant, NULL, MTX_DEF | MTX_RECURSE); mtx_init(sched_lock, sched lock, NULL, MTX_SPIN | MTX_RECURSE); mtx_init(proc0.p_mtx, process lock, NULL, MTX_DEF | MTX_DUPOK); + mtx_init(devmtx, cdev, NULL, MTX_DEF); mtx_lock(Giant); } -- John Baldwin [EMAIL PROTECTED]http://www.FreeBSD.org/~jhb/ Power Users Use the Power to Serve = http://www.FreeBSD.org ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
dev_lock() question
Hi, dev_lock() looks this way: void dev_lock(void) { if (!mtx_initialized(devmtx)) mtx_init(devmtx, cdev, NULL, MTX_DEF); mtx_lock(devmtx); } I wonder why is the mtx_initialized checking necessary? shouldnt explicit initialization be sufficient? thnx for answer roman ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: dev_lock() question
On Thu, Sep 29, 2005 at 06:55:38PM +0200, Divacky Roman wrote: Hi, dev_lock() looks this way: void dev_lock(void) { if (!mtx_initialized(devmtx)) mtx_init(devmtx, cdev, NULL, MTX_DEF); mtx_lock(devmtx); } I wonder why is the mtx_initialized checking necessary? shouldnt explicit initialization be sufficient? thnx for answer roman Moving mtx_initialized() check into mtx_init will decrease speed of other mutexes initialization. We must check if it's initialized here because of it's not permiited to pass already initialized mutex to mtx_init(). ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: dev_lock() question
On Thursday 29 September 2005 01:04 pm, Stanislav Sedov wrote: On Thu, Sep 29, 2005 at 06:55:38PM +0200, Divacky Roman wrote: Hi, dev_lock() looks this way: void dev_lock(void) { if (!mtx_initialized(devmtx)) mtx_init(devmtx, cdev, NULL, MTX_DEF); mtx_lock(devmtx); } I wonder why is the mtx_initialized checking necessary? shouldnt explicit initialization be sufficient? thnx for answer roman Moving mtx_initialized() check into mtx_init will decrease speed of other mutexes initialization. We must check if it's initialized here because of it's not permiited to pass already initialized mutex to mtx_init(). Actually, you would think that it could be initialized either via an early SYSINIT() or in the init_mutexes() function in kern_mutex.c and thus not need the early check and avoid penalizing dev_lock(). phk, how early his dev_lock needed? -- John Baldwin [EMAIL PROTECTED]http://www.FreeBSD.org/~jhb/ Power Users Use the Power to Serve = http://www.FreeBSD.org ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: dev_lock() question
In message [EMAIL PROTECTED], John Baldwin writes: Actually, you would think that it could be initialized either via an early SYSINIT() or in the init_mutexes() function in kern_mutex.c and thus not need the early check and avoid penalizing dev_lock(). phk, how early his dev_lock needed? Far too early due to console madness (in syscons I belive). -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 [EMAIL PROTECTED] | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: dev_lock() question
On Thursday 29 September 2005 02:14 pm, Poul-Henning Kamp wrote: In message [EMAIL PROTECTED], John Baldwin writes: Actually, you would think that it could be initialized either via an early SYSINIT() or in the init_mutexes() function in kern_mutex.c and thus not need the early check and avoid penalizing dev_lock(). phk, how early his dev_lock needed? Far too early due to console madness (in syscons I belive). So would mutex_init() work? It's called very early in the MD startup code right after things like curthread are initialized. If dev_lock() is called before mutex_init() it can't work right anyway as mtx_init() doesn't work until then. -- John Baldwin [EMAIL PROTECTED]http://www.FreeBSD.org/~jhb/ Power Users Use the Power to Serve = http://www.FreeBSD.org ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: dev_lock() question
In message [EMAIL PROTECTED], John Baldwin writes: On Thursday 29 September 2005 02:14 pm, Poul-Henning Kamp wrote: In message [EMAIL PROTECTED], John Baldwin writes: Actually, you would think that it could be initialized either via an early SYSINIT() or in the init_mutexes() function in kern_mutex.c and thus not need the early check and avoid penalizing dev_lock(). phk, how early his dev_lock needed? Far too early due to console madness (in syscons I belive). So would mutex_init() work? Havn't tried. It basically has to work right before the copyright is printed. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 [EMAIL PROTECTED] | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]