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 0FC03C4338F for ; Thu, 5 Aug 2021 15:43:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E644D61157 for ; Thu, 5 Aug 2021 15:43:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242519AbhHEPno (ORCPT ); Thu, 5 Aug 2021 11:43:44 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:43974 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242397AbhHEPmC (ORCPT ); Thu, 5 Aug 2021 11:42:02 -0400 Message-ID: <20210805153954.446652036@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1628178107; 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=fT3l3HJQchbNTggPTFF8rMzyk++cOOz1/cpvRfZOaj0=; b=XTqTyjx3vUwizzcDMw7rdX/Fnc8aMV5bpjlJ2UQxfA6kTn6sR8mZbtC8EIqHVT9sNOX7U+ eyJQkGWa6j5UepG+lS0FLEVaj9h8K1J1fWF86f/ldaRk1M73vmOHkM4+SG1bBwlt7aV/4j jy60u1Jy1TN3bFdpPDkL6Y3xnROekLwhz6gkanMT2WZaJBW7vKqs+hW0/6iQpv3jifcXPr 0WLsWqBU09YNKrD59YPv/dd6cm9Iej48LT61tcVvSP9BwZIUMvUSTqbhMFTt2rGgY4c1F9 e2/3ERegUTgIthwAhmhg050jEHHH0FCfbEkftbqZAwEXy/dqh4uXLgKVPTlLDA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1628178107; 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=fT3l3HJQchbNTggPTFF8rMzyk++cOOz1/cpvRfZOaj0=; b=JZeU3Vx2PE7z4qLjZUO8B3asYUE3e20YRJcQvvGqVvuSqDnu0mSQscyvSEEDqQs16uJ4/E 5jDOD7GbeTvAwwAw== Date: Thu, 05 Aug 2021 17:13:28 +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 , Mike Galbraith Subject: [patch V3 28/64] locking/spinlock: Provide RT specific spinlock type References: <20210805151300.330412127@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 across the lock operation. Signed-off-by: Thomas Gleixner --- include/linux/spinlock_types.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) --- --- a/include/linux/spinlock_types.h +++ b/include/linux/spinlock_types.h @@ -11,6 +11,9 @@ #include +#ifndef CONFIG_PREEMPT_RT + +/* Non PREEMPT_RT kernels map spinlock to raw_spinlock */ typedef struct spinlock { union { struct raw_spinlock rlock; @@ -39,6 +42,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_base lock; +#ifdef CONFIG_DEBUG_LOCK_ALLOC + struct lockdep_map dep_map; +#endif +} spinlock_t; + +#define __SPIN_LOCK_UNLOCKED(name) \ + { \ + .lock = __RT_MUTEX_BASE_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 */