linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pre7-1 semicolon & nicely readable
@ 2000-05-01 14:46 Rik van Riel
  0 siblings, 0 replies; 2+ messages in thread
From: Rik van Riel @ 2000-05-01 14:46 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-mm, linux-kernel

Hi Linus,

after getting a number of complaints that the semicolon
thing wasn't nicely readable (they're right) I changed my
code as per the patch below.

Could you please put the more readable version in the
next pre kernel?

thanks,

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/



--- mm/vmscan.c.org2	Sat Apr 29 06:53:00 2000
+++ mm/vmscan.c	Mon May  1 11:42:34 2000
@@ -384,11 +384,12 @@
 			for (; p != &init_task; p = p->next_task) {
 				int i = 0;
 				struct mm_struct *mm = p->mm;
-				if (!p->swappable || !mm || mm->rss <= 0)
+				if (!p->swappable || !mm || mm->swap_cnt <= 0)
 					continue;
 				/* small processes are swapped out less */
 				while ((mm->swap_cnt << 2 * (i + 1) < max_cnt)
-						&& i++ < 10)
+						&& i < 10)
+					i++;
 				mm->swap_cnt >>= i;
 				mm->swap_cnt += i; /* if swap_cnt reaches 0 */
 				/* we're big -> hog treatment */

--
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] 2+ 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
  0 siblings, 1 reply; 2+ 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] 2+ messages in thread

end of thread, other threads:[~2000-05-02  1:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-01 14:46 [PATCH] pre7-1 semicolon & nicely readable Rik van Riel
2000-05-02  1:28 [PATCH] pre7-1 semicolon & nicely readableB Rik van Riel
2000-05-02  1:38 ` [PATCH] pre7-1 semicolon & nicely readable Roel van der Goot

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