From: Clemens Ladisch <clemens@ladisch.de>
To: "Leonidas ." <leonidas137@gmail.com>
Cc: Valdis.Kletnieks@vt.edu, linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Can current macro be accessed from interrupt context?
Date: Fri, 23 Oct 2009 10:13:21 +0200 [thread overview]
Message-ID: <4AE165A1.5080204@ladisch.de> (raw)
In-Reply-To: <f22d86810910221046l366d3017r8b8823e4750ffea2@mail.gmail.com>
Leonidas . wrote:
> I am trying to emulate thread local storage in kernel space. [...]
> Assume that, a multithreaded app talks to my kernel module using
> /dev/node, and I need to book keep certain data in kernel module. The
> data I am book keeping can be kept in a central data structure
> protected by spinlocks. A better way would be per cpu data structure.
>
> My idea is to keep data specific to each task which is talking to my
> kernel module. Assumption here is a certain task can be in kernel mode
> only on one cpu at a time hence that task specific data structure can
> be accessed without locks.
There is no fixed association between your tasks and the CPUs they are
running on. It is possible for two of your threads to be executed on
the same CPU (one after the other), or for one thread to migrate between
CPUs.
> All book keeping which needs to be done in ISRs would be just book
> keeping for the interrupted task, i.e. we would populate interrupted
> task's data structure. This is where current comes in picture.
The task that was interrupted is probably some entirely different task
(the X server, the shell, your mail reader, some kernel thread, or
any of the other tasks running on your system).
It is possible for your interrupt handler to be called for some device
request that belongs to one of your tasks that is currently running on
another CPU, so you won't be able to manage that data without locking.
Best regards,
Clemens
next prev parent reply other threads:[~2009-10-23 8:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-22 11:10 Can current macro be accessed from interrupt context? Leonidas .
2009-10-22 11:27 ` Frederic Weisbecker
2009-10-22 11:43 ` Leonidas .
2009-10-22 11:49 ` Leonidas .
2009-10-22 12:06 ` Frederic Weisbecker
2009-10-22 13:37 ` Leonidas .
2009-10-22 13:45 ` Arjan van de Ven
2009-10-22 15:17 ` Valdis.Kletnieks
2009-10-22 17:46 ` Leonidas .
2009-10-22 18:12 ` Leonidas .
2009-10-23 8:13 ` Clemens Ladisch [this message]
2009-10-23 9:34 ` Leonidas .
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=4AE165A1.5080204@ladisch.de \
--to=clemens@ladisch.de \
--cc=Valdis.Kletnieks@vt.edu \
--cc=leonidas137@gmail.com \
--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