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 4BF8CC43334 for ; Mon, 20 Jun 2022 17:25:51 +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:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IwvGk+tkFhN8/UZs0rSCALOdbbxT9NucLsKEOcD+q/M=; b=G42HrP6GhJ0/o+ kBDXl1KWo7zTLZqLQIEX51Vbv0tu5tWONbxSYC0B4770ZCJD4QX1PKpcEIVJxZqfkUUtp3ZPiMAGD xOyEjr7G4FQpiNTkM8Br1kzSDIiM/E+foQEzfOxMoTLjn4W5BPjpTSmfScPy+omGXw89kind+FfGw mXRVeMjgNFL88xd5F3MQ/tUQNf96ZwAyP0U+bkXvMZmyXzsy7ST8LmXaMtzdnnqTdYehH9R9I7CxV fYyRLsEh2ibgy4w3sgBLkwhLoTnungfDcwi+Hrs2LN7QqB2C6l8i9jHkB3frxB+2Py+fSbTEZ/tRa WJMTCtdLjxFDO/fh3Daw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3L8u-001Zse-8Q; Mon, 20 Jun 2022 17:24:52 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3L8r-001ZrE-65 for linux-arm-kernel@lists.infradead.org; Mon, 20 Jun 2022 17:24:51 +0000 Received: by mail-pf1-x42c.google.com with SMTP id p14so5135181pfh.6 for ; Mon, 20 Jun 2022 10:24:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=378B6AarfCsUnZPRyvz8/gQguvAL2Hh1HBjIQaMIiAE=; b=yV0Kc6wRhdE/cj5b5juTpHMlvmkY8Nvv+/l9sm8yEizaKk7GOIW673f81bJTQDQJzF sdFFYLCBZZN/6eqKe2s7OJcEfTQ49zEEj4US/ZyyhuBTmznILrJvIb5Q0NEWgfiwFu1i emjfiXNBEr9IR3K9cLlhV9uMPT9E0toElufcP4KbeedtAA1y9G3kjPYO62nlEZRsD54g xfl1i3Up3BEwZWRbIhxWCFvBlC9J5e93ez35ddoCSmZlrRaSd41R3pH4ZOcphJK/inyO KcfUMcGTV0Ldf0ra5qFSxFaPkEOH7y/iOSc74OWkUY+U2Dfd2KbvsRrrml8ehsGdEQhw yoYA== 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=378B6AarfCsUnZPRyvz8/gQguvAL2Hh1HBjIQaMIiAE=; b=COojE9uzsy8cEGe7dBsyttPunG7pQZRt96+ZRSBCxW2jDe9eKo7jh2vFoQs7LHQb4n Jqe8Qw0IL4kYIQ2tBB6WRKC2s/Ui/nLx9Es8A4j5o78cc4P6HYxkCpr8gXRgavUHFOsK dYeuFnrVxHP1ZeVF4jGkVP0GUOPt3Vs57mdKgLYWUCFRsVdfa2P0lpVYAG37fHQhm18d 6pMHf9pGyrmCea7v3cpLdOQAfc2UgZz5byngnkYv5durCclz6XGWkW+GsNhWTHgdZlO8 euFPrLua+UHMmvJLFgwWKnMbWjUazwwBNRKndKncK7ynlq3QqeioZZ8yEupP9xAUZ9eJ I0Og== X-Gm-Message-State: AJIora9RhxTS/xHjos/d7Y71gZdAIl7b73f92ypGDFNZntdlKTHWCrNv ysnX+dC/ei8ND32zu22GSxMkgA== X-Google-Smtp-Source: AGRyM1tv9LoQREr/ywAotQ7isz2K+LlXji9NnQRojuO9bRW+atXaJ05eleyg0SdaNnDEaf5XknCMeA== X-Received: by 2002:a05:6a00:164c:b0:50a:472a:6b0a with SMTP id m12-20020a056a00164c00b0050a472a6b0amr25843548pfc.77.1655745883108; Mon, 20 Jun 2022 10:24:43 -0700 (PDT) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id o1-20020a629a01000000b0051bada81bc7sm9358861pfe.161.2022.06.20.10.24.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 10:24:41 -0700 (PDT) Date: Mon, 20 Jun 2022 11:24:38 -0600 From: Mathieu Poirier To: Jiapeng Chong Cc: john.garry@huawei.com, will@kernel.org, leo.yan@linaro.org, suzuki.poulose@arm.com, mike.leach@linaro.org, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Abaci Robot , james.clark@arm.com Subject: Re: [PATCH] perf cs-etm: Use swap() instead of open coding it Message-ID: <20220620172438.GB1458883@p14s> References: <20220506091718.82858-1-jiapeng.chong@linux.alibaba.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220506091718.82858-1-jiapeng.chong@linux.alibaba.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220620_102449_271110_52BD8843 X-CRM114-Status: GOOD ( 19.74 ) 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 [Adding James] Hi Jiapeng, On Fri, May 06, 2022 at 05:17:18PM +0800, Jiapeng Chong wrote: > Clean the following coccicheck warning: > > ./tools/perf/util/cs-etm.c:418:34-35: WARNING opportunity for swap(). > > Reported-by: Abaci Robot > Signed-off-by: Jiapeng Chong > --- > tools/perf/util/cs-etm.c | 9 ++------- > 1 file changed, 2 insertions(+), 7 deletions(-) > > diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c > index 8b95fb3c4d7b..0cb555cc766f 100644 > --- a/tools/perf/util/cs-etm.c > +++ b/tools/perf/util/cs-etm.c > @@ -406,18 +406,13 @@ struct cs_etm_packet_queue > static void cs_etm__packet_swap(struct cs_etm_auxtrace *etm, > struct cs_etm_traceid_queue *tidq) > { > - struct cs_etm_packet *tmp; > - > if (etm->synth_opts.branches || etm->synth_opts.last_branch || > - etm->synth_opts.instructions) { > + etm->synth_opts.instructions) > /* > * Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for > * the next incoming packet. > */ > - tmp = tidq->packet; > - tidq->packet = tidq->prev_packet; > - tidq->prev_packet = tmp; Those 3 lines have burned a lot of eyes... As far as I can remember the idea is simply to make sure that after that point, ->prev_packet is now set to ->packet in preparation for the next iteration. There is no point in setting ->packet to ->prev_packet. As such the following would work just fine: tidq->prev_packet = tidq->packet; ... but I will let James and Leo have a final say on that. > - } > + swap(tidq->packet, tidq->prev_packet); If we absolutely need to keep swapping the packets please add the header file where swap() is found. Thanks, Mathieu > } > > static void cs_etm__packet_dump(const char *pkt_string) > -- > 2.20.1.7.g153144c > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel