Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/uvm use maximum-size fixed size array instead of variabl...
details: https://anonhg.NetBSD.org/src/rev/e8cf415e5283
branches: trunk
changeset: 935121:e8cf415e5283
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Thu Jun 25 09:58:44 2020 +0000
description:
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
diffstat:
sys/uvm/uvm_pager.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diffs (41 lines):
diff -r 435f53571871 -r e8cf415e5283 sys/uvm/uvm_pager.c
--- a/sys/uvm/uvm_pager.c Thu Jun 25 09:48:29 2020 +0000
+++ b/sys/uvm/uvm_pager.c Thu Jun 25 09:58:44 2020 +0000
@@ -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: 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;
Home |
Main Index |
Thread Index |
Old Index