Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3469055pxu; Tue, 15 Dec 2020 07:44:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGSAuYBMwBQdhm+S1i33Eh2NOwV7AeBaZ5GMk7GpsmotR847sDiek1Cw4FeLlhoA4I2gnh X-Received: by 2002:a17:907:9d0:: with SMTP id bx16mr28532498ejc.426.1608047088278; Tue, 15 Dec 2020 07:44:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608047088; cv=none; d=google.com; s=arc-20160816; b=Z8x4P8Ap7xNgKrm6zT6gS7+USqqre0Cm4MVfR+LTz7+bzZgo8Knyb9dADvZ4CWExVW cF8YVIE9Gux/gJrxFN2oulgswAEEUxOeM7k29koC6eOKejijAgSJqO1sS2wWhchX8ZnH ah6Ga/gqNRtIEibQPWMAUfIiWf4grtLR8XVhFhGxEo6/b7qI4MR6NoZPw2yUDsWE+7LN Nwgwhp7XYY67QHB59O+YcmKTgkADttdn3RX6OZamZ9/NGHove5Ze8rgCwAzC98NUwzpv PlWBqNQ4KHePDg0lDrz68JdfeKjt8Nrpf4dj8+K9O/sLbfKBYYpwZJ1D/0lBohulZ8Rr E5TQ== 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:dkim-signature:date; bh=9odu9mpk2mtLUOSE+fo7LpKLNCieQIAS0wZdOBjwIyk=; b=I3VMdW0f02VKYf3Nqh51VY0C3B46R/hubcft5rinm4IPJ0U6rlAlrs2FeuctUgqG8D 8+olIzRF2Y9sMbMcjrotV+8cLrLVN6ZC2x+uSZJ2zsFMzwueXSdiF15l2k9Yq89ifgiA vWjBxBD6S+iQmWOkmMIoRh+brqTzrn7yMRBCWsaxHbNTqCfasf88zLfeRB4m7cokbpEO axWQ0wP7WpNjQNCHkgipeyoBFKLeenVAwBObFu9B+wb7KE5UC1Xf9HE3x3X6LTk+f1gx Z2xudpj8jN0RLgctHoE6xCdyEoHgoJStLm/3NwOZgpqj2oPDUxc6Bjgmz/nfXFps6b6H VQug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fQEnLIpw; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id en21si1185835ejc.393.2020.12.15.07.44.24; Tue, 15 Dec 2020 07:44:48 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fQEnLIpw; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730267AbgLOPls (ORCPT + 99 others); Tue, 15 Dec 2020 10:41:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:37888 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730153AbgLOPlq (ORCPT ); Tue, 15 Dec 2020 10:41:46 -0500 Date: Tue, 15 Dec 2020 12:41:18 -0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608046865; bh=3EvisKc98OBFF9zv6xZ4nmuhbaRRngq2LpQsymSenps=; h=From:To:Cc:Subject:References:In-Reply-To:From; b=fQEnLIpwKjgTgBeCwCu1/RAH8YmESZpO4kz/4Ctm7DK1n0mXbr4QtcaTWg3MDXkrI 2mIMpgcmcy4IR3+0yl6HwjkZn2yplgZP0bg2LXKeXIpeNKkYxb6KIHQGh8l5Xog9VM t3p2s6f97kfZ9028TOe40qWI4tsZlpGcFSvVSqeNvt7iOBkrMDF+FZtTEWWsVOb51r uHPClaxtd2mT+H8sN9iwXJCA+4/akAxu5Fe4G7EX86qQAD6Jo5l9TA9CostsGCFT57 ECRS6299RiwxydY1KmsQlUuREYPq4eKrf1XawkS75SvUzNKmqpg+Ma5gBMPpddvYUz BXcP4yXzVcazw== From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Ian Rogers , Stephane Eranian , Alexei Budankov Subject: Re: [PATCH 3/8] perf tools: Add config set interface Message-ID: <20201215154118.GD258566@kernel.org> References: <20201212104358.412065-1-jolsa@kernel.org> <20201212104358.412065-4-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201212104358.412065-4-jolsa@kernel.org> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Sat, Dec 12, 2020 at 11:43:53AM +0100, Jiri Olsa escreveu: > Add interface to load config set from custom file > by using perf_config_set__new_file function. > > It will be used in perf daemon command to process > custom config file. The naming may be misleading, as this is not _setting_ the perf config to be that one, but to apply a set of changes to whatever is the current configuration, right? Perhaps 'perf_config_set__load_file()' There is value in _resetting_ the config to some configuration, i.e. moving everything to the strict defaults and then loading a file that sets the configuration to a state similar to what perf does when it first starts. - Arnaldo > Signed-off-by: Jiri Olsa > --- > tools/perf/util/config.c | 28 +++++++++++++++++++++++----- > tools/perf/util/config.h | 3 +++ > 2 files changed, 26 insertions(+), 5 deletions(-) > > diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c > index 6969f82843ee..dc3f03f8bbf5 100644 > --- a/tools/perf/util/config.c > +++ b/tools/perf/util/config.c > @@ -738,6 +738,18 @@ struct perf_config_set *perf_config_set__new(void) > return set; > } > > +struct perf_config_set *perf_config_set__new_file(const char *file) > +{ > + struct perf_config_set *set = zalloc(sizeof(*set)); > + > + if (set) { > + INIT_LIST_HEAD(&set->sections); > + perf_config_from_file(collect_config, file, set); > + } > + > + return set; > +} > + > static int perf_config__init(void) > { > if (config_set == NULL) > @@ -746,17 +758,15 @@ static int perf_config__init(void) > return config_set == NULL; > } > > -int perf_config(config_fn_t fn, void *data) > +int perf_config_set(struct perf_config_set *set, > + config_fn_t fn, void *data) > { > int ret = 0; > char key[BUFSIZ]; > struct perf_config_section *section; > struct perf_config_item *item; > > - if (config_set == NULL && perf_config__init()) > - return -1; > - > - perf_config_set__for_each_entry(config_set, section, item) { > + perf_config_set__for_each_entry(set, section, item) { > char *value = item->value; > > if (value) { > @@ -778,6 +788,14 @@ int perf_config(config_fn_t fn, void *data) > return ret; > } > > +int perf_config(config_fn_t fn, void *data) > +{ > + if (config_set == NULL && perf_config__init()) > + return -1; > + > + return perf_config_set(config_set, fn, data); > +} > + > void perf_config__exit(void) > { > perf_config_set__delete(config_set); > diff --git a/tools/perf/util/config.h b/tools/perf/util/config.h > index 8c881e3a3ec3..f58b457e7e5f 100644 > --- a/tools/perf/util/config.h > +++ b/tools/perf/util/config.h > @@ -30,6 +30,8 @@ typedef int (*config_fn_t)(const char *, const char *, void *); > int perf_config_from_file(config_fn_t fn, const char *filename, void *data); > int perf_default_config(const char *, const char *, void *); > int perf_config(config_fn_t fn, void *); > +int perf_config_set(struct perf_config_set *set, > + config_fn_t fn, void *data); > int perf_config_int(int *dest, const char *, const char *); > int perf_config_u8(u8 *dest, const char *name, const char *value); > int perf_config_u64(u64 *dest, const char *, const char *); > @@ -38,6 +40,7 @@ int config_error_nonbool(const char *); > const char *perf_etc_perfconfig(void); > > struct perf_config_set *perf_config_set__new(void); > +struct perf_config_set *perf_config_set__new_file(const char *file); > void perf_config_set__delete(struct perf_config_set *set); > int perf_config_set__collect(struct perf_config_set *set, const char *file_name, > const char *var, const char *value); > -- > 2.26.2 > -- - Arnaldo