Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp742843ybi; Fri, 24 May 2019 10:41:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNJQWJjG89w8/WIFKhGEoRohyQL7S3BOgXXnyb9dvzSzo8VU7e3fZ6KHsoj1+FOt0nL1S1 X-Received: by 2002:a63:5964:: with SMTP id j36mr105828868pgm.384.1558719699096; Fri, 24 May 2019 10:41:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558719699; cv=none; d=google.com; s=arc-20160816; b=ldiOWZO3Zmuwx2qUVAID7L41Dc7OrUsJ/uVG3chlmY5r6S8bh8e/1R6HBGbfIwQ5d3 WTD2oiceIxhPY8ei9Wywpm2xIdhNVFSvq1yslSSMjD698PgXW0/UZS/EGzgoJ4sYShRy xeeV28b7co3xSkwVR/FxB7+I6XWrZT/BdGXpOc4h9gMDAjVa4JL+zN3lAAy8Z0ld8F5p zKIhJuBC4keFMhsB29m41dTAzDxL2jnJ8AbjYLzJrldCzirEvbGqVUSa1yoCqvqf3eE/ VpXFsgCmpZcqD7gJ2x+waGqyr2yfplQ7j8AZDHCzewwIc2AWoacsF6A3jYHM4QK1IUMx +59Q== 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=yCwFBqQuxuu7Snq6QWW50362/rDdCgkPwmsiYegKwqQ=; b=AL5UEvvibH7T8jvxccqxJ11YxclvzbAcc0cG4b6BUbyUFwiJFlFlanYZgZc6fCADsg 3sX5/DqDcTpW07Om3A3HK3UX+bgeACv39w2eArhwWJQlPRofv/nP5hjQcupq4AR2LecN dUCf/CnY+JJm4NhRNz6DOrpFM/3boJKK5XLls5IdcTAR/s0LUSD7/GhP9gfeMhJfaakD R7NBYk2vqr093+OJGOx/Y4jlyophI9XmXJe0x8LLbV0QxMb1taWGpUslsWeFznWbYbDn lIjJ9FfBi4EG0g39U5oDaUdyyICPBXhSm9BGJ5jDB+hZzLzFGLuiDSyBuqCD3QClQerj VmRw== 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 q19si4951452pls.124.2019.05.24.10.41.23; Fri, 24 May 2019 10:41:39 -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 S2391479AbfEXRjU (ORCPT + 99 others); Fri, 24 May 2019 13:39:20 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:47706 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726381AbfEXRjU (ORCPT ); Fri, 24 May 2019 13:39:20 -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 ADB42A78; Fri, 24 May 2019 10:39:19 -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 9901C3F703; Fri, 24 May 2019 10:39:17 -0700 (PDT) Date: Fri, 24 May 2019 18:39:15 +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: <20190524173915.GB9120@fuggles.cambridge.arm.com> References: <20190524165346.26373-1-longman@redhat.com> <20190524171939.GA9120@fuggles.cambridge.arm.com> <8ceebb1c-e8f1-8bc5-e032-48f1a653a979@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8ceebb1c-e8f1-8bc5-e032-48f1a653a979@redhat.com> 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 01:35:39PM -0400, Waiman Long wrote: > On 5/24/19 1:27 PM, Linus Torvalds wrote: > > On Fri, May 24, 2019 at 10:19 AM Will Deacon wrote: > >> Are you sure this works wrt IRQs? For example, if I take an interrupt when > >> trying to update the counter, and then the irq handler takes a qspinlock > >> which in turn tries to update the counter. Would I lose an update in that > >> scenario? > > Sounds about right. > > > > We might decide that the lock event counters are not necessarily > > precise, but just rough guide-line statistics ("close enough in > > practice") > > > > But that would imply that it shouldn't be dependent on CONFIG_PREEMPT > > at all, and we should always use the double-underscore version, except > > without the debug checking. > > > > Maybe the #ifdef should just be CONFIG_PREEMPT_DEBUG, with a comment > > saying "we're not exact, but debugging complains, so if you enable > > debugging it will be slower and precise". Because I don't think we > > have a "do this unsafely and without any debugging" option. > > I am not too worry about losing count here and there once in a while > because of interrupts, but the possibility of having the count from one > CPU to be put into another CPU in a preempt kernel may distort the total > count significantly. This is what I want to avoid. > > > > > > 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. Will