Skip to content

Commit b52ade8

Browse files
krekre
authored andcommitted
Revert previous. We cannot hold the uvm_swap_data_lock
That is not while doing any operations which might require the current process (or maybe just lwp, for this, irrelevant) to actuually engage in paging. And a copyout() does exactly that, or might.
1 parent 7adabaf commit b52ade8

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

sys/uvm/uvm_swap.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: uvm_swap.c,v 1.212 2026/02/12 00:08:37 mrg Exp $ */
1+
/* $NetBSD: uvm_swap.c,v 1.213 2026/02/12 13:34:45 kre Exp $ */
22

33
/*
44
* Copyright (c) 1995, 1996, 1997, 2009 Matthew R. Green
@@ -30,7 +30,7 @@
3030
*/
3131

3232
#include <sys/cdefs.h>
33-
__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.212 2026/02/12 00:08:37 mrg Exp $");
33+
__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.213 2026/02/12 13:34:45 kre Exp $");
3434

3535
#include "opt_uvmhist.h"
3636
#include "opt_compat_netbsd.h"
@@ -782,7 +782,7 @@ uvm_swap_stats(char *ptr, int misc,
782782
struct swapdev *sdp;
783783
struct swapent sep;
784784
int count = 0;
785-
int error = 0;
785+
int error;
786786

787787
KASSERT(len <= sizeof(sep));
788788
if (len == 0)
@@ -800,7 +800,6 @@ uvm_swap_stats(char *ptr, int misc,
800800

801801
KASSERT(rw_lock_held(&swap_syscall_lock));
802802

803-
mutex_enter(&uvm_swap_data_lock);
804803
LIST_FOREACH(spp, &swap_priority, spi_swappri) {
805804
TAILQ_FOREACH(sdp, &spp->spi_swapdev, swd_next) {
806805
int inuse;
@@ -816,17 +815,13 @@ uvm_swap_stats(char *ptr, int misc,
816815
if (f)
817816
(*f)(&sep, &sep);
818817
if ((error = copyout(&sep, ptr, len)) != 0)
819-
break;
818+
return error;
820819
ptr += len;
821820
count++;
822821
}
823-
if (error)
824-
break;
825822
}
826-
mutex_exit(&uvm_swap_data_lock);
827-
if (error == 0)
828-
*retval = count;
829-
return error;
823+
*retval = count;
824+
return 0;
830825
}
831826

832827
/*

0 commit comments

Comments
 (0)