mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Valdis.Kletnieks@vt.edu
To: kernel coder <lhrkernelcoder@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: profile code added to netif_receive_skb function
Date: Mon, 26 Nov 2007 23:00:23 -0500	[thread overview]
Message-ID: <21348.1196136023@turing-police.cc.vt.edu> (raw)
In-Reply-To: Your message of "Sun, 25 Nov 2007 21:46:26 PST." <f69849430711252146q3046d3e1n48c377a18e4e4dfb@mail.gmail.com>

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

On Sun, 25 Nov 2007 21:46:26 PST, kernel coder said:
> hi,
> 
> I have added some code to netif_receive_skb function.As linux kernel
> is multhreaded , so there is no gaurantee than mine code is completely
> executed without being disturbed by any other process .Timer interrupt
> handler is an example of code which might interrupt execution of mine
> code.

The trick is to write your code so it doesn't *matter* if other code runs.

For example - the timer interrupt almost certainly doesn't look at or modify
any of *your* code's variables.  So 98% of the kernel's code you don't
even have to *care* if it runs (as long as you aren't doing something
real-time or has similar response-time or throughput constraints).

And if you are worried about that other 2%, where related code, for example the
IRQ handler for a network interface, may have to look at and/or modify some of
your variables, that's when you should be using appropriate locking - there's
mutexes, semaphores, the whole RCU family, and more - none of which I'll
attempt to explain, because I'm not all that good at that stuff.

Basic rule of thumb - if you have something that will break if two things
access it at the same time, put a lock around it, so they take turns.

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

      reply	other threads:[~2007-11-27  4:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-26  5:46 kernel coder
2007-11-27  4:00 ` Valdis.Kletnieks [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=21348.1196136023@turing-police.cc.vt.edu \
    --to=valdis.kletnieks@vt.edu \
    --cc=lhrkernelcoder@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

all inboxes | Powered by JetHome®