Commit Graph

117 Commits

Author SHA1 Message Date
rmind 5503429772 shmexit: simplify a lot by avoiding unnecessary memory allocations, since
it is a last reference, just re-lock and check mapping list again.  Often
there wont be re-locks at all, moreover, shm_lock is not contended at all.
2009-10-05 23:47:04 +00:00
joerg f5b0fec0e0 Remove SHMMAXPGS from all kernel configs. Dynamically compute the
initial limit as 1/4 of the physical memory. Ensure the limit is at
least 1024 pages, the old default on most platforms.
2009-03-06 20:31:46 +00:00
christos 461a86f9bd merge christos-time_t 2009-01-11 02:45:45 +00:00
rmind d2fec2fc4f sys_shmat: initialise shmid of shmmap entry earlier. Now error path,
i.e. shm_delete_mapping, wont use random value.
2008-12-22 13:49:17 +00:00
erh 75072b1c6f Change the order of error checks in shmget so EEXIST is returned before
EINVAL or EACCESS so callers have a more reliable way to tell if a
 shared memory segment already exists.
2008-10-27 15:40:56 +00:00
rmind 68121d6afa - Allow changing of kern.ipc.shmmax, just to avoid confusion.
- Change type of kern.ipc.shmmax to CTLTYPE_QUAD.
2008-10-07 09:35:03 +00:00
rmind ea71ae9284 Fix the aligning of memory blocks again, finally...
Tested by <martin> on his sparc64 box.
2008-09-19 11:21:33 +00:00
ad 10d96b47b0 shmrealloc: destroy condition variables before freeing them. 2008-05-31 13:11:14 +00:00
rmind 15e36ef766 sys_shmget: use the correct size variable for uobj_wirepages().
Adjust shm_memlock() for consistency too.

Fixes PR/38782, reported by Adam Hoka.
2008-05-29 21:38:18 +00:00
rmind 76db3ec4cd sys_shmget: fix an object leak in case of error. 2008-05-11 18:48:00 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
rmind 8d700f664c Fix shared memory code that it could handle > 4GB addresses correctly.
PR/38109, patch (a little bit modified) from Chris Brand.
2008-04-12 20:49:22 +00:00
njoly 1a6eaef2f2 Fix shm_cv/newshm_cv offset value by using the correct sizeof argument
(kcondvar_t -> struct shmid_ds).

ok by rmind@
2008-01-30 21:09:41 +00:00
rmind 4c26b5ddf3 - sys_shmget: size type must be size_t, not int. Should avoid possible
problems with huge allocations.
- shmrealloc: use newshmni for calculation of new sz, shminfo.shmmni
  was a mistake.  Convert sz to size_t type.
2008-01-27 18:37:50 +00:00
ad 77e0b2120f Patch up sysctl locking:
- Lock processes, credentials, filehead etc correctly.
- Acquire a read hold on sysctl_treelock if only doing a query.
- Don't wire down the output buffer. It doesn't work correctly and the code
  regularly does long term sleeps with it held - it's not worth it.
- Don't hold locks other than sysctl_lock while doing copyout().
- Drop sysctl_lock while doing copyout / allocating memory in a few places.
- Don't take kernel_lock for sysctl.
- Fix a number of bugs spotted along the way
2008-01-07 16:12:52 +00:00
ad 4a780c9ae2 Merge vmlocking2 to head. 2008-01-02 11:48:20 +00:00
dsl 7e2790cf6f Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
    int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
2007-12-20 23:02:38 +00:00
msaitoh 8ce1f4fff2 fix typos 2007-04-29 20:23:34 +00:00
ad 59d979c5f1 Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
2007-03-12 18:18:22 +00:00
christos 53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
thorpej 4f3d5a9cc0 TRUE -> true, FALSE -> false 2007-02-22 06:34:42 +00:00
ad 9abeea588a Replace some uses of lockmgr() / simplelocks. 2007-02-15 15:40:50 +00:00
ad b07ec3fc38 Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
rmind ea2709ce49 PR/28458: shmat(2) shmaddr argument is not honored as intended.
Patch applied, thanks for Minoura Makoto.

Please note, that one should fail if cannot attach to shmaddr,
but not attach it to other place.

OK by uwe@
2007-02-07 18:45:36 +00:00
ad dfe7788c29 Avoid sleeping with a held simple_lock. 2006-11-28 20:35:16 +00:00
christos df031f1edc PR/34837: Mindaguas: Add SysV SHM dynamic reallocation and locking to the
physical memory
2006-11-25 21:40:04 +00:00
yamt 1a7bc55dcc remove some __unused from function parameters. 2006-11-01 10:17:58 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
ad f474dceb13 Use the LWP cached credentials where sane. 2006-07-23 22:06:03 +00:00
kardel de4337ab21 merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
  time.tv_sec -> time_second
- struct timeval mono_time is gone
  mono_time.tv_sec -> time_uptime
- access to time via
	{get,}{micro,nano,bin}time()
	get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
  Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
  NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
2006-06-07 22:33:33 +00:00
elad 215bd95ba4 integrate kauth. 2006-05-14 21:15:11 +00:00
thorpej 218b07e98d Use ANSI function delcs. 2005-12-07 06:14:13 +00:00
christos 032305b8bd fix debugging; remove some defines that are now in the header file. 2005-11-10 18:45:20 +00:00
yamt 6b2d8b66a4 merge yamt-km branch.
- don't use managed mappings/backing objects for wired memory allocations.
  save some resources like pv_entry.  also fix (most of) PR/27030.
- simplify kernel memory management API.
- simplify pmap bootstrap of some ports.
- some related cleanups.
2005-04-01 11:59:21 +00:00
fvdl c487efe4a7 Fix some things regarding COMPAT_NETBSD32 and limits/VM addresses.
* For sparc64 and amd64, define *SIZ32 VM constants.
* Add a new function pointer to struct emul, pointing at a function
  that will return the default VM map address. The default function
  is uvm_map_defaultaddr, which just uses the VM_DEFAULT_ADDRESS
  macro. This gives emulations control over the default map address,
  and allows things to be mapped at the right address (in 32bit range)
  for COMPAT_NETBSD32.
* Add code to adjust the data and stack limits when a COMPAT_NETBSD32
  or COMPAT_SVR4_32 binary is executed.
* Don't use USRSTACK in kern_resource.c, use p_vmspace->vm_minsaddr
  instead (emulations might have set it differently)
* Since this changes struct emul, bump kernel version to 3.99.2

Tested on amd64, compile-tested on sparc64.
2005-03-26 05:12:34 +00:00
jdolecek 065df3bb84 fix typo (missing &) 2004-10-17 11:24:42 +00:00
jdolecek 84e86b0dce use nointr allocator for shmmap_entry_pool - this is always accessed
from process context
2004-10-17 11:23:16 +00:00
jdolecek 3b6adcdea1 kill the indirection via struct shm_handle and store pointer to the uvm
object direct to _shm_private; the indirection doesn't serve any
useful purpose and just wastes memory and cpu cycles
2004-10-16 13:34:07 +00:00
jdolecek f64366a240 add flag for shmget(2) to specify that later shmat(2) for the shared memory
segment should succeed even if the segment would be marked removed; use this
to implement the Linux-compatible semantics of shmat(2)

this fixes the old Linux VMware3 graphics problem with local display,
and possibly other local Linux X clients using MIT-SHM
2004-09-28 19:05:19 +00:00
jdolecek 68ee548306 fold shmat1() back into sys_shmat(), the change in rev 1.64 is not sufficient
for Linux-compatible shmat() behaviour - shmat() for the removed shared memory
segment must work from all callers, the shared memory id could be passed e.g.
to native X server via MIT-SHM

temporarily remove the functionality, the Linux-compatible semantics
will be reimplemented differently
2004-09-28 17:26:25 +00:00
simonb b5d0e6bf06 Initialise (most) pools from a link set instead of explicit calls
to pool_init.  Untouched pools are ones that either in arch-specific
code, or aren't initialiased during initial system startup.

 Convert struct session, ucred and lockf to pools.
2004-04-25 16:42:40 +00:00
junyoung fdc32973e7 - Nuke __P().
- Drop trailing spaces.
2004-03-23 13:22:32 +00:00
christos 13057976a6 include <uvm/uvm_object.h> for the benefit of ports that don't include
it in <machine/pmap.h>
2004-02-06 13:46:27 +00:00
christos 0283dcd8a6 - Don't use uao_ functions directly; use them through the pgops methods.
- Fix missing reference leak in the error path of shmat() mentioned in
  Full-Disclosure.
2004-02-05 22:28:33 +00:00
simonb efee714557 Wrap long line. 2003-12-06 01:53:14 +00:00
jdolecek 43dfb7e7a8 add #ifdef DEBUG segnum sanity check in shm_delete_mapping() 2003-12-05 22:09:56 +00:00
jdolecek 2e59e9ae06 allocate virtual memory for SYSV shm, msg and semaphore structures
separately from the bufpages, so that it would be possible to eventually
make their limits changeable in runtime

make static all local variables which do not need to be exported to other
kernel parts
2003-10-26 10:32:24 +00:00
drochner 6fb02278a3 Fix the "COW" case if a process does a detach() between fork()
and exit(): we have to lookup the entry in the private copy
again, otherwise the wrong list is manipulated.
should fix a panic on postgres shutdown reported by Marc Recht

being here, improve sone debug messages
2003-09-10 17:01:04 +00:00
drochner 00c27c6064 Make per-process shm segment descriptor magement scale better for large
shminfo.shmseg, in view of the fact that only few processes utilize a
significant fraction of it:
-turn the table into a linked list, elements allocated from a pool(9)
-On fork(), just bump a refcount instead of copying the list; it will
 be decremented on exit() and exec(). Only copy if an attach or detach
 takes place in between, which is rarely the case.
2003-09-09 15:02:45 +00:00
atatat df0a9badc6 Introduce "top down" memory management for mmap()ed allocations. This
means that the dynamic linker gets mapped in at the top of available
user virtual memory (typically just below the stack), shared libraries
get mapped downwards from that point, and calls to mmap() that don't
specify a preferred address will get mapped in below those.

This means that the heap and the mmap()ed allocations will grow
towards each other, allowing one or the other to grow larger than
before.  Previously, the heap was limited to MAXDSIZ by the placement
of the dynamic linker (and the process's rlimits) and the space
available to mmap was hobbled by this reservation.

This is currently only enabled via an *option* for the i386 platform
(though other platforms are expected to follow).  Add "options
USE_TOPDOWN_VM" to your kernel config file, rerun config, and rebuild
your kernel to take advantage of this.

Note that the pmap_prefer() interface has not yet been modified to
play nicely with this, so those platforms require a bit more work
(most notably the sparc) before they can use this new memory
arrangement.

This change also introduces a VM_DEFAULT_ADDRESS() macro that picks
the appropriate default address based on the size of the allocation or
the size of the process's text segment accordingly.  Several drivers
and the SYSV SHM address assignment were changed to use this instead
of each one picking their own "default".
2003-02-20 22:16:05 +00:00