Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp796889ybi; Fri, 24 May 2019 11:34:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrtvy+QWL6E/TUcuRLl/imPT7uvCsZ3MxW6Dy9lak3shM0RGCaK0khhZdp6zKem/ggQp4f X-Received: by 2002:a63:4a4f:: with SMTP id j15mr11498895pgl.338.1558722866687; Fri, 24 May 2019 11:34:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558722866; cv=none; d=google.com; s=arc-20160816; b=srkbguNuwhlm0ROj4xcgRjNzmc7/9/34zNrhKSl6WAUWVEU/ar4CayF0n9Qt2Y74AH KVfR5dDbsoszkUsbRYkJwr43sPdIpDaIdOHMU2k7wou7DGvZPXLnmi5xRPTVF5yNCTS/ ieM9+vR1u4nvM4i8Ps60+I9lOQ9p4S4+i9DxGOzHPABo5QVQ2FzsMfhkin/Ll5g8SpTG K2PBGo37mXISSamkBKL8ePUS6oSLSlx39kvwBGY18C4fHZNAV8lLNK2hGxrak00LlLO6 MEc2VqttSKFHYmv04NDp3WQYE6h1VV1fy9wnBemIrOMV1r91mJRgjCNyDCm503Q7pTAS mVfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Qbn22SJdncw82lCl311h/WONRqQY/YZYI4wanOxedQk=; b=D9OZUkSQC2YoH5ErDZtzVvTc06nS9aPXDHauT2dgPa49Orq885DNUcg/MoUprV/EDs LLJPIGovBVppzBn4GmElNFkQ4q5Q2RI5xvl/I4rl0CfCUHQJwdMkfLbYSdKB3sAR8D5y 9RaQNUgD45OnIceipgRRoqtteJaZbIl0Utl5vODdTmZrqqThIqh5Im1DahBcWL3+8xP3 WUy4FUMiVBpHrN+A2giXRS4g49iAmyD5SA23euePlfqPnG2WwSeyulGNHa5mWUgnbgqN RSCsf43hdorIx8ocuGM4pDOAQLVkNTM/09fQCZ2+6EuTzC6oh3jbXhVm4HngcZpcDuQT nObA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z9si5345831pgi.341.2019.05.24.11.34.11; Fri, 24 May 2019 11:34:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729678AbfEXSdD (ORCPT + 99 others); Fri, 24 May 2019 14:33:03 -0400 Received: from foss.arm.com ([217.140.101.70]:48642 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726581AbfEXSdD (ORCPT ); Fri, 24 May 2019 14:33:03 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A0005A78; Fri, 24 May 2019 11:33:02 -0700 (PDT) Received: from fuggles.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8B6ED3F703; Fri, 24 May 2019 11:33:00 -0700 (PDT) Date: Fri, 24 May 2019 19:32:58 +0100 From: Will Deacon To: Waiman Long Cc: Linus Torvalds , Peter Zijlstra , Ingo Molnar , Thomas Gleixner , Borislav Petkov , "H. Peter Anvin" , Linux List Kernel Mailing , the arch/x86 maintainers , Davidlohr Bueso , Tim Chen , huang ying Subject: Re: [PATCH v2] locking/lock_events: Use this_cpu_add() when necessary Message-ID: <20190524183258.GD9697@fuggles.cambridge.arm.com> References: <20190524165346.26373-1-longman@redhat.com> <20190524171939.GA9120@fuggles.cambridge.arm.com> <8ceebb1c-e8f1-8bc5-e032-48f1a653a979@redhat.com> <20190524173915.GB9120@fuggles.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.1+86 (6f28e57d73f2) () Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 24, 2019 at 02:11:23PM -0400, Waiman Long wrote: > On 5/24/19 1:39 PM, Will Deacon wrote: > > And the whole "not precise" thing should be documented, of course. > > Yes, I will update the patch to document that fact that the count may > not be precise. Anyway even if we have a 1-2% error, it is not a big > deal in term of presenting a global picture of what operations are being > done. > > I suppose one alternative would be to have a per-cpu local_t variable, > and do the increments on that. However, that's probably worse than the > current approach for x86. > > I don't quite understand what you mean by per-cpu local_t variable. A per-cpu > variable is either statically allocated or dynamically allocated. Even with > dynamical allocation, the same problem exists, I think unless you differentiate > between irq context and process context. That will make it a lot more messier, > I think. So I haven't actually tried this to see if it works, but all I meant was that you could replace the current: DECLARE_PER_CPU(unsigned long, lockevents[lockevent_num]); with: DECLARE_PER_CPU(local_t, lockevents[lockevent_num]); and then rework the inc/add macros to use a combination of raw_cpu_ptr and local_inc(). I think that would allow you to get rid of the #ifdeffery, but it may introduce a small overhead for x86. Will