Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 03 Mar 2005 06:55:39 +0800
From:      David Xu <davidxu@freebsd.org>
To:        John Baldwin <jhb@freebsd.org>
Cc:        cvs-all@freebsd.org
Subject:   Re: cvs commit: src/sys/kern kern_sig.c
Message-ID:  <4226446B.7020406@freebsd.org>
In-Reply-To: <200503020915.28512.jhb@FreeBSD.org>
References:  <200503021343.j22DhpQ3075008@repoman.freebsd.org> <200503020915.28512.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
John Baldwin wrote:

>On Wednesday 02 March 2005 08:43 am, David Xu wrote:
>  
>
>>davidxu     2005-03-02 13:43:51 UTC
>>
>>  FreeBSD src repository
>>
>>  Modified files:
>>    sys/kern             kern_sig.c
>>  Log:
>>  In kern_sigtimedwait, remove waitset bits for td_sigmask before
>>  sleeping, so in do_tdsignal, we no longer need to test td_waitset.
>>  now td_waitset is only used to give a thread higher priority when
>>  delivering signal to multithreads process.
>>  This also fixes a bug:
>>  when a thread in sigwait states was suspended and later resumed
>>  by SIGCONT, it can no longer receive signals belong to waitset.
>>    
>>
>
>Is this related at all to Peter Holm's panic where sigwait() + swapping 
>invokes a panic?
>
>  
>
No. Peter Holm's found is a swapping problem. vm swaps out sleeping
thread's stack under memory stressing case. but I think that's not safe,
that means, following code can not be used in kernel:

int *p;

func()
 {
    int n;

    n = 0;
    p = &n;
    msleep(p);
    /* check variable n ...
}

func2()
{
   *p = 2;
   wakeup(p);
}

unless million lines of kernel code are reviewed, I don't think the
vm code is safe. The following patch should avoid the problem:

Index: vm_glue.c
===================================================================
RCS file: /home/ncvs/src/sys/vm/vm_glue.c,v
retrieving revision 1.210
diff -u -r1.210 vm_glue.c
--- vm_glue.c    22 Jan 2005 19:21:29 -0000    1.210
+++ vm_glue.c    2 Mar 2005 11:22:32 -0000
@@ -334,6 +334,7 @@
 void
 vm_thread_swapout(struct thread *td)
 {
+#if 0
     vm_object_t ksobj;
     vm_page_t m;
     int i, pages;
@@ -353,6 +354,7 @@
         vm_page_unlock_queues();
     }
     VM_OBJECT_UNLOCK(ksobj);
+#endif
 }
 
 /*

---
David Xu



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4226446B.7020406>