From patchwork Fri May 6 15:48:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Lagerwall X-Patchwork-Id: 9034211 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2848FBF29F for ; Fri, 6 May 2016 15:50:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3F47D203A1 for ; Fri, 6 May 2016 15:50:46 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 443C020394 for ; Fri, 6 May 2016 15:50:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ayhzL-0001eO-QV; Fri, 06 May 2016 15:48:23 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ayhzK-0001dk-BD for xen-devel@lists.xen.org; Fri, 06 May 2016 15:48:22 +0000 Received: from [193.109.254.147] by server-1.bemta-14.messagelabs.com id E2/DA-02869-5CCBC275; Fri, 06 May 2016 15:48:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEIsWRWlGSWpSXmKPExsXitHSDve7RPTr hBlPesFgs+biYxYHR4+ju30wBjFGsmXlJ+RUJrBlLpz1jL5iiULHgWjdzA+MVsS5GTg4JAX+J vx3/2EBsNgEDiVuXvjOD2CICshKru+awdzFycTALrGSUOHR5HhNIQljAQaJ/52dWEJtFQEXix uyZLCA2r4CnxKNLz9ghhspJnFv/BSzOKeAl0fz3NdhQIaCaJVO2QtlqEm+Xn4HqFZQ4OfMJmM 0sICFx8MULZog53BK3T09lnsDINwtJ2SwkZQsYmVYxahSnFpWlFukamuklFWWmZ5TkJmbm6Bo amujlphYXJ6an5iQmFesl5+duYgSGVT0DA+MOxq+nPQ8xSnIwKYnyfi/QCRfiS8pPqcxILM6I LyrNSS0+xCjDwaEkwftiN1BOsCg1PbUiLTMHGOAwaQkOHiUR3h0gad7igsTc4sx0iNQpRkUpc YiEAEgiozQPrg0WVZcYZaWEeRkZGBiEeApSi3IzS1DlXzGKczAqCfPuBJnCk5lXAjf9FdBiJq DF7+dqgiwuSURISTUwli1X0Clnb/m0+vMUlgNsBvknnd2erovsNvis9PVbVGezgKNP7X0xmQl y9w2nfPr6a/L/eTvrYn65Hdn3izWnPl8v7dbdj+lnb13eYhtaMH/n26nuzrsWb094rrdkxUuW UwcV3S8qC8xJenToV9s7zs28Qs8lCv4xXpT50vJLeWKt38F5RZ7qnkosxRmJhlrMRcWJAMrq+ g+lAgAA X-Env-Sender: prvs=92798eb09=ross.lagerwall@citrix.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1462549699!27820697!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30464 invoked from network); 6 May 2016 15:48:20 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-14.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 6 May 2016 15:48:20 -0000 X-IronPort-AV: E=Sophos;i="5.24,587,1454976000"; d="scan'208";a="358833630" From: Ross Lagerwall To: Date: Fri, 6 May 2016 16:48:04 +0100 Message-ID: <1462549688-29263-4-git-send-email-ross.lagerwall@citrix.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1462549688-29263-1-git-send-email-ross.lagerwall@citrix.com> References: <1462549688-29263-1-git-send-email-ross.lagerwall@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: George Dunlap , Ross Lagerwall , Jan Beulich , Andrew Cooper Subject: [Xen-devel] [PATCH v1 3/7] mm: Use statically defined locking order X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of using a locking order based on line numbers which doesn't play nicely with xSplice, statically define the locking order. Signed-off-by: Ross Lagerwall Reviewed-by: Dario Faggioli --- xen/arch/x86/mm/mm-locks.h | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/mm/mm-locks.h b/xen/arch/x86/mm/mm-locks.h index 086c8bb..da7f52d 100644 --- a/xen/arch/x86/mm/mm-locks.h +++ b/xen/arch/x86/mm/mm-locks.h @@ -46,8 +46,10 @@ static inline int mm_locked_by_me(mm_lock_t *l) return (l->lock.recurse_cpu == current->processor); } -/* If you see this crash, the numbers printed are lines in this file - * where the offending locks are declared. */ +/* + * If you see this crash, the numbers printed are order levels defined + * in this file. + */ #define __check_lock_level(l) \ do { \ if ( unlikely(__get_lock_level() > (l)) ) \ @@ -152,12 +154,12 @@ static inline void mm_read_unlock(mm_rwlock_t *l) /* This wrapper uses the line number to express the locking order below */ #define declare_mm_lock(name) \ static inline void mm_lock_##name(mm_lock_t *l, const char *func, int rec)\ - { _mm_lock(l, func, __LINE__, rec); } + { _mm_lock(l, func, MM_LOCK_ORDER_##name, rec); } #define declare_mm_rwlock(name) \ static inline void mm_write_lock_##name(mm_rwlock_t *l, const char *func) \ - { _mm_write_lock(l, func, __LINE__); } \ + { _mm_write_lock(l, func, MM_LOCK_ORDER_##name); } \ static inline void mm_read_lock_##name(mm_rwlock_t *l) \ - { _mm_read_lock(l, __LINE__); } + { _mm_read_lock(l, MM_LOCK_ORDER_##name); } /* These capture the name of the calling function */ #define mm_lock(name, l) mm_lock_##name(l, __func__, 0) #define mm_lock_recursive(name, l) mm_lock_##name(l, __func__, 1) @@ -169,10 +171,10 @@ static inline void mm_read_unlock(mm_rwlock_t *l) * to ordering constraints. */ #define declare_mm_order_constraint(name) \ static inline void mm_enforce_order_lock_pre_##name(void) \ - { _mm_enforce_order_lock_pre(__LINE__); } \ + { _mm_enforce_order_lock_pre(MM_LOCK_ORDER_##name); } \ static inline void mm_enforce_order_lock_post_##name( \ int *unlock_level, unsigned short *recurse_count) \ - { _mm_enforce_order_lock_post(__LINE__, unlock_level, recurse_count); } \ + { _mm_enforce_order_lock_post(MM_LOCK_ORDER_##name, unlock_level, recurse_count); } \ static inline void mm_unlock(mm_lock_t *l) { @@ -201,11 +203,20 @@ static inline void mm_enforce_order_unlock(int unlock_level, /************************************************************************ * * - * To avoid deadlocks, these locks _MUST_ be taken in the order they're * - * declared in this file. The locking functions will enforce this. * + * To avoid deadlocks, these locks _MUST_ be taken in the order listed * + * below. The locking functions will enforce this. * * * ************************************************************************/ +#define MM_LOCK_ORDER_nestedp2m 10000 +#define MM_LOCK_ORDER_p2m 20000 +#define MM_LOCK_ORDER_altp2mlist 30000 +#define MM_LOCK_ORDER_altp2m 40000 +#define MM_LOCK_ORDER_per_page_sharing 50000 +#define MM_LOCK_ORDER_pod 60000 +#define MM_LOCK_ORDER_page_alloc 70000 +#define MM_LOCK_ORDER_paging 80000 + /* Nested P2M lock (per-domain) * * A per-domain lock that protects the mapping from nested-CR3 to