The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 1/1] drivers/s390/cio/qdio_main.c: replace shift loop by ilog2
@ 2014-05-20 16:37 Fabian Frederick
  2014-05-20 16:45 ` Joe Perches
  2014-06-02 14:41 ` Sebastian Ott
  0 siblings, 2 replies; 7+ messages in thread
From: Fabian Frederick @ 2014-05-20 16:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Sebastian Ott, akpm


This is untested.

Cc: Sebastian Ott <sebott@linux.vnet.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 drivers/s390/cio/qdio_main.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c
index 77466c4..8bf9ec1 100644
--- a/drivers/s390/cio/qdio_main.c
+++ b/drivers/s390/cio/qdio_main.c
@@ -411,15 +411,14 @@ static inline void qdio_stop_polling(struct qdio_q *q)
 
 static inline void account_sbals(struct qdio_q *q, int count)
 {
-	int pos = 0;
+	int pos;
 
 	q->q_stats.nr_sbal_total += count;
 	if (count == QDIO_MAX_BUFFERS_MASK) {
 		q->q_stats.nr_sbals[7]++;
 		return;
 	}
-	while (count >>= 1)
-		pos++;
+	pos = ilog2(count);
 	q->q_stats.nr_sbals[pos]++;
 }
 
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] drivers/s390/cio/qdio_main.c: replace shift loop by ilog2
  2014-05-20 16:37 [PATCH 1/1] drivers/s390/cio/qdio_main.c: replace shift loop by ilog2 Fabian Frederick
@ 2014-05-20 16:45 ` Joe Perches
  2014-05-21 12:32   ` Sebastian Ott
  2014-06-02 14:41 ` Sebastian Ott
  1 sibling, 1 reply; 7+ messages in thread
From: Joe Perches @ 2014-05-20 16:45 UTC (permalink / raw)
  To: Fabian Frederick; +Cc: linux-kernel, Sebastian Ott, akpm

On Tue, 2014-05-20 at 18:37 +0200, Fabian Frederick wrote:
> This is untested.
[]
> diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c
[]
> @@ -411,15 +411,14 @@ static inline void qdio_stop_polling(struct qdio_q *q)
>  
>  static inline void account_sbals(struct qdio_q *q, int count)
>  {
> -	int pos = 0;
> +	int pos;
>  
>  	q->q_stats.nr_sbal_total += count;
>  	if (count == QDIO_MAX_BUFFERS_MASK) {
>  		q->q_stats.nr_sbals[7]++;
>  		return;
>  	}
> -	while (count >>= 1)
> -		pos++;
> +	pos = ilog2(count);

What guarantees count > 0 here?

count may be better unsigned.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] drivers/s390/cio/qdio_main.c: replace shift loop by ilog2
  2014-05-20 16:45 ` Joe Perches
@ 2014-05-21 12:32   ` Sebastian Ott
  0 siblings, 0 replies; 7+ messages in thread
From: Sebastian Ott @ 2014-05-21 12:32 UTC (permalink / raw)
  To: Joe Perches, Ursula Braun; +Cc: Fabian Frederick, linux-kernel, akpm

On Tue, 20 May 2014, Joe Perches wrote:
> On Tue, 2014-05-20 at 18:37 +0200, Fabian Frederick wrote:
> > This is untested.
> []
> > diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c
> []
> > @@ -411,15 +411,14 @@ static inline void qdio_stop_polling(struct qdio_q *q)
> >  
> >  static inline void account_sbals(struct qdio_q *q, int count)
> >  {
> > -	int pos = 0;
> > +	int pos;
> >  
> >  	q->q_stats.nr_sbal_total += count;
> >  	if (count == QDIO_MAX_BUFFERS_MASK) {
> >  		q->q_stats.nr_sbals[7]++;
> >  		return;
> >  	}
> > -	while (count >>= 1)
> > -		pos++;
> > +	pos = ilog2(count);
> 
> What guarantees count > 0 here?

We would already be screwed when called with count < 0. Ursula, do the
callers assure that count is positive?

Regards,
Sebastian
> 
> count may be better unsigned.
> 
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] drivers/s390/cio/qdio_main.c: replace shift loop by ilog2
       [not found] <OF57E68FFD.38663B1A-ONC1257CE0.00383C6B-C1257CE0.0038457A@de.ibm.com>
@ 2014-05-22 10:22 ` Ursula Braun
  0 siblings, 0 replies; 7+ messages in thread
From: Ursula Braun @ 2014-05-22 10:22 UTC (permalink / raw)
  To: Sebastian Ott
  Cc: Joe Perches, ursula.braun, Fabian Frederick, linux-kernel, akpm

yes, the callers guarantee that count > 0 here.

Regards, Ursula Braun

On Thu, 2014-05-22 at 12:14 +0200, Ursula Braun1 wrote:
> From:        Sebastian Ott <sebott@linux.vnet.ibm.com> 
> To:        Joe Perches <joe@perches.com>, Ursula
> Braun1/Germany/IBM@IBMDE, 
> Cc:        Fabian Frederick <fabf@skynet.be>, linux-kernel
> <linux-kernel@vger.kernel.org>, akpm <akpm@linux-foundation.org> 
> Date:        21/05/2014 14:32 
> Subject:        Re: [PATCH 1/1] drivers/s390/cio/qdio_main.c: replace
> shift loop by ilog2 
> 
> ______________________________________________________________________
> 
> 
> 
> On Tue, 20 May 2014, Joe Perches wrote:
> > On Tue, 2014-05-20 at 18:37 +0200, Fabian Frederick wrote:
> > > This is untested.
> > []
> > > diff --git a/drivers/s390/cio/qdio_main.c
> b/drivers/s390/cio/qdio_main.c
> > []
> > > @@ -411,15 +411,14 @@ static inline void qdio_stop_polling(struct
> qdio_q *q)
> > >  
> > >  static inline void account_sbals(struct qdio_q *q, int count)
> > >  {
> > > -                 int pos = 0;
> > > +                 int pos;
> > >  
> > >                   q->q_stats.nr_sbal_total += count;
> > >                   if (count == QDIO_MAX_BUFFERS_MASK) {
> > >                                    q->q_stats.nr_sbals[7]++;
> > >                                    return;
> > >                   }
> > > -                 while (count >>= 1)
> > > -                                  pos++;
> > > +                 pos = ilog2(count);
> > 
> > What guarantees count > 0 here?
> 
> We would already be screwed when called with count < 0. Ursula, do the
> callers assure that count is positive?
> 
> Regards,
> Sebastian
> > 
> > count may be better unsigned.
> > 
> > 



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] drivers/s390/cio/qdio_main.c: replace shift loop by ilog2
  2014-05-20 16:37 [PATCH 1/1] drivers/s390/cio/qdio_main.c: replace shift loop by ilog2 Fabian Frederick
  2014-05-20 16:45 ` Joe Perches
@ 2014-06-02 14:41 ` Sebastian Ott
  2014-06-02 18:17   ` Fabian Frederick
  1 sibling, 1 reply; 7+ messages in thread
From: Sebastian Ott @ 2014-06-02 14:41 UTC (permalink / raw)
  To: Fabian Frederick; +Cc: linux-kernel, akpm

Hello Fabian,

On Tue, 20 May 2014, Fabian Frederick wrote:
> 
> This is untested.
> 
> Cc: Sebastian Ott <sebott@linux.vnet.ibm.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Fabian Frederick <fabf@skynet.be>
> ---
>  drivers/s390/cio/qdio_main.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c
> index 77466c4..8bf9ec1 100644
> --- a/drivers/s390/cio/qdio_main.c
> +++ b/drivers/s390/cio/qdio_main.c
> @@ -411,15 +411,14 @@ static inline void qdio_stop_polling(struct qdio_q *q)
> 
>  static inline void account_sbals(struct qdio_q *q, int count)
>  {
> -	int pos = 0;
> +	int pos;
> 
>  	q->q_stats.nr_sbal_total += count;
>  	if (count == QDIO_MAX_BUFFERS_MASK) {
>  		q->q_stats.nr_sbals[7]++;
>  		return;
>  	}
> -	while (count >>= 1)
> -		pos++;
> +	pos = ilog2(count);
>  	q->q_stats.nr_sbals[pos]++;
>  }
> 
> -- 
> 1.8.4.5
> 
> 

Could you please resend the patch with a better description plus
the change Joe suggested.

Thanks,
Sebastian


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] drivers/s390/cio/qdio_main.c: replace shift loop by ilog2
  2014-06-02 14:41 ` Sebastian Ott
@ 2014-06-02 18:17   ` Fabian Frederick
  2014-06-03  7:41     ` Sebastian Ott
  0 siblings, 1 reply; 7+ messages in thread
From: Fabian Frederick @ 2014-06-02 18:17 UTC (permalink / raw)
  To: Sebastian Ott; +Cc: linux-kernel, akpm

On Mon, 2 Jun 2014 16:41:48 +0200 (CEST)
Sebastian Ott <sebott@linux.vnet.ibm.com> wrote:

> Hello Fabian,
> 
> On Tue, 20 May 2014, Fabian Frederick wrote:
> > 
> > This is untested.
> > 
> > Cc: Sebastian Ott <sebott@linux.vnet.ibm.com>
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Signed-off-by: Fabian Frederick <fabf@skynet.be>
> > ---
> >  drivers/s390/cio/qdio_main.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c
> > index 77466c4..8bf9ec1 100644
> > --- a/drivers/s390/cio/qdio_main.c
> > +++ b/drivers/s390/cio/qdio_main.c
> > @@ -411,15 +411,14 @@ static inline void qdio_stop_polling(struct qdio_q *q)
> > 
> >  static inline void account_sbals(struct qdio_q *q, int count)
> >  {
> > -	int pos = 0;
> > +	int pos;
> > 
> >  	q->q_stats.nr_sbal_total += count;
> >  	if (count == QDIO_MAX_BUFFERS_MASK) {
> >  		q->q_stats.nr_sbals[7]++;
> >  		return;
> >  	}
> > -	while (count >>= 1)
> > -		pos++;
> > +	pos = ilog2(count);
> >  	q->q_stats.nr_sbals[pos]++;
> >  }
> > 
> > -- 
> > 1.8.4.5
> > 
> > 
> 
> Could you please resend the patch with a better description plus
> the change Joe suggested.
> 
> Thanks,
> Sebastian

Hello Sebastian,
   Conclusion of that patch/thread was that callers guarantee count to be > 0

Joe suggested to have unsigned count. Is it what you're talking about ?

Regards,
Fabian

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] drivers/s390/cio/qdio_main.c: replace shift loop by ilog2
  2014-06-02 18:17   ` Fabian Frederick
@ 2014-06-03  7:41     ` Sebastian Ott
  0 siblings, 0 replies; 7+ messages in thread
From: Sebastian Ott @ 2014-06-03  7:41 UTC (permalink / raw)
  To: Fabian Frederick; +Cc: linux-kernel, akpm

On Mon, 2 Jun 2014, Fabian Frederick wrote:
> On Mon, 2 Jun 2014 16:41:48 +0200 (CEST)
> Sebastian Ott <sebott@linux.vnet.ibm.com> wrote:
> 
> > Hello Fabian,
> > 
> > On Tue, 20 May 2014, Fabian Frederick wrote:
> > > 
> > > This is untested.
> > > 
> > > Cc: Sebastian Ott <sebott@linux.vnet.ibm.com>
> > > Cc: Andrew Morton <akpm@linux-foundation.org>
> > > Signed-off-by: Fabian Frederick <fabf@skynet.be>
> > > ---
> > >  drivers/s390/cio/qdio_main.c | 5 ++---
> > >  1 file changed, 2 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c
> > > index 77466c4..8bf9ec1 100644
> > > --- a/drivers/s390/cio/qdio_main.c
> > > +++ b/drivers/s390/cio/qdio_main.c
> > > @@ -411,15 +411,14 @@ static inline void qdio_stop_polling(struct qdio_q *q)
> > > 
> > >  static inline void account_sbals(struct qdio_q *q, int count)
> > >  {
> > > -	int pos = 0;
> > > +	int pos;
> > > 
> > >  	q->q_stats.nr_sbal_total += count;
> > >  	if (count == QDIO_MAX_BUFFERS_MASK) {
> > >  		q->q_stats.nr_sbals[7]++;
> > >  		return;
> > >  	}
> > > -	while (count >>= 1)
> > > -		pos++;
> > > +	pos = ilog2(count);
> > >  	q->q_stats.nr_sbals[pos]++;
> > >  }
> > > 
> > > -- 
> > > 1.8.4.5
> > > 
> > > 
> > 
> > Could you please resend the patch with a better description plus
> > the change Joe suggested.
> > 
> > Thanks,
> > Sebastian
> 
> Hello Sebastian,
>    Conclusion of that patch/thread was that callers guarantee count to be > 0

Correct.

> Joe suggested to have unsigned count. Is it what you're talking about ?

Yes.

Regards,
Sebastian


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-06-03  7:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-20 16:37 [PATCH 1/1] drivers/s390/cio/qdio_main.c: replace shift loop by ilog2 Fabian Frederick
2014-05-20 16:45 ` Joe Perches
2014-05-21 12:32   ` Sebastian Ott
2014-06-02 14:41 ` Sebastian Ott
2014-06-02 18:17   ` Fabian Frederick
2014-06-03  7:41     ` Sebastian Ott
     [not found] <OF57E68FFD.38663B1A-ONC1257CE0.00383C6B-C1257CE0.0038457A@de.ibm.com>
2014-05-22 10:22 ` Ursula Braun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox