Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1239567pxp; Thu, 17 Mar 2022 05:58:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQfpSkAmndjw3DLRnivNolGbeBckVKRRwc/GI8D/l0BWbXNpl4m14zZRbvcnZIlq6pIgIX X-Received: by 2002:aa7:8c45:0:b0:4f6:bf82:7aba with SMTP id e5-20020aa78c45000000b004f6bf827abamr4727590pfd.20.1647521928612; Thu, 17 Mar 2022 05:58:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647521928; cv=none; d=google.com; s=arc-20160816; b=RGUcxObV2MR/YksT7F5xKyKE8seAGmW9Swrsj/eMGuArjd+Kfkhh0VPurMVTsFzMTy Zoyjp8AYc5mmhE77gnY+fxdvFz062PN7SC1oklQNKCbVanEORIyrNiP54u4P7ieZj4Xg 0gEpipqtGL5XYDB4A1qCqfEYxgEi8Lg4lXL3AZKEFdH/4NGJ67O5LNYFLU+Coi3xmL9+ NrsgSD8lSySKGUz81SI22qLcG3rCjBO8luaAA1wiBYS4Bhv54fISFZmBppg9+1RriVTM X75s+AvyEvVd2I8mTP8t0prxUSOD0+iydz6px2CQLVHTe+YINtBtOvyHzhOn3avM8iX1 h3Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FRZFWYXu0lglEsdbgAkHKkmcItgzgemxTYTZc8fsVTc=; b=mv30MFPS6lNFgCSuPjYb8K+Nhrv1r5cCE4Syzu8ZfZM6JJnyVlwXogkxIiYxHwmkgV WxwNnAEJd9HHxzJCyHyZRPnwrlmFLvV9h9ceP27KKvNLACESYBqid6WNFeyZoYWPagkR YRbEJPBd5xU0GkMepJQA19DHkWlD52aZtufGkS4l7JX+y0zvOsTCRZaQsbhwp0rbkabo tPZvHxHFVMn+edx9apzBd1X8Wy5g+Zkns5dU2Lcdev+f5UaR67GmcYbFn3nACqOlnoOG 4LJ+dinX6SPZDtbTpMrZEW0T5/3qQP+vQLlbNS6yY/OJOzB2j5F1EETDemBHdjOgXZlS U2bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=InraB4+0; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t7-20020a63b707000000b003816043f14bsi1905119pgf.832.2022.03.17.05.58.36; Thu, 17 Mar 2022 05:58:48 -0700 (PDT) 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; dkim=pass header.i=@suse.com header.s=susede1 header.b=InraB4+0; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232783AbiCQLAi (ORCPT + 99 others); Thu, 17 Mar 2022 07:00:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232774AbiCQLAg (ORCPT ); Thu, 17 Mar 2022 07:00:36 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF572176D29; Thu, 17 Mar 2022 03:59:19 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 3453021110; Thu, 17 Mar 2022 10:59:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1647514758; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FRZFWYXu0lglEsdbgAkHKkmcItgzgemxTYTZc8fsVTc=; b=InraB4+0kSCdc8UDu/okTjNgatj5P6RAXhgCUwmKkl5JBuP6Jc7a82aAVFQCKM5cJV03oP loW9dzgewNjtEz6rsoEZ9jmW3SA7GOPDLYpS9JFRAiS9/7oKRCLfQcaX5T5WrPRqHSmMPf 97Oh7UgJ4tESVOfSiJe/aFWx82wNEnE= Received: from suse.cz (unknown [10.100.224.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 97D36A3B83; Thu, 17 Mar 2022 10:59:16 +0000 (UTC) Date: Thu, 17 Mar 2022 11:59:15 +0100 From: Petr Mladek To: Maninder Singh Cc: mcgrof@kernel.org, rostedt@goodmis.org, senozhatsky@chromium.org, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, akpm@linux-foundation.org, wangkefeng.wang@huawei.com, v.narang@samsung.com, swboyd@chromium.org, ojeda@kernel.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, avimalin@gmail.com, atomlin@redhat.com, keescook@chromium.org, ndesaulniers@google.com, rdunlap@infradead.org, void@manifault.com Subject: Re: [PATCH 1/1 module-next] kallsyms: enhance %pS/s/b printing when KALLSYSMS is disabled Message-ID: References: <20220316043540.677128-1-maninder1.s@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220316043540.677128-1-maninder1.s@samsung.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Wed 2022-03-16 10:05:40, Maninder Singh wrote: > print module information when KALLSYMS is disabled. > > No change for %pB, as it needs to know symbol name to adjust address > value which can't be done without KALLSYMS. > > (A) original output with KALLSYMS: > [8.842129] ps function_1 [crash] > [8.842735] pS function_1+0x4/0x2c [crash] > [8.842890] pSb function_1+0x4/0x2c [crash b367e79021b9f3b0172f9a36d4261c1f528ca1b3] > [8.843175] pB function_1+0x4/0x2c [crash] > [8.843362] pBb function_1+0x4/0x2c [crash b367e79021b9f3b0172f9a36d4261c1f528ca1b3] > > (B) original output without KALLSYMS: > [12.487424] ps 0xffff800000eb008c > [12.487598] pS 0xffff800000eb008c > [12.487723] pSb 0xffff800000eb008c > [12.487850] pB 0xffff800000eb008c > [12.487967] pBb 0xffff800000eb008c > > (C) With patched kernel > with KALLYSMS: > [41.974576] ps function_1 [crash] > [41.975173] pS function_1+0x4/0x2c [crash] > [41.975386] pSb function_1+0x4/0x2c [crash a8b20caaec9635b316cf4812f6b55598fe2b7cee] > [41.975879] pB function_1+0x4/0x2c [crash] > [41.976076] pBb function_1+0x4/0x2c [crash a8b20caaec9635b316cf4812f6b55598fe2b7cee] > > without KALLSYMS: > [9.624152] ps 0xffff800001bd008c [crash] // similar to original, no changes > [9.624548] pS 0x(____ptrval____)+0x8c [crash] // base address hashed and offset is without hash > [9.624847] pSb 0x(____ptrval____)+0x8c [crash a8b20caaec9635b316cf4812f6b55598fe2b7cee] > [9.625388] pB 0x(____ptrval____)+0x8c [crash] > [9.625594] pBb 0x(____ptrval____)+0x8c [crash a8b20caaec9635b316cf4812f6b55598fe2b7cee] > > with disable hashing: > [8.563916] ps 0xffff800000f2008c [crash] > [8.564574] pS 0xffff800000f20000+0x8c [crash] > [8.564749] pSb 0xffff800000f20000+0x8c [crash 3423a8993a7033fb79e5add14bf9d8d6b56330ca] > [8.565008] pB 0xffff800000f20000+0x8c [crash] > [8.565154] pBb 0xffff800000f20000+0x8c [crash 3423a8993a7033fb79e5add14bf9d8d6b56330ca] > > --- a/lib/vsprintf.c > +++ b/lib/vsprintf.c > @@ -979,33 +979,92 @@ char *bdev_name(char *buf, char *end, struct block_device *bdev, > } > #endif > > +#if !defined(CONFIG_KALLSYMS) && defined(CONFIG_MODULES) > +static int sprint_module_info(char *buf, unsigned long value, > + int modbuildid, int backtrace, int symbol) > +{ > + struct module *mod; > + unsigned long offset; > + void *base; > + char *modname; > + int len; > + const unsigned char *buildid = NULL; > + bool add_offset; > + > + if (is_ksym_addr(value)) > + return 0; > + > + if (backtrace || symbol) > + add_offset = true; > + else > + add_offset = false; > + > + preempt_disable(); > + mod = __module_address(value); > + if (mod) { > + modname = mod->name; > +#if IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID) > + if (modbuildid) > + buildid = mod->build_id; > +#endif > + if (add_offset) { > + base = mod->core_layout.base; > + offset = value - (unsigned long)base; > + } > + } > + preempt_enable(); > + if (!mod) > + return 0; I think that some earlier version of the patch allowed to print also the address from vmlinux with the offset. My concern was that it would show non-hashed base pointer. IMHO, it is fine to show it hashed. > + > + /* address belongs to module */ > + if (add_offset) > + len = sprintf(buf, "0x%p+0x%lx", base, offset); > + else > + len = sprintf(buf, "0x%lx", value); > + > + return len + fill_name_build_id(buf, modname, modbuildid, buildid, len); > +} Otherwise, it looks good to me. I did also some basic testing. The vmlinux address with offset can be added by a followup patch. Feel free to use: Reviewed-by: Petr Mladek Tested-by: Petr Mladek Best Regards, Petr