All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mao Han <han_mao@c-sky.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-kernel@vger.kernel.org, guoren@kernel.org
Subject: Re: [PATCH 2/3] riscv: Add support for perf registers sampling
Date: Fri, 12 Apr 2019 17:38:53 +0800	[thread overview]
Message-ID: <20190412093851.GA4961@vmh-VirtualBox> (raw)
In-Reply-To: <20190411141435.GA8343@infradead.org>

On Thu, Apr 11, 2019 at 07:24:32AM -0700, Christoph Hellwig wrote:
> > --- /dev/null
> > +++ b/arch/riscv/kernel/perf_callchain.c
> > @@ -0,0 +1,122 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +// Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd.
> 
> Please use normal /* */ Style comment for everything but the SPDX
> tags.
>
OK
 
> Please do early exists for all the error conditions.  Also no casts
> are needed for using ->fp as a scalar value, and we should probably
> just do a struct copy instead of copying both values individually.
> 
> The function should look something like:
> 
> static int unwind_frame_kernel(struct stackframe *frame)
> {
> 	if (!kstack_end((void *)frame->fp))
> 		return -EPERM;
> 	if ((frame->fp & 0x3 || frame->fp >= TASK_SIZE)
> 		return -EPERM;
> 
> 	*frame = *((struct stackframe *)frame->fp - 1);
> 	if (__kernel_text_address(frame->ra)) {
> 		int graph = 0;
> 
> 		frame->ra = ftrace_graph_ret_addr(NULL, &graph, frame->ra,
> 				NULL);
> 	}
> 	return 0;
> }
>
Thanks for suggestion. It looks much better with the modification.

> 
> Why not:
> 
> 	do {
> 		perf_callchain_store(entry, fr->ra);
> 	} while (unwind_frame_kernel(fr) >= 0);
> 
Yes, it's much simpler.

> > +/*
> > + * Get the return address for a single stackframe and return a pointer to the
> > + * next frame tail.
> > + */
> > +static unsigned long user_backtrace(struct perf_callchain_entry_ctx *entry,
> > +			unsigned long fp, unsigned long reg_ra)
> > +{
> > +	struct stackframe buftail;
> > +	unsigned long ra = 0;
> > +	unsigned long *user_frame_tail = (unsigned long *)(fp - sizeof(struct stackframe));
> 
> Overly long line.
Will fix the style.

> 
> > +	fp = user_backtrace(entry, fp, regs->ra);
> > +	while ((entry->nr < entry->max_stack) &&
> > +		fp && !((unsigned long)fp & 0x3))
> > +		fp = user_backtrace(entry, fp, 0);
> 
> Please don't indent the condition continuation and the loop body
> by the same amount.

Like this?
	while ((entry->nr < entry->max_stack) &&
					fp && !((unsigned long)fp & 0x3))
		fp = user_backtrace(entry, fp, 0);

Thanks,
Mao Han

  reply	other threads:[~2019-04-12  9:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-11  7:53 [PATCH 0/3] riscv: Add perf callchain support Mao Han
2019-04-11  7:53 ` [PATCH 1/3] " Mao Han
2019-04-11 14:24   ` Christoph Hellwig
2019-04-25 21:11   ` Palmer Dabbelt
2019-04-29  8:39     ` Mao Han
2019-04-29  8:39       ` Mao Han
2019-04-11  7:53 ` [PATCH 2/3] riscv: Add support for perf registers sampling Mao Han
2019-04-25 21:11   ` Palmer Dabbelt
2019-04-29  8:42     ` Mao Han
2019-04-29  8:42       ` Mao Han
2019-04-11  7:53 ` [PATCH 3/3] riscv: Add support for libdw Mao Han
2019-04-25 21:11   ` Palmer Dabbelt
2019-04-29  8:45     ` Mao Han
2019-04-29  8:45       ` Mao Han
2019-04-11 14:14 ` [PATCH 0/3] riscv: Add perf callchain support Christoph Hellwig
2019-04-12  9:38   ` Mao Han [this message]
2019-04-13  8:01     ` [PATCH 2/3] riscv: Add support for perf registers sampling Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190412093851.GA4961@vmh-VirtualBox \
    --to=han_mao@c-sky.com \
    --cc=guoren@kernel.org \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.