History log of /freebsd-10-stable/sys/kern/subr_unit.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 312325 17-Jan-2017 ngie

MFC r312113:

Clean up trailing whitespace


# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 255057 30-Aug-2013 kib

Move the definition of the struct unrhdr into a separate header file,
to allow embedding the struct. Add init_unrhdr(9) initializer, which
sets up preallocated unrhdr.

Reviewed by: alc
Tested by: pho, bf


# 240518 14-Sep-2012 eadler

Correct double "the the"

Approved by: cperciva
MFC after: 3 days


# 218909 21-Feb-2011 brucec

Fix typos - remove duplicate "the".

PR: bin/154928
Submitted by: Eitan Adler <lists at eitanadler.com>
MFC after: 3 days


# 209844 09-Jul-2010 jh

Remove redundant high >= 0.

Reported by: rstone


# 209816 08-Jul-2010 jh

Assert that low and high are >= 0. The allocator doesn't support the
negative range.


# 209710 05-Jul-2010 jh

Extend the kernel unit number allocator for allocating specific unit
numbers. This change adds a new function alloc_unr_specific() which
returns the requested unit number if it is free. If the number is
already allocated or out of the range, -1 is returned.

Update alloc_unr(9) manual page accordingly and add a MLINK for
alloc_unr_specific(9).

Discussed on: freebsd-hackers


# 209549 27-Jun-2010 jh

Correct a comment typo.


# 209256 17-Jun-2010 jh

- Fix compilation of the subr_unit.c user space test program.
- Use %zu for size_t in a few format strings.


# 171202 04-Jul-2007 kib

Since cdev mutex is after system map mutex in global lock order, free()
shall not be called while holding cdev mutex. devfs_inos unrhdr has cdev as
mutex, thus creating this LOR situation.

Postpone calling free() in kern/subr_unit.c:alloc_unr() and nested functions
until the unrhdr mutex is dropped. Save the freed items on the ppfree list
instead, and provide the clean_unrhdrl() and clean_unrhdr() functions to
clean the list.
Call clean_unrhdrl() after devfs_create() calls immediately before
dropping cdev mutex. devfs_create() is the only user of the alloc_unrl()
in the tree.

Reviewed by: phk
Tested by: Peter Holm
LOR: 80
Approved by: re (kensmith)


# 170949 19-Jun-2007 kib

Add the witness warning for free_unr. Function could sleep, thus callers
shall not have any non-sleepable locks held.

Submitted by: Hans Petter Selasky <hselasky c2i net>
Approved by: re (kensmith)


# 143550 14-Mar-2005 phk

Remove debugging printfs.


# 143283 08-Mar-2005 phk

Reengineer subr_unit

Add support for passing in a mutex. If NULL is passed a global
subr_unit mutex is used.

Add alloc_unrl() which expects the mutex to be held.

Allocating a unit will never sleep as it does not need to allocate
memory.

Cut possible range in half so we can use -1 to mean "out of number".

Collapse first and last runs into the head by means of counters.
This saves memory in the common case(s).


# 143238 07-Mar-2005 phk

Add placeholder mutex argument to new_unrhdr().


# 139804 06-Jan-2005 imp

/* -> /*- for copyright notices, minor format tweaks as necessary


# 136945 25-Oct-2004 phk

Add delete_unrhdr() function.

It will fail fatally if all allocated numbers have not been returned first.


# 135979 30-Sep-2004 jhb

Fix a typo to fix the !DIAGNOSTIC build.

Submitted by: many


# 135956 30-Sep-2004 phk

Add a new API for allocating unit number (-like) resources.

Allocation is always lowest free unit number.

A mixed range/bitmap strategy for maximum memory efficiency. In
the typical case where no unit numbers are freed total memory usage
is 56 bytes on i386.

malloc is called M_WAITOK but no locking is provided (yet). A bit of
experience will be necessary to determine the best strategy. Hopefully
a "caller provides locking" strategy can be maintained, but that may
require use of M_NOWAIT allocation and failure handling.

A userland test driver is included.