From: Tony Battersby <tonyb@cybernetics.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Christoph Hellwig <hch@lst.de>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Matthew Wilcox <willy@infradead.org>,
Sathya Prakash <sathya.prakash@broadcom.com>,
Chaitra P B <chaitra.basappa@broadcom.com>,
Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>,
iommu@lists.linux-foundation.org, linux-mm <linux-mm@kvack.org>,
linux-scsi <linux-scsi@vger.kernel.org>,
MPT-FusionLinux.pdl@broadcom.com
Subject: Re: [PATCH 1/3] dmapool: improve scalability of dma_pool_alloc
Date: Fri, 27 Jul 2018 09:50:34 -0400 [thread overview]
Message-ID: <2a7cf138-3c2e-6db8-de87-7f4689404adb@cybernetics.com> (raw)
In-Reply-To: <2a04ee8b-478d-39f1-09a0-1b2f8c6ee8c6@cybernetics.com>
> That would be true if the test were "if
> (list_empty(&pool->avail_page_list))".A But it is testing the list
> pointers in the item rather than the list pointers in the pool.A It may
> be a bit confusing if you have never seen that usage before, which is
> why I added a comment.A Basically, if you use list_del_init() instead of
> list_del(), then you can use list_empty() on the item itself to test if
> the item is present in a list or not.A For example, the comments in
> list.h warn not to use list_empty() on the entry after just list_del():
>
> /**
> * list_del - deletes entry from list.
> * @entry: the element to delete from the list.
> * Note: list_empty() on entry does not return true after this, the entry is
> * in an undefined state.
> */
Sorry for the crappy line length (fixed above).A Should have just used
Preformat in Thunderbird like always rather than following
Documentation/process/email-clients.rst and changing mailnews.wraplength
from 72 to 0.
Anyway, I have been using list_del_init() for a long time in various
places, but now I can't find where any of its useful features are
documented.A I will have to submit a separate patch to add more
documentation for it.A I find it useful for two things.
1) If you use list_del_init(), you can delete an item from a list
multiple times without checking if it has already been deleted.A So the
following is safe:
list_add(entry, list);
list_del_init(entry);
list_del_init(entry);
That would not be safe if just using list_del().
2) If you use list_del_init(), you can test if an item is present in a
list using list_empty() on the entry.A So:
list_add(entry, list);
/* list_empty(entry) is false */
list_del_init(entry);
/* list_empty(entry) is true */
That would not work if using just list_del().
Since the list_empty() name is unintuitive for this purpose, it might be
useful to add a new macro for this use case.
prev parent reply other threads:[~2018-07-27 13:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-26 18:54 Tony Battersby
2018-07-26 19:37 ` Andy Shevchenko
2018-07-26 19:56 ` Tony Battersby
2018-07-27 13:50 ` Tony Battersby [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=2a7cf138-3c2e-6db8-de87-7f4689404adb@cybernetics.com \
--to=tonyb@cybernetics.com \
--cc=MPT-FusionLinux.pdl@broadcom.com \
--cc=andy.shevchenko@gmail.com \
--cc=chaitra.basappa@broadcom.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=linux-scsi@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=sathya.prakash@broadcom.com \
--cc=suganath-prabu.subramani@broadcom.com \
--cc=willy@infradead.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