Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCB73C05027 for ; Thu, 2 Feb 2023 02:23:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230375AbjBBCXW (ORCPT ); Wed, 1 Feb 2023 21:23:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229612AbjBBCXS (ORCPT ); Wed, 1 Feb 2023 21:23:18 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C9FEC5AB50 for ; Wed, 1 Feb 2023 18:23:16 -0800 (PST) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8Cx+emSHttjiP0LAA--.24405S3; Thu, 02 Feb 2023 10:23:14 +0800 (CST) Received: from [10.130.0.135] (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cx2r2RHttjD_AmAA--.10846S3; Thu, 02 Feb 2023 10:23:14 +0800 (CST) Subject: Re: [PATCH v12 0/5] Add kprobe and kretprobe support for LoongArch To: Jeff Xie , Huacai Chen References: <1674007261-9198-1-git-send-email-yangtiezhu@loongson.cn> Cc: WANG Xuerui , Masami Hiramatsu , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org From: Tiezhu Yang Message-ID: <02806f85-bc09-d316-f058-3947353cb190@loongson.cn> Date: Thu, 2 Feb 2023 10:23:13 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID: AQAAf8Cx2r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lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcV C2z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjxU70PfDUUUU Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/01/2023 05:40 PM, Jeff Xie wrote: > On Wed, Feb 1, 2023 at 12:56 PM Huacai Chen wrote: >> >> Hi, Jeff, >> >> Could you please pay some time to test this series? Thank you. > > Thanks for notifying me about the test. > > I have tested the patchset(based on the > https://github.com/loongson/linux/tree/loongarch-next), > I found that some functions can't be probed e.g. scheduler_tick() or > uart_write_wakeup() > the two functions have the same point, they are all run in the hardirq context. > > I don't know if it's related to the hardirq context, I haven't had > time to study this patchset carefully. > and they can be probed in the x86_64 arch. > > root@loongarch modules]# insmod ./kprobe_example.ko symbol=scheduler_tick > insmod: can't insert './kprobe_example.ko': invalid parameter > > dmesg: > [ 39.806435] kprobe_init: register_kprobe failed, returned -22 > Thanks for your test. On my test environment, I can not reproduce the above issue, here are the test results, it seems no problem. [root@linux loongson]# dmesg -c [root@linux loongson]# uname -m loongarch64 [root@linux loongson]# modprobe kprobe_example symbol=scheduler_tick [root@linux loongson]# rmmod kprobe_example [root@linux loongson]# dmesg | tail -2 [ 3317.138086] handler_post: p->addr = 0x0000000065d12f66, estat = 0xc0000 [ 3317.154086] kprobe_exit: kprobe at 0000000065d12f66 unregistered [root@linux loongson]# dmesg -c [root@linux loongson]# uname -m loongarch64 [root@linux loongson]# modprobe kprobe_example symbol=uart_write_wakeup [root@linux loongson]# rmmod kprobe_example [root@linux loongson]# dmesg | tail -2 [ 3433.502092] handler_post: p->addr = 0x0000000019718061, estat = 0xc0000 [ 3433.762085] kprobe_exit: kprobe at 0000000019718061 unregistered Additionally, "register_kprobe failed, returned -22" means the symbol can not be probed, here is the related code: register_kprobe() check_kprobe_address_safe() static int check_kprobe_address_safe(struct kprobe *p, struct module **probed_mod) { int ret; ret = check_ftrace_location(p); if (ret) return ret; jump_label_lock(); preempt_disable(); /* Ensure it is not in reserved area nor out of text */ if (!(core_kernel_text((unsigned long) p->addr) || is_module_text_address((unsigned long) p->addr)) || in_gate_area_no_mm((unsigned long) p->addr) || within_kprobe_blacklist((unsigned long) p->addr) || jump_label_text_reserved(p->addr, p->addr) || static_call_text_reserved(p->addr, p->addr) || find_bug((unsigned long)p->addr)) { ret = -EINVAL; goto out; } ... } Thanks, Tiezhu