From owner-svn-src-all@freebsd.org Wed Sep 16 14:14:28 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 276FC3E751E; Wed, 16 Sep 2020 14:14:28 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Bs2Cm0FC5z3YV6; Wed, 16 Sep 2020 14:14:28 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E0EEC19FFC; Wed, 16 Sep 2020 14:14:27 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08GEERYI055600; Wed, 16 Sep 2020 14:14:27 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08GEEQeo055594; Wed, 16 Sep 2020 14:14:26 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202009161414.08GEEQeo055594@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 16 Sep 2020 14:14:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r365798 - stable/12/sys/vm X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/vm X-SVN-Commit-Revision: 365798 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2020 14:14:28 -0000 Author: kib Date: Wed Sep 16 14:14:26 2020 New Revision: 365798 URL: https://svnweb.freebsd.org/changeset/base/365798 Log: MFC r365484: Add interruptible variant of vm_wait(9), vm_wait_intr(9). Modified: stable/12/sys/vm/uma_core.c stable/12/sys/vm/vm_domainset.c stable/12/sys/vm/vm_domainset.h stable/12/sys/vm/vm_glue.c stable/12/sys/vm/vm_page.c stable/12/sys/vm/vm_pageout.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/vm/uma_core.c ============================================================================== --- stable/12/sys/vm/uma_core.c Wed Sep 16 14:12:57 2020 (r365797) +++ stable/12/sys/vm/uma_core.c Wed Sep 16 14:14:26 2020 (r365798) @@ -2813,7 +2813,7 @@ restart: if (rr && vm_domainset_iter_policy(&di, &domain) != 0) { if ((flags & M_WAITOK) != 0) { KEG_UNLOCK(keg); - vm_wait_doms(&keg->uk_dr.dr_policy->ds_mask); + vm_wait_doms(&keg->uk_dr.dr_policy->ds_mask, 0); KEG_LOCK(keg); goto restart; } @@ -3718,7 +3718,7 @@ uma_prealloc(uma_zone_t zone, int items) KEG_LOCK(keg); if (vm_domainset_iter_policy(&di, &domain) != 0) { KEG_UNLOCK(keg); - vm_wait_doms(&keg->uk_dr.dr_policy->ds_mask); + vm_wait_doms(&keg->uk_dr.dr_policy->ds_mask, 0); KEG_LOCK(keg); } } Modified: stable/12/sys/vm/vm_domainset.c ============================================================================== --- stable/12/sys/vm/vm_domainset.c Wed Sep 16 14:12:57 2020 (r365797) +++ stable/12/sys/vm/vm_domainset.c Wed Sep 16 14:14:26 2020 (r365798) @@ -245,7 +245,7 @@ vm_domainset_iter_page(struct vm_domainset_iter *di, s /* Wait for one of the domains to accumulate some free pages. */ if (obj != NULL) VM_OBJECT_WUNLOCK(obj); - vm_wait_doms(&di->di_domain->ds_mask); + vm_wait_doms(&di->di_domain->ds_mask, 0); if (obj != NULL) VM_OBJECT_WLOCK(obj); if ((di->di_flags & VM_ALLOC_WAITFAIL) != 0) @@ -310,7 +310,7 @@ vm_domainset_iter_policy(struct vm_domainset_iter *di, return (ENOMEM); /* Wait for one of the domains to accumulate some free pages. */ - vm_wait_doms(&di->di_domain->ds_mask); + vm_wait_doms(&di->di_domain->ds_mask, 0); /* Restart the search. */ vm_domainset_iter_first(di, domain); Modified: stable/12/sys/vm/vm_domainset.h ============================================================================== --- stable/12/sys/vm/vm_domainset.h Wed Sep 16 14:12:57 2020 (r365797) +++ stable/12/sys/vm/vm_domainset.h Wed Sep 16 14:14:26 2020 (r365798) @@ -50,6 +50,6 @@ void vm_domainset_iter_policy_init(struct vm_domainset void vm_domainset_iter_policy_ref_init(struct vm_domainset_iter *, struct domainset_ref *, int *, int *); -void vm_wait_doms(const domainset_t *); +int vm_wait_doms(const domainset_t *, int mflags); #endif /* __VM_DOMAINSET_H__ */ Modified: stable/12/sys/vm/vm_glue.c ============================================================================== --- stable/12/sys/vm/vm_glue.c Wed Sep 16 14:12:57 2020 (r365797) +++ stable/12/sys/vm/vm_glue.c Wed Sep 16 14:14:26 2020 (r365798) @@ -560,7 +560,7 @@ vm_forkproc(struct thread *td, struct proc *p2, struct } dset = td2->td_domain.dr_policy; while (vm_page_count_severe_set(&dset->ds_mask)) { - vm_wait_doms(&dset->ds_mask); + vm_wait_doms(&dset->ds_mask, 0); } if ((flags & RFMEM) == 0) { Modified: stable/12/sys/vm/vm_page.c ============================================================================== --- stable/12/sys/vm/vm_page.c Wed Sep 16 14:12:57 2020 (r365797) +++ stable/12/sys/vm/vm_page.c Wed Sep 16 14:14:26 2020 (r365798) @@ -2942,10 +2942,13 @@ vm_wait_count(void) return (vm_severe_waiters + vm_min_waiters + vm_pageproc_waiters); } -void -vm_wait_doms(const domainset_t *wdoms) +int +vm_wait_doms(const domainset_t *wdoms, int mflags) { + int error; + error = 0; + /* * We use racey wakeup synchronization to avoid expensive global * locking for the pageproc when sleeping with a non-specific vm_wait. @@ -2957,8 +2960,8 @@ vm_wait_doms(const domainset_t *wdoms) if (curproc == pageproc) { mtx_lock(&vm_domainset_lock); vm_pageproc_waiters++; - msleep(&vm_pageproc_waiters, &vm_domainset_lock, PVM | PDROP, - "pageprocwait", 1); + error = msleep(&vm_pageproc_waiters, &vm_domainset_lock, + PVM | PDROP | mflags, "pageprocwait", 1); } else { /* * XXX Ideally we would wait only until the allocation could @@ -2968,11 +2971,12 @@ vm_wait_doms(const domainset_t *wdoms) mtx_lock(&vm_domainset_lock); if (vm_page_count_min_set(wdoms)) { vm_min_waiters++; - msleep(&vm_min_domains, &vm_domainset_lock, - PVM | PDROP, "vmwait", 0); + error = msleep(&vm_min_domains, &vm_domainset_lock, + PVM | PDROP | mflags, "vmwait", 0); } else mtx_unlock(&vm_domainset_lock); } + return (error); } /* @@ -3003,20 +3007,12 @@ vm_wait_domain(int domain) panic("vm_wait in early boot"); DOMAINSET_ZERO(&wdom); DOMAINSET_SET(vmd->vmd_domain, &wdom); - vm_wait_doms(&wdom); + vm_wait_doms(&wdom, 0); } } -/* - * vm_wait: - * - * Sleep until free pages are available for allocation in the - * affinity domains of the obj. If obj is NULL, the domain set - * for the calling thread is used. - * Called in various places after failed memory allocations. - */ -void -vm_wait(vm_object_t obj) +static int +vm_wait_flags(vm_object_t obj, int mflags) { struct domainset *d; @@ -3031,7 +3027,27 @@ vm_wait(vm_object_t obj) if (d == NULL) d = curthread->td_domain.dr_policy; - vm_wait_doms(&d->ds_mask); + return (vm_wait_doms(&d->ds_mask, mflags)); +} + +/* + * vm_wait: + * + * Sleep until free pages are available for allocation in the + * affinity domains of the obj. If obj is NULL, the domain set + * for the calling thread is used. + * Called in various places after failed memory allocations. + */ +void +vm_wait(vm_object_t obj) +{ + (void)vm_wait_flags(obj, 0); +} + +int +vm_wait_intr(vm_object_t obj) +{ + return (vm_wait_flags(obj, PCATCH)); } /* Modified: stable/12/sys/vm/vm_pageout.h ============================================================================== --- stable/12/sys/vm/vm_pageout.h Wed Sep 16 14:12:57 2020 (r365797) +++ stable/12/sys/vm/vm_pageout.h Wed Sep 16 14:14:26 2020 (r365798) @@ -97,6 +97,7 @@ extern int vm_pageout_page_count; */ void vm_wait(vm_object_t obj); +int vm_wait_intr(vm_object_t obj); void vm_waitpfault(struct domainset *, int timo); void vm_wait_domain(int domain); void vm_wait_min(void);