mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Question about spinlock and timer
@ 2001-10-14 15:01 Evgeniy Polyakov
  0 siblings, 0 replies; only message in thread
From: Evgeniy Polyakov @ 2001-10-14 15:01 UTC (permalink / raw)
  To: Linux-kernel

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-10-14 14:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-14 15:01 Question about spinlock and timer Evgeniy Polyakov

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®