Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3534822ybv; Mon, 10 Feb 2020 01:36:51 -0800 (PST) X-Google-Smtp-Source: APXvYqxtxrdO2XQfWqDIW1fZYBdERpQHcKx5WQ0YwpP8DCAI9tyBcCL+cCQ88x1cJFRvS8QoYP2Z X-Received: by 2002:a9d:7e90:: with SMTP id m16mr366194otp.227.1581327411389; Mon, 10 Feb 2020 01:36:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581327411; cv=none; d=google.com; s=arc-20160816; b=tKW1Pbd/uLa+wmiQBKEFI0JqpRBSIZRGUJ/KrMDrONcbR/PIFDtsmPesqN8BLA99Jy F7E/ccTUp/cvblz0p1ocB3imqIrLsn+yTurttBk3eB7Z51deFSclhEmNleYqTC4IBa4P DMWzmpIdNqAHw5iJol6FKoWQVk4y9XYODwxFCcIA5ps1rmxO7P4AucR4eMziZOJcfHf2 SuVVsiU4UXu1xitKMKbeGXRIeaulQXlZHSrgu+T05Dpz34D9HXSPBVYHr9Sm63pKDQlg Ik8ThDkYXoS2OT6yDm/l6JiCBwSk45JCWcmlnz3lATsOda1VtKkR5GQ0nLVPJW1Kjy1S 4Iow== 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:dkim-signature; bh=KWSALxgD8DPKs4l9QdTGtfSb74FtrWq0gjEnbifVqg8=; b=vPnvpVFbQIFumAhhiPGKQQ8yNdlR9F4RBlpoZAOmESFjmI0uTsnOw7y69JAKG4cctp EGdO12dohu+tqbMNOrsMCkE/w7rNl3+pGtrUAhsgq2FmS9kF7jN5h2IZV3lB3XBIHD42 oYdFU14i0EnoxCKvFr1bfI1tXgw5seuiWj8SD+tJDcPkaeXqzOfBTNJ4RqUFAMTmuuy1 O4Uk2scbxPQUEJVSGIbSejL/7O0vQGmSI7Nrd0xCU2EkEWdMEiiC3g1aTDpzugpckrWz LLu5t2660++5JfG7/K7NNQlUjzgDbp68mAlO9AFTcMnuqIm5l7ZSoREfph6QQfawtPAp trcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=OVaJfwr6; 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 j20si4362562otp.147.2020.02.10.01.36.39; Mon, 10 Feb 2020 01:36:51 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=OVaJfwr6; 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 S1726961AbgBJJgc (ORCPT + 99 others); Mon, 10 Feb 2020 04:36:32 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:32858 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726118AbgBJJgc (ORCPT ); Mon, 10 Feb 2020 04:36:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=KWSALxgD8DPKs4l9QdTGtfSb74FtrWq0gjEnbifVqg8=; b=OVaJfwr6gYS4lvSTolSKQURRnZ bsUfpKOQXpyjcfuQ+GklUxLM+XPufwIZMez5WA9oXfzNCviUFc3Eci9Z6RbdboErXvezS5DW47NrS h87x6BwSNYCSd7QS0SqVwk9mmQNNOwYqkeSdjJq2f0ay0q68Mw3Qm6H9hCIbux1Jwmh1nUDzXhAQ3 xf/TJEl+vBfQqP4JZCQkQxgcOU9y45+lDSkmGZGMbZj5oPNk0xBO99OacaScB7EqDQKeMUef8bfDi 7m957y9dq4zemVJNKh7uGaRVTVd4sl0BILUhr5oKPsr0h+VeGr1vnUyB9FcfFkC+IJ7mCa+xxx3Mx HAFZmGnQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1j15UQ-0002wT-4b; Mon, 10 Feb 2020 09:36:26 +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 DB5E73012D8; Mon, 10 Feb 2020 10:34:35 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 15C602B1D5567; Mon, 10 Feb 2020 10:36:24 +0100 (CET) Date: Mon, 10 Feb 2020 10:36:24 +0100 From: Peter Zijlstra To: Amol Grover Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Joel Fernandes , Madhuparna Bhowmik , "Paul E . McKenney" Subject: Re: [PATCH] events: Annotate parent_ctx with __rcu Message-ID: <20200210093624.GB14879@hirez.programming.kicks-ass.net> References: <20200208144648.18833-1-frextrite@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200208144648.18833-1-frextrite@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 08, 2020 at 08:16:49PM +0530, Amol Grover wrote: > parent_ctx is used under RCU context in kernel/events/core.c, > tell sparse about it aswell. > > Fixes the following instances of sparse error: > kernel/events/core.c:3221:18: error: incompatible types in comparison > kernel/events/core.c:3222:23: error: incompatible types in comparison > > This introduces the following two sparse errors: > kernel/events/core.c:3117:18: error: incompatible types in comparison > kernel/events/core.c:3121:30: error: incompatible types in comparison > > Hence, use rcu_dereference() to access parent_ctx and silence > the newly introduced errors. > > Signed-off-by: Amol Grover > --- > include/linux/perf_event.h | 2 +- > kernel/events/core.c | 11 ++++++++--- > 2 files changed, 9 insertions(+), 4 deletions(-) > > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > index 6d4c22aee384..e18a7bdc6f98 100644 > --- a/include/linux/perf_event.h > +++ b/include/linux/perf_event.h > @@ -810,7 +810,7 @@ struct perf_event_context { > * These fields let us detect when two contexts have both > * been cloned (inherited) from a common ancestor. > */ > - struct perf_event_context *parent_ctx; > + struct perf_event_context __rcu *parent_ctx; > u64 parent_gen; > u64 generation; > int pin_count; > diff --git a/kernel/events/core.c b/kernel/events/core.c > index 2173c23c25b4..2a8c5670b254 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -3106,26 +3106,31 @@ static void ctx_sched_out(struct perf_event_context *ctx, > static int context_equiv(struct perf_event_context *ctx1, > struct perf_event_context *ctx2) > { > + struct perf_event_context *parent_ctx1, *parent_ctx2; > + > lockdep_assert_held(&ctx1->lock); > lockdep_assert_held(&ctx2->lock); > > + parent_ctx1 = rcu_dereference(ctx1->parent_ctx); > + parent_ctx2 = rcu_dereference(ctx2->parent_ctx); Bah. Why are you fixing all this sparse crap and making the code worse?