Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp458448pxb; Wed, 8 Sep 2021 05:17:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYAFu3qv1IL3FzeLNbctNwfJdREeMlwJI8YpPEnpQ2zkVWDZ1z7UYrQ4YTx955L7OGQkJf X-Received: by 2002:a17:906:7cd8:: with SMTP id h24mr1953348ejp.185.1631103420176; Wed, 08 Sep 2021 05:17:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631103420; cv=none; d=google.com; s=arc-20160816; b=bpEjUWOJdh0p5Wo3h79dDLnKHMdwPMr3FXkw96atuSCBjxA2RepQLGhs+WfNRBU6OX 4wg9w2PIA1LSAOaw0jzk6EWFSyTx663wKzIuv2QAMB5eQUZA5Zu+U8lZv4AYoh02MY6g P1CqiA5Xccj/1gqoBUraOibEukS8tSYzwIBQRC+RylSEhF4rZm+IHSbyUcpmcRqzhNBH fCWJv+Ug/84r/Da96fRme5NpSEBbujELhAMgb89xBGirJPgZs86cKguLGTKG9zPik72w rO6kI8MCJc/nDak7V6At5cAEZHmzcdUVmDj3oOxXFs/UVktfOVe5ThG+2y0d4kvYTMXU QiwA== 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=hEuKeBl0bf7BPTqdloL/nKyrupvk3MfCfBiLXZV+JGo=; b=tuT8Hgl9MW2IbouwQpDFqejERTW7g2prNUrmTI+lVbsGUpr1o3WJroeC4tGf7HSdYK CVJFXeSfmpxagVGZIek+UdsKi1mZ9MxSStdad5twrMLPG25/ozCKbObZy2ZJNsufaK6o 6UkKIeTyMqbYoaVEzMzRZsnIz11Fk2dls/4kYJw1nif/wwX8DA96xqVBFPMVqS64bdbD tgSXs7KxXrNb0SJYRIWfRjiQ1VK+Q2u2lo8jNU0qOkWq/ysqU5B3rfuntQOSsf2E1rZf +r5nlaBDIYP4CboxeA+PF3+u4xA+FZB8VgVxoj9hY0hGQAT0a4nynZEG9Lsg6MyyCA3O OZdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=C0pyq+4M; 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 v6si1836268ejh.227.2021.09.08.05.16.36; Wed, 08 Sep 2021 05:17:00 -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=pass header.i=@infradead.org header.s=desiato.20200630 header.b=C0pyq+4M; 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 S1348442AbhIHMP7 (ORCPT + 99 others); Wed, 8 Sep 2021 08:15:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235195AbhIHMP7 (ORCPT ); Wed, 8 Sep 2021 08:15:59 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC588C061575 for ; Wed, 8 Sep 2021 05:14:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=hEuKeBl0bf7BPTqdloL/nKyrupvk3MfCfBiLXZV+JGo=; b=C0pyq+4MTP9GV/XkkdcwdYrBeL VtLyT3IpdGg0rMMgrOB0oISXy/GE3Pt390RTiq0HNrmljJDklcwCdTVJHODRFpT27YiFokBnbciB7 tyZ/63dsfAg7Up6HojqXrMPrNxCy6BWLv0wkRRZF5zSZSkttM0vtgVq2SmD9Rv8D6swwA2pXELEQs kKucCfj7F1QikfTTiDweMb0peya5sNPum93U4/e9og+Y2QGIa3HcqIZ+R87K25a0ud57uhPkQtgzm 7dFiJ8N/vrrLeBW8MpXeN7ilNSwIGVQmmcTlQy1JH/5nDX/kSMxyrTwwbXF54kRLMqQBUOJFncyqD kPUNEupA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNwTH-001dYu-0C; Wed, 08 Sep 2021 12:14:31 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 1B646300332; Wed, 8 Sep 2021 14:14:29 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0578F2080015E; Wed, 8 Sep 2021 14:14:29 +0200 (CEST) Date: Wed, 8 Sep 2021 14:14:28 +0200 From: Peter Zijlstra To: Boqun Feng Cc: Thomas Gleixner , Ingo Molnar , Juri Lelli , Steven Rostedt , Davidlohr Bueso , Will Deacon , Waiman Long , Sebastian Andrzej Siewior , Mike Galbraith , Daniel Bristot de Oliveira , LKML Subject: Re: [RFC] locking: rwbase: Take care of ordering guarantee for fastpath reader Message-ID: References: <20210901150627.620830-1-boqun.feng@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 08, 2021 at 01:51:24PM +0200, Peter Zijlstra wrote: > On Wed, Sep 01, 2021 at 11:06:27PM +0800, Boqun Feng wrote: > @@ -201,23 +207,30 @@ static int __sched rwbase_write_lock(struct rwbase_rt *rwb, > { > struct rt_mutex_base *rtm = &rwb->rtmutex; > unsigned long flags; > + int readers; > > /* Take the rtmutex as a first step */ > if (rwbase_rtmutex_lock_state(rtm, state)) > return -EINTR; > > /* Force readers into slow path */ > - atomic_sub(READER_BIAS, &rwb->readers); > + readers = atomic_sub_return_relaxed(READER_BIAS, &rwb->readers); Hurmph... the above really begs for something like if (!readers) return 0; But then we needs that _acquire() thing again :/