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,URIBL_BLOCKED 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 2AC78C4338F for ; Fri, 30 Jul 2021 14:20:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 122EC60720 for ; Fri, 30 Jul 2021 14:20:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239305AbhG3OUz (ORCPT ); Fri, 30 Jul 2021 10:20:55 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:55564 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239161AbhG3ORb (ORCPT ); Fri, 30 Jul 2021 10:17:31 -0400 Message-ID: <20210730135206.188262987@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1627654643; 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=kPHQSdoRDDQ+gtY5Ph5Qk1JzSjWNCTU5piibPZKDGHI=; b=xGNU71IP7NIZf+EnrHmdo3o8REY3Z60k07Ueu1b9HdLeeW6NE2wAZYsI6/tQTpPStjqV12 O28DTP2nTduh372kvruhqCwPY/be1tXRffe4kvxvoSdEzx6gPZ/O+UgKUi2HWhAqDIxaDF scFuws6ler7jY4tan9LO+ShwMrM12xbRIz8OEqNVwyZd9GA+cdZMik1hNSd1Y2YbMfLHFx CJ9g5NrzstIe1mBYxGZTkOu39uCQlo8RreiS8OFxYdcNvX0Oc+tl4fJfYrfGqjd4HK+crW 5w7NlQCO1eTKcNxTFcmmd/jgrc/NV9GHo9hPExmE/bWrIya7VZTY0Kvehcxsng== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1627654643; 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=kPHQSdoRDDQ+gtY5Ph5Qk1JzSjWNCTU5piibPZKDGHI=; b=iwWfc4BPcPngQnBNalJBqeKpPA/i9RoSNUnTiOOxJApzQajHOfTj3nM/4dGvHuiDI4LadE AeVwtvwERx1npiBA== Date: Fri, 30 Jul 2021 15:50:25 +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 18/63] locking/rtmutex: Provide rt_wake_q and helpers References: <20210730135007.155909613@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 To handle the difference of wakeups for regular sleeping locks (mutex, rtmutex, rw_semaphore) and the wakeups for 'sleeping' spin/rwlocks on PREEMPT_RT enabled kernels correctly, it is required to provide a wake_q construct which allows to keep them seperate. Provide a wrapper around wake_q and the required helpers, which will be extended with the state handling later. No functional change. Signed-off-by: Thomas Gleixner --- V2: Rename according to PeterZ --- kernel/locking/rtmutex.c | 15 +++++++++++++++ kernel/locking/rtmutex_common.h | 14 ++++++++++++++ 2 files changed, 29 insertions(+) --- --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c @@ -347,6 +347,21 @@ static __always_inline void rt_mutex_adj rt_mutex_setprio(p, pi_task); } +/* RT mutex specific wake_q wrappers */ +static __always_inline void rt_mutex_wake_q_add(struct rt_wake_q_head *wqh, + struct rt_mutex_waiter *w) +{ + wake_q_add(&wqh->head, w->task); +} + +static __always_inline void rt_mutex_wake_up_q(struct rt_wake_q_head *wqh) +{ + wake_up_q(&wqh->head); + + /* Pairs with preempt_disable() in mark_wakeup_next_waiter() */ + preempt_enable(); +} + /* * Deadlock detection is conditional: * --- a/kernel/locking/rtmutex_common.h +++ b/kernel/locking/rtmutex_common.h @@ -39,6 +39,20 @@ struct rt_mutex_waiter { u64 deadline; }; +/** + * rt_wake_q_head - Wrapper around regular wake_q_head to support + * "sleeping" spinlocks on RT + * @head: The regular wake_q_head for sleeping lock variants + */ +struct rt_wake_q_head { + struct wake_q_head head; +}; + +#define DEFINE_RT_WAKE_Q(name) \ + struct rt_wake_q_head name = { \ + .head = WAKE_Q_HEAD_INITIALIZER(name.head), \ + } + /* * PI-futex support (proxy locking functions, etc.): */