Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp604564ybt; Wed, 8 Jul 2020 07:28:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxy3nLDgu3Ap3P6HnJC9RjphFNfCGvtmlt4c8VY97+GZFRIR/jGdhJSUHvbYQJwwx4HtOeQ X-Received: by 2002:a17:907:2633:: with SMTP id aq19mr14455757ejc.127.1594218516060; Wed, 08 Jul 2020 07:28:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594218516; cv=none; d=google.com; s=arc-20160816; b=jPLfsnFMjKBT7VYXw1eD8hy4sP24kO2FYAAPtIyipfbuU9UTMMJOxeFCNSX8MM7h2E PmI8NwjkbqL/tMzsPbE/qhl6hEXLMiSB11/rOPR0hVMAlEhSuNfKKgd2hGE/dxUfMtW5 YJcVJs8Ls+Ff6fQVSYFveTVmdui1BK5ggCsyIvP4bjPgmkA72x6xiPOHrAeCkZ9INVll grdKPC6xRZ6bKrS5nDQs5HuCwZKfCRY8AmdL4nyn1qS/2kSIuYggRkYrAmb16YXsIG2X rvU/DEMi0tcQxlNvXf4FK4+UslsELOf+th2F/y/zsHvv/zc+fCbQyAsUdX7HlXZt+0yE bFAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=+YUe1fHnh8Fc6MZuglb4QKVpoNIXOUgI7dCHoGx1luE=; b=Mpr32oCVE9zuHli8sL0KNUUk/bYIytUP/0M6k+yezbrQRp2KfdPFp0gHyR7HTWZYPV jfgAOW3BwG/ZLREdPR/4XgOljRmXFRTon9hnORf359R622VZRD4w00EC+vS7OSz7D0F/ oPllDVPTn/jdSfOtV+juMGXNZ6qZ0iKELWK2i/1b2hHb0O6m26WmYMwJ1KAeOTq+8ikM kk8l84nA8wX7WtvdLv2pG/TEyS8KDo4Bg8RiLiEUIQZalWw3kgKwXPrK6fJLi/7NNjf7 eB6ShWjSpyK6MTuqTN/j0oSyuDrhg+6oYGSiq6WE4yJVgTdH5QMIk4A/VFz72kxvH/WF /aUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=RxkDKFwZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bt10si94599edb.146.2020.07.08.07.28.12; Wed, 08 Jul 2020 07:28:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=RxkDKFwZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729579AbgGHOZf (ORCPT + 99 others); Wed, 8 Jul 2020 10:25:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729468AbgGHOZe (ORCPT ); Wed, 8 Jul 2020 10:25:34 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 722DAC061A0B for ; Wed, 8 Jul 2020 07:25:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=+YUe1fHnh8Fc6MZuglb4QKVpoNIXOUgI7dCHoGx1luE=; b=RxkDKFwZoqNTLBBbYfGgGUe4+O 5j83xJFKnsJW4vLbLWpzdQQJwqJ+6HP1kWNO3GX1zCgW7es+pDcpixR07wcr1bnkCuiKALYeSaVhY hScSwsKk7WByOKncEwgTCxofH9YZ6+R7ccEwJJEq/wfYnwazkdSv6JjIH/qAYW/auTb0pJ8bz0UAx 8CP4L0EthAkXqyuZ0Mh7RNlZbV4I7E4LMaADnJx03SfpBw5rNKtQS3/wJD2aMgiXYVdcutefbIFye ITonfS6BRI+r9t6sVO8ZTyaoTBnitjtANNK44rwMgUfFzR5e6ZYZ8W38RLeqyxKak+6iZckJtqkmq 4xzyYt5g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jtB0q-0007AN-9E; Wed, 08 Jul 2020 14:25:28 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id DFBD0304D58; Wed, 8 Jul 2020 16:25:26 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 970BF214ECDC2; Wed, 8 Jul 2020 16:25:26 +0200 (CEST) Date: Wed, 8 Jul 2020 16:25:26 +0200 From: Peter Zijlstra To: "Ahmed S. Darwish" Cc: Ingo Molnar , Will Deacon , Thomas Gleixner , "Paul E. McKenney" , "Sebastian A. Siewior" , Steven Rostedt , LKML Subject: Re: [PATCH v3 06/20] seqlock: Extend seqcount API with associated locks Message-ID: <20200708142526.GR117543@hirez.programming.kicks-ass.net> References: <20200630054452.3675847-1-a.darwish@linutronix.de> <20200630054452.3675847-7-a.darwish@linutronix.de> <20200706212148.GE5523@worktop.programming.kicks-ass.net> <20200707084024.GA4097637@debian-buster-darwi.lab.linutronix.de> <20200707130410.GO4800@hirez.programming.kicks-ass.net> <20200707143726.GO117543@hirez.programming.kicks-ass.net> <20200708103314.GB4151780@debian-buster-darwi.lab.linutronix.de> <20200708122938.GQ4800@hirez.programming.kicks-ass.net> <20200708141332.GQ117543@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200708141332.GQ117543@hirez.programming.kicks-ass.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 08, 2020 at 04:13:32PM +0200, Peter Zijlstra wrote: > On Wed, Jul 08, 2020 at 02:29:38PM +0200, Peter Zijlstra wrote: > > > #define SEQCOUNT_LOCKTYPE(name, locktype, preempt, lockmember) \ > > typedef struct seqcount_##name { \ > > seqcount_t seqcount; \ > > __SEQCOUNT_LOCKDEP(locktype *lock); \ > > } seqcount_##name##_t; \ > > \ > > static __always_inline void \ > > seqcount_##name##_init(seqcount_##name##_t *s, locktype *l) \ > > { \ > > seqcount_init(&s->seqcount); \ > > __SEQCOUNT_LOCKDEP(s->lock = l); \ > > } \ > > \ > > static __always_inline __seqprop_ptr_t \ > > __seqprop_##name##_ptr(seqcount_##name##_t *s) \ > > { \ > > return &s->seqcount; \ > > } \ > > \ > > static __always_inline __seqprop_preempt_t \ > > __seqprop_##name##_preempt(seqcount_##name##_t *s) \ > > { \ > > return preempt; \ > > } \ > > \ > > static __always_inline __seqprop_assert_t \ > > __seqprop_##name##_assert(seqcount_##name##_t *s) \ > > { \ > > __SEQCOUNT_LOCKDEP(lockdep_assert_held(s->lockmember)); \ > > } > > For PREEMPT_RT's magic thing, you can add: > > static __always_inline void \ > __seqprop_##name##_lock(seqcount_##name##_t *s) \ > { \ > if (!__SEQ_RT || !preempt) \ > return; \ > \ > lockbase##_lock(&s->lock); \ > lockbase##_unlock(&s->lock); \ > } > > and: > > #define __rt_lock_unlock_associated_sleeping_lock(s) __seqprop(s, lock) Or possible have it like: if (!__SEQ_RT || !preempt) return smp_cond_load_relaxed(&s->seqcount->sequence, !(VAL & 1)); lockbase##_lock(&s->lock); lockbase##_unlock(&s->lock); return READ_ONCE(s->seqcount->sequence); and then replace most of __read_seqcount_begin() with it.