Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp626402ima; Fri, 1 Feb 2019 08:24:49 -0800 (PST) X-Google-Smtp-Source: AHgI3IaJgknSw2pKhOC/A1AUe0wfPnEoZJBh6WV6YCcW8f+RdE3A4TMXAmqGgYc71Fq3Be0K5acu X-Received: by 2002:a63:587:: with SMTP id 129mr2858200pgf.273.1549038289318; Fri, 01 Feb 2019 08:24:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549038289; cv=none; d=google.com; s=arc-20160816; b=FPNur7E2jGy7tjBBVn8O/K6PwSKV3q+RrUCkGQrydSN+MdZqNERSkLXDQfdr5ZMFFy q2Ci1sN28OZ13FYPLyl+f25T+VTnn21OnSZjzc2ecDbrYfOIS5xI7OifhtQHuv42gaaH nDneyefg7kI/KsbfLa6RfzaK2fy2M6YV1c3SXrmodHuwt1vX/I/9Q0nMWVE1xcewfqcW wnu89L7D9HQCZtyNxNynTbBUbhIjYIn55aA8gKdN1ZKBUcQ8RUA7471WHTk8mQmivmBs ZoWo7q/Iw3WGghOxqzGC2qllF1PkiCAd10jTnKBmGhyF8S/1bBAVdjJSu0Bem+ZSly6o SkRw== 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=muNSZkjtTRSvEEUZd28tLCxRbwGaMcUkh3UGOUMZBOE=; b=e8ChDx7o2RiCGEsAgyryejklEPBMJDx4wvOdNXjvMqHADJDbcAjCZfqYewfhVek3F2 7whh/76oGILYL+6hj6bP8toMY3JlmxdoZv628cfIBljRSin5X5c3TDt91AmzS4OoEGaF llaFokrEy88FxHqrdf7hfK/mGgVoEnh+HlB1hv5xhD6YJU1ucFMizRcHcaJehvZSChrJ GBURp6BkYUFIGjBpRnnPY2UAsl0/qoMFdxIcd/+zQj6L9prvMzGbKmV4HY8cWqWKXteB b3V9uG0kRpduMnDlpkg3IHLGW9KzPg0LTD02Yh8phhYC+logoVP2a7ECaibGVwBs0Kna BgEQ== 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 p64si8009093pfa.94.2019.02.01.08.24.33; Fri, 01 Feb 2019 08:24:49 -0800 (PST) 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 S1730483AbfBAQYD (ORCPT + 99 others); Fri, 1 Feb 2019 11:24:03 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:34808 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727919AbfBAQYC (ORCPT ); Fri, 1 Feb 2019 11:24:02 -0500 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 04D4D15BE; Fri, 1 Feb 2019 08:24:02 -0800 (PST) Received: from lakrids.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 3766C3F71E; Fri, 1 Feb 2019 08:24:00 -0800 (PST) Date: Fri, 1 Feb 2019 16:23:53 +0000 From: Mark Rutland To: "Reshetova, Elena" , Peter Zijlstra Cc: "linux-kernel@vger.kernel.org" , "mingo@redhat.com" , "acme@kernel.org" , "namhyung@kernel.org" , "alexander.shishkin@linux.intel.com" , "jolsa@redhat.com" , "keescook@chromium.org" , "tglx@linutronix.de" Subject: Re: [PATCH 1/3] perf: convert perf_event_context.refcount to refcount_t Message-ID: <20190201162313.GA34079@lakrids.cambridge.arm.com> References: <1548678448-24458-1-git-send-email-elena.reshetova@intel.com> <1548678448-24458-2-git-send-email-elena.reshetova@intel.com> <20190129093748.GF28467@hirez.programming.kicks-ass.net> <2236FBA76BA1254E88B949DDB74E612BA4B98D3A@IRSMSX102.ger.corp.intel.com> <20190201103254.GB31409@lakrids.cambridge.arm.com> <2236FBA76BA1254E88B949DDB74E612BA4B9DD52@IRSMSX102.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2236FBA76BA1254E88B949DDB74E612BA4B9DD52@IRSMSX102.ger.corp.intel.com> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 01, 2019 at 03:44:38PM +0000, Reshetova, Elena wrote: > > On Tue, Jan 29, 2019 at 01:55:32PM +0000, Reshetova, Elena wrote: > > > > On Mon, Jan 28, 2019 at 02:27:26PM +0200, Elena Reshetova wrote: > > > > > diff --git a/kernel/events/core.c b/kernel/events/core.c > > > > > index 3cd13a3..a1e87d2 100644 > > > > > --- a/kernel/events/core.c > > > > > +++ b/kernel/events/core.c > > > > > @@ -1171,7 +1171,7 @@ static void perf_event_ctx_deactivate(struct > > > > perf_event_context *ctx) > > > > > > > > > > static void get_ctx(struct perf_event_context *ctx) > > > > > { > > > > > - WARN_ON(!atomic_inc_not_zero(&ctx->refcount)); > > > > > + WARN_ON(!refcount_inc_not_zero(&ctx->refcount)); > > > > > > > > This could be refcount_inc(), remember how that already produces a WARN > > > > when we try and increment 0. > > > > > > But is this true for the x86 arch-specific implementation also? > > > > If you use recount_inc_checked(), it will always produce the WARN(), > > even when using the x86-specific refcount implementation. > > > > (this was one place I had intended to use the *_checked() forms of the > > refcount ops). > > Yes, with refcount_inc_checked() it would work, but I don't like it > that much when we have functions that behave regardless of refcount > config. It does help for code minimization & clarity like here, but I think > it complicates things even more: two different configs, then functions that > do not obey configs, etc. Sure. The main idea of having the _checked() forms was to not lose warnings in a conversion to refcount_t, but I appreciate that people might not like the existing warnings at all. > Anyhow, I can change this to refcount_inc_checked(), if this is what everyone > thinks is the best. I'll defer to Peter. Peter, would you prefer refcount_inc() or refcount_inc_checked() here? Thanks, Mark.