From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753149AbdGSGg6 (ORCPT ); Wed, 19 Jul 2017 02:36:58 -0400 Received: from mga11.intel.com ([192.55.52.93]:40243 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752847AbdGSGg5 (ORCPT ); Wed, 19 Jul 2017 02:36:57 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,380,1496127600"; d="scan'208";a="994593085" From: Alexander Shishkin To: Alexey Budankov , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo Cc: Andi Kleen , Kan Liang , Dmitri Prokhorov , Valery Cherepennikov , Mark Rutland , David Carrillo-Cisneros , Stephane Eranian , linux-kernel Subject: Re: [PATCH v5 1/4]: perf/core: use rb trees for pinned/flexible groups In-Reply-To: <00247f4a-1637-b7fe-2408-07330fcb3171@linux.intel.com> References: <874luavsh5.fsf@ashishki-desk.ger.corp.intel.com> <00247f4a-1637-b7fe-2408-07330fcb3171@linux.intel.com> User-Agent: Notmuch/0.23.7 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) Date: Wed, 19 Jul 2017 09:36:53 +0300 Message-ID: <87h8y9ue4a.fsf@ashishki-desk.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Alexey Budankov writes: >>> +static void >>> +perf_event_groups_insert(struct perf_event_groups *groups, >>> + struct perf_event *event) >>> +{ >>> + struct rb_node **node; >>> + struct rb_node *parent; >>> + struct perf_event *node_event; >>> + >>> + WARN_ON_ONCE(!groups || !event); >> >> I'm pretty sure neither of these is plausible. > > Used that for debugging. It's a bad practice to keep leftovers of debugging code in the patches. In this particular case, as with most WARN*s that I've seen in this patchset, it is completely useless, because the code goes ahead and dereferences the pointers right after the assert, so there'd be an oops and we'd see it anyway. Normally, you'd use these assertions if you're actually handling the undesired scenario, like /* Can't happen because XXX */ if (WARN_ON_ONCE(!groups)) return -EINVAL; Also a comment justifying the WARN* is a good thing to have. > Does it affect performance somehow? It doesn't matter. Generally, we don't need an reason to remove code, we need a reason to add code. Regards, -- Alex