Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp343197rwb; Thu, 1 Dec 2022 03:00:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf4+38GOH43KAd2cJxRHUcr8NgOblB/OQtR6B3OJ3G1ncnvtm/2axZczLr6IVDVs+V8zNY0G X-Received: by 2002:a05:6402:4515:b0:461:cf2b:627b with SMTP id ez21-20020a056402451500b00461cf2b627bmr1937764edb.73.1669892417631; Thu, 01 Dec 2022 03:00:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669892417; cv=none; d=google.com; s=arc-20160816; b=vyEg/zj7KxXSlBvt1vhM0Ffr0IC7hwRpVVvTrLKqu4BItZ3/6VUf+hrEaEv/eux3bj NwkEwRsn7ASqxSgIIBUB5Fcj2Mu1Agk9yRtuqolrAAjZLwuLbMwlw2AaTb4U8B0nYbIt Hi6of09HDMJS/5tQ+uvHwXaQ78g8mxltt8R/4Hag61pKVfXf8mcJQGYmycPBPZT6D/zg tclqEDcR2qlfqqaL+AcCiBHk2qsSqZtn0lOxOU4NMmA6Dx4AkGvUAJdNQBUEDE6rCmfh C4qaDI1WQIcSPZdGaFbSTgQtZRfaWJ/IAUFBnsdYMndB7bce9qR2IxbmjpX69X/kZ260 Cw7g== 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=bHtQepiRroF5xmvwCcwc3dNK+GqoTFCbsMI4zmTrvQE=; b=y4EmklOFBVwatR7SbTy4Jlmm9AD3JgHBr9RaEdP5X9w6o+5hgk9NPwkVZaYWyYLP+6 hPPUGMB35ZMQ/w9Tk/O69kwP+AYEpfBj2UlnsjHeiHaZDmu40TcCx8rJx0igv8hUiQqu AoNtkt92IWC+dYUOUPjORF/1N1XrHDUgHKGEJpq+JRQP5olCyiPR/I7tKYWHJ8iksP8w 4F25o1HUQjAhZgiQw5XXRiWUVDicVpsSJSi8k+E7c2xaYD5T27sQg1RLNjPr1ufUuKMc vs5O99gYDKD+dkE2vHMrJpXAcIy3ipA0vxzgbehaVU15JEDYLPn5EDV1hE+kRItwayX/ /SNg== 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 x1-20020a05640226c100b00461c41bd7b6si4033105edd.209.2022.12.01.02.59.56; Thu, 01 Dec 2022 03:00:17 -0800 (PST) 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 S230169AbiLAKYQ (ORCPT + 82 others); Thu, 1 Dec 2022 05:24:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229619AbiLAKYO (ORCPT ); Thu, 1 Dec 2022 05:24:14 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D428E25E9D; Thu, 1 Dec 2022 02:24:12 -0800 (PST) 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 47667D6E; Thu, 1 Dec 2022 02:24:19 -0800 (PST) Received: from [10.57.7.90] (unknown [10.57.7.90]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 364F63F67D; Thu, 1 Dec 2022 02:24:11 -0800 (PST) Message-ID: Date: Thu, 1 Dec 2022 10:24:09 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH] perf/core: Reset remaining bits in perf_clear_branch_entry_bitfields() Content-Language: en-US To: Anshuman Khandual , linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-perf-users@vger.kernel.org References: <20221201055103.302019-1-anshuman.khandual@arm.com> From: James Clark In-Reply-To: <20221201055103.302019-1-anshuman.khandual@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE 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 01/12/2022 05:51, Anshuman Khandual wrote: > perf_clear_branch_entry_bitfields() resets all struct perf_branch_entry bit > fields before capturing branch records. This resets remaining bit fields > except 'new_type', which is valid only when 'type' is PERF_BR_EXTEND_ABI. > > Cc: Peter Zijlstra > Cc: Ingo Molnar > Cc: Arnaldo Carvalho de Melo > Cc: Mark Rutland > Cc: Alexander Shishkin > Cc: Jiri Olsa > Cc: Namhyung Kim > Cc: linux-perf-users@vger.kernel.org> > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Anshuman Khandual > --- > This applies on v6.1-rc6 > > 'perf_branch_entry.new_type' can remain uninitialized as explained earlier. > Also there is no PERF_BR_NEW_UNKNOWN to spare, because 'perf_branch_entry. > new_type' enumeration starts at PERF_BR_NEW_FAULT_ALGN, to save a position > for the extended branch types instead. > > include/linux/perf_event.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > index 0031f7b4d9ab..c97b5f6f77a4 100644 > --- a/include/linux/perf_event.h > +++ b/include/linux/perf_event.h > @@ -1110,8 +1110,9 @@ static inline void perf_clear_branch_entry_bitfields(struct perf_branch_entry *b > br->in_tx = 0; > br->abort = 0; > br->cycles = 0; > - br->type = 0; > + br->type = PERF_BR_UNKNOWN; > br->spec = PERF_BR_SPEC_NA; > + br->priv = PERF_BR_PRIV_UNKNOWN; > br->reserved = 0; > } I would vote for just memsetting the whole struct to 0 at this point and making it work by ensuring the cleared from and to values are only set after this function. Or do the thing where it's wrapped in a union and the 'u64 value' member is assigned 0. See union perf_mem_data_src. I don't know if this would be a breaking change, but it doesn't look like it. Currently this is a bit too fragile and the kind of bugs it will cause are almost undetectable. But as my proposal is an extra change on top of this: Reviewed-by: James Clark James >