Home | History | Annotate | Download | only in kern
History log of /src/sys/kern/subr_extent.c
RevisionDateAuthorComments
 1.89  15-Aug-2019  skrll More diagnostic
 1.88  15-Aug-2019  skrll Indentation and wrap the resulting long line
 1.87  31-Dec-2017  skrll branches: 1.87.4;
Don't take the mutex in extent_print if EX_EARLY
 1.86  09-Nov-2017  christos don't pass 0 to the pool flags
 1.85  18-Sep-2017  jakllsch Initialize ex_lock and ex_cv only in the not-EX_EARLY case.
 1.84  24-Aug-2017  kre Build fix attempt ... changes affect !KERNEL (ie: userland, rump) version
of this file only.

Rather than adding meaningless {} around all uses of functions that
are #defined to nothing for userland, #define the funcs to something
that is functionally equivalent (but which appeases gcc).

Also, define KASSERT() to nothing for userland, which avoids the need
to add a #definee for mutex_owned which would otherwise be needed,
and simmultaneoiusly stops gcc from complaining about a lack of a prototype.
 1.83  24-Aug-2017  skrll Whitespace fix
 1.82  24-Aug-2017  jmcneill Add EX_EARLY flag for extent_create, which skips locking. Required for
using extent subsystem in early bootstrap code, before caches are enabled.
From skrll@
 1.81  24-Jul-2017  skrll Add a condition variable (ex_flwanted) to struct extent so that ex_flags
becomes an invariant.

Remove strange locking for ex_flags as a result.
 1.80  19-Dec-2016  cherry branches: 1.80.8;
panic() must be able to take varargs - in userspace testing too.
 1.79  24-Aug-2015  pooka branches: 1.79.2;
to garnish, dust with _KERNEL_OPT
 1.78  28-Jul-2015  christos revert previous, will fix differently.
 1.77  28-Jul-2015  christos fix build
 1.76  10-Jul-2014  christos branches: 1.76.4;
don't cast void * in c.
 1.75  29-Jan-2012  para branches: 1.75.6; 1.75.20;
remove left over macro after kmem_map is gone
 1.74  27-Jan-2012  para extending vmem(9) to be able to allocated resources for it's own needs.
simplifying uvm_map handling (no special kernel entries anymore no relocking)
make malloc(9) a thin wrapper around kmem(9)
(with private interface for interrupt safety reasons)

releng@ acknowledged
 1.73  27-Jan-2012  para converting extent(9) from malloc(9) to kmem(9)
preceding kmem-vmem-pool-uvm patch

releng@ acknowledged
 1.72  28-Apr-2008  martin branches: 1.72.34; 1.72.38;
Remove clause 3 and 4 from TNF licenses
 1.71  17-Mar-2008  ad branches: 1.71.2; 1.71.4;
Make them compile again.
 1.70  17-Mar-2008  yamt - simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.
 1.69  05-Dec-2007  ad branches: 1.69.2; 1.69.8; 1.69.12;
Match the docs: MUTEX_DRIVER/SPIN are now only for porting code written
for Solaris.
 1.68  10-Jul-2007  ad branches: 1.68.6; 1.68.8; 1.68.14; 1.68.16;
Make the regression test build again.
 1.67  09-Jul-2007  ad Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.66  17-May-2007  yamt merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.65  13-Mar-2007  ad Revert previous now that simplelock.h has been fixed.
 1.64  13-Mar-2007  dogcow now that simple_lock is a define elsewhere as well, #undef it in the
regress case.
 1.63  12-Mar-2007  ad branches: 1.63.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
 1.62  04-Mar-2007  christos branches: 1.62.2;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.61  01-Nov-2006  yamt branches: 1.61.4;
remove some __unused from function parameters.
 1.60  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.59  21-Jul-2006  yamt branches: 1.59.6;
use ASSERT_SLEEPABLE where appropriate.
 1.58  15-Apr-2006  christos Spell coalesce correctly.
 1.57  15-Apr-2006  christos Coverity CID 2727: Simplify code.
 1.56  02-Apr-2006  dsl call extent_free_region_descriptor(ex, myrp) when ltseep() returns non-zero
(eg if interrupted).
Fixes Coverty CIDs 1555 and 1556.
 1.55  08-Mar-2006  thorpej branches: 1.55.2;
Make extent_alloc_subregion(), extent_alloc(), and extent_alloc1() real
functions, not CPP macros.
 1.54  24-Dec-2005  perry branches: 1.54.4; 1.54.6; 1.54.8; 1.54.10;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.53  11-Dec-2005  christos merge ktrace-lwp.
 1.52  23-Jun-2005  thorpej branches: 1.52.2;
Use ANSI function decls.
 1.51  15-Mar-2005  bouyer Fix off-by-one bug which would cause a region at the end of the extent
to be alloctated multiple times:
- we're allocating region of size 1
- there are holes in the extent, but all of size larger than 1
- there are 2 contigous allocations at the end of the extent, the last one
being of size 1.
While there fix a DIAGNOSTIC check: to check that a region is inside the extent
we need to check start and end, not only start.
 1.50  23-Mar-2004  junyoung branches: 1.50.8; 1.50.10;
- Nuke __P().
- Drop trailing spaces.
 1.49  23-Jun-2003  martin branches: 1.49.2;
Make sure to include opt_foo.h if a defflag option FOO is used.
 1.48  01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.47  04-Sep-2002  matt Use the queue macros from <sys/queue.h> instead of referring to the queue
members directly. Use *_FOREACH whenever possible.
 1.46  08-Mar-2002  thorpej Pool deals fairly well with physical memory shortage, but it doesn't
deal with shortages of the VM maps where the backing pages are mapped
(usually kmem_map). Try to deal with this:

* Group all information about the backend allocator for a pool in a
separate structure. The pool references this structure, rather than
the individual fields.
* Change the pool_init() API accordingly, and adjust all callers.
* Link all pools using the same backend allocator on a list.
* The backend allocator is responsible for waiting for physical memory
to become available, but will still fail if it cannot callocate KVA
space for the pages. If this happens, carefully drain all pools using
the same backend allocator, so that some KVA space can be freed.
* Change pool_reclaim() to indicate if it actually succeeded in freeing
some pages, and use that information to make draining easier and more
efficient.
* Get rid of PR_URGENT. There was only one use of it, and it could be
dealt with by the caller.

From art@openbsd.org.
 1.45  09-Feb-2002  bouyer extent_alloc_subregion1(): when a candidate region doesn't fit after being
rounded up to respect boundary limits, adjust newstart and last before
skiping to the next region. Otherwise we may check the same candidate
region against the start of the next region, no the one immediatly following
the hole, leading to corrupted map.

This fixes the panic seen on sparc64 with scsi drivers, and probably fixes
PR 15489.
 1.44  12-Nov-2001  lukem add RCSIDs
 1.43  27-Aug-2001  enami branches: 1.43.4;
extent_alloc_subregion shouldn't allocate a region pasts the end of subregion.
 1.42  05-Jun-2001  thorpej branches: 1.42.2;
Assert that no locks are held if we're called with EX_WAITSPACE.
From Bill Sommerfeld.
 1.41  09-May-2001  thorpej Use pool_init() rather then pool_create().
 1.40  27-Apr-2001  marcus STDC cleanup: multi line string literal removed.
 1.39  06-Dec-2000  thorpej branches: 1.39.2;
pool_handle_t -> struct pool *
 1.38  12-Aug-2000  augustss Define ltsleep() in the case of _EXTENT_TESTING so regressions testing
works again.
 1.37  12-Aug-2000  sommerfeld Use ltsleep(... PNORELOCK ) instead of simple_unlock()/tsleep()
 1.36  07-Jul-2000  mrg more extent_alloc() fixes:

check that newstart + size - 1 doesn't overflow the end of the extent, rather
than the "dontcross" value, which can easily overflow the end of an extent
when being asked for an object with a large boundary requirement. this test
is more valid, in any case, and fixes extent_alloc() failure when the start of
the extent is not "aligned".
 1.35  27-Jun-2000  mrg remove include of <vm/vm.h>
 1.34  26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.33  24-Jun-2000  pk Fix-up (#if 0'd) printf() formats.
 1.32  16-Jun-2000  mrg branches: 1.32.2;
in extent_alloc_subregion1(), check for EXTENT_ALIGN() overflow when
doing the boundary-case check. approved by thorpej.
 1.31  06-Jun-2000  thorpej Make this build as a regression test with the latest simple lock
changes.
 1.30  24-May-2000  jhawk branches: 1.30.2;
Kludge:

Change #define's of the form
#define panic(a) printf(a)
to
#define \
panic(a) printf(a)
to prevent ctags(1) from detecting there is a tag.
Otherwise, the tags file claims panic() is in subr_extent.c
instead of subr_prf.c.
 1.29  11-Oct-1999  thorpej branches: 1.29.2;
Detect if kmem is up, and if not, ignore EX_MALLOCOK.
 1.28  27-Jun-1999  ross branches: 1.28.2;
include <string.h> for memset(3) when compiling userland test setup
 1.27  07-Jun-1999  thorpej Make sure the regression test compiles.
 1.26  06-Jun-1999  pk Guard our global resource `expool' against all interrupts.
 1.25  11-May-1999  drochner fix 2 problems with subregion allocation:
-a subregion start was ignored if all previous allocations were before
the subregion, reported by Lennart Augustsson in PR kern/7539
-an existing allocation which overlaps the beginning of the subregion
was ignored (ie overlapped) if is is not the last allocation
 1.24  18-Feb-1999  mycroft branches: 1.24.2; 1.24.4; 1.24.6;
Fix a thinko in the previous.
Also:
* Do the boundary check when creating a new region as well.
* If we crossed the boundary, don't just throw away the region; lop off the
beginning and see if we still fit.
SB16 is now fully functional on the Alpha.
 1.23  18-Feb-1999  mycroft Speed up the calculation of dontcross; use EXTENT_ALIGN to calculate it
directly rather than using a loop. Also adjust so that we can allocate at
the end of the integer range.
 1.22  12-Feb-1999  thorpej Fix some printf format problems on Alpha.
 1.21  22-Jan-1999  chs no need to do locking in extext_destroy().
 1.20  12-Sep-1998  christos Make copyrights consistent; fix weird/trailing spaces add missing (c) etc.
 1.19  10-Sep-1998  pk Allow the result of an extent allocation to be congruous to an arbitrary
number modulo the given alignment.
To do this the function extent_alloc_subregion() takes an additional `skew'
parameter. For compatibility's sake, this function has been renamed to
extent_alloc_subregion1().
 1.18  01-Sep-1998  pk Make user-mode testing work again.
 1.17  01-Sep-1998  pk Fix a case of duplicate allocation in extent_alloc_subregion() triggered
by specifying a start address that happens to be beyond all currently
regions.
 1.16  04-Aug-1998  perry Abolition of bcopy, ovbcopy, bcmp, and bzero, phase one.
bcopy(x, y, z) -> memcpy(y, x, z)
ovbcopy(x, y, z) -> memmove(y, x, z)
bcmp(x, y, z) -> memcmp(x, y, z)
bzero(x, y) -> memset(x, 0, y)
 1.15  24-Jul-1998  sommerfe Don't create the extent region pool until one of our callers is of the
opinion that it's safe to call malloc.
 1.14  23-Jul-1998  pk Use a memory pool instead of malloc to allocate region descriptors.
 1.13  15-Jul-1998  pk Close a descriptor leak. This proved especially detrimental under heavy
paging.
 1.12  06-Jun-1998  thorpej Add fine-grained locking. Still one refinement to make, which will be
done in a separate commit.
 1.11  21-Jan-1998  thorpej Const'ify the extent name.
 1.10  09-Oct-1997  jtc Fix tipo inherited from old version of TNF copyright template.
 1.9  29-Aug-1997  thorpej Bring changes from marc-pcmcia branch down to the trunk.
 1.8  12-May-1997  thorpej branches: 1.8.4;
Fix two boundary/overflow errors in extent_alloc_subregion():
(1): "substart == ex->ex_end" and "subend == ex->ex_start"
are completely legal parameters for extent_alloc_subregion()
(2): "(subend - substart) + 1" can cause an overflow if the whole
numeric range is covered by the extent.
Submitted by Matthias Drochner <drochner@zelz26.zel.kfa-juelich.de>
in PR #3119.
 1.7  21-Nov-1996  cgd Feature:
If not compiled with -D_KERNEL, include different includes and
do so macro magic so that this will fit sanely into test harnesses.
When used in user-land, this should be compiled with -D_EXTENT_TESTING.

Bug fixes:
(extent_insert_and_optimize) You can't do things like:
LIST_REMOVE(elem->...le_next, ...);
free(elem->...le_next, ...);
They just don't work (and will corrupt your list and/or malloc free list).

(extent_alloc_region_descriptor) Unless you wait, malloc can fail.
Don't accidentally deref a potentially-NULL pointer.
 1.6  17-Oct-1996  thorpej Several changes:
- Rename EX_NOBLOB to EX_NOCOALESCE; it's much more descriptive of
what's going on.
- In extent_free_region_descriptor(), if we're a fixed extent,
freeing a dynamically allocated region descriptor, and someone
is waiting on the freelist, let the waiter have it, rather than
free'ing it back to the system.
- Use ALIGN(), rather than our homegrown EXTENT_ALIGN(), when dealing
with map overhead. Privatize the EXTENT_ALIGN() macro; there's no need
to export it.
- Implement EX_BOUNDZERO flag. This changes the boundary line policy in
extent_alloc() and extent_alloc_subregion(); boundary lines are
computed relative to 0, rather then the start of the extent.
- Fix a nasty race between multiple participants doing region and
descriptor allocation.
- Add a new flag to specify that it's ok to wait for space in the
extent: EX_WAITSPACE.
- Blow away an unnecessary splhigh()/splx().
- Put a bunch of sanity code inside #ifdef DIAGNOSTIC/#endif.
 1.5  13-Oct-1996  christos backout previous kprintf change
 1.4  10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.3  25-Jul-1996  thorpej Fix unititialized variable warning. Pointed out by Aaron Brown.
 1.2  23-Jul-1996  thorpej In extent_alloc_subregion(), don't adjust the initial boundary check
value if we're not concerned with boundary checking. Avoids a stupid
infinite loop.
 1.1  23-Jun-1996  thorpej My extent map manager. Sort of like resource maps, but more flexible.
Understands allocation aligment and boundary restrictions, "specific region"
allocations, and suballocations. Capable of statically or dynamically
allocating map overhead.

Many thanks to Matthias Drochner for running the code for me, and sending
me bug fixes, optimizations, and suggestions. Also, many thanks to
Chris Demetriou for his extremely helpful suggestions.

XXX No manual page yet. One is forthcoming, as soon as I can scare up
the time to write one. This has been sitting on my plate for quite a
while, and several projects are waiting for it. Time to move on.
 1.8.4.4  14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.8.4.3  29-Aug-1997  thorpej Fix a whitespace botch.
 1.8.4.2  29-Aug-1997  thorpej Fix a slight logic error in Marc's bugfix to extent_alloc_subregion():
When finding the first allocated region within the allocation subregion,
do not advance the "last" pointer if we do not need to skip any allocated
regions.
 1.8.4.1  30-Jul-1997  marc extent_alloc_subregion was wrong
 1.24.6.1  30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.24.4.2  01-Jul-1999  thorpej Sync w/ -current.
 1.24.4.1  21-Jun-1999  thorpej Sync w/ -current.
 1.24.2.1  24-Jun-1999  perry pullup 1.24->1.27 (pk): deal with missing "raise interrupt level" code
 1.28.2.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.29.2.2  08-Dec-2000  bouyer Sync with HEAD.
 1.29.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.30.2.1  22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.32.2.3  10-Feb-2002  he Pull up revisions 1.43,1.45 (requested by bouyer):
Two fixes:
o Make sure that extent_alloc_subregion() does not allocate a region
past the end of a subregion.
o Avoid allocating a region over an already-allocated one when
boundary is non-null.
 1.32.2.2  10-Jun-2001  he Pull up revision 1.36 (requested by he):
Fix calculation of whether we overflow the end of the extent.
Fixes PR#13075.
 1.32.2.1  27-Jun-2000  thorpej Pull up rev. 1.33:
Fix-up (#if 0'd) printf() formats.
 1.39.2.6  17-Sep-2002  nathanw Catch up to -current.
 1.39.2.5  01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.39.2.4  28-Feb-2002  nathanw Catch up to -current.
 1.39.2.3  14-Nov-2001  nathanw Catch up to -current.
 1.39.2.2  21-Sep-2001  nathanw Catch up to -current.
 1.39.2.1  21-Jun-2001  nathanw Catch up to -current.
 1.42.2.4  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.42.2.3  16-Mar-2002  jdolecek Catch up with -current.
 1.42.2.2  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.42.2.1  13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.43.4.1  12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.49.2.5  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.49.2.4  01-Apr-2005  skrll Sync with HEAD.
 1.49.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.49.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.49.2.1  03-Aug-2004  skrll Sync with HEAD
 1.50.10.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.50.8.1  29-Apr-2005  kent sync with -current
 1.52.2.6  24-Mar-2008  yamt sync with head.
 1.52.2.5  17-Mar-2008  yamt sync with head.
 1.52.2.4  07-Dec-2007  yamt sync with head
 1.52.2.3  03-Sep-2007  yamt sync with head.
 1.52.2.2  30-Dec-2006  yamt sync with head.
 1.52.2.1  21-Jun-2006  yamt sync with head.
 1.54.10.1  19-Apr-2006  elad sync with head.
 1.54.8.4  11-Aug-2006  yamt sync with head
 1.54.8.3  24-May-2006  yamt sync with head.
 1.54.8.2  11-Apr-2006  yamt sync with head
 1.54.8.1  13-Mar-2006  yamt sync with head.
 1.54.6.1  22-Apr-2006  simonb Sync with head.
 1.54.4.1  09-Sep-2006  rpaulo sync with head
 1.55.2.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.59.6.2  10-Dec-2006  yamt sync with head.
 1.59.6.1  22-Oct-2006  yamt sync with head
 1.61.4.3  24-Mar-2007  ad splhigh -> splvm
 1.61.4.2  24-Mar-2007  yamt sync with head.
 1.61.4.1  12-Mar-2007  rmind Sync with HEAD.
 1.62.2.4  15-Jul-2007  ad Sync with head.
 1.62.2.3  13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.62.2.2  13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.62.2.1  13-Mar-2007  ad Sync with head.
 1.63.2.1  11-Jul-2007  mjf Sync with head.
 1.68.16.1  08-Dec-2007  ad Sync with head.
 1.68.14.1  08-Dec-2007  mjf Sync with HEAD.
 1.68.8.2  23-Mar-2008  matt sync with HEAD
 1.68.8.1  09-Jan-2008  matt sync with HEAD
 1.68.6.1  09-Dec-2007  jmcneill Sync with HEAD.
 1.69.12.2  02-Jun-2008  mjf Sync with HEAD.
 1.69.12.1  03-Apr-2008  mjf Sync with HEAD.
 1.69.8.1  24-Mar-2008  keiichi sync with head.
 1.69.2.1  10-Dec-2007  yamt - separate kernel va allocation (kernel_va_arena) from
in-kernel fault handling (kernel_map).
- add vmem bootstrap code. vmem doesn't rely on malloc anymore.
- make kmem_alloc interrupt-safe.
- kill kmem_map. make malloc a wrapper of kmem_alloc.
 1.71.4.1  16-May-2008  yamt sync with head.
 1.71.2.1  18-May-2008  yamt sync with head.
 1.72.38.1  18-Feb-2012  mrg merge to -current.
 1.72.34.1  17-Apr-2012  yamt sync with head
 1.75.20.1  10-Aug-2014  tls Rebase.
 1.75.6.2  03-Dec-2017  jdolecek update from HEAD
 1.75.6.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.76.4.3  28-Aug-2017  skrll Sync with HEAD
 1.76.4.2  05-Feb-2017  skrll Sync with HEAD
 1.76.4.1  22-Sep-2015  skrll Sync with HEAD
 1.79.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.80.8.1  27-Feb-2018  martin Pull up following revision(s) (requested by mrg in ticket #593):
sys/dev/marvell/mvxpsec.c: revision 1.2
sys/arch/m68k/m68k/pmap_motorola.c: revision 1.70
sys/opencrypto/crypto.c: revision 1.102
sys/arch/sparc64/sparc64/pmap.c: revision 1.308
sys/ufs/chfs/chfs_malloc.c: revision 1.5
sys/arch/powerpc/oea/pmap.c: revision 1.95
sys/sys/pool.h: revision 1.80,1.82
sys/kern/subr_pool.c: revision 1.209-1.216,1.219-1.220
sys/arch/alpha/alpha/pmap.c: revision 1.262
sys/kern/uipc_mbuf.c: revision 1.173
sys/uvm/uvm_fault.c: revision 1.202
sys/sys/mbuf.h: revision 1.172
sys/kern/subr_extent.c: revision 1.86
sys/arch/x86/x86/pmap.c: revision 1.266 (via patch)
sys/dev/dtv/dtv_scatter.c: revision 1.4

Allow only one pending call to a pool's backing allocator at a time.
Candidate fix for problems with hanging after kva fragmentation related
to PR kern/45718.

Proposed on tech-kern:
https://mail-index.NetBSD.org/tech-kern/2017/10/23/msg022472.html
Tested by bouyer@ on i386.

This makes one small change to the semantics of pool_prime and
pool_setlowat: they may fail with EWOULDBLOCK instead of ENOMEM, if
there is a pending call to the backing allocator in another thread but
we are not actually out of memory. That is unlikely because nearly
always these are used during initialization, when the pool is not in
use.

Define the new flag too for previous commit.

pool_grow can now fail even when sleeping is ok. Catch this case in pool_get
and retry.

Assert that pool_get failure happens only with PR_NOWAIT.
This would have caught the mistake I made last week leading to null
pointer dereferences all over the place, a mistake which I evidently
poorly scheduled alongside maxv's change to the panic message on x86
for null pointer dereferences.

Since pr_lock is now used to wait for two things now (PR_GROWING and
PR_WANTED) we need to loop for the condition we wanted.
make the KASSERTMSG/panic strings consistent as '%s: [%s], __func__, wchan'
Handle the ERESTART case from pool_grow()

don't pass 0 to the pool flags
Guess pool_cache_get(pc, 0) means PR_WAITOK here.
Earlier on in the same context we use kmem_alloc(sz, KM_SLEEP).

use PR_WAITOK everywhere.
use PR_NOWAIT.

Don't use 0 for PR_NOWAIT

use PR_NOWAIT instead of 0

panic ex nihilo -- PR_NOWAITing for zerot

Add assertions that either PR_WAITOK or PR_NOWAIT are set.
- fix an assert; we can reach there if we are nowait or limitfail.
- when priming the pool and failing with ERESTART, don't decrement the number
of pages; this avoids the issue of returning an ERESTART when we get to 0,
and is more correct.
- simplify the pool_grow code, and don't wakeup things if we ENOMEM.

In pmap_enter_ma(), only try to allocate pves if we might need them,
and even if that fails, only fail the operation if we later discover
that we really do need them. This implements the requirement that
pmap_enter(PMAP_CANFAIL) must not fail when replacing an existing
mapping with the first mapping of a new page, which is an unintended
consequence of the changes from the rmind-uvmplock branch in 2011.

The problem arises when pmap_enter(PMAP_CANFAIL) is used to replace an existing
pmap mapping with a mapping of a different page (eg. to resolve a copy-on-write).
If that fails and leaves the old pmap entry in place, then UVM won't hold
the right locks when it eventually retries. This entanglement of the UVM and
pmap locking was done in rmind-uvmplock in order to improve performance,
but it also means that the UVM state and pmap state need to be kept in sync
more than they did before. It would be possible to handle this in the UVM code
instead of in the pmap code, but these pmap changes improve the handling of
low memory situations in general, and handling this in UVM would be clunky,
so this seemed like the better way to go.

This somewhat indirectly fixes PR 52706, as well as the failing assertion
about "uvm_page_locked_p(old_pg)". (but only on x86, various other platforms
will need their own changes to handle this issue.)
In uvm_fault_upper_enter(), if pmap_enter(PMAP_CANFAIL) fails, assert that
the pmap did not leave around a now-stale pmap mapping for an old page.
If such a pmap mapping still existed after we unlocked the vm_map,
the UVM code would not know later that it would need to lock the
lower layer object while calling the pmap to remove or replace that
stale pmap mapping. See PR 52706 for further details.
hopefully workaround the irregularly "fork fails in init" problem.
if a pool is growing, and the grower is PR_NOWAIT, mark this.
if another caller wants to grow the pool and is also PR_NOWAIT,
busy-wait for the original caller, which should either succeed
or hard-fail fairly quickly.

implement the busy-wait by unlocking and relocking this pools
mutex and returning ERESTART. other methods (such as having
the caller do this) were significantly more code and this hack
is fairly localised.
ok chs@ riastradh@

Don't release the lock in the PR_NOWAIT allocation. Move flags setting
after the acquiring the mutex. (from Tobias Nygren)
apply the change from arch/x86/x86/pmap.c rev. 1.266 commitid vZRjvmxG7YTHLOfA:

In pmap_enter_ma(), only try to allocate pves if we might need them,
and even if that fails, only fail the operation if we later discover
that we really do need them. If we are replacing an existing mapping,
reuse the pv structure where possible.

This implements the requirement that pmap_enter(PMAP_CANFAIL) must not fail
when replacing an existing mapping with the first mapping of a new page,
which is an unintended consequence of the changes from the rmind-uvmplock
branch in 2011.

The problem arises when pmap_enter(PMAP_CANFAIL) is used to replace an existing
pmap mapping with a mapping of a different page (eg. to resolve a copy-on-write).
If that fails and leaves the old pmap entry in place, then UVM won't hold
the right locks when it eventually retries. This entanglement of the UVM and
pmap locking was done in rmind-uvmplock in order to improve performance,
but it also means that the UVM state and pmap state need to be kept in sync
more than they did before. It would be possible to handle this in the UVM code
instead of in the pmap code, but these pmap changes improve the handling of
low memory situations in general, and handling this in UVM would be clunky,
so this seemed like the better way to go.

This somewhat indirectly fixes PR 52706 on the remaining platforms where
this problem existed.
 1.87.4.1  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411

RSS XML Feed