All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <dave-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
To: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
Cc: Mike Waychison <mikew-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	jeremy-TSDbQ3PG+2Y@public.gmane.org,
	arnd-r2nGTMty4D4@public.gmane.org,
	linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
	Linux Torvalds <torvalds-3NddpPZAyC0@public.gmane.org>,
	Alexander Viro
	<viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>,
	"H. Peter Anvin" <hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>,
	Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>,
	Ingo Molnar <mingo-X9Un+BFzKDI@public.gmane.org>
Subject: Re: [RFC v11][PATCH 05/13] Dump memory address space
Date: Thu, 18 Dec 2008 07:54:36 -0800	[thread overview]
Message-ID: <1229615676.17206.518.camel@nimitz> (raw)
In-Reply-To: <494A2F94.2090800-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>

On Thu, 2008-12-18 at 06:10 -0500, Oren Laadan wrote:
> >> +    for (i = pgarr->nr_used; i--; /**/)
> >> +        page_cache_release(pgarr->pages[i]);
> > 
> > This is sorta hard to read (and non-intuitive).  Is it easier to do:
> > 
> > for (i = 0; i < pgarr->nr_used; i++)
> >     page_cache_release(pgarr->pages[i]);
> > 
> > It shouldn't matter what order you release the pages in..
> 
> Was meant to avoid a dereference to 'pgarr->nr_used' in the comparison.
> (though I doubt if the performance impact is at all visible)

That's a bit to aggressive an optimization.  You two piqued my
curiosity, so I tried a little experiment with this .c file:

extern void bar(int i);

struct s {
        int *array;
        int size;
};

extern struct s *s;
void foo(void)
{
        int i;
#ifdef OREN
        for (i = s->size; i--; )
#else
        for (i = 0; i < s->size; i++)
#endif
                bar(s->array[i]);
}

for O in "" -O -O1 -O2 -O3 -Os; do
	gcc -DOREN $O -c f1.c -o oren.o;
	gcc $O -c f1.c -o mike.o;
	echo -n Oren:; objdump -d oren.o | grep ret;
	echo -n Mike:; objdump -d mike.o | grep ret;
done

Smaller numbers are better, and indicate the size of that function,
basically:

Oren:  38:	c3                   	ret    
Mike:  3b:	c3                   	ret    
Oren:  44:	c3                   	ret    
Mike:  36:	c3                   	ret    
Oren:  44:	c3                   	ret    
Mike:  36:	c3                   	ret    
Oren:  43:	c3                   	ret    
Mike:  34:	c3                   	ret    
Oren:  43:	c3                   	ret    
Mike:  34:	c3                   	ret    
Oren:  3a:	c3                   	ret    
Mike:  2a:	c3                   	ret    

gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3).  In all but the unoptimized
case, Mike's version wins.  Readability, and icache footprint all in one
package!

-- Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-api" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Dave Hansen <dave@linux.vnet.ibm.com>
To: Oren Laadan <orenl@cs.columbia.edu>
Cc: Mike Waychison <mikew@google.com>,
	jeremy@goop.org, arnd@arndb.de, linux-api@vger.kernel.org,
	containers@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Linux Torvalds <torvalds@linux-foundation.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>
Subject: Re: [RFC v11][PATCH 05/13] Dump memory address space
Date: Thu, 18 Dec 2008 07:54:36 -0800	[thread overview]
Message-ID: <1229615676.17206.518.camel@nimitz> (raw)
In-Reply-To: <494A2F94.2090800@cs.columbia.edu>

On Thu, 2008-12-18 at 06:10 -0500, Oren Laadan wrote:
> >> +    for (i = pgarr->nr_used; i--; /**/)
> >> +        page_cache_release(pgarr->pages[i]);
> > 
> > This is sorta hard to read (and non-intuitive).  Is it easier to do:
> > 
> > for (i = 0; i < pgarr->nr_used; i++)
> >     page_cache_release(pgarr->pages[i]);
> > 
> > It shouldn't matter what order you release the pages in..
> 
> Was meant to avoid a dereference to 'pgarr->nr_used' in the comparison.
> (though I doubt if the performance impact is at all visible)

That's a bit to aggressive an optimization.  You two piqued my
curiosity, so I tried a little experiment with this .c file:

extern void bar(int i);

struct s {
        int *array;
        int size;
};

extern struct s *s;
void foo(void)
{
        int i;
#ifdef OREN
        for (i = s->size; i--; )
#else
        for (i = 0; i < s->size; i++)
#endif
                bar(s->array[i]);
}

for O in "" -O -O1 -O2 -O3 -Os; do
	gcc -DOREN $O -c f1.c -o oren.o;
	gcc $O -c f1.c -o mike.o;
	echo -n Oren:; objdump -d oren.o | grep ret;
	echo -n Mike:; objdump -d mike.o | grep ret;
done

Smaller numbers are better, and indicate the size of that function,
basically:

Oren:  38:	c3                   	ret    
Mike:  3b:	c3                   	ret    
Oren:  44:	c3                   	ret    
Mike:  36:	c3                   	ret    
Oren:  44:	c3                   	ret    
Mike:  36:	c3                   	ret    
Oren:  43:	c3                   	ret    
Mike:  34:	c3                   	ret    
Oren:  43:	c3                   	ret    
Mike:  34:	c3                   	ret    
Oren:  3a:	c3                   	ret    
Mike:  2a:	c3                   	ret    

gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3).  In all but the unoptimized
case, Mike's version wins.  Readability, and icache footprint all in one
package!

-- Dave


WARNING: multiple messages have this Message-ID (diff)
From: Dave Hansen <dave@linux.vnet.ibm.com>
To: Oren Laadan <orenl@cs.columbia.edu>
Cc: Mike Waychison <mikew@google.com>,
	jeremy@goop.org, arnd@arndb.de, linux-api@vger.kernel.org,
	containers@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Linux Torvalds <torvalds@osdl.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>
Subject: Re: [RFC v11][PATCH 05/13] Dump memory address space
Date: Thu, 18 Dec 2008 07:54:36 -0800	[thread overview]
Message-ID: <1229615676.17206.518.camel@nimitz> (raw)
In-Reply-To: <494A2F94.2090800@cs.columbia.edu>

On Thu, 2008-12-18 at 06:10 -0500, Oren Laadan wrote:
> >> +    for (i = pgarr->nr_used; i--; /**/)
> >> +        page_cache_release(pgarr->pages[i]);
> > 
> > This is sorta hard to read (and non-intuitive).  Is it easier to do:
> > 
> > for (i = 0; i < pgarr->nr_used; i++)
> >     page_cache_release(pgarr->pages[i]);
> > 
> > It shouldn't matter what order you release the pages in..
> 
> Was meant to avoid a dereference to 'pgarr->nr_used' in the comparison.
> (though I doubt if the performance impact is at all visible)

That's a bit to aggressive an optimization.  You two piqued my
curiosity, so I tried a little experiment with this .c file:

extern void bar(int i);

struct s {
        int *array;
        int size;
};

extern struct s *s;
void foo(void)
{
        int i;
#ifdef OREN
        for (i = s->size; i--; )
#else
        for (i = 0; i < s->size; i++)
#endif
                bar(s->array[i]);
}

for O in "" -O -O1 -O2 -O3 -Os; do
	gcc -DOREN $O -c f1.c -o oren.o;
	gcc $O -c f1.c -o mike.o;
	echo -n Oren:; objdump -d oren.o | grep ret;
	echo -n Mike:; objdump -d mike.o | grep ret;
done

Smaller numbers are better, and indicate the size of that function,
basically:

Oren:  38:	c3                   	ret    
Mike:  3b:	c3                   	ret    
Oren:  44:	c3                   	ret    
Mike:  36:	c3                   	ret    
Oren:  44:	c3                   	ret    
Mike:  36:	c3                   	ret    
Oren:  43:	c3                   	ret    
Mike:  34:	c3                   	ret    
Oren:  43:	c3                   	ret    
Mike:  34:	c3                   	ret    
Oren:  3a:	c3                   	ret    
Mike:  2a:	c3                   	ret    

gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3).  In all but the unoptimized
case, Mike's version wins.  Readability, and icache footprint all in one
package!

-- Dave

--
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-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2008-12-18 15:54 UTC|newest]

Thread overview: 132+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-05 17:31 [RFC v11][PATCH 00/13] Kernel based checkpoint/restart Oren Laadan
2008-12-05 17:31 ` Oren Laadan
2008-12-05 17:31 ` Oren Laadan
2008-12-05 17:31 ` [RFC v11][PATCH 01/13] Create syscalls: sys_checkpoint, sys_restart Oren Laadan
2008-12-05 17:31   ` Oren Laadan
2008-12-05 17:31   ` Oren Laadan
2008-12-05 17:31 ` [RFC v11][PATCH 04/13] x86 support for checkpoint/restart Oren Laadan
2008-12-05 17:31   ` Oren Laadan
2008-12-05 17:31   ` Oren Laadan
     [not found]   ` <1228498282-11804-5-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-12-17  2:19     ` Mike Waychison
2008-12-17  2:19   ` Mike Waychison
2008-12-17  2:19     ` Mike Waychison
2008-12-17 15:23     ` Oren Laadan
2008-12-17 15:23       ` Oren Laadan
     [not found]     ` <494861CA.8000403-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2008-12-17 15:23       ` Oren Laadan
2008-12-05 17:31 ` [RFC v11][PATCH 06/13] Restore memory address space Oren Laadan
2008-12-05 17:31   ` Oren Laadan
2008-12-05 17:31   ` Oren Laadan
2008-12-05 17:31 ` [RFC v11][PATCH 10/13] External checkpoint of a task other than ourself Oren Laadan
2008-12-05 17:31 ` Oren Laadan
2008-12-05 17:31   ` Oren Laadan
2008-12-05 17:31 ` [RFC v11][PATCH 13/13] Restart multiple processes Oren Laadan
2008-12-05 17:31   ` Oren Laadan
2008-12-05 17:31 ` Oren Laadan
     [not found] ` <1228498282-11804-1-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-12-05 17:31   ` [RFC v11][PATCH 01/13] Create syscalls: sys_checkpoint, sys_restart Oren Laadan
2008-12-05 17:31   ` [RFC v11][PATCH 02/13] Checkpoint/restart: initial documentation Oren Laadan
2008-12-05 17:31   ` Oren Laadan
2008-12-05 17:31     ` Oren Laadan
2008-12-05 17:31     ` Oren Laadan
2008-12-05 17:31   ` [RFC v11][PATCH 03/13] General infrastructure for checkpoint restart Oren Laadan
2008-12-05 17:31     ` Oren Laadan
2008-12-05 17:31     ` Oren Laadan
     [not found]     ` <1228498282-11804-4-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-12-06  7:26       ` Joe Perches
2008-12-06  7:26       ` Joe Perches
2008-12-06  7:26         ` Joe Perches
2008-12-06  7:26         ` Joe Perches
2008-12-16 19:04       ` Mike Waychison
2008-12-16 21:54       ` Mike Waychison
2008-12-16 19:04     ` Mike Waychison
2008-12-16 19:04       ` Mike Waychison
     [not found]       ` <4947FBC8.2000601-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2008-12-16 19:28         ` Linus Torvalds
2008-12-16 19:28       ` Linus Torvalds
2008-12-16 19:28         ` Linus Torvalds
2008-12-16 21:54     ` Mike Waychison
2008-12-16 21:54       ` Mike Waychison
2008-12-16 22:14       ` Dave Hansen
2008-12-16 22:14         ` Dave Hansen
2008-12-16 22:43         ` Mike Waychison
2008-12-16 22:43           ` Mike Waychison
2008-12-17  0:13           ` Dave Hansen
2008-12-17  0:13             ` Dave Hansen
     [not found]           ` <49482F14.1040407-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2008-12-17  0:13             ` Dave Hansen
2008-12-16 22:43         ` Mike Waychison
2008-12-16 23:42         ` Oren Laadan
2008-12-16 23:42         ` Oren Laadan
2008-12-16 23:42           ` Oren Laadan
     [not found]           ` <49483D01.1050603-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-12-17  0:42             ` Mike Waychison
2008-12-17  0:42           ` Mike Waychison
2008-12-17  0:42             ` Mike Waychison
2008-12-17  2:08             ` Oren Laadan
2008-12-17  2:08               ` Oren Laadan
     [not found]             ` <49484AE2.3000007-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2008-12-17  2:08               ` Oren Laadan
     [not found]       ` <49482394.10006-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2008-12-16 22:14         ` Dave Hansen
2008-12-05 17:31   ` Oren Laadan
2008-12-05 17:31   ` [RFC v11][PATCH 04/13] x86 support for checkpoint/restart Oren Laadan
2008-12-05 17:31   ` [RFC v11][PATCH 05/13] Dump memory address space Oren Laadan
2008-12-05 17:31   ` Oren Laadan
2008-12-05 17:31     ` Oren Laadan
2008-12-05 17:31     ` Oren Laadan
     [not found]     ` <1228498282-11804-6-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-12-18  2:26       ` Mike Waychison
2008-12-18  2:26     ` Mike Waychison
2008-12-18  2:26       ` Mike Waychison
     [not found]       ` <4949B4ED.9060805-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2008-12-18 11:10         ` Oren Laadan
2008-12-18 11:10       ` Oren Laadan
2008-12-18 11:10         ` Oren Laadan
     [not found]         ` <494A2F94.2090800-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-12-18 15:05           ` Dave Hansen
2008-12-18 15:05             ` Dave Hansen
2008-12-18 15:05             ` Dave Hansen
2008-12-18 15:05           ` Dave Hansen
2008-12-18 15:54           ` Dave Hansen [this message]
2008-12-18 15:54             ` Dave Hansen
2008-12-18 15:54             ` Dave Hansen
2008-12-18 20:00             ` Oren Laadan
2008-12-18 20:00               ` Oren Laadan
2008-12-18 20:00             ` Oren Laadan
2008-12-18 15:54           ` Dave Hansen
2008-12-18 18:15           ` Mike Waychison
2008-12-18 18:15         ` Mike Waychison
2008-12-18 18:15           ` Mike Waychison
     [not found]           ` <494A9350.1060309-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2008-12-18 18:21             ` Dave Hansen
2008-12-18 18:21               ` Dave Hansen
2008-12-18 18:21               ` Dave Hansen
2008-12-18 18:21             ` Dave Hansen
2008-12-18 20:11             ` Oren Laadan
2008-12-18 20:11           ` Oren Laadan
2008-12-18 20:11             ` Oren Laadan
2008-12-05 17:31   ` [RFC v11][PATCH 06/13] Restore " Oren Laadan
2008-12-05 17:31   ` [RFC v11][PATCH 07/13] Infrastructure for shared objects Oren Laadan
2008-12-05 17:31   ` Oren Laadan
2008-12-05 17:31     ` Oren Laadan
2008-12-05 17:31     ` Oren Laadan
2008-12-05 17:31   ` [RFC v11][PATCH 08/13] Dump open file descriptors Oren Laadan
2008-12-05 17:31     ` Oren Laadan
2008-12-05 17:31     ` Oren Laadan
2008-12-05 17:31   ` Oren Laadan
2008-12-05 17:31   ` [RFC v11][PATCH 09/13] Restore open file descriprtors Oren Laadan
2008-12-05 17:31   ` Oren Laadan
2008-12-05 17:31     ` Oren Laadan
2008-12-05 17:31     ` Oren Laadan
2008-12-05 17:31   ` [RFC v11][PATCH 10/13] External checkpoint of a task other than ourself Oren Laadan
2008-12-05 17:31   ` Oren Laadan
2008-12-05 17:31   ` [RFC v11][PATCH 11/13] Track in-kernel when we expect checkpoint/restart to work Oren Laadan
2008-12-05 17:31   ` Oren Laadan
2008-12-05 17:31     ` Oren Laadan
2008-12-05 17:31     ` Oren Laadan
2008-12-05 17:31   ` [RFC v11][PATCH 12/13] Checkpoint multiple processes Oren Laadan
2008-12-05 17:31   ` Oren Laadan
2008-12-05 17:31     ` Oren Laadan
2008-12-05 17:31     ` Oren Laadan
2008-12-05 17:31   ` [RFC v11][PATCH 13/13] Restart " Oren Laadan
2008-12-05 17:31   ` Oren Laadan
2008-12-06  0:19   ` [RFC v11][PATCH 00/13] Kernel based checkpoint/restart Serge E. Hallyn
2008-12-06  0:19   ` Serge E. Hallyn
2008-12-06  0:19     ` Serge E. Hallyn
2008-12-06  0:19     ` Serge E. Hallyn
2008-12-09 19:42   ` Serge E. Hallyn
2008-12-09 19:42   ` Serge E. Hallyn
2008-12-09 19:42     ` Serge E. Hallyn
2008-12-09 19:42     ` Serge E. Hallyn
2008-12-16 18:43   ` Dave Hansen
2008-12-16 18:43 ` Dave Hansen
2008-12-16 18:43   ` Dave Hansen

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=1229615676.17206.518.camel@nimitz \
    --to=dave-23vcf4htsmix0ybbhkvfkdbpr1lh4cv8@public.gmane.org \
    --cc=arnd-r2nGTMty4D4@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org \
    --cc=jeremy-TSDbQ3PG+2Y@public.gmane.org \
    --cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
    --cc=mikew-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=mingo-X9Un+BFzKDI@public.gmane.org \
    --cc=orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org \
    --cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
    --cc=torvalds-3NddpPZAyC0@public.gmane.org \
    --cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org \
    /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.