Commit Graph

5712 Commits

Author SHA1 Message Date
David van Moolenbroek
b63b356ab3 VFS: worker thread model overhaul
The main purpose of this patch is to fix handling of unpause calls
from PM while another call is ongoing. The solution to this problem
sparked a full revision of the threading model, consisting of a large
number of related changes:

- all active worker threads are now always associated with a process,
  and every process has at most one active thread working for it;
- the process lock is always held by a process's worker thread;
- a process can now have both normal work and postponed PM work
  associated to it;
- timer expiry and non-postponed PM work is done from the main thread;
- filp garbage collection is done from a thread associated with VFS;
- reboot calls from PM are now done from a thread associated with PM;
- the DS events handler is protected from starting multiple threads;
- support for a system worker thread has been removed;
- the deadlock recovery thread has been replaced by a parameter to the
  worker_start() function; the number of worker threads has
  consequently been increased by one;
- saving and restoring of global but per-thread variables is now
  centralized in worker_suspend() and worker_resume(); err_code is now
  saved and restored in all cases;
- the concept of jobs has been removed, and job_m_in now points to a
  message stored in the worker thread structure instead;
- the PM lock has been removed;
- the separate exec lock has been replaced by a lock on the VM
  process, which was already being locked for exec calls anyway;
- PM_UNPAUSE is now processed as a postponed PM request, from a thread
  associated with the target process;
- the FP_DROP_WORK flag has been removed, since it is no longer more
  than just an optimization and only applied to processes operating on
  a pipe when getting killed;
- assignment to "fp" now takes place only when obtaining new work in
  the main thread or a worker thread, when resuming execution of a
  thread, and in the special case of exiting processes during reboot;
- there are no longer special cases where the yield() call is used to
  force a thread to run.

Change-Id: I7a97b9b95c2450454a9b5318dfa0e6150d4e6858
2013-09-28 00:10:50 +02:00
David van Moolenbroek
ecf94d5705 Retire ptrace(T_DUMPCORE), dumpcore(1), gcore(1)
The T_DUMPCORE implementation was not only broken - it would currently
produce a coredump of the tracer process rather than the traced
process - but also deeply flawed, and fixing it would require serious
alteration of PM's internal state machine. It should be possible to
implement the same functionality in userland, and that is now the
suggested way forward. For now, also remove the (identical) utilities
using T_DUMPCORE: dumpcore(1) and gcore(1).

Change-Id: I1d51be19c739362b8a5833de949b76382a1edbcc
2013-09-28 00:10:49 +02:00
David van Moolenbroek
6dd9aaab7b VFS: process char driver replies from main thread
Previously, processing of some replies coming from character drivers
could block on locks, and therefore, such processing was done from
threads that were associated to the character driver process. The
hidden consequence of this was that if all threads were in use, VFS
could drop replies coming from the driver. This patch returns VFS to
a situation where the replies from character drivers are processed
instantly from the main thread, by removing the situations that may
cause VFS to block while handling those replies.

- change the locking model for select, so that it will never block
  on any processing that happens after the select call has been set
  up, in particular processing of character driver select replies;
- clearly mark all select routines that may never block;
- protect against race conditions in do_select as result of the
  locking that still does happen there (as is required for pipes);
- also handle select timers from the main thread;
- move processing of character driver replies into device.c.

Change-Id: I4dc8e69f265cbd178de0fbf321d35f58f067cc57
2013-09-28 00:10:49 +02:00
David van Moolenbroek
39429a09e2 VFS: properly cancel select queries on unpause
Change-Id: I16e71db3f5c1bcc7ba6045bc9f02b13d71dc31eb
2013-09-28 00:10:49 +02:00
David van Moolenbroek
5b80768ca7 VFS: remove support for sync char driver protocol
Change-Id: I57cc870a053b813b3a3fc45da46606ea84fe4cb1
2013-09-28 00:10:49 +02:00
David van Moolenbroek
ee15ec95e3 VFS: remove FP_BLOCKED_ON_DOPEN
These days, DEV_OPEN calls to character drivers block the calling
thread until completion or failure, and thus never return SUSPEND to
the caller. The same already applied to BDEV_OPEN calls to block
drivers. It has thus become impossible for a process to enter a state
of being blocked on a device open call.

There is currently no support for restarting device open calls to
restarted character drivers. This support was present in the _DOPEN
logic, but was already no longer triggering. In the future, this case
should be handled by the thread performing the open request.

Change-Id: I6cc1e7b4c9ed116c6ce160b315e6e060124dce00
2013-09-28 00:10:48 +02:00
David van Moolenbroek
03bb6dd02e PFS: remember request information for IOCTLs
Not doing so caused PFS to commit protocol violations by relying on
stale information when sending replies. This stale information always
happened to be correct, which is why the problem went unnoticed.
Change-Id: Ia42ca670718d6e731193cd2c34a3ff455f8a94d3
2013-09-28 00:10:48 +02:00
David van Moolenbroek
9e2b5c667b Retire the synchronous character driver protocol
- change all sync char drivers into async drivers;
- retire support for the sync protocol in libchardev;
- remove async dev style, as this is now the default;
- remove dev_status from VFS;
- clean up now-unused protocol messages.

Change-Id: I6aacff712292f6b29f2ccd51bc1e7d7003723e87
2013-09-28 00:10:48 +02:00
David van Moolenbroek
1ae2372622 Sync char protocol: add nonblocking transfer flag
The async char protocol already has this, so this patch closes the
gap between the two protocols a bit. Support for this flag has been
added to all sync char drivers that support CANCEL at all.

The LOG driver was already using the asynchronous protocol, but it
did not support the nonblocking transfer flag. This has been fixed
as well.

Change-Id: Ia55432c9f102765b59ad3feb45a8bd47a782c93f
2013-09-28 00:10:48 +02:00
David van Moolenbroek
f76b334bc4 VFS: set w_drv_sendrec only when needed
As with w_task, this ensures that the field remains cleared if it is
not used. Without this, worker_stop could mistakenly identify a thread
as talking to a device driver rather than a (crashed) file server.

Change-Id: I7d3ebed3efc3cd4f5c891f61c67a6463109b6376
2013-09-28 00:10:48 +02:00
Thomas Veerman
035ed928d2 VFS: set w_task only when needed
It was always set, but not always cleared, when talking to asynchronous
drivers. This could cause erratic behavior upon a driver crash.

Normally, a worker thread's w_task field is set when it's about to
communicate with a driver or FS. Then upon receiving a reply we can
do sanity checks (that the thread we want to wake up was actually
waiting for a reply). Also, when a driver/FS crashes, we can identify
which worker threads were talking to the crashed endpoint and handle
the error gracefully.

Asynchronous drivers are a bit special, though. In most cases, the
sender of the request is not interested in the reply (the sender was
suspended and only wants to know whether the request was successfully
caried out or not). However, the open request is special, as the reply
carries information needed by the sender. This is the only request
where a worker thread actually yields and waits for the result. This is
also the only case where we're interested in setting w_task for
asynchronous drivers.

Change-Id: Ia1ce2747937df376122b5e13b6a069de27fcc379
2013-09-28 00:10:47 +02:00
Lionel Sambuc
77db0c5766 Removing CSU patches
* Removed startup code patches in lib/csu regarding kernel to userland
   ABI.

 * Aligned stack layout on NetBSD stack layout.

 * Generate valid stack pointers instead of offsets by taking into account
   _minix_kerninfo->kinfo->user_sp.

 * Refactored stack generation, by moving part of execve in two
   functions {minix_stack_params(), minix_stack_fill()} and using them
   in execve(), rs and vm.

 * Changed load offset of rtld (ld.so) to:
      execi.args.stack_high - execi.args.stack_size - 0xa00000
   which is 10MB below the main executable stack.

Change-Id: I839daf3de43321cded44105634102d419cb36cec
2013-09-28 00:10:47 +02:00
David van Moolenbroek
eb836677a8 Set M3_STRING to M3_LONG_STRING (ABI break)
Change-Id: Id48bbd4ba3000acf8a891445b4c890b1b42bd72f
2013-09-28 00:10:47 +02:00
David van Moolenbroek
390c4df3cd Remove support for obsolete 3.2.1 ABI
Change-Id: I76b4960bda41f55d9c42f8c99c5beae3424ca851
2013-09-28 00:10:47 +02:00
David van Moolenbroek
f8ebd3dee4 Fix various file system warnings
Change-Id: Ied10498c3ae14f9f2fd06914f23239df330fa296
2013-09-28 00:10:46 +02:00
David van Moolenbroek
cb32cbb218 VFS/FS: replace protocol version with flag field
The main motivation for this change is that only Loris supports
multithreading, and Loris supports dynamic thread allocation, so the
number of supported threads can be implemented as a bit flag (i.e.,
either 1 or "at least as many as VFS has"). The ABI break obviates the
need to support file system versioning at this time, and several
other aspects are better implemented as flags as well. Other changes:

- replace peek/bpeek test upon mount with FS flag as well;
- mark libsffs as 64-bit file size capable;
- remove old (3.2.1) getdents support.

Change-Id: I313eace9c50ed816656c31cd47d969033d952a03
2013-09-28 00:10:46 +02:00
David van Moolenbroek
acca21faed Import NetBSD df(1)
Change-Id: I7a99e335da666a15b43b9daeb59dbfee516f0118
2013-09-28 00:10:40 +02:00
David van Moolenbroek
080c91c8a5 Enable getmntinfo(3)
Change-Id: Ida9b0660471bb9fde3cdca6c9b9fd9e94341e02f
2013-09-28 00:10:26 +02:00
David van Moolenbroek
fceb38bbc5 test55: add tests for getvfsstat(2)
Change-Id: Idc3da4137494db836590c71414017832f15a2628
2013-09-28 00:10:15 +02:00
David van Moolenbroek
ab703fdfdf Implement support for [f]statvfs1(2)
The [f]statvfs(3) calls now use [f]statvfs1(2).

Change-Id: I949c177fc14abf976e45165c342f897f4ec988ee
2013-09-28 00:09:54 +02:00
David van Moolenbroek
cdcbf659a1 Implement support for getvfsstat(2)
Change-Id: I99b697919d411c57105de561105beefc7d1d309a
2013-09-28 00:09:43 +02:00
David van Moolenbroek
098ec7e415 Redo mount(2)/umount(2) ABI
- pass in file system type through mount(2), and return this type in
  statvfs structures as generated by [f]statvfs(2);
- align mount flags field with NetBSD's, splitting out service flags
  which are not to be passed to VFS;
- remove limitation of mount ABI to 16-byte labels, so that labels
  can be made larger in the future;
- introduce new m11 message union type for mount(2) as side effect.

Change-Id: I88b7710e297e00a5e4582ada5243d3d5c2801fd9
2013-09-28 00:09:33 +02:00
David van Moolenbroek
c4bd0e949e Align "struct statvfs" with NetBSD
This is a requirement for implementing calls such as getmntinfo(3).
VFS is now responsible for filling in some of the structure's fields.

Change-Id: I0c1fa78019587efefd2949b3be38cd9a7ddc2ced
2013-09-28 00:09:22 +02:00
David van Moolenbroek
92f858105b VFS/FS: remove fstatfs(2) and REQ_FSTATFS
The fstatfs(3) call now uses fstatvfs(2).

Change-Id: I3fa5d31f078457b4d80418c23060bb2c148cb460
2013-09-28 00:06:01 +02:00
Lionel Sambuc
1cb1d23986 usr.bin/stat Update
Change-Id: I029160c73baab1b3465bc5397a36c55886db225b
2013-09-28 00:03:44 +02:00
Lionel Sambuc
6112cea1e2 almost aligned ioctl prototype
Change-Id: I7f3eaa99d2a9767f71e8387cea5c7f56dcb28f99
2013-09-28 00:03:44 +02:00
Lionel Sambuc
2cf2960340 ABI Break: aligning struct termios
Change-Id: I0109188fffbb166a5036e324a4a75b2491c39fb3
2013-09-28 00:03:43 +02:00
Lionel Sambuc
29d530957e 32 to 64 bits fsblkcnt_t and fsfilcnt_t.
Change-Id: I432229143c85cd178262b802a76ac606801ac59a
2013-09-28 00:03:43 +02:00
Lionel Sambuc
730d1ea6d6 moving prototypes to lib.h
Change-Id: If53d3f5ee761b10e0f3d4346a0c5b39ba7901c65
2013-09-28 00:03:43 +02:00
Lionel Sambuc
43490dfc1d struct uucred
Change-Id: Ia97cb6c38bb566be30d568a252ae7b76142a21dd
2013-09-28 00:03:43 +02:00
Lionel Sambuc
54065af023 Alignement on netbsd types, part 1
The following types are modified (old -> new):
 * _BSD_USECONDS_T_ int       -> unsigned int
 * __socklen_t      __int32_t -> __uint32_t
 * blksize_t        uint32_t  -> int32_t
 * rlim_t           uint32_t  -> uint64_t
On ARM:
 * _BSD_CLOCK_T_    int       -> unsigned int
On Intel:
 * _BSD_CLOCK_T_    int       -> unsigned long

bin/cat is also updated in order to fix warnings.

_BSD_TIMER_T_ has still to be aligned.

Change-Id: I2b4fda024125a19901120546c4e22e443ba5e9d7
2013-09-28 00:03:42 +02:00
Lionel Sambuc
6b586091a6 Adapt the type used for adjtime_delta
clock_t is currently a signed type, but in NetBSD this is not the
case. As we plan on aligning our types we have to change this as this
prevents negative delta from being correctly used.

Change-Id: I9bccdee2b41626b0262471dc1900de505a1991a7
2013-09-28 00:03:42 +02:00
Lionel Sambuc
2ec49130c1 fix sysroot clang
Change-Id: I63adf8460e7fdbe3d9d5ad6c828ae5758cb1643c
2013-09-28 00:03:42 +02:00
Lionel Sambuc
0d76bdef63 Bumping version to 3.3.0
Change-Id: I4c88bdd449daf6ad3fe4e93ee8fc35d4f38becc4
2013-09-28 00:03:25 +02:00
Thomas Veerman
1fb2d93acc VFS: use 64-bit file offsets in all requests
Change-Id: I735c4068135474aff2c397f4bc9fb147a618b453
2013-09-28 00:03:14 +02:00
Thomas Veerman
72b91ca301 stat.h: remove some big_ types
Change-Id: I84017db3d54edfb823cc52e02d0b07fccb003988
2013-09-28 00:02:52 +02:00
Thomas Veerman
62b10087fc Define protocol version of {mode,ino,uid,gid}_t
Change-Id: Ia2027749f2ce55a561d19eb895a5618505e9a2ac
2013-09-28 00:02:32 +02:00
Thomas Veerman
334c19a7f8 VFS-FS protocol: add versioning
Change-Id: Ice6fbfd4b535b7435653fa08b27a3378d1cfdbf8
2013-09-28 00:02:15 +02:00
Ben Gras
b6d951df17 arm_sdimage.sh: use native minix partition util
. make filesystems on primary partitions to make it
	  easier on the minix partition util
	. so sfdisk isn't required as an external tool
	. also make partition and hitherto x86-only utilities
	  arch-independent

Change-Id: Ib4e07e45d038d084dde1858917d3deb7f0616532
2013-09-27 14:13:43 +02:00
Kees Jongenburger
ed45d98dac arm:ensure read_tsc_64 always returns a valid value.
Before this change overflowing the free running clock counter
between the time the timer was read and the time the overflow
check was done resulted in read_tsc_64 returning a to high value.

Change-Id: I1022f271213647f720477c4121d45f0c965456c6
2013-09-27 11:29:04 +02:00
Kees Jongenburger
02f6308a2b arm:mmc driver speedup.
Speedup the mmc driver one more time before doing a proper fix.

Change-Id: I9dbe9b1e16e71fed00c8ac3ca7fdc6c4374284c0
2013-09-26 12:11:29 +02:00
Kees Jongenburger
d60d07f045 arm:caching enable barriers
Change-Id: I2c54a3c3c8f0502bf365901d771a989f7c556958
2013-09-26 12:11:29 +02:00
Kees Jongenburger
400e577fd5 arm:caching clean caches before setting up mappings.
Change-Id: I9ff1bb04ea9c0adeb76e5176526448d93bfe29f5
2013-09-26 12:11:29 +02:00
Kees Jongenburger
73ed75a454 arm:vm allow per memory type flags.
Change-Id: Id5a5bd479bdfbbc3fb52a85c29e1d7712a1171a7
2013-09-26 12:11:28 +02:00
Kees Jongenburger
34b517ab12 arm:caching mark normal memory cacheable during identity mapping.
Change-Id: I7cd8da168744a3f32276803e99e8af0fea772574
2013-09-26 12:11:28 +02:00
Kees Jongenburger
d77debb5b7 arm:caching access the l1 pages over cacheable memory.
When we start using a new pagetable (for a new process)
the last part is to ensure the pagetable itself can be
accessed by VM. This is done in pt_bind by updating
the "pagetable of pagetables" and we want this mapping
to match other mappings to the l1 pagetable.

Change-Id: I7b506fd75553917fdc1abd25b55e4b2f25ccbf8d
2013-09-26 11:57:44 +02:00
Kees Jongenburger
2830a5af5c arm:perform copy operation using same cacheability.
When copying data from cacheable memory also use cacheable
attributes when creating temporary mappings.

Change-Id: I0e8380293fb4edaafba49f6262983ad86a5350c5
2013-09-26 11:54:36 +02:00
Kees Jongenburger
0d02dc9d54 arm:make the MMU fetch pagetable data through the caches.
Change-Id: Ibd7b66558c369d0c0792c02801562580d255fa1f
2013-09-26 11:54:36 +02:00
Kees Jongenburger
827378c57f arm:caching add methods to flush the data and unified cache
Change-Id: Idb066dd01afbdbccd684bcdcf4af88b4b1ef870a
2013-09-26 11:54:36 +02:00
Kees Jongenburger
c4ffaa0afb arm:caching define a new caching combination and use that.
This combo was taken from the startware examples.

Change-Id: I9ef8d4f4706124a6aaec72f5da65b5301c5c2301
2013-09-26 11:54:36 +02:00