Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3392150rwb; Tue, 8 Nov 2022 04:09:51 -0800 (PST) X-Google-Smtp-Source: AMsMyM7yZEltgjZGrxjD/YBgJsOF3K8/bOAzEQxGWH+Dml/qTnFvf0O8tzH/B0ajU/R7+0qGG3vw X-Received: by 2002:a05:6402:22a5:b0:462:b393:f281 with SMTP id cx5-20020a05640222a500b00462b393f281mr55948448edb.379.1667909391557; Tue, 08 Nov 2022 04:09:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667909391; cv=none; d=google.com; s=arc-20160816; b=sPTglNf45a/GqN5LlbhSDmtaz3PNOo/W6S7EZqzY09JvP3NQxjKHMOvB6okbQx4vV7 +v7BosvUcEi7n8/W4fdj2FLXCFg2zXJ6M4PCCmiU63HWxmH8uNu3QrMJ4IGJuHYVVNzF TyiHq+C6TAOIDqSj692ElHnEXzFM6m4IX4Fa3G9g+ZzPiV0MDGcw84JZhBOrqKuxtEsi jZunGbbxa1vEn1MSkrBx3TR1+TRXouQIDXOhciEna7P3op9WioC+KzRal1SPTxjajq7X hUNXykAgI1xmRCRLtCjkhUBSpLiWyKPyoBVm57nfLoB8JGhvPCCzrhHNPguoCjYwoeLJ KSCg== 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:subject:user-agent:mime-version:date:message-id; bh=CluLenCWqEVm3fxttZOkIF+KwzlQ3lpKJH6VZABLEhA=; b=XXtqztZtTFX2+kNVnST3SepaigauYFrYu46bohJ3K5JmnxidRKtcJtgCB5tK4ZSfdA qKM3aEV9xPSg2QBtdefcwXFR00ThfZUbtbwqYqilVGaqtUaHJzE8ca52ic/lSQPKNUcU GlAQYvCSLOJDBfF9JmUBPK3b4fj/VCa23jB6Ro6wd7dXz2R2mihUv71aBCyRKeOZg+uI Bb+OZgydVpfqcMNVLKF5sd1siA8zSC9feJZQoCSxewuRRKou/3ObTRNI7pCp8hiXm0kA tUQnlagUBdKLtaKdNzZ+ozkuNJ5RREd+bNmMSyJ0adzoeHLGBBD1XtEtoaT8b5c2NAR3 ecnQ== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o16-20020a170906975000b007ae74740f8bsi4578797ejy.386.2022.11.08.04.09.28; Tue, 08 Nov 2022 04:09:51 -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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233870AbiKHLeC (ORCPT + 90 others); Tue, 8 Nov 2022 06:34:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233846AbiKHLd7 (ORCPT ); Tue, 8 Nov 2022 06:33:59 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B17611277E for ; Tue, 8 Nov 2022 03:33:57 -0800 (PST) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4N65Vw2fD9zpWG1; Tue, 8 Nov 2022 19:30:16 +0800 (CST) Received: from [10.67.110.108] (10.67.110.108) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 8 Nov 2022 19:33:55 +0800 Message-ID: <598bc40d-e826-f9cc-14fd-f4570051f4c6@huawei.com> Date: Tue, 8 Nov 2022 19:33:54 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH v4 0/8] Add OPTPROBES feature on RISCV To: Xim , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= CC: , , , , , , , , Liao Chang References: <20221106100316.2803176-1-chenguokai17@mails.ucas.ac.cn> <87y1sm1z8j.fsf@all.your.base.are.belong.to.us> <9A705974-A007-45E2-BC5D-A7E90821A258@mails.ucas.ac.cn> From: "liaochang (A)" In-Reply-To: <9A705974-A007-45E2-BC5D-A7E90821A258@mails.ucas.ac.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.110.108] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,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 在 2022/11/8 19:04, Xim 写道: > 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? This corner case has been taken into account, look these condition parts, if kw == 1UL this expression will return 0 directly, no chance to invoke __builtin_ctzl. Thanks. > > Will be fixed. > > Regards, > Guokai Chen > -- BR, Liao, Chang