linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: 'Baoquan He' <bhe@redhat.com>
To: David Laight <David.Laight@aculab.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"willy@infradead.org" <willy@infradead.org>,
	"kexec@lists.infradead.org" <kexec@lists.infradead.org>,
	"yangtiezhu@loongson.cn" <yangtiezhu@loongson.cn>,
	"amit.kachhap@arm.com" <amit.kachhap@arm.com>,
	"hch@lst.de" <hch@lst.de>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH v4 4/4] fs/proc/vmcore: Use iov_iter_count()
Date: Mon, 21 Mar 2022 11:54:50 +0800	[thread overview]
Message-ID: <Yjf3CivCFMNE/Hbs@MiWiFi-R3L-srv> (raw)
In-Reply-To: <1592a861bd9e46e5adf1431ad6bbd25c@AcuMS.aculab.com>

Hi David,

On 03/18/22 at 01:48pm, David Laight wrote:
> From: Baoquan He
> > Sent: 18 March 2022 09:37
> > 
> > To replace open coded iter->count. This makes code cleaner.
> ...
> > diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
> > index 4cbb8db7c507..ed58a7edc821 100644
> > --- a/fs/proc/vmcore.c
> > +++ b/fs/proc/vmcore.c
> > @@ -319,21 +319,21 @@ static ssize_t __read_vmcore(struct iov_iter *iter, loff_t *fpos)
> >  	u64 start;
> >  	struct vmcore *m = NULL;
> > 
> > -	if (iter->count == 0 || *fpos >= vmcore_size)
> > +	if (!iov_iter_count(iter) || *fpos >= vmcore_size)
> 
> For some definition of 'cleaner' :-)
> 
> iter->count is clearly a simple, cheap structure member lookup.
> OTOH iov_iter_count(iter) might be an expensive traversal of
> the vector (or worse).
> 
> So a quick read of the code by someone who isn't an expert
> in the iov functions leaves them wondering what is going on
> or having to spend time locating the definition ...

Thanks for reviewing and looking into this.

People may have the same feeling as you when looking at codes at the
first glance. While usually we all use editor to explore codes, so.

Basically, I noticed putting open code into wrapper is a tendency, see a
lot of patches to clean up open code in sub component. About the extra
cost of wrapper, I believe it does have. It should be one of reasons
in some places open code is necessary. However, in fs/proc/vmcore, I
don't have the worry since it's very tiny and can be ignorable.

Thanks
Baoquan


  parent reply	other threads:[~2022-03-21  3:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-18  9:37 [PATCH v4 0/4] Convert vmcore to use an iov_iter Baoquan He
2022-03-18  9:37 ` [PATCH v4 1/4] vmcore: Convert copy_oldmem_page() to take " Baoquan He
2022-03-18  9:37 ` [PATCH v4 2/4] vmcore: Convert __read_vmcore to use " Baoquan He
2022-03-18  9:37 ` [PATCH v4 3/4] vmcore: Convert read_from_oldmem() to take " Baoquan He
2022-03-18  9:37 ` [PATCH v4 4/4] fs/proc/vmcore: Use iov_iter_count() Baoquan He
2022-03-18 13:48   ` David Laight
2022-03-18 13:50     ` Matthew Wilcox
2022-03-21  3:54     ` 'Baoquan He' [this message]
2022-03-18 10:25 ` [PATCH v4 0/4] Convert vmcore to use an iov_iter Baoquan He
2022-03-31 11:25 ` Baoquan He
2022-03-31 14:36   ` Matthew Wilcox
2022-04-01  0:14     ` Andrew Morton
2022-04-01  1:23       ` Baoquan He

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=Yjf3CivCFMNE/Hbs@MiWiFi-R3L-srv \
    --to=bhe@redhat.com \
    --cc=David.Laight@aculab.com \
    --cc=amit.kachhap@arm.com \
    --cc=hch@lst.de \
    --cc=kexec@lists.infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    --cc=yangtiezhu@loongson.cn \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).