Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3375957rwb; Tue, 8 Nov 2022 04:00:23 -0800 (PST) X-Google-Smtp-Source: AMsMyM7txmI4J10Ro9Dd0SgpGnT3A6Zd11u3vrlM0YV+/nmXT+vKNFQ6TGRK8flABtolI8pqbIEE X-Received: by 2002:a17:907:6288:b0:78d:ab30:c374 with SMTP id nd8-20020a170907628800b0078dab30c374mr52732978ejc.266.1667908823122; Tue, 08 Nov 2022 04:00:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667908823; cv=none; d=google.com; s=arc-20160816; b=UmhJn62/zJq4KEo6FSmYo57ZHMzKEGEZqWn1efnqoed3L8eogd2kNUBCGei10CI2si 7JhRGtqrV5BVqWNjb6ZCvAdkVTAZx0QKmAOnkyiEf22Jl6Ws3XXPYgDwlF6mDq1nUtVv 3YukvpzyeYD3BQbqu/Dc33L6SGo+qXrpUkp6lZ7KORfxiGxLMN+8THAzyF+zqFfsy04B VtldYyskBimMfdXYQCwIwqaY19Tc/FZuXOP8yKFvFDpTSFYDaMjHTv4Wyb4aQhFgwjKM 9zSVxeYh2MnDDXRRZNPm2o/4AiU/5v40qhKZsTm8MzhanWNOMiqW6xJetj7IDSHu8JF2 HR1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=04ZjUVO0GyboQRBl2rhJPT6qlvqxY6tXtRfABguSBI4=; b=T6is/fdhxi8IAX2V1VCBih1n/DRXGZViCJ0pR6ql+jeH8HRe+jzuq57wmlNGmP/J6p s0dz2ZcBYe2k9GksZ/OD+AaU/LPKximpO/GlBAYazt9sx2zYnDDvOtVaCapBkcxqWq0o ZEuYkO2rTutm93GZxkEpFRXp7azee/mLLmcBqq4r5CXPUkrkZwqSRX31181EHjH2Kran j3/VDvgFaPc+j4uFrWVwLF3k0asZWJLyFBh8DVxPIrVxq0IhD7DU7a4nOeV7eQi8t8V5 1ddV5EnvKH7aAxxvDRXs8wqiGreuQzeG24R8JSF12s2Mdgy7dBCo9lyoxqC/8sMQw7a8 JZbg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sa34-20020a1709076d2200b0078d25d59f62si12629903ejc.21.2022.11.08.03.59.52; Tue, 08 Nov 2022 04:00:23 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233961AbiKHLEm convert rfc822-to-8bit (ORCPT + 89 others); Tue, 8 Nov 2022 06:04:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233658AbiKHLEi (ORCPT ); Tue, 8 Nov 2022 06:04:38 -0500 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 16B8312636 for ; Tue, 8 Nov 2022 03:04:34 -0800 (PST) Received: from smtpclient.apple (unknown [219.141.235.82]) by APP-01 (Coremail) with SMTP id qwCowABXX4+qN2pj8Y3iCA--.26885S3; Tue, 08 Nov 2022 19:04:10 +0800 (CST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: [PATCH v4 0/8] Add OPTPROBES feature on RISCV From: Xim In-Reply-To: <87y1sm1z8j.fsf@all.your.base.are.belong.to.us> Date: Tue, 8 Nov 2022 19:04:09 +0800 Cc: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, rostedt@goodmis.org, mingo@redhat.com, sfr@canb.auug.org.au, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, liaochang1@huawei.com, Liao Chang Content-Transfer-Encoding: 8BIT Message-Id: <9A705974-A007-45E2-BC5D-A7E90821A258@mails.ucas.ac.cn> References: <20221106100316.2803176-1-chenguokai17@mails.ucas.ac.cn> <87y1sm1z8j.fsf@all.your.base.are.belong.to.us> To: =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= X-Mailer: Apple Mail (2.3696.120.41.1.1) X-CM-TRANSID: qwCowABXX4+qN2pj8Y3iCA--.26885S3 X-Coremail-Antispam: 1UD129KBjvJXoW7KrW7WF1xAF4DWw48urW3Wrg_yoW8Cryfpa yIkws8Ka1vyasFg3WqvF4xX3WS9r4jqrWUZFnrGw15Gw15XF9avw4Sg3y5uFn8KrWFyr4I vFyjyw1kZ3s7AaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9qb7Iv0xC_KF4lb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4 A2jsIEc7CjxVAFwI0_GcCE3s1lnxkEFVAIw20F6cxK64vIFxWle2I262IYc4CY6c8Ij28I cVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_JrI_JrylYx 0Ex4A2jsIE14v26r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwAC I402YVCY1x02628vn2kIc2xKxwCY02Avz4vE14v_Gw4l42xK82IYc2Ij64vIr41l4I8I3I 0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWU GVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI 0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0 rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r 4UJbIYCTnIWIevJa73UjIFyTuYvjxU4nmiDUUUU X-Originating-IP: [219.141.235.82] X-CM-SenderInfo: xfkh0w5xrntxyrx6ztxlovh3xfdvhtffof0/1tbiBwIEE2Np+0jc0gAAsl X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS 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 Hi Björn, Thanks for your great review! Some explanations below. > 2022年11月8日 00:54,Björn Töpel 写道: > > Have you run the series on real hardware, or just qemu? Currently only qemu tests are made, I will try to test it on a FPGA real hardware soon. > AFAIU, the algorithm only tracks registers that are *in use*. You are > already scanning the whole function (next patch). What about the caller > saved registers that are *not* used by the function in the probe range? > Can those, potentially unused, regs be used? Great missing part! I have made a static analyzation right upon receiving this mail. The result shows that this newly purposed idea reaches about the same success rate on my test set (rv64 defconf with RVI only) while when combined, they can reach a higher success rate, 1/3 above their baseline. A patch that includes this strategy will be sent soon. > >> +static void arch_find_register(unsigned long start, unsigned long end, > > Nit; When I see "arch_" I think it's functionality that can be > overridden per-arch. This is not the case, but just a helper for RV. It can be explained from two aspects. First, it can be extended to most RISC archs, which can be extracted into the common flow of Kprobe. Second, it is indeed a internal helper for now, so I will correct the name in the next version. >> static void find_free_registers(struct kprobe *kp, struct optimized_kprobe *op, >> - int *rd1, int *rd2) >> + int *rd, int *ra) > > Nit; Please get rid of this code churn, just name the parameters > correctly on introduction in the previous patch. Will be fixed. >> + *rd = ((kw | ow) == 1UL) ? 0 : __builtin_ctzl((kw | ow) & ~1UL); >> + *ra = (kw == 1UL) ? 0 : __builtin_ctzl(kw & ~1UL); > > Hmm, __builtin_ctzl is undefined for 0, right? Can that be triggered > here? Will be fixed. Regards, Guokai Chen