Module Name:    src
Committed By:   jdolecek
Date:           Thu Jun 25 09:58:44 UTC 2020

Modified Files:
        src/sys/uvm: uvm_pager.c

Log Message:
use maximum-size fixed size array instead of variable-length array
in uvm_aio_aiodone() so that the stack usage can be determined and
checked in compile time; this is not called recursively not
particularly deep in call stack, so there is no need to save every
last drop of stack space here


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sys/uvm/uvm_pager.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/uvm/uvm_pager.c
diff -u src/sys/uvm/uvm_pager.c:1.125 src/sys/uvm/uvm_pager.c:1.126
--- src/sys/uvm/uvm_pager.c:1.125	Sun Apr 19 21:53:38 2020
+++ src/sys/uvm/uvm_pager.c	Thu Jun 25 09:58:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_pager.c,v 1.125 2020/04/19 21:53:38 ad Exp $	*/
+/*	$NetBSD: uvm_pager.c,v 1.126 2020/06/25 09:58:44 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_pager.c,v 1.125 2020/04/19 21:53:38 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_pager.c,v 1.126 2020/06/25 09:58:44 jdolecek Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_readahead.h"
@@ -516,17 +516,19 @@ uvm_aio_aiodone_pages(struct vm_page **p
  * uvm_aio_aiodone: do iodone processing for async i/os.
  * this should be called in thread context, not interrupt context.
  */
-
 void
 uvm_aio_aiodone(struct buf *bp)
 {
-	int npages = bp->b_bufsize >> PAGE_SHIFT;
-	struct vm_page *pgs[npages];
+	const int npages = bp->b_bufsize >> PAGE_SHIFT;
+	struct vm_page *pgs[howmany(MAXPHYS, MIN_PAGE_SIZE)];
 	int i, error;
 	bool write;
 	UVMHIST_FUNC("uvm_aio_aiodone"); UVMHIST_CALLED(ubchist);
 	UVMHIST_LOG(ubchist, "bp %#jx", (uintptr_t)bp, 0,0,0);
 
+	KASSERT(bp->b_bufsize <= MAXPHYS);
+	KASSERT(npages <= __arraycount(pgs));
+
 	error = bp->b_error;
 	write = (bp->b_flags & B_READ) == 0;
 

Reply via email to