Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5848479rwr; Mon, 24 Apr 2023 09:46:16 -0700 (PDT) X-Google-Smtp-Source: AKy350Z/FFsxXvPMBseazRl0+tAd6d8iKCsZGoeQ+bsM1Mnss73Vfz3DwRV81YCI2xRvAXP4oC/i X-Received: by 2002:a17:90a:b798:b0:240:e532:d868 with SMTP id m24-20020a17090ab79800b00240e532d868mr14564762pjr.43.1682354776327; Mon, 24 Apr 2023 09:46:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682354776; cv=none; d=google.com; s=arc-20160816; b=kXlBYYA3jYggt5EwmLlwBQNjaFHBEYpXrAwGGGToFEOxQaWnuPJfuCAcIMSZUkJBs1 t1WYUt0cW5Z/6YGpR8kR5i3WuYjZw7bzc2Q6v7Eso/KjXmauae1WFaZbbsXCIDMKuK2K Uy/sE7Ipp5tPd/3Brs5dhs70uVhCxvX/bxmWLqY4gbH5ivoot5zw/YJ4dbyxpjCvN4nH iOoqxNgVVzuXw6oLqtYWBb6Ye3WRp4mXN5rw3+FxxN8v6vaeal6DWA77UuBnlTBqUvej lUQKHwHUEUSWRs2Yb5Tqs3hKlqxqy6i1rgQ3eXWQrKn3m3CbvsMscnfagxwlE0eZzTNt C50w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=vQEJ51Q5FAWiFOFfatTn5c/2oOtxA/MCb0ffeNO7+vI=; b=OZStaKyGQGxYgWRVe3MMhfhcwvH6EA22OS3QBhrWNCHu3c9bPa7t/UzYqxlhol5Xbr LZNUGm3t1rnyKyE3MlWImMvNgp3RpNR/P8Rfk94mpgCwOUVB1KGU9IFwVVoEyJgxhleB uN8S86byqVJr5i69g19+1TOAFnLsA6FzoAolLywJ+ZwHc6EXB7NXVv07dfLhom7Oh3l1 PLQfm9AWwtP3VhuHR0z8n61/3O3aM0URRO18gbOpJN3cbPJY2hlHq238H1UnyTAYSwp6 fTMQg+cQaYHUJjRYkuHhobONcHGoJR3ulidoOVNVAqAZOUenCFImoxBe5CGPPrb5mxJ/ BizQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mu10-20020a17090b388a00b002470f78a168si15613677pjb.104.2023.04.24.09.46.02; Mon, 24 Apr 2023 09:46:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231939AbjDXQnd (ORCPT + 99 others); Mon, 24 Apr 2023 12:43:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230319AbjDXQnd (ORCPT ); Mon, 24 Apr 2023 12:43:33 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A5F3944B1; Mon, 24 Apr 2023 09:43:31 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1D72F4B3; Mon, 24 Apr 2023 09:44:15 -0700 (PDT) Received: from [192.168.1.3] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ABED23F5A1; Mon, 24 Apr 2023 09:43:28 -0700 (PDT) Message-ID: Date: Mon, 24 Apr 2023 17:43:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH 2/7] perf tools: Add util function for overriding user set config values Content-Language: en-US To: Adrian Hunter Cc: denik@google.com, Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, coresight@lists.linaro.org, shy828301@gmail.com References: <20230424134748.228137-1-james.clark@arm.com> <20230424134748.228137-3-james.clark@arm.com> From: James Clark In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 24/04/2023 16:36, Adrian Hunter wrote: > On 24/04/23 16:47, James Clark wrote: >> There is some duplicated code to only override config values if they >> haven't already been set by the user so make a util function for this. >> >> Signed-off-by: James Clark > > One minor comment, nevertheless: > > Acked-by: Adrian Hunter > Thanks for the review >> --- >> tools/perf/arch/arm64/util/arm-spe.c | 26 ++----------------------- >> tools/perf/arch/x86/util/intel-pt.c | 22 ++------------------- >> tools/perf/util/evsel.c | 29 ++++++++++++++++++++++++++++ >> tools/perf/util/evsel.h | 3 +++ >> 4 files changed, 36 insertions(+), 44 deletions(-) >> [...] >> } >> } >> + >> +/* >> + * Set @config_name to @val as long as the user hasn't already set or cleared it >> + * by passing a config term on the command line. >> + * >> + * @val is the value to put into the bits specified by @config_name rather than >> + * the bit pattern. It is shifted into position by this function, so to set >> + * something to true, pass 1 for val rather than a pre shifted value. >> + */ >> +#define field_prep(_mask, _val) (((_val) << (ffsll(_mask) - 1)) & (_mask)) > > I notice there is already tools/include/linux/bitfield.h > so may FIELD_PREP from there could be used? I tried that first, but it seems like quite a lot of effort went into it to make it work on const only values so it doesn't work here. There is this [1] change to make a non const one but it doesn't look like it went anywhere: [1]: https://patchwork.kernel.org/project/linux-omap/patch/3a54a6703879d10f08cf0275a2a69297ebd2b1d4.1637592133.git.geert+renesas@glider.be/#24610749