public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Andi Kleen <ak@suse.de>, linux-kernel@vger.kernel.org
Subject: [PATCH] account_system_vtime() should be a macro, not a function
Date: Thu, 19 Oct 2006 15:43:18 +0200	[thread overview]
Message-ID: <200610191543.18951.dada1@cosmosbay.com> (raw)
In-Reply-To: <20061019014446.36410c81.akpm@osdl.org>

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

[PATCH] account_system_vtime() should be a macro, not a function

Because the way 'current' is implemented on some archs, it's better to use a 
null macro for account_system_vtime(current) 

I discovered that gcc was (correctly) issuing one useless instruction (to 
load %rax with current from pda) on x86_64 on irq_enter() and __irq_exit()

This saves few bytes in kernel size, on archs where current is 'asm volatile'

Sample of asm code :

<smp_apic_timer_interrupt>:    
...
    callq  <exit_idle>
    mov    %gs:0x0,%rax // useless load of pda.'pcurrent' into %rax
    mov    %gs:0x10,%rax
    addl   $0x10000,0xffffffffffffe044(%rax) // 
add_preempt_count(HARDIRQ_OFFSET);

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>

[-- Attachment #2: account_system_vtime.patch --]
[-- Type: text/plain, Size: 478 bytes --]

--- linux/include/linux/hardirq.h	2006-10-19 15:13:34.000000000 +0200
+++ linux-ed/include/linux/hardirq.h	2006-10-19 15:15:58.000000000 +0200
@@ -95,9 +95,11 @@
 struct task_struct;
 
 #ifndef CONFIG_VIRT_CPU_ACCOUNTING
-static inline void account_system_vtime(struct task_struct *tsk)
-{
-}
+/*
+ * It's better to provide a macro and not a function
+ * because the way 'current' is implemented on some archs
+ */
+#define account_system_vtime(X) do {} while (0)
 #endif
 
 /*

  parent reply	other threads:[~2006-10-19 13:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-17 15:47 [Bug 185] Sometimes kernel freezes sometime lists OOPS - hostap_cs CIJOML
2006-10-19  6:56 ` Andrew Morton
2006-10-19  8:12   ` CIJOML
2006-10-19  8:44     ` Andrew Morton
2006-10-19  9:51       ` CIJOML
2006-10-19 13:43       ` Eric Dumazet [this message]
2006-10-19 13:46         ` [PATCH] account_system_vtime() should be a macro, not a function Andi Kleen

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=200610191543.18951.dada1@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox