Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1235305imm; Tue, 5 Jun 2018 11:07:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLWb+tlDt/PhFo7SOdZ7Hg25iMQHpwgYx7ZbIy5uGWDnfpPARxb1QMY9wUNqi8tf5sasg5V X-Received: by 2002:a62:66c6:: with SMTP id s67-v6mr26518263pfj.139.1528222042230; Tue, 05 Jun 2018 11:07:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528222042; cv=none; d=google.com; s=arc-20160816; b=FmVBm3P/zg+Y4VLn/ejAzzUG/EJIJURsk+8VhlJyHKrnh5IUgt0go15SitFipuIkye 6kLM72t/n2csmI14geYVbcGrLQfQP++7A5hjLopdKQIWKTtEXdkBeESsgWj4SChSixwQ DQ6jtQMSAoAoD17OtbEjOPJK7RxeT+fHLf5JUXn4eu0nlFowugC7jlViPWEMi9EUDPyF RwAdzLRu/wNS31/TuDYZeCFVK9MQthR2ZER34n56RmbcWaKgPRh/FhnNFJeBSlnVuknC M5ikVjTuvJ8Dy1vrGg1eG6Bc6ydZvDSo4JzvfBgiNsm2K1ul55kmNjRbap3kOOME8ZW6 E4qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=LndNZcloorFDvPQYnlbDSoYAFAmBr2YKhymXME0LDqU=; b=xCJXjW+vCcXhdvcUTsWeEyL7DJOTsB2v3EF3dUmIuvNFLL2lrHnPCNzioJsMc1ISPx YwdJnRszxXFZRw5v3JZehVEsFvOT8kunwFbbb9MZc+Ic9DanSYrCZYjCDTTYmVAEJhMk RDIIa7a+UvGR/RLRYi5OzO/OKULcPExqlnFp2LriMQhLam0p7olnGsk/TkHsGxb9lyUI iz806XOU+8T28rsutSF+VvIUzfQepSCq98QeQsihI3zBmXOtEk73683o0IkdcY4tQQCP cbDZG/RgzCKGeqteLVnr6wQd/jRkFIc/orAfYRBHQz4rVmoGscxBWcKDIu22kaW55hIV myLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RG4PfLC+; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d7-v6si16283079pfl.122.2018.06.05.11.07.08; Tue, 05 Jun 2018 11:07:22 -0700 (PDT) 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=@kernel.org header.s=default header.b=RG4PfLC+; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752411AbeFESG0 (ORCPT + 99 others); Tue, 5 Jun 2018 14:06:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:45390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751986AbeFERuv (ORCPT ); Tue, 5 Jun 2018 13:50:51 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 39E6320874; Tue, 5 Jun 2018 17:50:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528221050; bh=KQEAQo7MSUtTgquBE0oEQcjWhweG+6CQ/jAqSsPbSDM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RG4PfLC+1d5/XerPctXHgf1OzWCz6tEc5//9t4mMIUwbAkFX7JAeOdKYRnnrpXndC JJLz++AlmwpA0cDFXXvbk3K5AkqnW41Y5Ogqchh4K4oRilwSs0Ru6CJOH6ph63M1Uf +R2hkteH5yK7Y673pd/VVtHoKn0JJNXn6Ex5Zs28= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Adrian Hunter , David Ahern , Jiri Olsa , Namhyung Kim , Stephane Eranian , Wang Nan Subject: [PATCH 03/46] perf cgroup: Make evlist__find_cgroup() more compact Date: Tue, 5 Jun 2018 14:49:47 -0300 Message-Id: <20180605175030.32549-4-acme@kernel.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180605175030.32549-1-acme@kernel.org> References: <20180605175030.32549-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaldo Carvalho de Melo By taking advantage that __get() routines return the pointer to the object for which a reference count is being get. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Stephane Eranian Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-xnvd07rdxliy04oi062samik@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cgroup.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c index decb91f9da82..ccd02634a616 100644 --- a/tools/perf/util/cgroup.c +++ b/tools/perf/util/cgroup.c @@ -93,20 +93,17 @@ static int open_cgroup(const char *name) static struct cgroup *evlist__find_cgroup(struct perf_evlist *evlist, const char *str) { struct perf_evsel *counter; - struct cgroup *cgrp = NULL; /* * check if cgrp is already defined, if so we reuse it */ evlist__for_each_entry(evlist, counter) { if (!counter->cgrp) continue; - if (!strcmp(counter->cgrp->name, str)) { - cgrp = cgroup__get(counter->cgrp); - break; - } + if (!strcmp(counter->cgrp->name, str)) + return cgroup__get(counter->cgrp); } - return cgrp; + return NULL; } static struct cgroup *cgroup__new(const char *name) -- 2.14.3