Handle UMA_ANYDOMAIN in kstack_import().

The kernel thread stack zone performs first-touch allocations by
default, and must handle the case where the local memory domain
is empty.  For most UMA zones this is handled in the keg layer,
but cache zones currently must implement a policy for this case.
Simply use a round-robin policy if UMA_ANYDOMAIN is passed.

Reported and tested by:	bcran
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Mark Johnston 2019-08-25 21:14:46 +00:00
parent c6a810919b
commit b48d4efe75
3 changed files with 10 additions and 4 deletions

View File

@ -294,6 +294,8 @@ uma_zone_t uma_zcache_create(char *name, int size, uma_ctor ctor, uma_dtor dtor,
#define UMA_ALIGN_CACHE (0 - 1) /* Cache line size align */
#define UMA_ALIGNOF(type) (_Alignof(type) - 1) /* Alignment fit for 'type' */
#define UMA_ANYDOMAIN -1 /* Special value for domain search. */
/*
* Destroys an empty uma zone. If the zone is not empty uma complains loudly.
*

View File

@ -234,8 +234,6 @@ enum zfreeskip {
SKIP_FINI = 0x00020000,
};
#define UMA_ANYDOMAIN -1 /* Special value for domain search. */
/* Prototypes.. */
int uma_startup_count(int);

View File

@ -454,12 +454,18 @@ vm_thread_dispose(struct thread *td)
static int
kstack_import(void *arg, void **store, int cnt, int domain, int flags)
{
struct domainset *ds;
vm_object_t ksobj;
int i;
if (domain == UMA_ANYDOMAIN)
ds = DOMAINSET_RR();
else
ds = DOMAINSET_PREF(domain);
for (i = 0; i < cnt; i++) {
store[i] = (void *)vm_thread_stack_create(
DOMAINSET_PREF(domain), &ksobj, kstack_pages);
store[i] = (void *)vm_thread_stack_create(ds, &ksobj,
kstack_pages);
if (store[i] == NULL)
break;
}