Date: Tue, 7 Mar 2017 09:17:48 +0000 (UTC) From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= <royger@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314841 - in head/sys: dev/xen/control dev/xen/xenstore xen/xenstore Message-ID: <201703070917.v279HmBg061783@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: royger Date: Tue Mar 7 09:17:48 2017 New Revision: 314841 URL: https://svnweb.freebsd.org/changeset/base/314841 Log: xenstore: fix suspension when using the xenstore device Lock the xenstore request mutex when suspending user-space processes, in order to prevent any process from holding this lock when going into suspension, or else the xenstore suspend process is going to deadlock. Submitted by: Liuyingdong <liuyingdong@huawei.com> Reviewed by: royger MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D9638 Modified: head/sys/dev/xen/control/control.c head/sys/dev/xen/xenstore/xenstore.c head/sys/xen/xenstore/xenstorevar.h Modified: head/sys/dev/xen/control/control.c ============================================================================== --- head/sys/dev/xen/control/control.c Tue Mar 7 09:16:51 2017 (r314840) +++ head/sys/dev/xen/control/control.c Tue Mar 7 09:17:48 2017 (r314841) @@ -199,7 +199,9 @@ xctrl_suspend() #endif EVENTHANDLER_INVOKE(power_suspend_early); + xs_lock(); stop_all_proc(); + xs_unlock(); EVENTHANDLER_INVOKE(power_suspend); #ifdef EARLY_AP_STARTUP Modified: head/sys/dev/xen/xenstore/xenstore.c ============================================================================== --- head/sys/dev/xen/xenstore/xenstore.c Tue Mar 7 09:16:51 2017 (r314840) +++ head/sys/dev/xen/xenstore/xenstore.c Tue Mar 7 09:17:48 2017 (r314841) @@ -1699,3 +1699,20 @@ xs_unregister_watch(struct xs_watch *wat sx_xunlock(&xs.xenwatch_mutex); } } + +void +xs_lock(void) +{ + + sx_xlock(&xs.request_mutex); + return; +} + +void +xs_unlock(void) +{ + + sx_xunlock(&xs.request_mutex); + return; +} + Modified: head/sys/xen/xenstore/xenstorevar.h ============================================================================== --- head/sys/xen/xenstore/xenstorevar.h Tue Mar 7 09:16:51 2017 (r314840) +++ head/sys/xen/xenstore/xenstorevar.h Tue Mar 7 09:17:48 2017 (r314841) @@ -338,4 +338,15 @@ void xs_unregister_watch(struct xs_watch */ struct sbuf *xs_join(const char *, const char *); +/** + * Lock the xenstore request mutex. + */ +void xs_lock(void); + +/** + * Unlock the xenstore request mutex. + */ +void xs_unlock(void); + #endif /* _XEN_XENSTORE_XENSTOREVAR_H */ +
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703070917.v279HmBg061783>