Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp21963pxb; Wed, 30 Mar 2022 21:45:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzY/wHa+BS/w6gHX7fEz9Ua1hHlsbkLJR2bBW4bKcXDvi+mPs2956+rCFZ8cNkspQfxoaqL X-Received: by 2002:a63:d316:0:b0:380:85b6:d595 with SMTP id b22-20020a63d316000000b0038085b6d595mr9110890pgg.0.1648701955318; Wed, 30 Mar 2022 21:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648701955; cv=none; d=google.com; s=arc-20160816; b=AzGP/cj4PDHCRh6cwf6Z2MGHKX1TlJtBR8wvsRXbv6XqQ7DhxN/kPKmqDNHCkhSwmn 7XWYoXsqWhoySeAuufsLSbNqcexdhU2gKVY4ZI/N011DdnPxFRPHieGmghNv1TU9M/KS O2ovMqtt0PU5kU/AyIYOqFORYVbuvm7dQVaCvisvy4IQHLgqURCOoyVZHzlCURCiSoeS rg4m2pIZ2+PqNKRap6VMedanHpPvySuIu0HieEyi5/JufKv3o48KJy492/39soFpZlaJ k/YJCMqJLs8AtZ2MdE3+JktUTasMSr13b+IUwhI0yhIJYQSdhSTiTTlE28uvlpTa+QGs +2Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DOMbg6u/qsHzVPLO4CX/iXdj5nd/37ZO9EctcnuGwKw=; b=eh0hypKSlaJLzUe0OzJH+W+hSpCM32MIXm+mt717G0505eyeq0KmyGxgMMmzCbrbCd qhiAO6aXl0KI/0+uI+u+OuCVnVSCt2HxWFFXiZ2dt5nLiGMmtSsrTxxqGoLYR+y+TCmR FqAzYxXiWybo0q0+C022Nc3RcHQeABFTwdDFnUSBgTIzuCt4ED2RwBtozlLQS9KIvPgN FTY5w3geOJo4TC+IGZQ3aPqcr20GhmioIBSaBGtCawton10czWoGdOd7i8IljL94+02X cwOhFYP0yfewaXbqCxhr9mB0YnoBSFXdQ0zD5Emyw5WTyvkc+nrDOSPNywj1VPZRzp7b AVcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mgUtXIWG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d12-20020a17090a498c00b001bd14e01fa0si2019322pjh.142.2022.03.30.21.45.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 21:45:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mgUtXIWG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2769A1EDA0B; Wed, 30 Mar 2022 20:27:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346388AbiC3NwP (ORCPT + 99 others); Wed, 30 Mar 2022 09:52:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346430AbiC3NwL (ORCPT ); Wed, 30 Mar 2022 09:52:11 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4148010BBF4; Wed, 30 Mar 2022 06:50:26 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id lr4so33225506ejb.11; Wed, 30 Mar 2022 06:50:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=DOMbg6u/qsHzVPLO4CX/iXdj5nd/37ZO9EctcnuGwKw=; b=mgUtXIWGGCaJy+j7qeKmMJvhlKiYfD7tkdrZafb1qe35U/pS4S3unocriKPhGS4+hT 3/3fowb713GwLMB8qjnLhtwV+oxagEuEVzWXWTeSm3JhgrXIfYJKKpJLES1O/kImmRYc D+yzgJzo3tWe7Alx4rBwseOsu9JiC+7gt8VKckavLRQ5JZFNT4QpvkVjjML0F6pWDEsk XG2q2YU25fJyCfooYcguyXW+mBkBghaMA10jE+TPazO7vz4cfuusJ4lBdl3bdvO8LME9 pnYAgSdQO0Q+RTuHNggACqMoHvW5seB3Q47QHpVFoZyzApHvDvPFeFeIDB85FTNyHqgu S7cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=DOMbg6u/qsHzVPLO4CX/iXdj5nd/37ZO9EctcnuGwKw=; b=CraLNW4tZhPNMlvC4q1Dk+evNvS+00y74RBH+gJbhAv4gPJcRhPKu0m7r2pHud7wNx 9dz691tECxxwJ1OsTen9LVxzv3PlBsw57s+n2nKtEyJ60M012C69EmGbIeRDBxXHnaUm 1isK65oqSNAAbh9vW6dRYfuLBZPXumndNi3e/0UAJ31maQFNnR9n7L+vnBF8TYoenEJc A7eeny68XjIkOaooOO/szX2oGaBDUjKOv85Z7ll6sSc9Oi+Bq1rFtEgTBchepHiVVjbl FaINjTnV7PhaoO9nrAe/Nkdl5qp7AAR291orrjBs/DLTrSple/8DPLW+YMlp0B+OK1/c kSGA== X-Gm-Message-State: AOAM532/Zl0sosRixmo7Lw5Vpkc4XeDzoscjMVkPdy+yzC33AaPCrYXV mhTfjH0jHPXpZfV2C6SLGrs= X-Received: by 2002:a17:906:27d1:b0:6df:ccdd:1a8d with SMTP id k17-20020a17090627d100b006dfccdd1a8dmr41388826ejc.751.1648648224453; Wed, 30 Mar 2022 06:50:24 -0700 (PDT) Received: from krava ([193.85.244.190]) by smtp.gmail.com with ESMTPSA id 22-20020a17090600d600b006dfbc46efabsm8258773eji.126.2022.03.30.06.50.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 06:50:24 -0700 (PDT) Date: Wed, 30 Mar 2022 15:50:22 +0200 From: Jiri Olsa To: Shunsuke Nakamura Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: Re: [RFC PATCH v2 3/7] libperf: Add perf_evsel__{refresh, period}() functions Message-ID: References: <20220325043829.224045-1-nakamura.shun@fujitsu.com> <20220325043829.224045-4-nakamura.shun@fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220325043829.224045-4-nakamura.shun@fujitsu.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 25, 2022 at 01:38:25PM +0900, Shunsuke Nakamura wrote: SNIP > +int perf_evsel__refresh_cpu(struct perf_evsel *evsel, int refresh, int cpu_map_idx) > +{ > + return perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_REFRESH, refresh, cpu_map_idx); > +} > + > +int perf_evsel__refresh(struct perf_evsel *evsel, int refresh) > +{ > + int i; > + int err = 0; > + > + for (i = 0; i < xyarray__max_x(evsel->fd) && !err; i++) > + err = perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_REFRESH, refresh, i); > + return err; > +} > + > +int perf_evsel__period_cpu(struct perf_evsel *evsel, __u64 period, int cpu_map_idx) > +{ > + struct perf_event_attr *attr; > + int err = 0; > + > + attr = perf_evsel__attr(evsel); > + if (!attr) > + return -EINVAL; > + > + err = perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_PERIOD, > + (unsigned long)&period, cpu_map_idx); > + if (err) > + return err; > + > + attr->sample_period = period; what's the point in updating attr? this will be used after event is created right? > + > + return err; > +} > + > +int perf_evsel__period(struct perf_evsel *evsel, __u64 period) > +{ > + struct perf_event_attr *attr; > + int i; > + int err = 0; > + > + attr = perf_evsel__attr(evsel); > + if (!attr) > + return -EINVAL; > + > + for (i = 0; i < xyarray__max_x(evsel->fd); i++) { > + err = perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_PERIOD, > + (unsigned long)&period, i); > + if (err) > + return err; > + } > + > + attr->sample_period = period; same as above thanks, jirka > + > return err; > } > SNIP