* Re: [PATCH] pre7-1 semicolon & nicely readableB
@ 2000-05-02 1:08 Roel van der Goot
2000-05-02 1:28 ` Rik van Riel
0 siblings, 1 reply; 5+ messages in thread
From: Roel van der Goot @ 2000-05-02 1:08 UTC (permalink / raw)
To: riel; +Cc: linux-mm, linux-kernel
Hi Rik,
I want to inform you that there is a subtle difference between
the following two loops:
(i)
while ((mm->swap_cnt << 2 * (i + 1) < max_cnt)
&& i++ < 10);
(ii)
while ((mm->swap_cnt << 2 * (i + 1) < max_cnt)
&& i < 10)
i++;
Cheers,
Roel.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] pre7-1 semicolon & nicely readableB
2000-05-02 1:08 [PATCH] pre7-1 semicolon & nicely readableB Roel van der Goot
@ 2000-05-02 1:28 ` Rik van Riel
2000-05-02 1:38 ` [PATCH] pre7-1 semicolon & nicely readable Roel van der Goot
2000-05-02 10:54 ` [PATCH] pre7-1 semicolon & nicely readableB Chris Evans
0 siblings, 2 replies; 5+ messages in thread
From: Rik van Riel @ 2000-05-02 1:28 UTC (permalink / raw)
To: Roel van der Goot; +Cc: linux-mm, linux-kernel
On Mon, 1 May 2000, Roel van der Goot wrote:
> I want to inform you that there is a subtle difference between
> the following two loops:
>
> (i)
>
> while ((mm->swap_cnt << 2 * (i + 1) < max_cnt)
> && i++ < 10);
>
> (ii)
>
> while ((mm->swap_cnt << 2 * (i + 1) < max_cnt)
> && i < 10)
> i++;
I want to inform you that you're wrong. The only difference is
in readability.
If the first test fails, the clause behind the && won't be run.
Furthermore, i will only reach 10 if the RSS difference between
the current process and the biggest process is more than a factor
2^21 ... which can never happen on 32-bit hardware, unless the
RSS of the current process is 0.
In fact, the <10 test is only there to prevent infinite looping
for when a process with 0 swap_cnt "slips through" the tests above.
regards,
Rik
--
The Internet is not a network of computers. It is a network
of people. That is its real strength.
Wanna talk about the kernel? irc.openprojects.net / #kernelnewbies
http://www.conectiva.com/ http://www.surriel.com/
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] pre7-1 semicolon & nicely readable
2000-05-02 1:28 ` Rik van Riel
@ 2000-05-02 1:38 ` Roel van der Goot
2000-05-02 10:54 ` [PATCH] pre7-1 semicolon & nicely readableB Chris Evans
1 sibling, 0 replies; 5+ messages in thread
From: Roel van der Goot @ 2000-05-02 1:38 UTC (permalink / raw)
To: riel; +Cc: linux-mm, linux-kernel
On Mon, 1 May 2000, Rik van Riel wrote:
> In fact, the <10 test is only there to prevent infinite looping
> for when a process with 0 swap_cnt "slips through" the tests above.
In case of a "slip through" variable i will have a different
value after the loop. But I understand from your reply that you
covered that case.
Cheers,
Roel.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] pre7-1 semicolon & nicely readableB
2000-05-02 1:28 ` Rik van Riel
2000-05-02 1:38 ` [PATCH] pre7-1 semicolon & nicely readable Roel van der Goot
@ 2000-05-02 10:54 ` Chris Evans
2000-05-02 11:19 ` Rik van Riel
1 sibling, 1 reply; 5+ messages in thread
From: Chris Evans @ 2000-05-02 10:54 UTC (permalink / raw)
To: riel; +Cc: Roel van der Goot, linux-mm, linux-kernel
On Mon, 1 May 2000, Rik van Riel wrote:
> I want to inform you that you're wrong. The only difference is
> in readability.
[..]
> In fact, the <10 test is only there to prevent infinite looping
> for when a process with 0 swap_cnt "slips through" the tests above.
If such a value should never "slip through", then, for readability, you
want an assert (e.g. BUG() ).
Chris
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] pre7-1 semicolon & nicely readableB
2000-05-02 10:54 ` [PATCH] pre7-1 semicolon & nicely readableB Chris Evans
@ 2000-05-02 11:19 ` Rik van Riel
0 siblings, 0 replies; 5+ messages in thread
From: Rik van Riel @ 2000-05-02 11:19 UTC (permalink / raw)
To: Chris Evans; +Cc: Roel van der Goot, linux-mm, linux-kernel
On Tue, 2 May 2000, Chris Evans wrote:
> On Mon, 1 May 2000, Rik van Riel wrote:
>
> > I want to inform you that you're wrong. The only difference is
> > in readability.
>
> [..]
>
> > In fact, the <10 test is only there to prevent infinite looping
> > for when a process with 0 swap_cnt "slips through" the tests above.
>
> If such a value should never "slip through", then, for
> readability, you want an assert (e.g. BUG() ).
It's ok for them to slip through, it's just not ok for the kernel
to go into an infinite loop here...
Rik
--
The Internet is not a network of computers. It is a network
of people. That is its real strength.
Wanna talk about the kernel? irc.openprojects.net / #kernelnewbies
http://www.conectiva.com/ http://www.surriel.com/
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2000-05-02 11:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-02 1:08 [PATCH] pre7-1 semicolon & nicely readableB Roel van der Goot
2000-05-02 1:28 ` Rik van Riel
2000-05-02 1:38 ` [PATCH] pre7-1 semicolon & nicely readable Roel van der Goot
2000-05-02 10:54 ` [PATCH] pre7-1 semicolon & nicely readableB Chris Evans
2000-05-02 11:19 ` Rik van Riel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox