Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1072489pxk; Fri, 18 Sep 2020 03:09:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz33dyjuUzpA8HDgZ/GZYl0c8tLdnWZEaEgAhpqamVrWnJCvUJ2FzBeZcH8qb77AFN9A38M X-Received: by 2002:a05:6402:346:: with SMTP id r6mr38506422edw.301.1600423752554; Fri, 18 Sep 2020 03:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600423752; cv=none; d=google.com; s=arc-20160816; b=hiA/Bad8MBmoYqgo5C8MrMJ7OXeTKa4182AWV5jP8B7vAwq+vri0znXZOCASOSFaAN m0TZdaZTd1RxexT1Metq6lTl3wQkl9wq0bXFth+1CZ6uiFRKQn5FsA63Nz582asNPZ7S k3AbFK3E1LUxwlEiBR9fXGJKQBBlVclPnApITSgMPLpaKM35pvQWx/rn5n47M1gHOhGN UaB2r8P0MJOCks7XR8buixtqNtbPZ4R8a+32dFt7DmS62myMV5aHQd0K3u4PaJv7RtTu T1jyVEITjXnvY0DzSW60IDygG2dChjBgIHogE+geRbq37jhkPBHh6HvfP1MskIL13rTT uT4Q== 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=XzBING0RVqy6DwPzZA42LOJqO0/ETIdbqaGA73DICbI=; b=MD4IxtyN0ihH9zhe5DzFYyRoSf8aoCaoUuM3yRuTZskreup/Ew4d1oqVXrUSRibVtL MnaGkYoJNW59eE6I9K0C181+d5cxCxQbfd06rXPophqoXzqz5TjwbnQ7aZNZBAJVvlMc OMkr6cLUOrOZN9SpCsH1kLxbNCRRVGKq+G/Nd6zbDe5BAwuschmDz1k2fs5P0IK2upHz yUsKVWQlfbypaMm9eb6cyDTu2xtwKRuv6O9GsNLZRhZ4wLnOLO2o6LF1RQduWs62WwC4 xPnga6pluVvIwsEZq+Jp4Kg6eTp+h8x3Y/0yyv61kAi1KD7+xpsg19lRI73h7VfEMrps EUZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=X9ro1ToO; 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 r26si1706232eds.384.2020.09.18.03.08.49; Fri, 18 Sep 2020 03:09:12 -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=casper.20170209 header.b=X9ro1ToO; 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 S1726149AbgIRKH5 (ORCPT + 99 others); Fri, 18 Sep 2020 06:07:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbgIRKH5 (ORCPT ); Fri, 18 Sep 2020 06:07:57 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D505BC06174A; Fri, 18 Sep 2020 03:07:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=XzBING0RVqy6DwPzZA42LOJqO0/ETIdbqaGA73DICbI=; b=X9ro1ToOCaMy9lcez/FyZ/GeQj 7C5CXExsAMS9EyWiJI/LtZWHB8JySVqVmOLavXLW6GkOvCysxjs8majl+BwhYYLXHME3wSy+EuYoY LrdP8bEJo87NWTn0c4EE72DWUzV9CM1apG/+BXf/vC47qI1OXwLrhApf3T4ASVFBamx1EWXr6wGS/ 7ZI3xEub9TyyVIMvFMvgE+YvEn2IQGfdQjybGlSTUBRpUH6SZygLdLff1ScT/8udawuTaTqn0JMLZ AZBn1qvPb0GPeyc+TYwdhjBA0oXAW2npNHgbPMewtBFkXxs3CPK9RziUlEvkXgx6yUccuxcuoWphi 6KaMNZNw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJDIu-0006iZ-0E; Fri, 18 Sep 2020 10:07:44 +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 9CB41307697; Fri, 18 Sep 2020 12:07:43 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 8B7AB203EB182; Fri, 18 Sep 2020 12:07:43 +0200 (CEST) Date: Fri, 18 Sep 2020 12:07:43 +0200 From: peterz@infradead.org To: Jan Kara Cc: Oleg Nesterov , Boaz Harrosh , Hou Tao , Ingo Molnar , Will Deacon , Dennis Zhou , Tejun Heo , Christoph Lameter , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [RFC PATCH] locking/percpu-rwsem: use this_cpu_{inc|dec}() for read_count Message-ID: <20200918100743.GK35926@hirez.programming.kicks-ass.net> References: <20200915150610.GC2674@hirez.programming.kicks-ass.net> <20200915153113.GA6881@redhat.com> <20200915155150.GD2674@hirez.programming.kicks-ass.net> <20200915160344.GH35926@hirez.programming.kicks-ass.net> <20200917120132.GA5602@redhat.com> <20200918090702.GB18920@quack2.suse.cz> <20200918100112.GN1362448@hirez.programming.kicks-ass.net> <20200918100432.GJ35926@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200918100432.GJ35926@hirez.programming.kicks-ass.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 18, 2020 at 12:04:32PM +0200, peterz@infradead.org wrote: > On Fri, Sep 18, 2020 at 12:01:12PM +0200, peterz@infradead.org wrote: > > @@ -198,7 +198,9 @@ EXPORT_SYMBOL_GPL(__percpu_down_read); > > */ > > static bool readers_active_check(struct percpu_rw_semaphore *sem) > > { > > - if (per_cpu_sum(*sem->read_count) != 0) > > + u64 sum = per_cpu_sum(*(u64 *)sem->read_count); > > + > > + if (sum + (sum >> 32)) > > That obviously wants to be: > > if ((u32)(sum + (sum >> 32))) > > > return false; > > > > /* I suppose an alternative way of writing that would be something like: union { u64 sum; struct { u32 a, b; }; } var; var.sum = per_cpu_sum(*(u64 *)sem->read_count); if (var.a + var.b) return false; which is more verbose, but perhaps easier to read.