vm_machdep.c (b0db6a81d2588b0d8d58ecfe866b7a57506143c6) vm_machdep.c (d3cb0d99e0eeb9340c5457127068eb039709cc8b)
1/*-
2 * Copyright (c) 1982, 1986 The Regents of the University of California.
3 * Copyright (c) 1989, 1990 William Jolitz
4 * Copyright (c) 1994 John Dyson
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * the Systems Programming Group of the University of Utah Computer

--- 217 unchanged lines hidden (view full) ---

226 sf_buf_alloc_want = 0;
227 mtx_init(&sf_buf_lock, "sf_buf", NULL, MTX_DEF);
228}
229
230/*
231 * Get an sf_buf from the freelist. Will block if none are available.
232 */
233struct sf_buf *
1/*-
2 * Copyright (c) 1982, 1986 The Regents of the University of California.
3 * Copyright (c) 1989, 1990 William Jolitz
4 * Copyright (c) 1994 John Dyson
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * the Systems Programming Group of the University of Utah Computer

--- 217 unchanged lines hidden (view full) ---

226 sf_buf_alloc_want = 0;
227 mtx_init(&sf_buf_lock, "sf_buf", NULL, MTX_DEF);
228}
229
230/*
231 * Get an sf_buf from the freelist. Will block if none are available.
232 */
233struct sf_buf *
234sf_buf_alloc(struct vm_page *m, int pri)
234sf_buf_alloc(struct vm_page *m, int flags)
235{
236 struct sf_head *hash_list;
237 struct sf_buf *sf;
238 int error;
239
240 hash_list = &sf_buf_active[SF_BUF_HASH(m)];
241 mtx_lock(&sf_buf_lock);
242 LIST_FOREACH(sf, hash_list, list_entry) {
243 if (sf->m == m) {
244 sf->ref_count++;
245 if (sf->ref_count == 1) {
246 TAILQ_REMOVE(&sf_buf_freelist, sf, free_entry);
247 nsfbufsused++;
248 nsfbufspeak = imax(nsfbufspeak, nsfbufsused);
249 }
250 goto done;
251 }
252 }
253 while ((sf = TAILQ_FIRST(&sf_buf_freelist)) == NULL) {
235{
236 struct sf_head *hash_list;
237 struct sf_buf *sf;
238 int error;
239
240 hash_list = &sf_buf_active[SF_BUF_HASH(m)];
241 mtx_lock(&sf_buf_lock);
242 LIST_FOREACH(sf, hash_list, list_entry) {
243 if (sf->m == m) {
244 sf->ref_count++;
245 if (sf->ref_count == 1) {
246 TAILQ_REMOVE(&sf_buf_freelist, sf, free_entry);
247 nsfbufsused++;
248 nsfbufspeak = imax(nsfbufspeak, nsfbufsused);
249 }
250 goto done;
251 }
252 }
253 while ((sf = TAILQ_FIRST(&sf_buf_freelist)) == NULL) {
254 if (flags & SFB_NOWAIT)
255 goto done;
254 sf_buf_alloc_want++;
255 mbstat.sf_allocwait++;
256 sf_buf_alloc_want++;
257 mbstat.sf_allocwait++;
256 error = msleep(&sf_buf_freelist, &sf_buf_lock, PVM | pri,
257 "sfbufa", 0);
258 error = msleep(&sf_buf_freelist, &sf_buf_lock,
259 (flags & SFB_CATCH) ? PCATCH | PVM : PVM, "sfbufa", 0);
258 sf_buf_alloc_want--;
259
260
261 /*
262 * If we got a signal, don't risk going back to sleep.
263 */
264 if (error)
265 goto done;

--- 114 unchanged lines hidden ---
260 sf_buf_alloc_want--;
261
262
263 /*
264 * If we got a signal, don't risk going back to sleep.
265 */
266 if (error)
267 goto done;

--- 114 unchanged lines hidden ---