Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2263021pxj; Sun, 16 May 2021 20:30:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymF8Ms9jFI7hQXnaK+RHK/zdSfnkcbAnuwpIzkIbCsiAIkRLBNnWdwCW/l1N8JSeTOMgg4 X-Received: by 2002:a17:906:134e:: with SMTP id x14mr3819374ejb.190.1621222204439; Sun, 16 May 2021 20:30:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621222204; cv=none; d=google.com; s=arc-20160816; b=zLtolPX18ljauI3oGXvAAIz5eqRezyGGSGImWxM2C/PR0suKaIxaaF3WlR9V85gcXq 6YeWZJs6kLVAqCoy5gx7SQAN5gF4Ufe+QyKfv6sbXJiktNDoXpT6cXIq8aFYfc7tS215 +iUMFUaDKXk+boY8u3u2PBxcWgYOsKcJjSqmCJolWceWX56UkYJNotaC0qhe2vB/zqWg NVYNgmwhI7RTbCEs3pKxWV3edtwr1ES1LD+92i7Zr4MnEgHH1haIJMEQh/jrHrPY70y6 3qldSmFvNxt+73NV6vb5iXQHTo9VhpxhiKX+i6Nj0jmz/ebvWq00s2A4uqEWDr32kV7w 8D/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=yBze23S242TVxFJHsDVfPTSCoB9i9Hy1s2Qqu+NOlbI=; b=wJ+NvymfrDdOeO4mWJHOCUAPGCFX6TJYFpVO6lK8ysqQNJ/ybY/l9UTFcNVN3L0Oca Lb4gpCk57/0V4Ewr35hW/mVpPOdQnpfanc2XkyT3nJWtuFKwUgtTLsE3rPaXUAOlJDYv 1MRz3QqcB1ZBYBy8p+esDNhXHQ2BHU3kkfu5NhpqJVf9ipW/fkODvYWqnq251oENW9JB q3IaqSXKfnP4qrzD1y1QYoevGXbqOSPTme/RESGdxOuOKnADCii49JegvTVNWpy2tb08 +Lp8HLwLTp/KQ3XHFG0tSCFd8hVlYwQacZd7PPkBH6+4TM/8GZtJw+5jyZdd0uUirMkI 1N2g== 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 q2si13040551ejx.698.2021.05.16.20.29.24; Sun, 16 May 2021 20:30:04 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231776AbhEQCXJ (ORCPT + 99 others); Sun, 16 May 2021 22:23:09 -0400 Received: from mail.loongson.cn ([114.242.206.163]:40968 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231249AbhEQCXI (ORCPT ); Sun, 16 May 2021 22:23:08 -0400 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9DxP+4k06FgP_cXAA--.20760S4; Mon, 17 May 2021 10:21:29 +0800 (CST) From: Tiezhu Yang To: Jonathan Corbet , Marc Koderer , Masami Hiramatsu , Mauro Carvalho Chehab , Christian Brauner , Jisheng Zhang , Mathieu Desnoyers , Ananth N Mavinakayanahalli , Andrew Morton , Randy Dunlap , Martin Schwidefsky , Johannes Thumshirn , Heiko Carstens , Joe Perches Cc: linux-kernel@vger.kernel.org, Xuefeng Li Subject: [PATCH v4 2/2] samples/kprobes: Fix typo in handler_post() Date: Mon, 17 May 2021 10:21:23 +0800 Message-Id: <1621218083-23519-3-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1621218083-23519-1-git-send-email-yangtiezhu@loongson.cn> References: <1621218083-23519-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf9DxP+4k06FgP_cXAA--.20760S4 X-Coremail-Antispam: 1UD129KBjvJXoWxAr1kJF47Xw17AF15CrykXwb_yoWrtFyDpa 4Yyw1UJF4rtw4agay2vF4vgryqkr1akaykurZ7CryYyFyIgw45ZF1ru3W0vrWruryFqw4j qryFyFy7C3WjvrUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPE14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jryl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26F4UJVW0 owAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUAVWUtwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCY02Avz4vE14v_Gr1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_ Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17 CE14v26r4a6rW5MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0 I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I 8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73 UjIFyTuYvjfU55l1DUUUU X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It should use post_handler instead of pre_handler in handler_post(). As Joe Perches suggested, it would be better to use pr_fmt and remove all the embedded pre/post/fault strings. This would change the style of the output through. Fixes: e16c5dd5157e ("samples/kprobes: Add s390 case in kprobe example module") Acked-by: Marc Koderer Acked-by: Masami Hiramatsu Suggested-by: Joe Perches Signed-off-by: Tiezhu Yang --- samples/kprobes/kprobe_example.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/samples/kprobes/kprobe_example.c b/samples/kprobes/kprobe_example.c index d77a546..5f1eb8b 100644 --- a/samples/kprobes/kprobe_example.c +++ b/samples/kprobes/kprobe_example.c @@ -10,6 +10,8 @@ * whenever kernel_clone() is invoked to create a new process. */ +#define pr_fmt(fmt) "%s: " fmt, __func__ + #include #include #include @@ -27,32 +29,31 @@ static struct kprobe kp = { static int __kprobes handler_pre(struct kprobe *p, struct pt_regs *regs) { #ifdef CONFIG_X86 - pr_info("<%s> pre_handler: p->addr = 0x%p, ip = %lx, flags = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, ip = %lx, flags = 0x%lx\n", p->symbol_name, p->addr, regs->ip, regs->flags); #endif #ifdef CONFIG_PPC - pr_info("<%s> pre_handler: p->addr = 0x%p, nip = 0x%lx, msr = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, nip = 0x%lx, msr = 0x%lx\n", p->symbol_name, p->addr, regs->nip, regs->msr); #endif #ifdef CONFIG_MIPS - pr_info("<%s> pre_handler: p->addr = 0x%p, epc = 0x%lx, status = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, epc = 0x%lx, status = 0x%lx\n", p->symbol_name, p->addr, regs->cp0_epc, regs->cp0_status); #endif #ifdef CONFIG_ARM64 - pr_info("<%s> pre_handler: p->addr = 0x%p, pc = 0x%lx," - " pstate = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, pc = 0x%lx, pstate = 0x%lx\n", p->symbol_name, p->addr, (long)regs->pc, (long)regs->pstate); #endif #ifdef CONFIG_ARM - pr_info("<%s> pre_handler: p->addr = 0x%p, pc = 0x%lx, cpsr = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, pc = 0x%lx, cpsr = 0x%lx\n", p->symbol_name, p->addr, (long)regs->ARM_pc, (long)regs->ARM_cpsr); #endif #ifdef CONFIG_RISCV - pr_info("<%s> pre_handler: p->addr = 0x%p, pc = 0x%lx, status = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, pc = 0x%lx, status = 0x%lx\n", p->symbol_name, p->addr, regs->epc, regs->status); #endif #ifdef CONFIG_S390 - pr_info("<%s> pre_handler: p->addr, 0x%p, ip = 0x%lx, flags = 0x%lx\n", + pr_info("<%s> p->addr, 0x%p, ip = 0x%lx, flags = 0x%lx\n", p->symbol_name, p->addr, regs->psw.addr, regs->flags); #endif @@ -65,31 +66,31 @@ static void __kprobes handler_post(struct kprobe *p, struct pt_regs *regs, unsigned long flags) { #ifdef CONFIG_X86 - pr_info("<%s> post_handler: p->addr = 0x%p, flags = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, flags = 0x%lx\n", p->symbol_name, p->addr, regs->flags); #endif #ifdef CONFIG_PPC - pr_info("<%s> post_handler: p->addr = 0x%p, msr = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, msr = 0x%lx\n", p->symbol_name, p->addr, regs->msr); #endif #ifdef CONFIG_MIPS - pr_info("<%s> post_handler: p->addr = 0x%p, status = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, status = 0x%lx\n", p->symbol_name, p->addr, regs->cp0_status); #endif #ifdef CONFIG_ARM64 - pr_info("<%s> post_handler: p->addr = 0x%p, pstate = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, pstate = 0x%lx\n", p->symbol_name, p->addr, (long)regs->pstate); #endif #ifdef CONFIG_ARM - pr_info("<%s> post_handler: p->addr = 0x%p, cpsr = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, cpsr = 0x%lx\n", p->symbol_name, p->addr, (long)regs->ARM_cpsr); #endif #ifdef CONFIG_RISCV - pr_info("<%s> post_handler: p->addr = 0x%p, status = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, status = 0x%lx\n", p->symbol_name, p->addr, regs->status); #endif #ifdef CONFIG_S390 - pr_info("<%s> pre_handler: p->addr, 0x%p, flags = 0x%lx\n", + pr_info("<%s> p->addr, 0x%p, flags = 0x%lx\n", p->symbol_name, p->addr, regs->flags); #endif } @@ -101,7 +102,7 @@ static void __kprobes handler_post(struct kprobe *p, struct pt_regs *regs, */ static int handler_fault(struct kprobe *p, struct pt_regs *regs, int trapnr) { - pr_info("fault_handler: p->addr = 0x%p, trap #%d\n", p->addr, trapnr); + pr_info("p->addr = 0x%p, trap #%d\n", p->addr, trapnr); /* Return 0 because we don't handle the fault. */ return 0; } -- 2.1.0