From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9224CC07E96 for ; Tue, 13 Jul 2021 16:14:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7BFF6611AC for ; Tue, 13 Jul 2021 16:14:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233923AbhGMQQx (ORCPT ); Tue, 13 Jul 2021 12:16:53 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:54378 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233095AbhGMQQ2 (ORCPT ); Tue, 13 Jul 2021 12:16:28 -0400 Message-Id: <20210713160748.288862984@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1626192817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=RACUEYQWWTuTg5rIuaS/OKtL0LjmH9/maMT9DMgtSP0=; b=2tejnREXqcOiBV3mieJr2+O/TwSVL58xSVl5T1iJf7lzhfaQy537sd/sJakWe2dXEZdyNp qAptbfJbkVWLLR1glK3E6rTwWhCGyAaS29cXxIavWgZbzN7OShHTqvpxT56P0muayDdkSx 6/R9tG25ITm6ktb6i7fIAD6ClIWI+8kr87DPsqaVljxGopGdCPM2W8eBMS2Z9Barh351lX cKeKrz6ZqCWIrA+ny7mCpKOW3nl+dRJfjXccgiLBHoMsiQF0RqPVfu/jAYFzIn0MpJeRa8 YEkEPYAG43Nwc7jjURzuCkcoyuapO35BayEYrdj/J4qfK+ZiUQB5SPz+/8Z+xw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1626192817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=RACUEYQWWTuTg5rIuaS/OKtL0LjmH9/maMT9DMgtSP0=; b=yl6K3ITp46aJZa0X7XMkdoJEUv0+rwBb7PsS/vxm5kmWuylCivEm4686meZ5oiYbX816hg TBPBjdNKaOnxjfDQ== Date: Tue, 13 Jul 2021 17:11:18 +0200 From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Ingo Molnar , Juri Lelli , Steven Rostedt , Daniel Bristot de Oliveira , Will Deacon , Waiman Long , Boqun Feng , Sebastian Andrzej Siewior , Davidlohr Bueso Subject: [patch 24/50] locking/spinlock: Provide RT specific spinlock type References: <20210713151054.700719949@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-transfer-encoding: 8-bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner RT replaces spinlocks with a simple wrapper around a rtmutex which turns spinlocks on RT into 'sleeping' spinlocks. The actual implementation of the spinlock API differs from a regular rtmutex as it does neither handle timeouts nor signals and it is state preserving accross the lock operation. Signed-off-by: Thomas Gleixner --- include/linux/spinlock_types.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) --- diff --git a/include/linux/spinlock_types.h b/include/linux/spinlock_types.h index 7c8107c280c0..98d498f9e4fc 100644 --- a/include/linux/spinlock_types.h +++ b/include/linux/spinlock_types.h @@ -51,6 +51,9 @@ #define DEFINE_RAW_SPINLOCK(x) raw_spinlock_t x = __RAW_SPIN_LOCK_UNLOCKED(x) +#ifndef CONFIG_PREEMPT_RT + +/* Non PREEMPT_RT kernels map spinlock to raw_spinlock */ typedef struct spinlock { union { struct raw_spinlock rlock; @@ -79,6 +82,29 @@ typedef struct spinlock { #define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x) +#else /* !CONFIG_PREEMPT_RT */ + +/* PREEMPT_RT kernels map spinlock to rt_mutex */ +#include + +typedef struct spinlock { + struct rt_mutex lock; +#ifdef CONFIG_DEBUG_LOCK_ALLOC + struct lockdep_map dep_map; +#endif +} spinlock_t; + +#define __SPIN_LOCK_UNLOCKED(name) \ + { \ + .lock = __RT_MUTEX_INITIALIZER(name.lock), \ + SPIN_DEP_MAP_INIT(name) \ + } + +#define DEFINE_SPINLOCK(name) \ + spinlock_t name = __SPIN_LOCK_UNLOCKED(name) + +#endif /* CONFIG_PREEMPT_RT */ + #include #endif /* __LINUX_SPINLOCK_TYPES_H */