Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3894006pxk; Tue, 8 Sep 2020 05:35:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZVgISo0R6ltfu2nC9Uy0GVDVwhKg4jsC1V03/W8GTPzN+W0a9tO5xurYNfhirBcJ1zCpb X-Received: by 2002:aa7:c504:: with SMTP id o4mr27481700edq.82.1599568545638; Tue, 08 Sep 2020 05:35:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599568545; cv=none; d=google.com; s=arc-20160816; b=gma9tl8PDm1Y6WSNGCF0U//ZjodCmYzuSHqfuLHdGSbVO+erGJIZ0O0knV6YQp91/n hOqH6rqpQ6lBLX4yCTyoVojokIB5vVk5h63MUQzXSoG/sjasEfNHyguEg0A3HYQ3ztHL wb4jSWCQluv+jMOtd7Jr968rYYtGkVvzWBStx7ULCuV09HiHp8CExzCBtXuH7U24bri7 iIV+YAQboMttziMJq8lI8jC9SWnKYHqowyPZ5crEzmNcedGh3IyPi7jXkMoAuSVNOuG3 OXbtQbSKagWSn6NBN2At5YM07lKLhOHqVIc+g0jL8Hs1aXYB4XzMeFl3jF/XXnQXZqaR EC6A== 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=rwZTinpRniPb7Gd1GV/B2gVHbCl/qhwed8EPpBMTgTE=; b=iJD4yJ+xMiM1IYh4jQwu7h27qrJ/1QnnoPWLdbgrQy4SianCUbtLx21XjMrIP4/y+5 x47gzUd1FY+g77yD+37jtqMugCg2PB+WGYbgen1L/NpfDUB6wYkQi4MKXQAr4zZhF7Ne BYrhsGe6zmpq43vgX3POaL+rQ3NKAGpauqa7nXt/zYOB9D7qUuaqS2ZCLU07u0xKGDXX VHBUBPRVThPcrNBLIVlUKRgLTYMbIhMGuvrlrOh5w93C5FbnzzYp6VbFLD9prCe+KEfH r5YumSMrZ9gNBiVq5BWtJHvhuhck8mrM+VAvmZ2/D/FoPVAj9rORY4ZFT2wTrb8me/7S THaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=lIC+QSi3; 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 s11si3263565edq.473.2020.09.08.05.35.22; Tue, 08 Sep 2020 05:35:45 -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=lIC+QSi3; 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 S1730177AbgIHMbZ (ORCPT + 99 others); Tue, 8 Sep 2020 08:31:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730180AbgIHLwa (ORCPT ); Tue, 8 Sep 2020 07:52:30 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E7AFC061786 for ; Tue, 8 Sep 2020 04:45:30 -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=rwZTinpRniPb7Gd1GV/B2gVHbCl/qhwed8EPpBMTgTE=; b=lIC+QSi3V7SId5JZjcNohDmysc qmx2MvJwL3IbLHaxbriGHwXNOSqeka81XwOpXNocu2vi8SvFz0ieH/L3eCCU2FwtSjOtsUvtuidou Qi5WDVWrAbvYBSMtB+SKXjnTTY1jMOgMMcJ1IFTTKKJlz8w/SKGfeT1gOrd6jvMqwSaqGQSYK/Lwh jdM+OGvEQPuxSHnxwR1OmKVbJru2s4Nye7fwdx3WlOZGOAamBQT45aHh+V0Ny9PrU3L1JHeKg6ChL cieBfyuJd21PqkAHBicSaljqPfOwAMlsNRRsy+66+4XRFbyHAZHlNT257ViNenkZ63NxmwUQJkjRB e7Xr449A==; 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 1kFc3u-0005zW-Do; Tue, 08 Sep 2020 11:45:24 +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 3F97F304B92; Tue, 8 Sep 2020 13:45:21 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id E3BED20CB2043; Tue, 8 Sep 2020 13:45:20 +0200 (CEST) Date: Tue, 8 Sep 2020 13:45:20 +0200 From: peterz@infradead.org To: "Ahmed S. Darwish" Cc: Ingo Molnar , Will Deacon , Thomas Gleixner , "Sebastian A. Siewior" , "Paul E. McKenney" , Steven Rostedt , LKML Subject: Re: [PATCH v2 4/5] seqlock: seqcount_LOCKNAME_t: Introduce PREEMPT_RT support Message-ID: <20200908114520.GS1362448@hirez.programming.kicks-ass.net> References: <20200904153231.11994-1-a.darwish@linutronix.de> <20200904153231.11994-5-a.darwish@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200904153231.11994-5-a.darwish@linutronix.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 04, 2020 at 05:32:30PM +0200, Ahmed S. Darwish wrote: > @@ -406,13 +443,20 @@ static inline int read_seqcount_t_retry(const seqcount_t *s, unsigned start) > return __read_seqcount_t_retry(s, start); > } > > +/* > + * Enforce non-preemptibility for all seqcount_LOCKNAME_t writers. Don't > + * do it for PREEMPT_RT, for the reasons outlined at __SEQ_LOCK(). > + */ > +#define __seq_enforce_writer_non_preemptibility(s) \ > + (!IS_ENABLED(CONFIG_PREEMPT_RT) && __seqcount_lock_preemptible(s)) > + > /** > * raw_write_seqcount_begin() - start a seqcount_t write section w/o lockdep > * @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants > */ > #define raw_write_seqcount_begin(s) \ > do { \ > - if (__seqcount_lock_preemptible(s)) \ > + if (__seq_enforce_writer_non_preemptibility(s)) \ > preempt_disable(); \ > \ > raw_write_seqcount_t_begin(__seqcount_ptr(s)); \ > @@ -433,7 +477,7 @@ static inline void raw_write_seqcount_t_begin(seqcount_t *s) > do { \ > raw_write_seqcount_t_end(__seqcount_ptr(s)); \ > \ > - if (__seqcount_lock_preemptible(s)) \ > + if (__seq_enforce_writer_non_preemptibility(s)) \ > preempt_enable(); \ > } while (0) > > @@ -456,7 +500,7 @@ static inline void raw_write_seqcount_t_end(seqcount_t *s) > do { \ > __seqcount_assert_lock_held(s); \ > \ > - if (__seqcount_lock_preemptible(s)) \ > + if (__seq_enforce_writer_non_preemptibility(s)) \ > preempt_disable(); \ > \ > write_seqcount_t_begin_nested(__seqcount_ptr(s), subclass); \ > @@ -483,7 +527,7 @@ static inline void write_seqcount_t_begin_nested(seqcount_t *s, int subclass) > do { \ > __seqcount_assert_lock_held(s); \ > \ > - if (__seqcount_lock_preemptible(s)) \ > + if (__seq_enforce_writer_non_preemptibility(s)) \ > preempt_disable(); \ > \ > write_seqcount_t_begin(__seqcount_ptr(s)); \ > @@ -504,7 +548,7 @@ static inline void write_seqcount_t_begin(seqcount_t *s) > do { \ > write_seqcount_t_end(__seqcount_ptr(s)); \ > \ > - if (__seqcount_lock_preemptible(s)) \ > + if (__seq_enforce_writer_non_preemptibility(s)) \ > preempt_enable(); \ > } while (0) I've replaced the above with the below, afaict there were no users of __seqcount_lock_preemptible() left. --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h @@ -228,7 +228,11 @@ __seqprop_##lockname##_sequence(const se static __always_inline bool \ __seqprop_##lockname##_preemptible(const seqcount_##lockname##_t *s) \ { \ - return preemptible; \ + if (!IS_ENABLED(CONFIG_PREEMPT_RT)) \ + return preemptible; \ + \ + /* PREEMPT_RT relies on the above LOCK+UNLOCK */ \ + return false; \ } \ \ static __always_inline void \