Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4765791rdb; Fri, 15 Sep 2023 11:30:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGGBnidL7D+iOZWzn6gxEU/v7SpcQAWDHcEp7HAwHsoNHyEdxOjS/g0NjFgDNcND+ghHttg X-Received: by 2002:a17:903:18e:b0:1bb:9506:d47c with SMTP id z14-20020a170903018e00b001bb9506d47cmr2446599plg.19.1694802632850; Fri, 15 Sep 2023 11:30:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694802632; cv=none; d=google.com; s=arc-20160816; b=UjWd8sWQ6+CLR7vjCxLT6e3fj4pDbaWOosKIi0zgmvHB4ns/kOBNjx73MyvUly483I n6FIXQGBkOvwVOAshVRlh6reBh8av2FRuWnEwAEyRhAwnR8q8/p/dCITa0rk7ZrIVHfU sQf36UvjxxLSrIP/zaWX1uyLyfbpEpSukhPI8c8uSZf5eTHan5ODeBei6KGxQnYxSZaL GNfk13NjiE25VSwnXx1wKsrqndTQhKN3tpL+Nc7csynK1pRatb+7Y8eYsPS8FEX0StNW 3UG6Kyihlcz2R9TF3aZVgT+k9TowXhw9CmE9wMp9XLp2YJE9BmAiGF5cYiJvRlHD0qRB xk0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Q8fuCtaQ2e6PwfofeXoOTrxsOtpnkgnwieogMCDOixs=; fh=AsQjTfXl1hSOJkK7KghQCWPhvFubOyDy0iM1fmQs3eY=; b=w2qEbw4YqGnQJzBZBmqbHvPT2AMceUWb1ZwR4cUSthTZHxlkTOUh+oG62sZ4lrMCBc +1pcjloeZT7tTUtiE1MgJtgFKbtvMRuagHHhmEr2cPRxH3gGUwMieWzKUIpdMKxIbOcH W0S1UeUYzjHMbqSXwHn8QOv4Fpi3mcu32WPH57LaaUE69/UPqHthIyoozWUI8wClm/YQ bafFRzRd0Lzeqmby3KJeJnFsDSmot30QXnU3TGGd4A8dmgqvCI75rXeSodDNisC64lVh +TD4ykfQyL4oHEGhUAQlH+djys0CMXqcufZsBS+Z4eg1KogCKoXB6xtb97bU1rv9WG2F 5+3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Atqv/D9R"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id i1-20020a170902cf0100b0019c354055d0si3757087plg.304.2023.09.15.11.30.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 11:30:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Atqv/D9R"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 35E5E8040D5D; Fri, 15 Sep 2023 11:26:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235770AbjIOS0B (ORCPT + 99 others); Fri, 15 Sep 2023 14:26:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236593AbjIOSZ7 (ORCPT ); Fri, 15 Sep 2023 14:25:59 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 761212D5D for ; Fri, 15 Sep 2023 11:25:37 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9961EC433C8; Fri, 15 Sep 2023 18:25:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694802336; bh=tI4aIfone71e2rJtw81f/6/MavNYU+k1+mNvMUh5TA4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Atqv/D9RjXan1oJbtAgBvbdJRn03JAT/MvFlzWwRNZ2oZr8jFZU7pJDgBdecw7Go0 7edHXyg9udHnr4MAzrNPXWy4+2/AzvvCsBTY0/q2ZhUKTEmkVwAtSE5eKCNTdMY7+r EJ3k0zKnaCj9goknDZrM8VkHhp2gF1l2IvwY0UuvH5fZBhUHwhUkD0A2P6cNJyLb4+ r0LGQRkScxsxsRsnrV9mZjY16b8iU8youOptYenFLfegaRrHRWjqG9odXzuxCa9Mel VVB4n9LvB8i7Th2N6X2+iTQJs3thylSoy2+CjUpsumRLpKoLjPD8eDjsxN6V1JBejg MExPW/2nAS3zg== Date: Fri, 15 Sep 2023 20:25:31 +0200 From: Alexey Gladkov To: Oleg Nesterov Cc: Boqun Feng , Ingo Molnar , Peter Zijlstra , Rik van Riel , Thomas Gleixner , Waiman Long , Will Deacon , "Eric W. Biederman" , linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/5] seqlock: introduce seqprop_lock/unlock Message-ID: References: <20230913154907.GA26210@redhat.com> <20230913155000.GA26248@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230913155000.GA26248@redhat.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 morse.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 (morse.vger.email [0.0.0.0]); Fri, 15 Sep 2023 11:26:39 -0700 (PDT) On Wed, Sep 13, 2023 at 05:50:00PM +0200, Oleg Nesterov wrote: > which can be used to take/release the corresponding lock. > > Thanks to the previous patch, it is trivial to pass 2 arguments to > the new __seqprop_##lockname##_lock/unlock "methods", plus we do not > loose the type info and thus the new seqprop's are "type safe". > > So for example > > void func(seqcount_rwlock_t *s, rwlock_t *l) > { > seqprop_lock(s, l); > } > > happily compiles, but this one > > void func(seqcount_rwlock_t *s, spinlock_t *l) > { > seqprop_lock(s, l); > } > > doesn't. > > Signed-off-by: Oleg Nesterov > --- > include/linux/seqlock.h | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h > index 41e36f8afad4..9831683a0102 100644 > --- a/include/linux/seqlock.h > +++ b/include/linux/seqlock.h > @@ -241,6 +241,21 @@ static __always_inline void \ > __seqprop_##lockname##_assert(const seqcount_##lockname##_t *s) \ > { \ > __SEQ_LOCK(lockdep_assert_held(s->lock)); \ > +} \ > + \ > +static __always_inline void \ > +__seqprop_##lockname##_lock(seqcount_##lockname##_t *s, \ > + locktype *lock) \ > +{ \ > + __SEQ_LOCK(WARN_ON_ONCE(s->lock != lock)); \ > + lockbase##_lock(lock); \ > +} \ > + \ > +static __always_inline void \ > +__seqprop_##lockname##_unlock(seqcount_##lockname##_t *s, \ > + locktype *lock) \ > +{ \ > + lockbase##_unlock(lock); \ > } Why are you creating a new method with an unused argument s ? > > /* > @@ -306,6 +321,12 @@ SEQCOUNT_LOCKNAME(mutex, struct mutex, true, mutex) > #define seqprop_preemptible(s) __seqprop(s, preemptible)(s) > #define seqprop_assert(s) __seqprop(s, assert)(s) > > +/* seqcount_t doesn't have these methods */ > +static inline void __seqprop_lock (seqcount_t *s, void *l) { BUILD_BUG(); } > +static inline void __seqprop_unlock (seqcount_t *s, void *l) { BUILD_BUG(); } > +#define seqprop_lock(s, l) __seqprop(s, lock)(s, l) > +#define seqprop_unlock(s, l) __seqprop(s, unlock)(s, l) > + > /** > * __read_seqcount_begin() - begin a seqcount_t read section w/o barrier > * @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants > -- > 2.25.1.362.g51ebf55 > -- Rgrds, legion