Re: CVS commit: src/sys
Alex, Alexander Nasonov wrote: > Lourival Pereira Vieira Neto wrote: > > Module Name:src > > Committed By: lneto > > Date: Sat Jul 19 17:13:22 UTC 2014 > > > > Modified Files: > > src/sys/modules/lua: lua.c > > src/sys/sys: lua.h > > > > Log Message: > > lua(4): added support for running Lua scripts in intr context > > Please revert this. You can't make a mechanical change > (s/kmem_/kmem_intr_/g and so on) to enable lua in softintr > context. You need to design it. > > What if GC kicks-in in softintr? What if the code tries to > load a chunk of new code in softintr? And there are other > questions. I have explained to Lourival that softint context is a very constrained environment and he should seek for a better design, e.g. have per-CPU Lua state while keeping such Lua programs mostly stateless and sharing no global state. Ideally, we should have deterministic behaviour and memory pre-allocation with such programs (whether it is Lua or not). This is tricky with Lua, but I think he understands the implications and issues. The change is more of an initial step to (inefficiently) support the capability. Meanwhile, those interested can research and experiment with NPF+Lua. Such use of Lua is not really meant to be production-ready at this point. -- Mindaugas
Re: CVS commit: src
On Sat, Jul 19, 2014 at 02:53:22PM +, Roy Marples wrote: > Module Name: src > Committed By: roy > Date: Sat Jul 19 14:53:22 UTC 2014 > > Modified Files: > src/lib/libc/gen: arc4random.c pthread_atfork.3 > src/share/man/man7: signal.7 > > Log Message: > Document that our use of pthread_mutex_unlock(3) is async-signal-safe > and as such can be used in a phtread_atfork(3) child handler. I don't think the former is true and the latter doesn't really need it. Joerg
Re: CVS commit: src/sys
Lourival Vieira Neto wrote: > ... > Yes, I do. > ... > Yes, I am. > ... > Yes, I have. Good to know. Please document it. Thanks, Alex
Re: CVS commit: src/sys
On Sat, Jul 19, 2014 at 6:34 PM, Alexander Nasonov wrote: > Lourival Vieira Neto wrote: >> On Sat, Jul 19, 2014 at 5:45 PM, Alexander Nasonov wrote: >> >> > What if GC kicks-in in softintr? >> >> >> >> It will call kmem_intr_free(9). >> > How many times? >> >> It depends on your script. > > Ok, let me ask a more general question. Do you mix softintr Lua code and > regular Lua kernel code in one Lua state? Yes, I do. > If you do, are you aware that > GC running in softintr context can collect objects you created outside > of softintr context? Yes, I am. > Have you thought of that? Yes, I have. Regards, -- Lourival Vieira Neto
Re: CVS commit: src/sys
Lourival Vieira Neto wrote: > On Sat, Jul 19, 2014 at 5:45 PM, Alexander Nasonov wrote: > >> > What if GC kicks-in in softintr? > >> > >> It will call kmem_intr_free(9). > > How many times? > > It depends on your script. Ok, let me ask a more general question. Do you mix softintr Lua code and regular Lua kernel code in one Lua state? If you do, are you aware that GC running in softintr context can collect objects you created outside of softintr context? Have you thought of that? Alex
Re: CVS commit: src/sys
On Sat, Jul 19, 2014 at 5:45 PM, Alexander Nasonov wrote: > Lourival Vieira Neto wrote: >> Hi Alexander, >> >> On Sat, Jul 19, 2014 at 4:39 PM, Alexander Nasonov wrote: >> ... >> > What if GC kicks-in in softintr? >> >> It will call kmem_intr_free(9). > How many times? It depends on your script. >> > What if the code tries to >> > load a chunk of new code in softintr? >> >> What if? Have you tried that already? > > Do I have to? See also my point below about documentation. No, you don't. >> You can formulate these questions and help to improve this work. > > Please document softintr interface in Lua (and other bits) so that > I can write my first module and formulate my questions and report > any problems. Sure, at the appropriate time I will. Regards, -- Lourival Vieira Neto
Re: CVS commit: src
Hi Alan, On Sat, Jul 19, 2014 at 5:43 PM, Alan Barrett wrote: > On Sat, 19 Jul 2014, Lourival Pereira Vieira Neto wrote: >> >> lua: updated from 5.1 to 5.3 work3 > > Is this a well-planned and well-tested update, or does it feel "rushed" > to get it done before the netbsd-7 branch? I think this was as planned and as tested as Lua 5.1 import. However, maybe, I'm missing something. > I don't see any recent > discussion in public mailing lists. It was discussed on tech-kern [1] and also on icb/irc. [1] http://mail-index.netbsd.org/tech-kern/2014/07/12/msg017341.html > Also, if this doesn't get reverted for being rushed, then please > import it on a vendor branch as per the usual practice. Did you mean moving it from -current to a specific branch? Regards, -- Lourival Vieira Neto
Re: CVS commit: src/sys
Lourival Vieira Neto wrote: > Hi Alexander, > > On Sat, Jul 19, 2014 at 4:39 PM, Alexander Nasonov wrote: > ... > > What if GC kicks-in in softintr? > > It will call kmem_intr_free(9). How many times? > > What if the code tries to > > load a chunk of new code in softintr? > > What if? Have you tried that already? Do I have to? See also my point below about documentation. > You can formulate these questions and help to improve this work. Please document softintr interface in Lua (and other bits) so that I can write my first module and formulate my questions and report any problems. Alex
Re: CVS commit: src
On Sat, 19 Jul 2014, Lourival Pereira Vieira Neto wrote: lua: updated from 5.1 to 5.3 work3 Is this a well-planned and well-tested update, or does it feel "rushed" to get it done before the netbsd-7 branch? I don't see any recent discussion in public mailing lists. Also, if this doesn't get reverted for being rushed, then please import it on a vendor branch as per the usual practice. --apb (Alan Barrett)
Re: CVS commit: src/sys/modules/lua
On Sat, Jul 19, 2014 at 4:58 PM, Alexander Nasonov wrote: > Lourival Vieira Neto wrote: >> You can always provide a better hack. > > Clean someone's mess? No, thanks. What mess? > I could import Lua 5.3 and rework the kernel bits but you in a > hurry to import wip version. You still can do that. If other developers want, I can revert this commit too. > I don't think you will be satisfied > with a pace of my work. Actually, I really don't care about your pace of work. It is really not my business =). However, I think you could wait a little more before claiming for something that was already done ;-). Regards, -- Lourival Vieira Neto
Re: CVS commit: src
Am 19.07.2014 um 21:54 schrieb Alexander Nasonov : > > That's not how we update 3rd-party code in the tree. We use cvs import > and resolve conflicts afterwards. Oh well.. Having recent Lua is more important than following a procedure that is difficult to follow.
Re: CVS commit: src
On Sat, Jul 19, 2014 at 4:54 PM, Alexander Nasonov wrote: > Lourival Pereira Vieira Neto wrote: >> Module Name: src >> Committed By: lneto >> Date: Sat Jul 19 18:38:35 UTC 2014 >> >> Modified Files: >> src/distrib/sets/lists/base: ad.arm ad.mips ad.powerpc md.amd64 >> md.sparc64 mi shl.mi >> src/distrib/sets/lists/debug: ad.arm ad.mips ad.powerpc md.amd64 >> md.sparc64 shl.mi >> src/doc: CHANGES RESPONSIBLE >> src/etc/mtree: NetBSD.dist.base NetBSD.dist.earm NetBSD.dist.mips64eb >> NetBSD.dist.mips64el NetBSD.dist.powerpc64 NetBSD.dist.sparc64 >> NetBSD.dist.x86_64 >> src/external/mit/lua/dist: Makefile README >> src/external/mit/lua/dist/doc: contents.html lua.1 lua.css luac.1 >> manual.css manual.html readme.html >> src/external/mit/lua/dist/src: Makefile lapi.c lapi.h lauxlib.c >> lauxlib.h lbaselib.c lcode.c lcode.h ldblib.c ldebug.c ldebug.h >> ldo.c ldo.h ldump.c lfunc.c lfunc.h lgc.c lgc.h linit.c liolib.c >> llex.c llex.h llimits.h lmathlib.c lmem.c lmem.h loadlib.c >> lobject.c lobject.h lopcodes.c lopcodes.h loslib.c lparser.c >> lparser.h lstate.c lstate.h lstring.c lstring.h lstrlib.c ltable.c >> ltable.h ltablib.c ltm.c ltm.h lua.c lua.h luac.c luaconf.h >> lualib.h lundump.c lundump.h lvm.c lvm.h lzio.c lzio.h >> src/external/mit/lua/lib/liblua: Makefile shlib_version >> src/external/mit/lua/usr.bin/luac: Makefile >> src/lib/lua/gpio: gpio.c >> src/lib/lua/sqlite: sqlite.c >> src/libexec/httpd: lua-bozo.c >> src/share/examples/lua: gpio.lua sqlite.lua >> src/share/mk: bsd.lua.mk >> src/sys/external/bsd/acpica/dist/include/platform: acnetbsd.h >> src/sys/lib/libkern: Makefile.libkern libkern.h >> src/sys/modules/lua: Makefile lua.c test.lua >> src/sys/modules/luapmf: Makefile luapmf.c >> src/sys/modules/luasystm: Makefile luasystm.c test.lua >> Added Files: >> src/common/lib/libc/string: strcspn.c strpbrk.c strspn.c >> src/external/mit/lua/dist/doc: alert.png osi-certified-72x60.png >> src/external/mit/lua/dist/src: lbitlib.c lcorolib.c lctype.c lctype.h >> lua.hpp lutf8lib.c >> Removed Files: >> src/external/mit/lua/dist: COPYRIGHT HISTORY INSTALL >> src/external/mit/lua/dist/doc: cover.png lua.html luac.html >> src/external/mit/lua/dist/etc: Makefile README all.c lua.hpp lua.ico >> lua.pc luavs.bat min.c noparser.c strict.lua >> src/external/mit/lua/dist/src: print.c >> src/external/mit/lua/dist/test: README bisect.lua cf.lua echo.lua >> env.lua factorial.lua fib.lua fibfor.lua globals.lua hello.lua >> life.lua luac.lua printf.lua readonly.lua sieve.lua sort.lua >> table.lua trace-calls.lua trace-globals.lua xd.lua >> src/lib/libc/string: strcspn.c strpbrk.c strspn.c >> src/sys/modules/lua: assert.h ctype.h errno.h inttypes.h limits.h >> locale.h math.h setjmp.h signal.h stdarg.h stddef.h stdio.h >> stdlib.h string.h >> >> Log Message: >> lua: updated from 5.1 to 5.3 work3 > > That's not how we update 3rd-party code in the tree. We use cvs import > and resolve conflicts afterwards. Are there some guide or policy available? Regards, -- Lourival Vieira Neto
Re: CVS commit: src/sys
Hi Alexander, On Sat, Jul 19, 2014 at 4:39 PM, Alexander Nasonov wrote: > Lourival Pereira Vieira Neto wrote: >> Module Name: src >> Committed By: lneto >> Date: Sat Jul 19 17:13:22 UTC 2014 >> >> Modified Files: >> src/sys/modules/lua: lua.c >> src/sys/sys: lua.h >> >> Log Message: >> lua(4): added support for running Lua scripts in intr context > > Please revert this. Sure; if other developers want it too, I can revert this. BTW, rmind@ and mbalmer@ have OKed this. > You can't make a mechanical change > (s/kmem_/kmem_intr_/g and so on) to enable lua in softintr > context. You need to design it. IMO, it is not a mechanical change. It is an incremental one. > What if GC kicks-in in softintr? It will call kmem_intr_free(9). > What if the code tries to > load a chunk of new code in softintr? What if? Have you tried that already? > And there are other > questions. You can formulate these questions and help to improve this work. Regards, -- Lourival Vieira Neto
Re: CVS commit: src/sys/modules/lua
Lourival Vieira Neto wrote: > You can always provide a better hack. Clean someone's mess? No, thanks. I could import Lua 5.3 and rework the kernel bits but you in a hurry to import wip version. I don't think you will be satisfied with a pace of my work. Alex
Re: CVS commit: src
Lourival Pereira Vieira Neto wrote: > Module Name: src > Committed By: lneto > Date: Sat Jul 19 18:38:35 UTC 2014 > > Modified Files: > src/distrib/sets/lists/base: ad.arm ad.mips ad.powerpc md.amd64 > md.sparc64 mi shl.mi > src/distrib/sets/lists/debug: ad.arm ad.mips ad.powerpc md.amd64 > md.sparc64 shl.mi > src/doc: CHANGES RESPONSIBLE > src/etc/mtree: NetBSD.dist.base NetBSD.dist.earm NetBSD.dist.mips64eb > NetBSD.dist.mips64el NetBSD.dist.powerpc64 NetBSD.dist.sparc64 > NetBSD.dist.x86_64 > src/external/mit/lua/dist: Makefile README > src/external/mit/lua/dist/doc: contents.html lua.1 lua.css luac.1 > manual.css manual.html readme.html > src/external/mit/lua/dist/src: Makefile lapi.c lapi.h lauxlib.c > lauxlib.h lbaselib.c lcode.c lcode.h ldblib.c ldebug.c ldebug.h > ldo.c ldo.h ldump.c lfunc.c lfunc.h lgc.c lgc.h linit.c liolib.c > llex.c llex.h llimits.h lmathlib.c lmem.c lmem.h loadlib.c > lobject.c lobject.h lopcodes.c lopcodes.h loslib.c lparser.c > lparser.h lstate.c lstate.h lstring.c lstring.h lstrlib.c ltable.c > ltable.h ltablib.c ltm.c ltm.h lua.c lua.h luac.c luaconf.h > lualib.h lundump.c lundump.h lvm.c lvm.h lzio.c lzio.h > src/external/mit/lua/lib/liblua: Makefile shlib_version > src/external/mit/lua/usr.bin/luac: Makefile > src/lib/lua/gpio: gpio.c > src/lib/lua/sqlite: sqlite.c > src/libexec/httpd: lua-bozo.c > src/share/examples/lua: gpio.lua sqlite.lua > src/share/mk: bsd.lua.mk > src/sys/external/bsd/acpica/dist/include/platform: acnetbsd.h > src/sys/lib/libkern: Makefile.libkern libkern.h > src/sys/modules/lua: Makefile lua.c test.lua > src/sys/modules/luapmf: Makefile luapmf.c > src/sys/modules/luasystm: Makefile luasystm.c test.lua > Added Files: > src/common/lib/libc/string: strcspn.c strpbrk.c strspn.c > src/external/mit/lua/dist/doc: alert.png osi-certified-72x60.png > src/external/mit/lua/dist/src: lbitlib.c lcorolib.c lctype.c lctype.h > lua.hpp lutf8lib.c > Removed Files: > src/external/mit/lua/dist: COPYRIGHT HISTORY INSTALL > src/external/mit/lua/dist/doc: cover.png lua.html luac.html > src/external/mit/lua/dist/etc: Makefile README all.c lua.hpp lua.ico > lua.pc luavs.bat min.c noparser.c strict.lua > src/external/mit/lua/dist/src: print.c > src/external/mit/lua/dist/test: README bisect.lua cf.lua echo.lua > env.lua factorial.lua fib.lua fibfor.lua globals.lua hello.lua > life.lua luac.lua printf.lua readonly.lua sieve.lua sort.lua > table.lua trace-calls.lua trace-globals.lua xd.lua > src/lib/libc/string: strcspn.c strpbrk.c strspn.c > src/sys/modules/lua: assert.h ctype.h errno.h inttypes.h limits.h > locale.h math.h setjmp.h signal.h stdarg.h stddef.h stdio.h > stdlib.h string.h > > Log Message: > lua: updated from 5.1 to 5.3 work3 That's not how we update 3rd-party code in the tree. We use cvs import and resolve conflicts afterwards. Alex
Re: CVS commit: src/sys
Lourival Pereira Vieira Neto wrote: > Module Name: src > Committed By: lneto > Date: Sat Jul 19 17:13:22 UTC 2014 > > Modified Files: > src/sys/modules/lua: lua.c > src/sys/sys: lua.h > > Log Message: > lua(4): added support for running Lua scripts in intr context Please revert this. You can't make a mechanical change (s/kmem_/kmem_intr_/g and so on) to enable lua in softintr context. You need to design it. What if GC kicks-in in softintr? What if the code tries to load a chunk of new code in softintr? And there are other questions. softint(9): Since software interrupts are a limited resource and run with higher priority than most other LWPs in the system, all block-and-resume activity by a software interrupt must be kept short to allow further processing at that level to continue. By extension, code running with process context must take care to ensure that any lock that may be taken from a software interrupt can not be held for more than a short period of time. The kernel does not allow software interrupts to use facilities or perform actions that are likely to block for a significant amount of time. This means that it's not valid for a software interrupt to sleep on condition variables or to wait for resources to become available (for example, memory). Alex
Re: CVS commit: src/sys/modules/lua
Hi Alexander, On Sat, Jul 19, 2014 at 4:15 PM, Alexander Nasonov wrote: > Lourival Pereira Vieira Neto wrote: >> ... >> Index: src/sys/modules/lua/stdlib.h >> diff -u src/sys/modules/lua/stdlib.h:1.1 src/sys/modules/lua/stdlib.h:1.2 >> --- src/sys/modules/lua/stdlib.h:1.1 Wed Oct 16 19:44:57 2013 >> +++ src/sys/modules/lua/stdlib.h Sat Jul 19 17:10:02 2014 >> @@ -1,7 +1,7 @@ >> /* $NetBSD */ >> >> /* >> - * Copyright (c) 2011, Lourival Neto . >> + * Copyright (c) 2011-2014, Lourival Neto . >> * All rights reserved. >> * >> * Redistribution and use in source and binary forms, with or without >> @@ -36,11 +36,8 @@ >> #include >> #include >> >> -#ifndef _LUA_INCLUDE_STDLIB >> -#define _LUA_INCLUDE_STDLIB >> - >> -#define realloc(ptr, nsize) kmem_alloc(nsize, KM_SLEEP) >> -#define free(ptr)kmem_free(ptr, osize) >> +#ifndef _LUA_INCLUDE_STDLIB_ >> +#define _LUA_INCLUDE_STDLIB_ >> >> #define exit(EXIT_FAILURE) return > > Infamous hack is still in the tree. You can always provide a better hack. Regards, -- Lourival Vieira Neto
Re: CVS commit: src/external/mit/lua/dist/src
Hi Alexander, On Sat, Jul 19, 2014 at 4:09 PM, Alexander Nasonov wrote: > Lourival Pereira Vieira Neto wrote: >> Module Name: src >> Committed By: lneto >> Date: Sat Jul 19 17:11:53 UTC 2014 >> >> Modified Files: >> src/external/mit/lua/dist/src: luaconf.h >> >> Log Message: >> lua(4): preventing division by zero >> >> * note: we should raise an error instead of return INTMAX_MAX > > Userspace lua returns +inf or -inf. So, something like this would > be even better than your change: > > #define luai_numdiv(a,b) \ > ((b) != 0 ? (a)/(b) : (a) > 0 ? INTMAX_MAX : INTMAX_MIN) > > Alex Did you read the note? How would you represent inf using int types? Regards, -- Lourival Vieira Neto
Re: CVS commit: src/sys/modules/lua
Lourival Pereira Vieira Neto wrote: > ... > Index: src/sys/modules/lua/stdlib.h > diff -u src/sys/modules/lua/stdlib.h:1.1 src/sys/modules/lua/stdlib.h:1.2 > --- src/sys/modules/lua/stdlib.h:1.1 Wed Oct 16 19:44:57 2013 > +++ src/sys/modules/lua/stdlib.h Sat Jul 19 17:10:02 2014 > @@ -1,7 +1,7 @@ > /* $NetBSD */ > > /* > - * Copyright (c) 2011, Lourival Neto . > + * Copyright (c) 2011-2014, Lourival Neto . > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > @@ -36,11 +36,8 @@ > #include > #include > > -#ifndef _LUA_INCLUDE_STDLIB > -#define _LUA_INCLUDE_STDLIB > - > -#define realloc(ptr, nsize) kmem_alloc(nsize, KM_SLEEP) > -#define free(ptr)kmem_free(ptr, osize) > +#ifndef _LUA_INCLUDE_STDLIB_ > +#define _LUA_INCLUDE_STDLIB_ > > #define exit(EXIT_FAILURE) return Infamous hack is still in the tree. Alex
Re: CVS commit: src/external/mit/lua/dist/src
Lourival Pereira Vieira Neto wrote: > Module Name: src > Committed By: lneto > Date: Sat Jul 19 17:11:53 UTC 2014 > > Modified Files: > src/external/mit/lua/dist/src: luaconf.h > > Log Message: > lua(4): preventing division by zero > > * note: we should raise an error instead of return INTMAX_MAX Userspace lua returns +inf or -inf. So, something like this would be even better than your change: #define luai_numdiv(a,b) \ ((b) != 0 ? (a)/(b) : (a) > 0 ? INTMAX_MAX : INTMAX_MIN) Alex