Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp353737rdg; Thu, 12 Oct 2023 07:34:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGe+rn33LivD4k7xGRXb8YaTeKqda2Rxdpn9ppU+jgmaKgKHiCjigDlOesZXyduxB14Nh+Z X-Received: by 2002:a05:6a20:da9c:b0:16c:b60c:953c with SMTP id iy28-20020a056a20da9c00b0016cb60c953cmr19040963pzb.58.1697121255212; Thu, 12 Oct 2023 07:34:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697121255; cv=none; d=google.com; s=arc-20160816; b=OikrBb/HtZkMQbFUn2c1/IKdvYe5mJ1I71SUrNz7TRGjMcu39VT7eHFqbwutDHtf36 pPAcyi+L7Kh12lCH8/ouQvAccXvwghh4hpssSIrLUNBswMUCKisXs83jYGACsFt7Z8PW ZczdpRBRbYg3QeyueAlHgIEI8DaWdA4MPnqevjCCT6FO7qdxTZ/4wT6d3gKzWWbSGf1H a2rniK4F1DFv05H28inSI4J8Vp57UBZUMzYU7fdo3hhQ0aDlhV1Bt44tyJg3yxZJT3Od CjXKiovXQdnqHugp+rUohpJmSXOUaLdhltj0h8SMBldWQQFTBfMfOiOfx+MSP67+GAmx IDVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=dEigp1+IVvbV3HsL5vf6dh/kMBqJisFQ+4N2B09Iu7A=; fh=9Anu/xS0FThiK+xJgFxROatCrv9gNGrU8+NgNF+Jvyg=; b=Iv4+bOjflAAVKJ02QDrLjrQo169iB4xlPAbNkvux/Ohu0ADDmDy9aXXlpMIxMoFvGQ LcYTD7BZ9KEn6X6D+iGbN+I59v1y/gTEF/ABxvlvSl1GZA1MJQGr2oPEgYh0m/zfsxvh eAu36zX76+GKuXs71PXyOw5OMoIRnwfR5hB47QtYjHDL134HOSi5k2LbyGxW492j20RX UkWsCaX4V+GWKBzpxXYS+FeEJ0Gtub4ULxN0E7A64z+j7hSaF7BvMHr4LniIrVyyUyy5 +mhbAQA+J8jpE+ROttehioDqbTh8bKmoI5TKcOap0wZck4ac7e5IevZgTs8sODKryLrd D17w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RMOPXIMW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id ca23-20020a056a02069700b0057759a5b7dasi2827929pgb.827.2023.10.12.07.34.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 07:34:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RMOPXIMW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 122E783F1CF0; Thu, 12 Oct 2023 07:34:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233195AbjJLOdw (ORCPT + 99 others); Thu, 12 Oct 2023 10:33:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231750AbjJLOdv (ORCPT ); Thu, 12 Oct 2023 10:33:51 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B169A9 for ; Thu, 12 Oct 2023 07:33:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697121185; 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; bh=dEigp1+IVvbV3HsL5vf6dh/kMBqJisFQ+4N2B09Iu7A=; b=RMOPXIMWbsGvfGzjqNIDbPmIWSC1GRqsoRXU357IftiIx8EERJ/z16vf29dOzz6eGJPKPq huYBNSR7Pv5Ie5AFpxIeLhS2akBrH6GhR22tK3p4ugK9nIDhWtH+9mEEC32TvbzAFGESxi 6WUW61Xqm2j3JnMa1H0/rix3OG+g1qc= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-494-65IOoLAJN6OwML0JWpkZ9w-1; Thu, 12 Oct 2023 10:32:59 -0400 X-MC-Unique: 65IOoLAJN6OwML0JWpkZ9w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 62B03280C297; Thu, 12 Oct 2023 14:32:59 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.224.172]) by smtp.corp.redhat.com (Postfix) with SMTP id B61B01C060DF; Thu, 12 Oct 2023 14:32:57 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Thu, 12 Oct 2023 16:32:00 +0200 (CEST) Date: Thu, 12 Oct 2023 16:31:58 +0200 From: Oleg Nesterov To: Peter Zijlstra Cc: Alexey Gladkov , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] seqlock: simplify SEQCOUNT_LOCKNAME() Message-ID: <20231012143158.GA16133@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,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 fry.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 (fry.vger.email [0.0.0.0]); Thu, 12 Oct 2023 07:34:12 -0700 (PDT) 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 --- 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 e9bd2f65d7f4..b9a30c62ffe4 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 -- 2.25.1.362.g51ebf55