All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicholas Mc Guire <der.herr@hofr.at>
To: Joe Perches <joe@perches.com>
Cc: Wolfram Sang <wsa@the-dreams.de>,
	linux-kernel@vger.kernel.org, Joe Schultz <jschultz@xes-inc.com>,
	linux-mtd@lists.infradead.org,
	Nicholas Mc Guire <hofrat@osadl.org>,
	Aaron Sierra <asierra@xes-inc.com>,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH] mtd: fsl_ifc_nand: use msecs_to_jiffies for time conversion
Date: Thu, 2 Apr 2015 02:20:20 +0200	[thread overview]
Message-ID: <20150402002020.GA30284@opentech.at> (raw)
In-Reply-To: <1427901535.31790.10.camel@perches.com>

On Wed, 01 Apr 2015, Joe Perches wrote:

> On Wed, 2015-04-01 at 10:08 -0500, Aaron Sierra wrote:
> > ----- Original Message -----
> > > From: "Nicholas Mc Guire" <der.herr@hofr.at>
> > > Sent: Wednesday, April 1, 2015 9:24:44 AM
> > > 
> > > On Wed, 01 Apr 2015, Aaron Sierra wrote:
> > > 
> > > > ----- Original Message -----
> > > > > From: "Nicholas Mc Guire" <hofrat@osadl.org>
> > > > > Sent: Friday, March 13, 2015 6:23:47 AM
> > > > > 
> > > > > This is only an API consolidation and should make things more readable
> > > > > it replaces var * HZ / 1000 by msecs_to_jiffies(var) which helps
> > > > > readability
> > > > > and also handles all corner-cases properly.
> > > > > 
> > > > > Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> > > > > ---
> > > > > 
> > > > > Patch was compile tested with corenet64_smp_defconfig
> > > > > (implies CONFIG_MTD_NAND_FSL_IFC=y)
> > > > > 
> > > > > Patch is against 4.0-rc3 (localversion-next is -next-20150313
> > > > > 
> > > > >  drivers/mtd/nand/fsl_ifc_nand.c |    4 ++--
> > > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/mtd/nand/fsl_ifc_nand.c
> > > > > b/drivers/mtd/nand/fsl_ifc_nand.c
> > > > > index 4c05f4f..51394e5 100644
> > > > > --- a/drivers/mtd/nand/fsl_ifc_nand.c
> > > > > +++ b/drivers/mtd/nand/fsl_ifc_nand.c
> > > > > @@ -317,7 +317,7 @@ static void fsl_ifc_run_command(struct mtd_info *mtd)
> > > > >  
> > > > >  	/* wait for command complete flag or timeout */
> > > > >  	wait_event_timeout(ctrl->nand_wait, ctrl->nand_stat,
> > > > > -			   IFC_TIMEOUT_MSECS * HZ/1000);
> > > > > +			   msecs_to_jiffies(IFC_TIMEOUT_MSECS));
> > > > 
> > > > Nicholas,
> > > > Your patch makes me think that this timeout value should be calculated
> > > > once during initialization and stored in a new member of
> > > > struct fsl_ifc_mtd. That would improve readability AND have some
> > > > positive impact on performance.
> > > >
> > > 
> > > is it not a bit wasteful to put it into struct fsl_ifc_mtd
> > > which is used quite often in here ?cho
> > 
> > Storing the timeout in the private structure would use 4 or 8 bytes,
> > but the structure is passed around as pointer reference, so there is
> > no added overhead there.
> >  
> > > #define IFC_TIMEOUT msecs_to_jiffies(500)
> > >
> > > sould do - its only referenced twice and would achieve what you
> > > suggested - initializing it in one location and improved readability
> > > 
> > > 	wait_event_timeout(ctrl->nand_wait, ctrl->nand_stat, IFC_TIMEOUT);
> > > 
> > > would there be any disadvantage of this solution?
> > 
> > I don't have an issue with the compactness of your code. The issue
> > to me is that msecs_to_jiffies() is a real function call, not a macro.
> > That means that there would be a branch to that function followed by a
> > non-trivial calculation *every* time fsl_ifc_run_command() is called.
> > 
> > If the timeout value were calculated during init, then the cost of
> > accessing it would simply a pointer dereference.
> 
> Nicholas, any progress on that builtin_const_p variant
>
did not get to it yet - but thats the next thing
on my fun list.

thx!
hofrat

WARNING: multiple messages have this Message-ID (diff)
From: Nicholas Mc Guire <der.herr@hofr.at>
To: Joe Perches <joe@perches.com>
Cc: Aaron Sierra <asierra@xes-inc.com>,
	Nicholas Mc Guire <hofrat@osadl.org>,
	David Woodhouse <dwmw2@infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	Joe Schultz <jschultz@xes-inc.com>,
	Wolfram Sang <wsa@the-dreams.de>,
	linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mtd: fsl_ifc_nand: use msecs_to_jiffies for time conversion
Date: Thu, 2 Apr 2015 02:20:20 +0200	[thread overview]
Message-ID: <20150402002020.GA30284@opentech.at> (raw)
In-Reply-To: <1427901535.31790.10.camel@perches.com>

On Wed, 01 Apr 2015, Joe Perches wrote:

> On Wed, 2015-04-01 at 10:08 -0500, Aaron Sierra wrote:
> > ----- Original Message -----
> > > From: "Nicholas Mc Guire" <der.herr@hofr.at>
> > > Sent: Wednesday, April 1, 2015 9:24:44 AM
> > > 
> > > On Wed, 01 Apr 2015, Aaron Sierra wrote:
> > > 
> > > > ----- Original Message -----
> > > > > From: "Nicholas Mc Guire" <hofrat@osadl.org>
> > > > > Sent: Friday, March 13, 2015 6:23:47 AM
> > > > > 
> > > > > This is only an API consolidation and should make things more readable
> > > > > it replaces var * HZ / 1000 by msecs_to_jiffies(var) which helps
> > > > > readability
> > > > > and also handles all corner-cases properly.
> > > > > 
> > > > > Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> > > > > ---
> > > > > 
> > > > > Patch was compile tested with corenet64_smp_defconfig
> > > > > (implies CONFIG_MTD_NAND_FSL_IFC=y)
> > > > > 
> > > > > Patch is against 4.0-rc3 (localversion-next is -next-20150313
> > > > > 
> > > > >  drivers/mtd/nand/fsl_ifc_nand.c |    4 ++--
> > > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/mtd/nand/fsl_ifc_nand.c
> > > > > b/drivers/mtd/nand/fsl_ifc_nand.c
> > > > > index 4c05f4f..51394e5 100644
> > > > > --- a/drivers/mtd/nand/fsl_ifc_nand.c
> > > > > +++ b/drivers/mtd/nand/fsl_ifc_nand.c
> > > > > @@ -317,7 +317,7 @@ static void fsl_ifc_run_command(struct mtd_info *mtd)
> > > > >  
> > > > >  	/* wait for command complete flag or timeout */
> > > > >  	wait_event_timeout(ctrl->nand_wait, ctrl->nand_stat,
> > > > > -			   IFC_TIMEOUT_MSECS * HZ/1000);
> > > > > +			   msecs_to_jiffies(IFC_TIMEOUT_MSECS));
> > > > 
> > > > Nicholas,
> > > > Your patch makes me think that this timeout value should be calculated
> > > > once during initialization and stored in a new member of
> > > > struct fsl_ifc_mtd. That would improve readability AND have some
> > > > positive impact on performance.
> > > >
> > > 
> > > is it not a bit wasteful to put it into struct fsl_ifc_mtd
> > > which is used quite often in here ?cho
> > 
> > Storing the timeout in the private structure would use 4 or 8 bytes,
> > but the structure is passed around as pointer reference, so there is
> > no added overhead there.
> >  
> > > #define IFC_TIMEOUT msecs_to_jiffies(500)
> > >
> > > sould do - its only referenced twice and would achieve what you
> > > suggested - initializing it in one location and improved readability
> > > 
> > > 	wait_event_timeout(ctrl->nand_wait, ctrl->nand_stat, IFC_TIMEOUT);
> > > 
> > > would there be any disadvantage of this solution?
> > 
> > I don't have an issue with the compactness of your code. The issue
> > to me is that msecs_to_jiffies() is a real function call, not a macro.
> > That means that there would be a branch to that function followed by a
> > non-trivial calculation *every* time fsl_ifc_run_command() is called.
> > 
> > If the timeout value were calculated during init, then the cost of
> > accessing it would simply a pointer dereference.
> 
> Nicholas, any progress on that builtin_const_p variant
>
did not get to it yet - but thats the next thing
on my fun list.

thx!
hofrat

  reply	other threads:[~2015-04-02  0:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-13 11:23 [PATCH] mtd: fsl_ifc_nand: use msecs_to_jiffies for time conversion Nicholas Mc Guire
2015-03-13 11:23 ` Nicholas Mc Guire
2015-04-01 13:58 ` Aaron Sierra
2015-04-01 13:58   ` Aaron Sierra
2015-04-01 14:24   ` Nicholas Mc Guire
2015-04-01 14:24     ` Nicholas Mc Guire
2015-04-01 15:08     ` Aaron Sierra
2015-04-01 15:08       ` Aaron Sierra
2015-04-01 15:18       ` Joe Perches
2015-04-01 15:18         ` Joe Perches
2015-04-02  0:20         ` Nicholas Mc Guire [this message]
2015-04-02  0:20           ` Nicholas Mc Guire
2015-04-06  1:05 ` Brian Norris
2015-04-06  1:05   ` Brian Norris

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=20150402002020.GA30284@opentech.at \
    --to=der.herr@hofr.at \
    --cc=asierra@xes-inc.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=hofrat@osadl.org \
    --cc=joe@perches.com \
    --cc=jschultz@xes-inc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=wsa@the-dreams.de \
    /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.