Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp449671rwe; Thu, 1 Sep 2022 02:12:30 -0700 (PDT) X-Google-Smtp-Source: AA6agR4RrjaFtilwNa0MrTUUK8v7uL7mZugb4pwurMbPuOJnQNbevvUgYZwcJmvDNsA5s/Y8W+9H X-Received: by 2002:a17:90b:3b8d:b0:1fe:30f0:6c37 with SMTP id pc13-20020a17090b3b8d00b001fe30f06c37mr6688512pjb.205.1662023549707; Thu, 01 Sep 2022 02:12:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662023549; cv=none; d=google.com; s=arc-20160816; b=uZ8g0mdDIB/DfRfGzg3BKkL+pWwswvoUecA0KlFDenNNS1RMhfpSUcU+pRcjLRlFex N0wBxVsBbOdGBLwsXPxlGGm/+7rFqDmbnIrRJ1o/Pdz0gAiPgLhi5/s/zxCGCCndTW08 ZvLKLukWLPdEN347gQlgHtZC1vQ6/6B/BSESBp+wjmuGgRTM8VpAQ66tdidQuE/Xk+WH AORdgLXabzG1Z64BYjM/L3MKPRsHGgmeChGnZ7x3+NRRMn0+VfnwnmGsvSNA9QfhHSDe EEjPjAWH5VOb0FxPaBJ6bCnswXC+kTXagYdhiOtHTnnKmUZOPkDLgpPy96BEgWHx4hOe cbkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=a62B0FmM3OYf2e39k6Hozana5GgpPEPcVLT73fqWX2Q=; b=w14+zyZF0jajUM8EjRjE5E2BObqATYa+DUhYr4tQL60L2am3i877ZEr3BgmWblTcTY bbycB+a0IVJn7vKOaZN9Na2ExY+TqE9EMp2nqTzs8HNb9xL0Nj2qfSFVG5TfjtQ9ur5K iD8GrJkH5ueZqS3B8RJwtccx+xFi0EJQDklQeAXp+57C6N3rLGAcw+MzUfeUT7dOxN3J ltcWaDKXn1lJMX3hTEbfcvm9fyFRc/TiPdEUNgsNTSU7iqvf63m9h9g9oJrcj6CTVF7L AwkxXzNhAWApvcTgEDTST2vIUVqz7CBZVICZVpt+4ihFM9DEblBdflejqoJT1VFeDh0D EVpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vLE7MwQM; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b12-20020a056a00114c00b00537c15d8804si16980694pfm.76.2022.09.01.02.12.16; Thu, 01 Sep 2022 02:12:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vLE7MwQM; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234057AbiIAINK (ORCPT + 99 others); Thu, 1 Sep 2022 04:13:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233296AbiIAIMr (ORCPT ); Thu, 1 Sep 2022 04:12:47 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CC1812BF5C; Thu, 1 Sep 2022 01:12:46 -0700 (PDT) Date: Thu, 01 Sep 2022 08:12:43 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1662019964; h=from:from:sender:sender:reply-to: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: in-reply-to:in-reply-to:references:references; bh=a62B0FmM3OYf2e39k6Hozana5GgpPEPcVLT73fqWX2Q=; b=vLE7MwQME1MoAbGaG2N5pbpCbX32NNTTk9/k/Q6j4QP1k7NDFVQsqOXiwM9YhfPdzsqWpJ w/YuUDHhZw3JrzU6bggC5LkOin3ann3xIm27DAamLs/NN9LLGWwcsJJ74y7ULSQDrz040+ LPjRj4K+keErH2IGWq52yANQKarydvYQdAsRryt8iaFQlICyFQLDxW/art0s8Exn3NqUKM n/CK2xus7ANc/ixmKeLfnNdJjPvOZ2gac3JjedeHIaNkN6pTLqCx35cQsPXYJlJwityc9P AK9GcDlaSOcAb0o7i5WA682qldqx23UZyFIpXvabLWoXXcI47q/UKTIdoxYokg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1662019964; h=from:from:sender:sender:reply-to: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: in-reply-to:in-reply-to:references:references; bh=a62B0FmM3OYf2e39k6Hozana5GgpPEPcVLT73fqWX2Q=; b=+2nRMpk6z9ETI36RPbVj3KtcpDsZuS7BlPldawRpLI8gQ1m3d38Wq4Ch7OqPdgj8jjJPWr k3EGzN2ovRI+dcDg== From: "tip-bot2 for Marco Elver" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] locking/percpu-rwsem: Add percpu_is_write_locked() and percpu_is_read_locked() Cc: Marco Elver , "Peter Zijlstra (Intel)" , Dmitry Vyukov , Ian Rogers , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220829124719.675715-11-elver@google.com> References: <20220829124719.675715-11-elver@google.com> MIME-Version: 1.0 Message-ID: <166201996350.401.14184268596375790493.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: 01fe8a3f818e1074a9a95d624be4549ee7ea2b2b Gitweb: https://git.kernel.org/tip/01fe8a3f818e1074a9a95d624be4549ee7ea2b2b Author: Marco Elver AuthorDate: Mon, 29 Aug 2022 14:47:15 +02:00 Committer: Peter Zijlstra CommitterDate: Tue, 30 Aug 2022 10:56:23 +02:00 locking/percpu-rwsem: Add percpu_is_write_locked() and percpu_is_read_locked() Implement simple accessors to probe percpu-rwsem's locked state: percpu_is_write_locked(), percpu_is_read_locked(). Signed-off-by: Marco Elver Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Dmitry Vyukov Acked-by: Ian Rogers Link: https://lore.kernel.org/r/20220829124719.675715-11-elver@google.com --- include/linux/percpu-rwsem.h | 6 ++++++ kernel/locking/percpu-rwsem.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/include/linux/percpu-rwsem.h b/include/linux/percpu-rwsem.h index 5fda40f..36b942b 100644 --- a/include/linux/percpu-rwsem.h +++ b/include/linux/percpu-rwsem.h @@ -121,9 +121,15 @@ static inline void percpu_up_read(struct percpu_rw_semaphore *sem) preempt_enable(); } +extern bool percpu_is_read_locked(struct percpu_rw_semaphore *); extern void percpu_down_write(struct percpu_rw_semaphore *); extern void percpu_up_write(struct percpu_rw_semaphore *); +static inline bool percpu_is_write_locked(struct percpu_rw_semaphore *sem) +{ + return atomic_read(&sem->block); +} + extern int __percpu_init_rwsem(struct percpu_rw_semaphore *, const char *, struct lock_class_key *); diff --git a/kernel/locking/percpu-rwsem.c b/kernel/locking/percpu-rwsem.c index 5fe4c54..185bd1c 100644 --- a/kernel/locking/percpu-rwsem.c +++ b/kernel/locking/percpu-rwsem.c @@ -192,6 +192,12 @@ EXPORT_SYMBOL_GPL(__percpu_down_read); __sum; \ }) +bool percpu_is_read_locked(struct percpu_rw_semaphore *sem) +{ + return per_cpu_sum(*sem->read_count) != 0 && !atomic_read(&sem->block); +} +EXPORT_SYMBOL_GPL(percpu_is_read_locked); + /* * Return true if the modular sum of the sem->read_count per-CPU variable is * zero. If this sum is zero, then it is stable due to the fact that if any