Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1844028pxb; Fri, 22 Oct 2021 08:41:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7oz/SPJisUdgXSRMg0Ew6egLM6kkbm/Hpjzk2nLh9cI2ZoBs3bL/lPqeCFQ6yCWnjEtMT X-Received: by 2002:a17:90b:1b49:: with SMTP id nv9mr753976pjb.134.1634917315144; Fri, 22 Oct 2021 08:41:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634917315; cv=none; d=google.com; s=arc-20160816; b=B7VtcHj0//CvcHf/R1aSlJL/IUQCz1wq31cHe5RLMilDTbIVhns0lg+nVDQpLZ08lt VzqTb26RpfbSA1Z0tCKv0NhPVrQbqF0dSEJeCzUAa4hBSlFTym7Pt1/O4ZpEP/ySa3QJ IbMNahEyVtEksQAyBFPzzSl2qu5Insw6e/EPp5o6RfiRALYRL7oxY8iPUw0qSZ9BBvwl xlCf2D9dmNdOL9DbsdxPlGguM1K7dTCZ6Hwk5NjE1MD1qySZp6NnmT04A1PS7ZXn9pHU 9YM+2LbwBN2fzIt5FIL9xP6Avr8btwevwPbiiQkntJAQuHcKTpotywmwLnnlgKi+MU9u mCIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:cc:references :to:from:subject; bh=9eUy5N2BYi+EqM0kV0JhDweZkvY2TzxPKjkJ00NX3J0=; b=iwheB88FiWfGDsGAfGZgoaqKsVZG49pggpWR5dkzJhiSXmclMl8nsL6fFMddWu6nkg FeCRBc7vvv0ZuKFbrzndD0QUWEEMWGkB441loNee36O77h5drb3bMaZV/aWddohPoSnP ExReEfDWIRvGv95ShW3mgrGSasdH0lH2dgjl7BXKDUZkvlXCGzEVjOKvYwGdF+mlwEdr jEnc5jt5uEMyvWcyavxmJpsZoAAjTm94jc8iWf+tleInwxbNlbiFYDn+rPqj45pSZsmp b4IwXgfE2O6U9rtkE61ZTFM+VJTUi21ADlF4e2BHInh0eCkXc441FaJ1mBtFCYAOoVPi 5JTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q8si14081231pfu.132.2021.10.22.08.41.41; Fri, 22 Oct 2021 08:41:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S232576AbhJVPmt (ORCPT + 99 others); Fri, 22 Oct 2021 11:42:49 -0400 Received: from foss.arm.com ([217.140.110.172]:56094 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233222AbhJVPms (ORCPT ); Fri, 22 Oct 2021 11:42:48 -0400 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 2616D1FB; Fri, 22 Oct 2021 08:40:30 -0700 (PDT) Received: from [10.57.27.181] (unknown [10.57.27.181]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E04DE3F694; Fri, 22 Oct 2021 08:40:27 -0700 (PDT) Subject: Re: [RFCv1 4/4] perf: arm_spe: Dynamically switch PID tracing to contextidr From: James Clark To: Leo Yan References: <20211021134530.206216-1-leo.yan@linaro.org> <20211021134530.206216-5-leo.yan@linaro.org> <854fb1a2-e5f1-f237-685f-8ddb0557c98b@arm.com> Cc: Catalin Marinas , Will Deacon , Mark Rutland , Kees Cook , Ard Biesheuvel , Sami Tolvanen , Nicholas Piggin , James Morse , Marc Zyngier , Joey Gouly , Peter Collingbourne , Vincenzo Frascino , "Peter Zijlstra (Intel)" , Stephane Eranian , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Message-ID: Date: Fri, 22 Oct 2021 16:40:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <854fb1a2-e5f1-f237-685f-8ddb0557c98b@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22/10/2021 16:36, James Clark wrote: > > > On 21/10/2021 14:45, Leo Yan wrote: >> Now Arm64 provides API for enabling and disable PID tracing, Arm SPE >> driver invokes these functions to dynamically enable it during >> profiling when the program runs in root PID name space, and disable PID >> tracing when the perf event is stopped. >> >> Device drivers should not depend on CONFIG_PID_IN_CONTEXTIDR for PID >> tracing, so this patch uses the consistent condition for setting bit >> EL1_CX for PMSCR. > > Hi Leo, > > I've been testing this change, but I'm seeing something strange. Not sure > if it's a problem on my side or not yet. With this command: > > sudo ./perf record -vvv -e arm_spe//u -- taskset --cpu-list 1 bash -c ls > > I'm only seeing 0 values for context: > > sudo ./perf report -D | grep CONTEXT > > . 00038dce: 65 00 00 00 00 CONTEXT 0x0 el2 > . 00038e0e: 65 00 00 00 00 CONTEXT 0x0 el2 > > I added a printk to the function, and I see it print non zero values, although > there are some zero ones mixed in there too: > > diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h > index 0c1669db19a1..8f0fb43a5fac 100644 > --- a/arch/arm64/include/asm/mmu_context.h > +++ b/arch/arm64/include/asm/mmu_context.h > @@ -33,7 +33,8 @@ static inline void contextidr_thread_switch(struct task_struct *next) > if (!static_branch_unlikely(&contextidr_in_use)) > return; > > - write_sysreg(task_pid_nr(next), contextidr_el1); > + printk("Set %d\n", task_pid_nr(next)); > + write_sysreg(task_pid_nr(next), contextidr_el2); Ignore this second line change, that doesn't even compile. It's just the printk that I added.