mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
To: Linux-kernel <linux-kernel@vger.kernel.org>
Subject: Question about spinlock and timer
Date: Sun, 14 Oct 2001 19:01:44 +0400	[thread overview]
Message-ID: <20011014190144.58e6f212.johnpol@2ka.mipt.ru> (raw)

Hello, linux guru.

After reading spinlock documentation at the kernelnewbie.org, i've got a
question:
If i clearly understand, each kernel timer is connected with some memory
region, and this region should be freed when timer becomes clear.
And this can occur before spi_lock_bh(). Therefore this memory regin will
be freed second time in the loop.

   spin_lock_bh(&list_lock);

         while (list) {
                 struct foo *next = list->next;
                 del_timer(&list->timer);
                 kfree(list);
                 list = next;
         }
         spin_unlock_bh(&list_lock);


This is correct example:

      retry:  
                 spin_lock_bh(&list_lock);

                 while (list) {
                         struct foo *next = list->next;
                         if (!del_timer(&list->timer)) {
                                 /* Give timer a chance to delete this */
                                 spin_unlock_bh(&list_lock);
                                 goto retry;
                         }
                         kfree(list);
                         list = next;
                 }

                 spin_unlock_bh(&list_lock);

If i was right in previous assumption, than this code may be owervritten
in such manner:
.....
 if (!del_timer(&list->timer)) {
     if (!next)
          break;
     list = next;
     continue;
     }
.....

Or am I wrong again?
If it is so, please tell me the write answer and explanation.

Thanks in advance for you answers and appologies.

---
WBR. //s0mbre

                 reply	other threads:[~2001-10-14 14:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20011014190144.58e6f212.johnpol@2ka.mipt.ru \
    --to=johnpol@2ka.mipt.ru \
    --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®