mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Average number of instructions per line of kernel code
@ 2007-08-30 13:00 Mohamed Bamakhrama
  2007-08-30 13:31 ` Jesper Juhl
  0 siblings, 1 reply; 7+ messages in thread
From: Mohamed Bamakhrama @ 2007-08-30 13:00 UTC (permalink / raw)
  To: linux-mips, linux-kernel

Hi all,
I have a question regarding the average number of assembly
instructions per line of kernel code. I know that this is a difficult
question since it depends on many factors such as the instruction set
architecture, compiler used, optimizations used, type of code, coding
style, etc...
I would like to know a rough estimate for such a quantity for the
kernel 2.4/2.6 code running on MIPS32 architecture.
My estimate is between 5-10 instructions. I googled for such a thing
but couldn't find any useful papers/resources.

Many thanks in advance.

Best regards

-- 
Mohamed A. Bamakhrama

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

* Re: Average number of instructions per line of kernel code
  2007-08-30 13:00 Average number of instructions per line of kernel code Mohamed Bamakhrama
@ 2007-08-30 13:31 ` Jesper Juhl
  2007-08-30 13:48   ` Mohamed Bamakhrama
  0 siblings, 1 reply; 7+ messages in thread
From: Jesper Juhl @ 2007-08-30 13:31 UTC (permalink / raw)
  To: bamakhrama; +Cc: linux-mips, linux-kernel

On 30/08/2007, Mohamed Bamakhrama <bamakhrama@gmail.com> wrote:
> Hi all,
> I have a question regarding the average number of assembly
> instructions per line of kernel code. I know that this is a difficult
> question since it depends on many factors such as the instruction set
> architecture, compiler used, optimizations used, type of code, coding
> style, etc...
> I would like to know a rough estimate for such a quantity for the
> kernel 2.4/2.6 code running on MIPS32 architecture.
> My estimate is between 5-10 instructions. I googled for such a thing
> but couldn't find any useful papers/resources.
>

Why don't you simply count the number of non-blank non-comment lines
in the source files that you are building, build the kernel and then
count the number of instructions in the resulting binary ?

-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

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

* Re: Average number of instructions per line of kernel code
  2007-08-30 13:31 ` Jesper Juhl
@ 2007-08-30 13:48   ` Mohamed Bamakhrama
  2007-08-30 13:54     ` Jesper Juhl
  2007-08-30 16:29     ` J. Scott Kasten
  0 siblings, 2 replies; 7+ messages in thread
From: Mohamed Bamakhrama @ 2007-08-30 13:48 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: linux-mips, linux-kernel

On 8/30/07, Jesper Juhl <jesper.juhl@gmail.com> wrote:
> On 30/08/2007, Mohamed Bamakhrama <bamakhrama@gmail.com> wrote:
> > Hi all,
> > I have a question regarding the average number of assembly
> > instructions per line of kernel code. I know that this is a difficult
> > question since it depends on many factors such as the instruction set
> > architecture, compiler used, optimizations used, type of code, coding
> > style, etc...
> > I would like to know a rough estimate for such a quantity for the
> > kernel 2.4/2.6 code running on MIPS32 architecture.
> > My estimate is between 5-10 instructions. I googled for such a thing
> > but couldn't find any useful papers/resources.
> >
>
> Why don't you simply count the number of non-blank non-comment lines
> in the source files that you are building, build the kernel and then
> count the number of instructions in the resulting binary ?

Hi,
I agree with you but is there any way to include ALL the drivers in
the kernel tree in building the image? Otherwise, I will be counting
un-used lines.

-- 
Mohamed

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

* Re: Average number of instructions per line of kernel code
  2007-08-30 13:48   ` Mohamed Bamakhrama
@ 2007-08-30 13:54     ` Jesper Juhl
  2007-08-30 16:29     ` J. Scott Kasten
  1 sibling, 0 replies; 7+ messages in thread
From: Jesper Juhl @ 2007-08-30 13:54 UTC (permalink / raw)
  To: bamakhrama; +Cc: linux-mips, linux-kernel

On 30/08/2007, Mohamed Bamakhrama <bamakhrama@gmail.com> wrote:
> On 8/30/07, Jesper Juhl <jesper.juhl@gmail.com> wrote:
> > On 30/08/2007, Mohamed Bamakhrama <bamakhrama@gmail.com> wrote:
> > > Hi all,
> > > I have a question regarding the average number of assembly
> > > instructions per line of kernel code. I know that this is a difficult
> > > question since it depends on many factors such as the instruction set
> > > architecture, compiler used, optimizations used, type of code, coding
> > > style, etc...
> > > I would like to know a rough estimate for such a quantity for the
> > > kernel 2.4/2.6 code running on MIPS32 architecture.
> > > My estimate is between 5-10 instructions. I googled for such a thing
> > > but couldn't find any useful papers/resources.
> > >
> >
> > Why don't you simply count the number of non-blank non-comment lines
> > in the source files that you are building, build the kernel and then
> > count the number of instructions in the resulting binary ?
>
> Hi,
> I agree with you but is there any way to include ALL the drivers in
> the kernel tree in building the image? Otherwise, I will be counting
> un-used lines.
>
make allyesconfig
make


-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

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

* Re: Average number of instructions per line of kernel code
  2007-08-30 13:48   ` Mohamed Bamakhrama
  2007-08-30 13:54     ` Jesper Juhl
@ 2007-08-30 16:29     ` J. Scott Kasten
  2007-08-30 19:49       ` Jan Engelhardt
  1 sibling, 1 reply; 7+ messages in thread
From: J. Scott Kasten @ 2007-08-30 16:29 UTC (permalink / raw)
  To: Mohamed Bamakhrama; +Cc: linux-mips, linux-kernel


On Thu, 30 Aug 2007, Mohamed Bamakhrama wrote:
>>> Hi all,
>>> I have a question regarding the average number of assembly
>>> instructions per line of kernel code. I know that this is a difficult
>>> question since it depends on many factors such as the instruction set

Here's a quick answer, not the best, but quick.

I took a user space flash memory driver I'm doing at work and compiled it 
on my R5000 at home using gcc 4.1 and the MIPS3 abi, stopping with a .o 
file.  I also ran the source through cpp and a couple of grep passes to 
strip out junk that wasn't really code.  This driver may be somewhat 
typical of what you would run into as it has quite a few inline functions 
and such.

The driver.o was about 23000 bytes.  Forgetting about the symboltables and 
just dividing by 4 to estimate instructions and dividing by about 1650 
net lines of code, I got about 3.5 instructions per line of C code.

I'm guessing that ball park, you're looking at 3-5 average - 10 seems high 
except in sections with lots and lots of inlines.

Regards,

-S-

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

* Re: Average number of instructions per line of kernel code
  2007-08-30 16:29     ` J. Scott Kasten
@ 2007-08-30 19:49       ` Jan Engelhardt
  2007-08-30 19:56         ` Freddy Spierenburg
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Engelhardt @ 2007-08-30 19:49 UTC (permalink / raw)
  To: J. Scott Kasten; +Cc: Mohamed Bamakhrama, linux-mips, linux-kernel


On Aug 30 2007 12:29, J. Scott Kasten wrote:
> On Thu, 30 Aug 2007, Mohamed Bamakhrama wrote:
>> > > Hi all,
>> > > I have a question regarding the average number of assembly
>> > > instructions per line of kernel code. I know that this is a difficult
>> > > question since it depends on many factors such as the instruction set
>
> Here's a quick answer, not the best, but quick.
>
> I took a user space flash memory driver I'm doing at work and compiled it on my
> R5000 at home using gcc 4.1 and the MIPS3 abi, stopping with a .o file.  I also
> ran the source through cpp and a couple of grep passes to strip out junk that
> wasn't really code.  This driver may be somewhat typical of what you would run
> into as it has quite a few inline functions and such.
>
> The driver.o was about 23000 bytes.  Forgetting about the symboltables and just
> dividing by 4 to estimate instructions and dividing by about 1650 net lines of
> code, I got about 3.5 instructions per line of C code.

objcopy -j .text input.o output.o
objcopy -O binary output.o output2.o

Then you can objdump -S output.o and count. output2.o has the ELF header
stripped, so provides the raw size, but at the cost of not being able to run
objdump. If you know that every instruction is fixed size, then of course
output2.o is easy.


	Jan
-- 

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

* Re: Average number of instructions per line of kernel code
  2007-08-30 19:49       ` Jan Engelhardt
@ 2007-08-30 19:56         ` Freddy Spierenburg
  0 siblings, 0 replies; 7+ messages in thread
From: Freddy Spierenburg @ 2007-08-30 19:56 UTC (permalink / raw)
  To: linux-mips, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 477 bytes --]

Hi all,

On Thu, 30 Aug 2007, Mohamed Bamakhrama wrote:
> I have a question regarding the average number of assembly
> instructions per line of kernel code.

I may completely miss out on this one, but what's the point in
knowing?


-- 
$ cat ~/.signature
Freddy Spierenburg <freddy@dusktilldawn.nl>  http://freddy.snarl.nl/
GnuPG: 0x7941D1E1=C948 5851 26D2 FA5C 39F1  E588 6F17 FD5D 7941 D1E1
$ # Please read http://www.ietf.org/rfc/rfc2015.txt before complain!

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

end of thread, other threads:[~2007-08-30 20:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-30 13:00 Average number of instructions per line of kernel code Mohamed Bamakhrama
2007-08-30 13:31 ` Jesper Juhl
2007-08-30 13:48   ` Mohamed Bamakhrama
2007-08-30 13:54     ` Jesper Juhl
2007-08-30 16:29     ` J. Scott Kasten
2007-08-30 19:49       ` Jan Engelhardt
2007-08-30 19:56         ` Freddy Spierenburg

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

all inboxes | Powered by JetHome®