From: Rik van Riel <riel@surriel.com>
To: Daniel Rodrick <daniel.rodrick@gmail.com>
Cc: Linux Newbie <linux-newbie@vger.kernel.org>,
kernelnewbies <kernelnewbies@nl.linux.org>
Subject: Re: why "need_resched" per process?
Date: Mon, 25 Sep 2006 08:11:17 -0400 [thread overview]
Message-ID: <4517C765.3040907@surriel.com> (raw)
In-Reply-To: <292693080609250243r711cc218p55339fbca1f839ee@mail.gmail.com>
Daniel Rodrick wrote:
> Hi,
>
> I was determining a reason for the need_resched flag to be per process
> rather than being a global variable. I read that the sole reason is
> for performance.
>
> I could not understand how would having it (need_resched) per process
> result in a better performance? Having it as a global variable in the
> kernel address space would be just a matter of getting the value at a
> known address.
>
> On the other hand, having a per process copy sure results in
> unecessary memory occupancy.
1) not every CPU needs to reschedule simultaneously, think
about an 8-cpu core SMP system where one of the current
tasks needs to reschedule
2) the cacheline with the current task_struct pointer in
it is probably in the CPU's L2 cache, since it is used
very frequently - a global variable would probably not
be in the CPU cache
3) the thread struct (IIRC need_resched lives there, please
correct me if I misremember) is the first few bytes of a
task's kernel thread, so it doesn't really take any extra
memory
--
"You don't have to be crazy to do this... but it helps." -- Bob Ross
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
prev parent reply other threads:[~2006-09-25 12:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-25 9:43 why "need_resched" per process? Daniel Rodrick
2006-09-25 12:11 ` Rik van Riel [this message]
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=4517C765.3040907@surriel.com \
--to=riel@surriel.com \
--cc=daniel.rodrick@gmail.com \
--cc=kernelnewbies@nl.linux.org \
--cc=linux-newbie@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 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.