From patchwork Thu Oct 12 18:35:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 152115 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1427404vqb; Thu, 12 Oct 2023 11:36:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0EbT7OHTat3B+WrUIyvNX+S1yg9VuDpRl+2TFFRYJAfAn5n/e1LPKM/z6gAKTyk99dJ96 X-Received: by 2002:a05:6a00:2e87:b0:690:c79c:1912 with SMTP id fd7-20020a056a002e8700b00690c79c1912mr27608435pfb.0.1697135793374; Thu, 12 Oct 2023 11:36:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697135793; cv=none; d=google.com; s=arc-20160816; b=e3OnCPm+opOj1096UTtI0wl9ACdCeLhvZWyWAOKuVkbPTfX/Hdw/pVKA7z5YE4rGll cqgB5T5h62wqQpPtcfmsbMVhIs64cudXnbLYrE0c3z+nRyU2EW3/ygcbihJk0qvUdpMw NEOyUzk3a+YHJDGQ/K2QYFG6m1dU8eAn+A5agj8bVIGZQeCwCikvDtVekz66e1aX1ixn BrzDWBEzYrgs6IRiJa620XSz3ZAD4MRqh2AQzsqmL9qoC/2qOrl4PoYF6D0yPShdjE96 o3sIj148fSNoiADiIWhd2etSvcyd9OJyQRWYWXLJunKXNiajknNJzYWOCQl0ZUCuWDmM R1ng== 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=AaaP0/zh6OCb+5ToMe9sajJWn4xGggVgNktRglPzutM=; fh=kFB9uQyxVvjm2R0ul7wxypzO2CDQ/Wd3RLAPUv0GPQE=; b=aG2hnDWBKbRfMvYxkTmvFaLmd7LY3hiD1TkzLlP+hmulGe+YIXOeh8cIVPIlsiKTUD WL3zC4KOUzdW5VQmtiim7hlGCqRtQ3B4o58aCuhyJnX6AouC8CNljosNQcvBjQkQcQzm iX2JuLFxN3Fk1gb6I070H8ll+Z0y4go9CXOgmhLP5Mp9tIuElAXr4IKzKrhmH2/Sn2P0 Cpe7ofk1gBkflnkkjKD1wwxwjHq/1stBUDl1ry9eEDmL/2j+l05rg1miakgS9yYpZ5/w Kok4Pf8BPOcKNlf0vAtgVGGfNMeDT4dPFMoj2MIsSM8H1YXtTG7EweZ4iuVJBw7xQ+8Y 3Q6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0qZIclCD; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id ay9-20020a056a00300900b0068c01fba745si15157743pfb.184.2023.10.12.11.36.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 11:36:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0qZIclCD; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 42C9A8027CE1; Thu, 12 Oct 2023 11:36:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379699AbjJLSgO (ORCPT + 19 others); Thu, 12 Oct 2023 14:36:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235786AbjJLSgG (ORCPT ); Thu, 12 Oct 2023 14:36:06 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29B9A114; Thu, 12 Oct 2023 11:35:57 -0700 (PDT) Date: Thu, 12 Oct 2023 18:35:54 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697135755; 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=AaaP0/zh6OCb+5ToMe9sajJWn4xGggVgNktRglPzutM=; b=0qZIclCDsX1rZaYJ73003speA4HZliX5+prUDXS+qG1rrDEew8eXXCj1uc7/LudEdqory6 HDq/oG9ms2WqKmb7/+JsnZHVIKFc2xKwKBdDH7trGNd2A63bua+wgCC6O3hD9q6CMnrYfW FAdRITq6Uy5CbMWW7OSBrLkkav487036dKotp4tt8CXLGbljAxWqlu1IMRXCWFQ0DjAaej /Kb4ISzdHcrD4Z4orLUcTH68Ag7q6UMVVi0Lqu/lIDVrWzcD/5F7MlAK7f6gvtD0BpG0W5 4AQsso/+mHkLn4S5bZxkn80i9acatqVo9vjkPH7jD1ma9SwYiIzDfyMiBKj0cQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697135755; 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=AaaP0/zh6OCb+5ToMe9sajJWn4xGggVgNktRglPzutM=; b=8fVDPzka9nHsdsW4Ls/a/xWKkkwDFY8myA7YsYmX5R+fmM545Dfj9CYmckNMFY/bygQcWL N8Zgjou8jYmkZxAQ== From: "tip-bot2 for Oleg Nesterov" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] locking/seqlock: Simplify SEQCOUNT_LOCKNAME() Cc: Oleg Nesterov , Ingo Molnar , Peter Zijlstra , Waiman Long , Will Deacon , Thomas Gleixner , Linus Torvalds , "Paul E. McKenney" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231012143158.GA16133@redhat.com> References: <20231012143158.GA16133@redhat.com> MIME-Version: 1.0 Message-ID: <169713575506.3135.7190411037772365188.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 12 Oct 2023 11:36:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779575861870753788 X-GMAIL-MSGID: 1779575861870753788 The following commit has been merged into the locking/core branch of tip: Commit-ID: f995443f01b4dbcce723539b99050ce69b319e58 Gitweb: https://git.kernel.org/tip/f995443f01b4dbcce723539b99050ce69b319e58 Author: Oleg Nesterov AuthorDate: Thu, 12 Oct 2023 16:31:58 +02:00 Committer: Ingo Molnar CommitterDate: Thu, 12 Oct 2023 20:18:20 +02:00 locking/seqlock: Simplify SEQCOUNT_LOCKNAME() 1. Kill the "lockmember" argument. It is always s->lock plus __seqprop_##lockname##_sequence() already uses s->lock and ignores "lockmember". 2. Kill the "lock_acquire" argument. __seqprop_##lockname##_sequence() can use the same "lockbase" prefix for _lock and _unlock. Apart from line numbers, gcc -E outputs the same code. Signed-off-by: Oleg Nesterov Signed-off-by: Ingo Molnar Cc: Peter Zijlstra Cc: Waiman Long Cc: Will Deacon Cc: Thomas Gleixner Cc: Linus Torvalds Cc: Paul E. McKenney Link: https://lore.kernel.org/r/20231012143158.GA16133@redhat.com --- include/linux/seqlock.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index af518e4..7e7109d 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h @@ -191,11 +191,9 @@ static inline void seqcount_lockdep_reader_access(const seqcount_t *s) * @lockname: "LOCKNAME" part of seqcount_LOCKNAME_t * @locktype: LOCKNAME canonical C data type * @preemptible: preemptibility of above locktype - * @lockmember: argument for lockdep_assert_held() - * @lockbase: associated lock release function (prefix only) - * @lock_acquire: associated lock acquisition function (full call) + * @lockbase: prefix for associated lock/unlock */ -#define SEQCOUNT_LOCKNAME(lockname, locktype, preemptible, lockmember, lockbase, lock_acquire) \ +#define SEQCOUNT_LOCKNAME(lockname, locktype, preemptible, lockbase) \ typedef struct seqcount_##lockname { \ seqcount_t seqcount; \ __SEQ_LOCK(locktype *lock); \ @@ -216,7 +214,7 @@ __seqprop_##lockname##_sequence(const seqcount_##lockname##_t *s) \ return seq; \ \ if (preemptible && unlikely(seq & 1)) { \ - __SEQ_LOCK(lock_acquire); \ + __SEQ_LOCK(lockbase##_lock(s->lock)); \ __SEQ_LOCK(lockbase##_unlock(s->lock)); \ \ /* \ @@ -242,7 +240,7 @@ __seqprop_##lockname##_preemptible(const seqcount_##lockname##_t *s) \ static __always_inline void \ __seqprop_##lockname##_assert(const seqcount_##lockname##_t *s) \ { \ - __SEQ_LOCK(lockdep_assert_held(lockmember)); \ + __SEQ_LOCK(lockdep_assert_held(s->lock)); \ } /* @@ -271,10 +269,10 @@ static inline void __seqprop_assert(const seqcount_t *s) #define __SEQ_RT IS_ENABLED(CONFIG_PREEMPT_RT) -SEQCOUNT_LOCKNAME(raw_spinlock, raw_spinlock_t, false, s->lock, raw_spin, raw_spin_lock(s->lock)) -SEQCOUNT_LOCKNAME(spinlock, spinlock_t, __SEQ_RT, s->lock, spin, spin_lock(s->lock)) -SEQCOUNT_LOCKNAME(rwlock, rwlock_t, __SEQ_RT, s->lock, read, read_lock(s->lock)) -SEQCOUNT_LOCKNAME(mutex, struct mutex, true, s->lock, mutex, mutex_lock(s->lock)) +SEQCOUNT_LOCKNAME(raw_spinlock, raw_spinlock_t, false, raw_spin) +SEQCOUNT_LOCKNAME(spinlock, spinlock_t, __SEQ_RT, spin) +SEQCOUNT_LOCKNAME(rwlock, rwlock_t, __SEQ_RT, read) +SEQCOUNT_LOCKNAME(mutex, struct mutex, true, mutex) /* * SEQCNT_LOCKNAME_ZERO - static initializer for seqcount_LOCKNAME_t