From patchwork Tue Jun 6 23:24:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 103192 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp1670818qgd; Tue, 6 Jun 2017 16:25:45 -0700 (PDT) X-Received: by 10.98.245.24 with SMTP id n24mr23997916pfh.80.1496791544946; Tue, 06 Jun 2017 16:25:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496791544; cv=none; d=google.com; s=arc-20160816; b=H1cKfPM9OeG0EDBYfO3wQWEEeTN4b5pvV9xfhUBlzky3qDpyHmwVESEICu3inJVw/b j7a6eoFJlOXQQGq6QO9l3Z1MZkUfQslQreyl/d2ZN4od/XsXIoc1MId7d9mlXk+9oE58 +o6wY52XonhxjAmRVnkwYETbs957ICvMPeAkVlDo3P+Vw5n3uNPrLMqAn51aIBemsRFL yYIEshIrt9L/1m9dTgHIz15doal0kM6bCr9pVPVbSusMZCKrJtx2yMBgQDfV7b3zwRaL N28bvuJ9wwfeMc3KhSKidl3LhpnjfjCrbO1RXknqZaLEcLxqbJyJ4A3gVfUerq4GLnwj 7PHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Em8FZ295X4RDbh9Iiiz1NSjL1m0tlNB8v73PBCkttOY=; b=At0qei2259EYdQ7jHivJcPfPzvURpFmElsn8NsVSfGo9GuKzrgOGY5Gqaq9t7Coao0 yfVIr9H8LLznUuJaDJ5oOPboWx0iCNWeNIErLHtGV8Sofm69cUzlikYoId+VdaayUYtd Grr/BKatgXDYje2sJVxCZXNT0c2tzBrS6qiqFeBwANcQFlE+9+4I3tU1L7iIz8yM7079 w2SeWVFtkpqd254/+W1CeVkFhm/vawgu7MgR5ue0PLXugCawIW7dG9ByI2fJK1S1K+hr otBR/3IdAgwHh8nezEqs/yJLKLRXmZCImcN/Rmf5tVbv4gbNSzr2yufvh2vI7gTmvdB1 KsGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k130si24058235pga.169.2017.06.06.16.25.44; Tue, 06 Jun 2017 16:25:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751583AbdFFXZZ (ORCPT + 25 others); Tue, 6 Jun 2017 19:25:25 -0400 Received: from alt42.smtp-out.videotron.ca ([23.233.128.29]:10193 "EHLO alt42.smtp-out.videotron.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751454AbdFFXZD (ORCPT ); Tue, 6 Jun 2017 19:25:03 -0400 Received: from yoda.home ([96.23.157.65]) by Videotron with SMTP id INqOdGIlpcMN9INqPdgcd1; Tue, 06 Jun 2017 19:25:01 -0400 X-Authority-Analysis: v=2.1 cv=YqOvP9sX c=1 sm=1 tr=0 a=keA3yYpnlypCNW5BNWqu+w==:117 a=keA3yYpnlypCNW5BNWqu+w==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=LWSFodeU3zMA:10 a=KKAkSRfTAAAA:8 a=-V1JewGKzsJttYLv6mQA:9 a=cvBusfyB2V15izCimMoJ:22 Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 6DF192DA06F4; Tue, 6 Jun 2017 19:24:59 -0400 (EDT) From: Nicolas Pitre To: Ingo Molnar , Peter Zijlstra Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 7/8] rtmutex: compatibility wrappers when no RT support is configured Date: Tue, 6 Jun 2017 19:24:49 -0400 Message-Id: <20170606232450.30278-8-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170606232450.30278-1-nicolas.pitre@linaro.org> References: <20170606232450.30278-1-nicolas.pitre@linaro.org> X-CMAE-Envelope: MS4wfM0/chHqovxu/EbmcMH/lliL2bTWvlybT0m+pnuuA+3z40nVr6mtk/W/KPM4j3guXtXUX86nggXlwNQBGRQlJpJUN1hnv6HfkltjKI6llzQKl4mn0CiR ewOGJHewp84WZ5aR3Jh5Q+qevBhKHeBj1ApTG7pQUcmVsJz7lkzmdHH1LZaaVnKDtaH8SUBpYf/x7CnlbOj/KJNYHZB+aImj67Hl6W3qcs9ZQ9EZq8oFB4hM Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Prepare the code for the next patch making RT task support optional. With no actual RT task, there is no priority inversion issues to care about. We can therefore map RT mutexes to regular mutexes in that case and remain compatible with most users. The code that makes explicit assumptions about actual RT mutexes such as RT mutex debugging and PI futexes will have to be made conditional on the availability of RT task support. This will be done in a later patch when CONFIG_SCHED_RT gets defined. Signed-off-by: Nicolas Pitre --- include/linux/rtmutex.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) -- 2.9.4 diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h index 1abba5ce2a..01db77a41b 100644 --- a/include/linux/rtmutex.h +++ b/include/linux/rtmutex.h @@ -12,6 +12,8 @@ #ifndef __LINUX_RT_MUTEX_H #define __LINUX_RT_MUTEX_H +#if 1 /* will become def CONFIG_SCHED_RT later */ + #include #include #include @@ -98,4 +100,71 @@ extern int rt_mutex_trylock(struct rt_mutex *lock); extern void rt_mutex_unlock(struct rt_mutex *lock); +#else /* CONFIG_SCHED_RT */ + +/* + * We have no realtime task support and therefore no priority inversion + * may occur. Let's map RT mutexes using regular mutexes. + */ + +#include + +struct rt_mutex { + struct mutex m; +}; + +#define __RT_MUTEX_INITIALIZER(m) \ + { .m = __MUTEX_INITIALIZER(m) } + +#define DEFINE_RT_MUTEX(mutexname) \ + struct rt_mutex mutexname = __RT_MUTEX_INITIALIZER(mutexname) + +static inline void __rt_mutex_init(struct rt_mutex *lock, const char *name) +{ + static struct lock_class_key __key; + __mutex_init(&lock->m, name, &__key); +} + +#define rt_mutex_init(mutex) __rt_mutex_init(mutex, #mutex) + +static inline int rt_mutex_is_locked(struct rt_mutex *lock) +{ + return mutex_is_locked(&lock->m); +} + +static inline void rt_mutex_destroy(struct rt_mutex *lock) +{ + mutex_destroy(&lock->m); +} + +static inline void rt_mutex_lock(struct rt_mutex *lock) +{ + mutex_lock(&lock->m); +} + +static inline int rt_mutex_lock_interruptible(struct rt_mutex *lock) +{ + return mutex_lock_interruptible(&lock->m); +} + +static inline int rt_mutex_trylock(struct rt_mutex *lock) +{ + return mutex_trylock(&lock->m); +} + +static inline void rt_mutex_unlock(struct rt_mutex *lock) +{ + mutex_unlock(&lock->m); +} + +static inline int rt_mutex_debug_check_no_locks_freed(const void *from, + unsigned long len) +{ + return 0; +} +#define rt_mutex_debug_check_no_locks_held(task) do { } while (0) +#define rt_mutex_debug_task_free(t) do { } while (0) + +#endif /* CONFIG_SCHED_RT */ + #endif