From nobody Fri Dec 09 12:17:38 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NT95G6hXfz4kPnS; Fri, 9 Dec 2022 12:17:38 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NT95G6HQJz3qk0; Fri, 9 Dec 2022 12:17:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670588258; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0Xnu3mn6oR7VnRAD3hoCfnZxD5gYbliCwsZOptg7z+E=; b=QJPk5+k2To4Ci1DUySBWYKgRXosECg0aSVw/uI3SQ9eGjBIkdv4UhLwe6SVbSJwHa0PDdt MRdWcerkAS6pZb63azRPgvPhz6PIEVkA4t6MgTB2iFxbtPWOhLrNA/o2MTEiKfWekTXKjO 63EOZEKVJ87IuZFHqhgRNawDpLWkeSDUNtqXhe5P78B+Nz+AEWu8ySXvc6+QG9WPX0FX+6 TcXctIZCaucmIGZh6G8d/oG0NDHUft9dC3fmTGy/4IN4mlWchuL9JnKC2xmy4kE8R+03je uxaEU0vr4bDZCWUD2L0dS6YubJ0oNPF3iz3eQnImzSmNvx04hGi8U1j8eeSB+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670588258; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0Xnu3mn6oR7VnRAD3hoCfnZxD5gYbliCwsZOptg7z+E=; b=tMAAOT/plhedjIP/7Dq6Eru5jyvr56PKv1SYHk+eyQBTdl36JzV9c6yVCVExW3gnzOqk8y 5Gb+3DY2z1A1T9s5cJMAWDISVr3p9gMqVGs/2wiU7dz+tgv/CXqBeD8m8isN77jIh79HCV y3bzpl0H3SkvvZOdoBL/AL52KxsR7siqpI2CN7nzJQ/gZAftNok9ifj+E9dekUQXitsjbk ZYig4mxVHC2iCI0uBLZj64pAZmzF36NmF+puDpQejTZxXX+zRDIwo4AwnBGEJj37Mvk+9V FHd7qLmf5CdJp5+kSdB4ztVxXAlp/JhhwbEP7A5T02qu4k/tz0Y+l/Y2Iqmszw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1670588258; a=rsa-sha256; cv=none; b=oKlYyS4IvzyBuTY/mxXc896Yga24DAfXgNgvRGRw2udzi5Nv9XSpu58P+y9qwHt9z4tOrR SMcMJry7I/cACrXB7RNfhKo4bKBNm3Otm5UTqwuPHzJqWrVDTPVCOolVh1hNkEoXAB+Pk2 zOsMfwdrnZRqAGmEGSqaBzzHXSqDXRX6QARCddBm9AVCFh2ZsiQP9FukBcmRy2TjP0uO3l 9oU76VJmYO+JkrkXK3Voc7gRNv10ri9LWVgDIuTcy/djLLNpFKoXLFZpG72VNco3yenaPc lyELP5NElgeiBaWiB3Us5EVu6fYWfst4IgmSO5r+L6QGT8vGQJX439nupwYwKw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NT95G5NwPzbZJ; Fri, 9 Dec 2022 12:17:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2B9CHcOm086425; Fri, 9 Dec 2022 12:17:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2B9CHcOc086424; Fri, 9 Dec 2022 12:17:38 GMT (envelope-from git) Date: Fri, 9 Dec 2022 12:17:38 GMT Message-Id: <202212091217.2B9CHcOc086424@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: ec201dddfbdd - main - vm_pager: add method to veto page allocation List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ec201dddfbddd3a77dd3f3afc9b007d0e13e7ad1 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ec201dddfbddd3a77dd3f3afc9b007d0e13e7ad1 commit ec201dddfbddd3a77dd3f3afc9b007d0e13e7ad1 Author: Konstantin Belousov AuthorDate: 2022-10-20 13:15:46 +0000 Commit: Konstantin Belousov CommitDate: 2022-12-09 12:15:37 +0000 vm_pager: add method to veto page allocation Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D37097 --- sys/vm/vm_fault.c | 4 ++++ sys/vm/vm_page.c | 4 ++++ sys/vm/vm_pager.c | 1 + sys/vm/vm_pager.h | 11 +++++++++++ 4 files changed, 20 insertions(+) diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index 8f30c5b93828..959e67b88a38 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -1212,6 +1212,10 @@ vm_fault_allocate(struct faultstate *fs) #if VM_NRESERVLEVEL > 0 vm_object_color(fs->object, atop(fs->vaddr) - fs->pindex); #endif + if (!vm_pager_can_alloc_page(fs->object, fs->pindex)) { + unlock_and_deallocate(fs); + return (FAULT_FAILURE); + } fs->m = vm_page_alloc(fs->object, fs->pindex, P_KILLED(curproc) ? VM_ALLOC_SYSTEM : 0); } diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 20238e0ad807..2b7bc6a5b66e 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -2027,6 +2027,8 @@ vm_page_alloc_domain_after(vm_object_t object, vm_pindex_t pindex, int domain, flags = 0; m = NULL; + if (!vm_pager_can_alloc_page(object, pindex)) + return (NULL); again: #if VM_NRESERVLEVEL > 0 /* @@ -4698,6 +4700,8 @@ retrylookup: *mp = NULL; return (VM_PAGER_FAIL); } else if ((m = vm_page_alloc(object, pindex, pflags)) == NULL) { + if (!vm_pager_can_alloc_page(object, pindex)) + return (VM_PAGER_AGAIN); goto retrylookup; } diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c index 36ce380dedbc..08ce98ab5dbd 100644 --- a/sys/vm/vm_pager.c +++ b/sys/vm/vm_pager.c @@ -432,6 +432,7 @@ vm_pager_alloc_dyn_type(struct pagerops *ops, int base_type) FIX(freespace); FIX(page_inserted); FIX(page_removed); + FIX(can_alloc_page); #undef FIX } pagertab[res] = ops; /* XXXKIB should be rel, but acq is too much */ diff --git a/sys/vm/vm_pager.h b/sys/vm/vm_pager.h index 5917bf651760..0e248d871250 100644 --- a/sys/vm/vm_pager.h +++ b/sys/vm/vm_pager.h @@ -71,6 +71,7 @@ typedef void pgo_freespace_t(vm_object_t object, vm_pindex_t start, vm_size_t size); typedef void pgo_page_inserted_t(vm_object_t object, vm_page_t m); typedef void pgo_page_removed_t(vm_object_t object, vm_page_t m); +typedef boolean_t pgo_can_alloc_page_t(vm_object_t object, vm_pindex_t pindex); struct pagerops { int pgo_kvme_type; @@ -91,6 +92,7 @@ struct pagerops { pgo_freespace_t *pgo_freespace; pgo_page_inserted_t *pgo_page_inserted; pgo_page_removed_t *pgo_page_removed; + pgo_can_alloc_page_t *pgo_can_alloc_page; }; extern const struct pagerops defaultpagerops; @@ -273,6 +275,15 @@ vm_pager_page_removed(vm_object_t object, vm_page_t m) method(object, m); } +static __inline bool +vm_pager_can_alloc_page(vm_object_t object, vm_pindex_t pindex) +{ + pgo_can_alloc_page_t *method; + + method = pagertab[object->type]->pgo_can_alloc_page; + return (method != NULL ? method(object, pindex) : true); +} + int vm_pager_alloc_dyn_type(struct pagerops *ops, int base_type); void vm_pager_free_dyn_type(objtype_t type);