Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3703034ybv; Mon, 10 Feb 2020 05:01:18 -0800 (PST) X-Google-Smtp-Source: APXvYqyRohDdLANlP5Zv/2iaj9o7SPL7eSNERvce4k2w6dLCD1kIJhv2ZFl7fa2EpC+tRgzkosv0 X-Received: by 2002:aca:be57:: with SMTP id o84mr750553oif.138.1581339678007; Mon, 10 Feb 2020 05:01:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581339677; cv=none; d=google.com; s=arc-20160816; b=dfX1Hds6XNsSK2VaL7W4C49VFUN/2YMDFpTe+iX+E5yJaIrLHoQdZbtuRF9BMAkijq OdlZc6I5tG/Z19cBgmfqA3j5e/uX0y4B7e6oOg6/z4SWmZP/dgNPgksVOeVGPnaNYDKu DdFTL9RpnlcntwFo+DbJrE2ijtiwjzp//CNA6ZCG0dazLWBNwfoMuOnQgfxYljL5BOL4 FIK7gMS2ZI3RjjJmOEBW6TMNOnKbJef85jDKNmXDhQXliAqoe/VfRy4waaI0YDb6RPOq ZvcS4WpHkl5klK9ulUlsv20LXmL1uzG+BxGcARP1aHmWeHZwQ5VvmoxmpmcjkNw9i1O2 +BdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=y0lLKcIRcrKBMjOb2t3dxuaz/hreV2rj4w3yWI5N9yg=; b=io8H8ve+VmUaWWVfeP62dEzXjKfIRfdcD8oDFjmWmBYuidu0WEKwo4vCWOMAYsGNrF +jFy5nnzP9qLNrfJ4x/yhLUTfI2dB9RbzB3gSaBE1NliLZankNeO5fUn5pnLAwpM28lU R0w1W/zv2cLmIG5ran0I7hJpZor8io4rbDAWXzn2JfizrmY0pLy7pdx21D/c9sp/F6Yh cpvek+QwKVeEh9s2f839PTOXFMNRcWyWFei/8YbeeqCASce0bjSaBhOaiKAqxkK8Ev8r k9pXxjGoKDYl5QPRbHnOfp7FSiY0C1BjoYFidengDG8+HFhfJpKC3fh+NNKYsiufl4Fw uJrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ShIXuYRh; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k20si121040oiw.273.2020.02.10.05.01.04; Mon, 10 Feb 2020 05:01:17 -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=@gmail.com header.s=20161025 header.b=ShIXuYRh; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730288AbgBJM77 (ORCPT + 99 others); Mon, 10 Feb 2020 07:59:59 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:35455 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729563AbgBJM75 (ORCPT ); Mon, 10 Feb 2020 07:59:57 -0500 Received: by mail-pg1-f195.google.com with SMTP id l24so3895563pgk.2 for ; Mon, 10 Feb 2020 04:59:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=y0lLKcIRcrKBMjOb2t3dxuaz/hreV2rj4w3yWI5N9yg=; b=ShIXuYRhJDp0KzLzF6UZgMsniFpEjmFjc61ljrmLMLTsjcl0HWTyMdFVPpbE+DPf/3 Zi/mg0ie+/dS9yy/39sLKz52WRV9E1CFI6L7ldSw4Vmst5iRVq/Ydqf3NYw2TF2cxjHL /j2DZNJBe2+MQRlC9yBlwF2/HEUz/BXB+rVuJKItBpjjV31vkqa4QgJGA/HzEryusoJz +uzigk7tPzocPlnwtJifPJJ8RZeaALg3Eh/WGiQ+U4LCx2lRjXp6ruH5YKAYH7LAM9TR 3S94DwDVd6T+IPzBoA31PGOOBqcy2UQ04iZ9Jv6Q2kEzdzqOtKB5x4XC76XWbS4HCtq4 YuZw== 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; bh=y0lLKcIRcrKBMjOb2t3dxuaz/hreV2rj4w3yWI5N9yg=; b=ruzCiW2Ire6/sHecN33QScmnLzkO61uD2GGIXFnXlofqlb6Bvy4zQzrDkKGAwMYrTG 31aykdBIBlnzlyxs8AmTd+Lc/LFe+LDeWvvQcCxZeY+oQVMJAqrVkvek+KpkfCnTtIdq KXrwI4mvi5z8Mi0c8lnJSTdv2kZ5anJtoKEzAoAup86vY1EFCOXowuuy1jk8+1vOnrsM 45otTLKebia3QD4oyb5Av+zTkD6aIG/VxsgeExYryHhCFZqDZZWNI9g4UqedXtsKRyvK yOScHdjteqoPk41v5HjwYUZvBHiT+jJEezV9q93tgsSiLpto6SBRtz5DWcuALWhKaqr2 Xmpw== X-Gm-Message-State: APjAAAXqqnkm+Q8F5cvGETZacmaSktFLYY0bqEyoRw7zYEwv52pM3uem IcrGKqH+ioB9oie9VWf2YIE= X-Received: by 2002:a63:3688:: with SMTP id d130mr1568945pga.422.1581339595955; Mon, 10 Feb 2020 04:59:55 -0800 (PST) Received: from workstation-portable ([146.196.37.217]) by smtp.gmail.com with ESMTPSA id w8sm455068pfj.20.2020.02.10.04.59.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2020 04:59:55 -0800 (PST) Date: Mon, 10 Feb 2020 18:29:48 +0530 From: Amol Grover To: Peter Zijlstra 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: <20200210125948.GA16485@workstation-portable> References: <20200208144648.18833-1-frextrite@gmail.com> <20200210093624.GB14879@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200210093624.GB14879@hirez.programming.kicks-ass.net> 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:36:24AM +0100, Peter Zijlstra wrote: > 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? Hi Peter, Sparse is quite noisy and we need to eliminate false-positives, right? __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. Thanks Amol