From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D5DB2C7618E for ; Mon, 24 Apr 2023 16:44:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ukqzfo8I7wBn7s9ZWolEDL/VnlLByQ4bqFuRiTMSQUE=; b=S/5ZcZbOtAXiTL plh9BV7F7H8ztd2e90AaU1YMHDjk4UYGsgQOfVODqiX5Bl+yYkzKqWMG5gkN43GRrxZJRvUwrD/Fz JgFQff57bXt1oOTtskwFABRdmV5Sz5fkx8ecKRLwESIy2HS3VCOXT8SsemsQsoFvzfcQiat1XvkYH rbMtPeXS32Bpo0I0gQNYQfbc5yNt0vkJmQ1VfTVhH/aqZicm2zdham8EFLmu1q56Ra8xVWrj5UguH I/3jh0VBupa1d1FJd+wNxf5Kc+rD9MNCW3M8fXEiA38KbMuqjH3sdVp+u/W9uNcVZqGOpJRAMyJOW TPBBjhWrTXe6uDzlQszw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pqzHv-00GpSF-2K; Mon, 24 Apr 2023 16:43:39 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pqzHt-00GpQX-0V for linux-arm-kernel@lists.infradead.org; Mon, 24 Apr 2023 16:43:39 +0000 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: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230424_094337_285311_0055C018 X-CRM114-Status: GOOD ( 21.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel