Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2508883pxb; Tue, 23 Feb 2021 08:39:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyGKnVP4tI4fpmgDDY9CAz/+1CEjLAcXrXQYUrodgTzBPnARCAIWD4GHvkjDWyg0zjehVTf X-Received: by 2002:a17:906:384e:: with SMTP id w14mr26444836ejc.285.1614098366440; Tue, 23 Feb 2021 08:39:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614098366; cv=none; d=google.com; s=arc-20160816; b=aZVB5Sj2o9dnC//9mH8csJlmBUL34M9H1CHf0RrW9D0Al50bifufVF3x0KPxIvjH8i s05bNom97DPABqrCeCNonJCBUmFpZ4e400HI7aLN16Nz3fC4CqPkDWYM2cm9K0S6WFtP FB1bSxX8j3GvRyxVxd8+14JRTATyoTT1qhjV4Zv0zJThyK0/aLPQaPQWb+RO+PbuBv2L RYtbKCIU9YKvP8UulC1Fatjgdp84DpYFXNm0v0cAaaLNt0EMqRib/j/oVql+QQDC3Pgn 2FCCdTnTuUT9vnFEiQ3A5kdrUrD1belDkWjC3tLo2qwmRCa9RoD29E+C3fuZB+Hj5Gec PIsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=qsmfwUKXK0SkkUxdagiZ50kzL7pxvcBYU/Bll1GLsCE=; b=cJXgcz3FuLJIcWJp4suQX/Pz7ZVDGLw/HWjotKaypX2UzBuEnn0PtwHM8O5IUPm/PR 3RnbqYgB7ydzO8uJdLL4F4MeBfiGScBU+TjE1S/8N38J4QPS9U3cnUKjz5rkXAWbmZTb NwFULWW2kuNmBw5Uz5LeibdkHi3ZPvpTHHt+vh3JpBggWNfgoWL413AcZLbww6RE1j1x YRxf0+K5JpjpoAJ+dGlRenBRn8QjcRbgj3AZB9IAt7nM2y7y9epy8M61j4yJ+E4Ys2Em rBzGxDpnUL4IqLehYwTAKdoo3891SQycDZ4tQc6/sODSmVi+kPROddHkfMl1/oq4X/Mk N32g== 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 f7si15675152edd.574.2021.02.23.08.39.01; Tue, 23 Feb 2021 08:39:26 -0800 (PST) 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 S233551AbhBWQgV (ORCPT + 99 others); Tue, 23 Feb 2021 11:36:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:40506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233546AbhBWQgP (ORCPT ); Tue, 23 Feb 2021 11:36:15 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6D82564E60; Tue, 23 Feb 2021 16:35:32 +0000 (UTC) Date: Tue, 23 Feb 2021 11:35:30 -0500 From: Steven Rostedt To: Andrew Scull Cc: kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, julien.thierry.kdev@gmail.com, will@kernel.org, catalin.marinas@arm.com, kernel-team@android.com, Peter Zijlstra Subject: Re: [PATCH v2 2/4] bug: Factor out a getter for a bug's file line Message-ID: <20210223113530.3703dd19@gandalf.local.home> In-Reply-To: <20210223155759.3495252-3-ascull@google.com> References: <20210223155759.3495252-1-ascull@google.com> <20210223155759.3495252-3-ascull@google.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 23 Feb 2021 15:57:57 +0000 Andrew Scull wrote: > There is some non-trivial config-based logic to get the file name and > line number associated with a bug. Factor this out to a getter that can > be resused. > > Signed-off-by: Andrew Scull > Cc: Peter Zijlstra > Cc: "Steven Rostedt (VMware)" > --- > include/linux/bug.h | 3 +++ > lib/bug.c | 27 +++++++++++++++++---------- > 2 files changed, 20 insertions(+), 10 deletions(-) > > diff --git a/include/linux/bug.h b/include/linux/bug.h > index f639bd0122f3..e3841bee4c8d 100644 > --- a/include/linux/bug.h > +++ b/include/linux/bug.h > @@ -36,6 +36,9 @@ static inline int is_warning_bug(const struct bug_entry *bug) > return bug->flags & BUGFLAG_WARNING; > } > > +void bug_get_file_line(struct bug_entry *bug, const char **file, > + unsigned int *line); > + > struct bug_entry *find_bug(unsigned long bugaddr); > > enum bug_trap_type report_bug(unsigned long bug_addr, struct pt_regs *regs); > diff --git a/lib/bug.c b/lib/bug.c > index 4ab398a2de93..f936615176b8 100644 > --- a/lib/bug.c > +++ b/lib/bug.c > @@ -130,6 +130,22 @@ static inline struct bug_entry *module_find_bug(unsigned long bugaddr) > } > #endif > > +void bug_get_file_line(struct bug_entry *bug, const char **file, > + unsigned int *line) > +{ > + *file = NULL; > + *line = 0; > + > +#ifdef CONFIG_DEBUG_BUGVERBOSE > +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS > + *file = bug->file; > +#else > + *file = (const char *)bug + bug->file_disp; > +#endif > + *line = bug->line; Not that it should be part of this patch, as this patch is moving the code and shouldn't modify it, but as a micro optimization, we could remove the initialization from the beginning and place it here: #else *file = NULL; *line = 0; But again, this patch is fine. Reviewed-by: Steven Rostedt (VMware) -- Steve > +#endif > +} > + > struct bug_entry *find_bug(unsigned long bugaddr) > { > struct bug_entry *bug; > @@ -156,17 +172,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs) > > disable_trace_on_warning(); > > - file = NULL; > - line = 0; > + bug_get_file_line(bug, &file, &line); > > -#ifdef CONFIG_DEBUG_BUGVERBOSE > -#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS > - file = bug->file; > -#else > - file = (const char *)bug + bug->file_disp; > -#endif > - line = bug->line; > -#endif > warning = (bug->flags & BUGFLAG_WARNING) != 0; > once = (bug->flags & BUGFLAG_ONCE) != 0; > done = (bug->flags & BUGFLAG_DONE) != 0;