Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp267132pxb; Wed, 3 Feb 2021 05:14:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJyu6HkF3R4MCXceKVErrremBvBOh/NzYerPKmQah7EAHltq/0wSNQ0hC986q3rZr5XNCHST X-Received: by 2002:a05:6402:b27:: with SMTP id bo7mr2816291edb.372.1612358077248; Wed, 03 Feb 2021 05:14:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612358077; cv=none; d=google.com; s=arc-20160816; b=04/ieeFA99Prd/fqNVZstXOrMABH9yukPWmSrpPEvglMFqMqDhm+jsVFxfFQxz+Obe UfODwk9qfIZeMsk8+QucOHOKTGl9BUG1ejF+mo/khe4PN3iC7FFwwa/yBE13HNiiuvC7 ENla/74QtbQXRL6JKGC8UIQea2PY8FKaW6OozaeRwwBKoAQ5OwY7mU07XIY4bYVhuGM5 /q1DdLlMHOH6wziGPnahpp1HUTWr4dU80nWnJIXYKpGmZ36eXSnmaU00uBWhENFmRhZJ rz4h6loEeWnbeJh4UnqtHuUWostQEJ4YS8noIBkgOtB2M2qDnWE+M7x4EmtjqpEpvovd NFNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=sC1JM0bzTj9rGm3VMz8UQ5qoFEZ/IGJ4W9fMuYuf7hY=; b=Gj3PKmTTt2DHnTxFfj2tSmPJdVi2um8dytAjVw6nEAXwPf54Kk27TKuNoyMIVq9ATP C5umk9Pxq7SRsmcmvD4ECl2iwM19at4854cSoYDth/vkz9zXyoDK4b0ZM1MgL+zvYw1m v3yPG+EFR9ppbtHYs+zLzC4uLT36shjwEupuXCCfzCEutl3puplb1vG5N3f8B4/PRini IL3VlIUmX8dcBjbzXEruQoG94dqf5tQH6F7ARFkT7GS7FyWVBycbX3QPKecdpxsXfJuc PiqUj5HkTY3dWOWWntYXGCGmau2slspRzWieYBKYghf8DMhlBSMyzEx1O+6TBLxNerKv LSPA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fx4si1307464ejb.157.2021.02.03.05.14.12; Wed, 03 Feb 2021 05:14:37 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230365AbhBCNNh (ORCPT + 99 others); Wed, 3 Feb 2021 08:13:37 -0500 Received: from mail.loongson.cn ([114.242.206.163]:54220 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229979AbhBCNNd (ORCPT ); Wed, 3 Feb 2021 08:13:33 -0500 Received: from [192.168.68.104] (unknown [111.18.92.2]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxf_MzoRpglroCAA--.3368S3; Wed, 03 Feb 2021 21:12:21 +0800 (CST) Subject: Re: [PATCH 1/3] MIPS: kernel: Support extracting off-line stack traces from user-space with perf To: Thomas Bogendoerfer Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Xuefeng Li , David Daney , Ralf Baechle , Archer Yan References: <1609246561-5474-1-git-send-email-yangtiezhu@loongson.cn> <1609246561-5474-2-git-send-email-yangtiezhu@loongson.cn> <20210201104338.GA6484@alpha.franken.de> <7c081c6f-bf47-353d-95c0-52e8640dc938@loongson.cn> <20210203104009.GE7586@alpha.franken.de> From: Tiezhu Yang Message-ID: <1ba8402b-77a0-a524-b9f0-55e91841cc20@loongson.cn> Date: Wed, 3 Feb 2021 21:12:28 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20210203104009.GE7586@alpha.franken.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-CM-TRANSID: AQAAf9Dxf_MzoRpglroCAA--.3368S3 X-Coremail-Antispam: 1UD129KBjvJXoWxXryDCFy5CF4UJr13Cw13twb_yoW5Gw1fpr W7Kay8Jws0qay3urWY9ayUur9xtF13JFW3urWfArW7Zr4jy3Z3Xw1kKFyaqwn7Xr18Ja1U urWDKFW8AF1YyrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBj14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r1I6r4UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcVAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kI c2xKxwCYjI0SjxkI62AI1cAE67vIY487MxkIecxEwVAFwVW5GwCF04k20xvY0x0EwIxGrw CFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE 14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2 IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxK x2IYs7xG6rWUJVWrZr1UMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxV AFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUSJP_UUUUU= X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/3/21 6:40 PM, Thomas Bogendoerfer wrote: > On Mon, Feb 01, 2021 at 08:56:06PM +0800, Tiezhu Yang wrote: >> On 02/01/2021 06:43 PM, Thomas Bogendoerfer wrote: >>> On Tue, Dec 29, 2020 at 08:55:59PM +0800, Tiezhu Yang wrote: >>>> +++ b/arch/mips/include/uapi/asm/perf_regs.h >>>> @@ -0,0 +1,42 @@ >>>> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ >>>> +#ifndef _ASM_MIPS_PERF_REGS_H >>>> +#define _ASM_MIPS_PERF_REGS_H >>>> + >>>> +enum perf_event_mips_regs { >>>> + PERF_REG_MIPS_PC, >>>> + PERF_REG_MIPS_R1, >>>> + PERF_REG_MIPS_R2, >>>> + PERF_REG_MIPS_R3, >>>> + PERF_REG_MIPS_R4, >>>> + PERF_REG_MIPS_R5, >>>> + PERF_REG_MIPS_R6, >>>> + PERF_REG_MIPS_R7, >>>> + PERF_REG_MIPS_R8, >>>> + PERF_REG_MIPS_R9, >>>> + PERF_REG_MIPS_R10, >>>> + PERF_REG_MIPS_R11, >>>> + PERF_REG_MIPS_R12, >>>> + PERF_REG_MIPS_R13, >>>> + PERF_REG_MIPS_R14, >>>> + PERF_REG_MIPS_R15, >>>> + PERF_REG_MIPS_R16, >>>> + PERF_REG_MIPS_R17, >>>> + PERF_REG_MIPS_R18, >>>> + PERF_REG_MIPS_R19, >>>> + PERF_REG_MIPS_R20, >>>> + PERF_REG_MIPS_R21, >>>> + PERF_REG_MIPS_R22, >>>> + PERF_REG_MIPS_R23, >>>> + PERF_REG_MIPS_R24, >>>> + PERF_REG_MIPS_R25, >>>> + /* >>>> + * 26 and 27 are k0 and k1, they are always clobbered thus not >>>> + * stored. >>>> + */ >>> haveing this hole here make all code more complicated. Does it hurt >>> to have R26 and R27 in the list ? >> I think there is no effect if have R26 and R27 in the list. >> >> In the perf_reg_value(), PERF_REG_MIPS_R{26,27} are default case. > why make them special ? After all they are real registers and are only > defined special by current ABIs. By convention, $26 and $27 are k registers which are reserved for use by the OS kernel. Here is an explanation [1]: "An interrupt handler must save any general - purpose registers that it is going to use (to be restored at return). But to do so requires you to modify at least one register first (something like sw $t0, saved_t0 expands to two machine instructions using $at). This situation is resolved by forbidding user programs from using two general - purpose registers, $k0 and $k1 (The k stands for kernel, which an exception handler is part of). The interrupt handler is allowed to use $k0 and $k1 without having to save or restore their values. This allows just enough leeway to start saving registers, as well as making returning from the interrupt handler possible." [1] https://stackoverflow.com/questions/27922315/how-to-use-mips-k0-and-k1-registers > >> Should I modify enum perf_event_mips_regs to add R26 and R27, >> and then send v2? > yes please. > > Thomas. >