Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C818C4338F for ; Fri, 13 Aug 2021 09:30:24 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A7D260FC0 for ; Fri, 13 Aug 2021 09:30:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9A7D260FC0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=csgroup.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GmJFB0NRvz3cWd for ; Fri, 13 Aug 2021 19:30:22 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=csgroup.eu (client-ip=93.17.235.10; helo=pegase2.c-s.fr; envelope-from=christophe.leroy@csgroup.eu; receiver=) Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4GmJDj0zNwz302V for ; Fri, 13 Aug 2021 19:29:55 +1000 (AEST) Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4GmJDd04Qnz9sX0; Fri, 13 Aug 2021 11:29:53 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id m097KQtPVGvi; Fri, 13 Aug 2021 11:29:52 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4GmJDc6DKcz9sWy; Fri, 13 Aug 2021 11:29:52 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id B78778B82E; Fri, 13 Aug 2021 11:29:52 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id il4_awmHn-5H; Fri, 13 Aug 2021 11:29:52 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 546988B826; Fri, 13 Aug 2021 11:29:52 +0200 (CEST) Subject: Re: [PATCH v2 2/2] powerpc/perf: Return regs->nip as instruction pointer value when SIAR is 0 To: Kajol Jain , mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org References: <20210813082450.429320-1-kjain@linux.ibm.com> <20210813082450.429320-2-kjain@linux.ibm.com> From: Christophe Leroy Message-ID: <95fc0f78-51d0-82f6-c9d6-de101fec445c@csgroup.eu> Date: Fri, 13 Aug 2021 11:29:33 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210813082450.429320-2-kjain@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: atrajeev@linux.vnet.ibm.com, maddy@linux.ibm.com, rnsastry@linux.ibm.com Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Le 13/08/2021 à 10:24, Kajol Jain a écrit : > Incase of random sampling, there can be scenarios where SIAR is not > latching sample address and results in 0 value. Since current code > directly returning the siar value, we could see multiple instruction > pointer values as 0 in perf report. > Patch resolves this issue by adding a ternary condition to return > regs->nip incase SIAR is 0. > > Fixes: 75382aa72f06 ("powerpc/perf: Move code to select SIAR or pt_regs > into perf_read_regs") > Signed-off-by: Kajol Jain > --- > arch/powerpc/perf/core-book3s.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c > index 1b464aad29c4..aeecaaf6810f 100644 > --- a/arch/powerpc/perf/core-book3s.c > +++ b/arch/powerpc/perf/core-book3s.c > @@ -2260,7 +2260,7 @@ unsigned long perf_instruction_pointer(struct pt_regs *regs) > else > return regs->nip; > } else if (use_siar && siar_valid(regs)) > - return siar + perf_ip_adjust(regs); > + return siar ? siar + perf_ip_adjust(regs) : regs->nip; Why bother about returning SIAR at all if regs->nip is ok ? Why not just return regs->nip all the time ? > else if (use_siar) > return 0; // no valid instruction pointer > else >