Re: lists and sentinels and splicing, oh my!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Mar 23, 2008 at 11:35 PM, Manish Katiyar <mkatiyar@xxxxxxxxx> wrote:
> On Sun, Mar 23, 2008 at 7:01 PM, Robert P. J. Day <rpjday@xxxxxxxxxxxxxx> wrote:
>  > On Sun, 23 Mar 2008, Manish Katiyar wrote:
>  >
>  >  ... snip ...
>  >
>  >
>  >  > >         list_splice(&d->fifo_list, &packet_list);
>  >  > >         list_splice(&d->pending_list, &packet_list);
>  >  > >         INIT_LIST_HEAD(&d->fifo_list);
>  >  > >         INIT_LIST_HEAD(&d->pending_list);
>  >  > >  ...
>  >  >
>  >  > Interesting point Robert, I agree. However not every call to
>  >  > list_splice is accompanied by a call to INIT_LIST_HEAD in the
>  >  > current code (26.24.2) and I can see this *seem to be buggy* call in
>  >  > some of the important files like VM and cache. One such example is
>  >  > in
>  >  >
>  >  > kmem_cache_shrink
>  >  > shrink_page_list
>  >  >
>  >  > etc. and lot of others. Wonder how they work unless we are missing
>  >  > something :-)
>  >
>  >  by the way, in some cases, there is a call to INIT_LIST_HEAD but it
>  >  might be a number of lines down in the code so sometimes it's not
>  >  obvious.  i've noticed a couple of those.
>  >
>
>  Hmmm.... after seeing the list_del(),  I was wondering if after
>  splicing the list, what seems to be more reasonable.
>
>  Setting the prev and next pointers of head to NULL, or setting them to
>  LIST_POISON1 and LIST_POISON2 as these two seem to be the ideal
>  candidate as they are made to notify(tracked easliy) in case of
>  illegal access of list pointers.
>
>  Robert your thoughts/comments ??

Following the footsteps of  list_del() and list_del_init(), i think we
should have

static inline void list_splice(struct list_head *list, struct list_head *head)
{
 if (!list_empty(list)){
  __list_splice(list, head);
  list->next = LIST_POISON1;
  list->prev = LIST_POISON2;
 }
}

as the default behaviour of list_splice()



>
>
>  >
>  >
>  >  rday
>  >  --
>  >
>  >  ========================================================================
>  >  Robert P. J. Day
>  >  Linux Consulting, Training and Annoying Kernel Pedantry:
>  >     Have classroom, will lecture.
>  >
>  >  http://crashcourse.ca                          Waterloo, Ontario, CANADA
>  >  ========================================================================
>  >
>
>
>
>
>
> --
>  Thanks & Regards,
>  ********************************************
>  Manish Katiyar ( http://mkatiyar.googlepages.com )
>  3rd Floor, Fair Winds Block
>  EGL Software Park
>  Off Intermediate Ring Road
>  Bangalore 560071, India
>  ***********************************************
>



-- 
Thanks & Regards,
********************************************
Manish Katiyar ( http://mkatiyar.googlepages.com )
3rd Floor, Fair Winds Block
EGL Software Park
Off Intermediate Ring Road
Bangalore 560071, India
***********************************************

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux