Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1417207pxk; Fri, 4 Sep 2020 08:54:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2jY/l5Nco+3Dostab4M8TQGdKoxThhrG5T6e33dfOMXoOjxMNsUTsq4NB6UJVXULuBKV3 X-Received: by 2002:a17:906:e103:: with SMTP id gj3mr7901242ejb.153.1599234841728; Fri, 04 Sep 2020 08:54:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599234841; cv=none; d=google.com; s=arc-20160816; b=IESZMsMpjXFdPJJT44gVSNUAbpBa1qO0cRZTAKZ8fV0LOiRp25ot/M2Ww1ybJ4pzVO sKfnQcxNY6hcA6kSgsqODgdmjPjLGz/nTk3OeFT9NkffuAdfdm1SlqCYP7sA6leUcua0 Nevv8umvYbCXjbL9TsaPVC5rxWa73HuI03rctDd0g4XuJXnCCeyHbPEf4I7a64/sb8/a Fy/Il0mz/LgYLCf6nfTkC+9A2VTZKHsNc7va2r1BEVftxR4pTiAcH2ToQqwBrjc9PcGz BjEW0QRxarmhGMLVeK7zyf/8K35Pk/gZBST5JFGwN9XQYLS32MuJDB0FPN7lkA3RTkMB uC/w== 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; bh=1H1E95duj8BRXlBVXWZDG8vDYkEWie/qTVOLM2ZvBPU=; b=bFJYmWMJaF7HkSyGdMMr+5aaZqJGkwPs0UxzDL1ad+tAnU9TIvPS5i7Wy6h0c133vz VOWxmnDRhzf23gdn78ARtyT20Nw3/+FYvuN3hVDjKDQCmce/BMk/9O12se0h5y3dR+nb npp3NrhflnR69Nh0pRkx1ZTsakVdGlCYGq3ESKxx3kjP5GON8Y6PN1DqaMKZqakzwkKb 8p37/kLxyiZLXXM2o43ESqTgYhzILZELMx01zbrPqYeFgywmT/caFfU1tXWOuD64yDic MlaGQqfs+ALSJRHXloiDDFD2oAwBt7arccxOoBs8/5GBjYWLzAxru+VAwaEMJCU6gaM/ 7Jkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y22si4542802edm.265.2020.09.04.08.53.38; Fri, 04 Sep 2020 08:54:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726361AbgIDPxG (ORCPT + 99 others); Fri, 4 Sep 2020 11:53:06 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:59767 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726063AbgIDPxE (ORCPT ); Fri, 4 Sep 2020 11:53:04 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-474-phUf1-h1O-qRNfE9OnVoiA-1; Fri, 04 Sep 2020 11:53:02 -0400 X-MC-Unique: phUf1-h1O-qRNfE9OnVoiA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F280F640C6; Fri, 4 Sep 2020 15:52:58 +0000 (UTC) Received: from krava (ovpn-112-34.ams2.redhat.com [10.36.112.34]) by smtp.corp.redhat.com (Postfix) with SMTP id 247A75DA81; Fri, 4 Sep 2020 15:52:52 +0000 (UTC) Date: Fri, 4 Sep 2020 17:52:51 +0200 From: Jiri Olsa To: Leo Yan Cc: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Namhyung Kim , Adrian Hunter , Andi Kleen , Ian Rogers , Nick Desaulniers , "Naveen N. Rao" , Kemeng Shi , James Clark , Wei Li , Al Grant , Will Deacon , Mathieu Poirier , Mike Leach , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 02/14] perf mem: Introduce weak function perf_mem_events__ptr() Message-ID: <20200904155251.GC939481@krava> References: <20200901083815.13755-1-leo.yan@linaro.org> <20200901083815.13755-3-leo.yan@linaro.org> <20200903135054.GD713364@krava> <20200904003447.GB5979@leoy-ThinkPad-X240s> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200904003447.GB5979@leoy-ThinkPad-X240s> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 04, 2020 at 08:34:47AM +0800, Leo Yan wrote: > Hi Jiri, > > On Thu, Sep 03, 2020 at 03:50:54PM +0200, Jiri Olsa wrote: > > On Tue, Sep 01, 2020 at 09:38:03AM +0100, Leo Yan wrote: > > > > SNIP > > > > > @@ -2941,30 +2942,38 @@ static int perf_c2c__record(int argc, const char **argv) > > > rec_argv[i++] = "record"; > > > > > > if (!event_set) { > > > - perf_mem_events[PERF_MEM_EVENTS__LOAD].record = true; > > > - perf_mem_events[PERF_MEM_EVENTS__STORE].record = true; > > > + e = perf_mem_events__ptr(PERF_MEM_EVENTS__LOAD); > > > + e->record = true; > > > + > > > + e = perf_mem_events__ptr(PERF_MEM_EVENTS__STORE); > > > + e->record = true; > > > } > > > > > > - if (perf_mem_events[PERF_MEM_EVENTS__LOAD].record) > > > + e = perf_mem_events__ptr(PERF_MEM_EVENTS__LOAD); > > > + if (e->record) > > > rec_argv[i++] = "-W"; > > > > > > rec_argv[i++] = "-d"; > > > rec_argv[i++] = "--phys-data"; > > > rec_argv[i++] = "--sample-cpu"; > > > > > > - for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) { > > > - if (!perf_mem_events[j].record) > > > + j = 0; > > > + while ((e = perf_mem_events__ptr(j)) != NULL) { > > > + if (!e->record) { > > > > you could keep the above 'for loop' in here, it seems better > > than taking care of j++ > > Actually in patch v1 I did this way :) I followed James' suggestion to > encapsulate PERF_MEM_EVENTS__MAX into perf_mem_events__ptr(), thus > builtin-mem.c and buildin-c2c.c are not necessary to use > PERF_MEM_EVENTS__MAX in the loop and only needs to detect if the > pointer is NULL or not when return from perf_mem_events__ptr(). ah because u added that load_store event > > How about change as below? > > for (j = 0; (e = perf_mem_events__ptr(j)) != NULL; j++) { > [...] will this work? e will be NULL for first iteration no? there are still other for loops with PERF_MEM_EVENTS__MAX used in the patch.. you overload the perf_mem_events access for arm, and add missing load_store NULL item to generic version, so there's always PERF_MEM_EVENTS__MAX items in the array can we just use the current for loop and check for e->tag != NULL or any other field thanks, jirka