Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3936601ybv; Mon, 10 Feb 2020 09:08:53 -0800 (PST) X-Google-Smtp-Source: APXvYqykTEEHLngZCa4MuCKO36Bg4/IJ/0oByDapKA6CQEJdfm6NhzLvOhGh2tfx+VV0OS365D8z X-Received: by 2002:a9d:3b09:: with SMTP id z9mr1815616otb.195.1581354533199; Mon, 10 Feb 2020 09:08:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581354533; cv=none; d=google.com; s=arc-20160816; b=zswYdr6er1PBgchgBT0VF1ladZntWXBNKlBgka57d0LBa5FOORlHcV/hNjQOJ7lJf6 0SJTOqIhTovP73mGIqLtskLEabVveRugppymwQgiCYVX7RE/B9sgy2LnNLmKG7NNlt+y guEsQNqt0KmjqiOFpwcZRIH4xxMJWgJ5sbcAN0QfQQEIcSLL4VCiidMZe+TS72WBA6mZ eDCm9zohgp65EhjyMcZdqDhixTlu62ikcL9mKS2l8zhk5YEPHXIyKPUHk0DCWBLe5MIW H7oQjY1mY5R77cReob8a963R4mSAHV9Cu0Z8JO4k1DfXrFKbYlCuZaNPkVKdAp+wd0ij hcIQ== 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=GRCpHDtsJ67okeGwIgvsSL9BK++UHh+4kCyjcA9A5ko=; b=0hMuCfD3Uiey6Vp0Co0NXC9i+eE2e6AMiJlKjqXOVbEFPL6YQtlFmfOz+HcxNuehcL aDOyl/nXUYDuSgeD4jN+IfL7GVpVqeXP3YByQiEun9rNU7/4rnvo9li/hqR/h6i3Jie9 5J+zBzlc9RJ72WN7i0uqHUjk+yjMmZq53bbYGEH73ntIY9uicqw3fij5pZYWXyzMlWGW a4Ts2sg06lU5LgLQMoO+/AipHgt9ddG3MgHjY6Q4P2UyF4hFNL9QBVsDFLxC/nwEzvju 2JtqOHjUy5rdVhPvqEBxhqG4vhzQj2PCDqYnXwoTWURmL951quM+sr+YnQYAcGV84uEZ ZZYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=jL687RAj; 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 l21si467080otk.142.2020.02.10.09.08.41; Mon, 10 Feb 2020 09:08:53 -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=pass header.i=@joelfernandes.org header.s=google header.b=jL687RAj; 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 S1727872AbgBJRIe (ORCPT + 99 others); Mon, 10 Feb 2020 12:08:34 -0500 Received: from mail-qv1-f65.google.com ([209.85.219.65]:36762 "EHLO mail-qv1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727587AbgBJRIe (ORCPT ); Mon, 10 Feb 2020 12:08:34 -0500 Received: by mail-qv1-f65.google.com with SMTP id db9so3518523qvb.3 for ; Mon, 10 Feb 2020 09:08:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=GRCpHDtsJ67okeGwIgvsSL9BK++UHh+4kCyjcA9A5ko=; b=jL687RAj+iaak76ia5BKrsjyleZ1AAx1iBnkuLt78MsrLOJrzMy4Tp/apdLbl5u/Ue z3M0jAHM6lzdCdKUMwwux1yN4cR0lDtY6RmTTmmCO+g+M+XapAiVjSWdKMwO6UTq4qg0 2stXVsIUZ6fn45H16Y/WnaeBPXm3xzJgQHwIY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=GRCpHDtsJ67okeGwIgvsSL9BK++UHh+4kCyjcA9A5ko=; b=FcPTkwCOQUSgqMMwpjSRREfPEyn+eRyKL6R4wl+jGfTE5Buj2FTrjKINCoEb6X61gT 7hVogix//OzB0Nq/BDbIvwqC245kGZQn65QlvLun3/tcqfs61vhMWbJ8LoP9zhKJ93is rZuB3OTJ9M0mF6Gb7m5VB+QVSxW8d/xpJsxV/8ayzH25vAMYEfXqa8blC9RlT5mNuXYz jEUf1k4Ev9ZtxXjk7reaH7iXSj/AuoN6j4/0H/ujrtTW+C/nwvxBCIwlF2ZqD5W4oNDP at07A1Nh/bsXq7yhwaw/lFQATEqDvTvhBg+qZF1sU1jyBdb90+U0npL8xCagHLHdhr7T wZVg== X-Gm-Message-State: APjAAAXBoadSsU3wPJlwddymEba1p3zsTZGCvT87VVk993pm8j/CUkoy voORR6l/EhsapW/kF38TiEkHlO1v2oI= X-Received: by 2002:ad4:4e24:: with SMTP id dm4mr10644914qvb.170.1581354513305; Mon, 10 Feb 2020 09:08:33 -0800 (PST) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id o55sm497974qtf.46.2020.02.10.09.08.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2020 09:08:31 -0800 (PST) Date: Mon, 10 Feb 2020 12:08:31 -0500 From: Joel Fernandes To: Amol Grover Cc: Peter Zijlstra , 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, Madhuparna Bhowmik , "Paul E . McKenney" Subject: Re: [PATCH] events: Annotate parent_ctx with __rcu Message-ID: <20200210170831.GB246160@google.com> References: <20200208144648.18833-1-frextrite@gmail.com> <20200210093624.GB14879@hirez.programming.kicks-ass.net> <20200210125948.GA16485@workstation-portable> <20200210133459.GJ14897@hirez.programming.kicks-ass.net> <20200210164727.GA22283@workstation-portable> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200210164727.GA22283@workstation-portable> 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 Mon, Feb 10, 2020 at 10:17:27PM +0530, Amol Grover wrote: > On Mon, Feb 10, 2020 at 02:34:59PM +0100, Peter Zijlstra wrote: > > On Mon, Feb 10, 2020 at 06:29:48PM +0530, Amol Grover wrote: > > > On Mon, Feb 10, 2020 at 10:36:24AM +0100, Peter Zijlstra wrote: > > > > On Sat, Feb 08, 2020 at 08:16:49PM +0530, Amol Grover wrote: > > > > > > > @@ -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); You can probably remove the earlier lockdep_assert_held(s) if you're going to use rcu_dereference_protected() here, since that would do the checking anyway. > > > > > > > > Bah. > > > > > > > > Why are you fixing all this sparse crap and making the code worse? > > > > > > Hi Peter, > > > > > > Sparse is quite noisy and we need to eliminate false-positives, right? > > > > Dunno, I've been happy just ignoring it all. FWIW some of the sparse fixes Amol made recently did uncover so existing "bugs" :) (Not in perf but other code). > > > __rcu will tell the developer, this pointer could change and he needs to > > > take the required steps to make sure the code doesn't break. > > > > I know what it does; what I don't know is why you need to make the code > > worse. In paricular, __rcu doesn't mandate rcu_dereference(), esp. not > > when you're actually holding the write side lock. > > I might've misinterpreted the code. How does replacing rcu_dereference() > with > parent_ctx1 = rcu_dereference_protected(ctx1->parent_ctx, > lockdep_is_held(&ctx1->lock)); > sound? FWIW, some maintainers do hate calling RCU APIs when write side lock is held. Evidently it does make the code readability a bit worse and I can see Peter's point of view because the existing code is correct. I leave it to you guys to decide how you want to handle it. thanks! - Joel