From: Al Viro <viro@ZenIV.linux.org.uk>
To: Byungchul Park <byungchul.park@lge.com>
Cc: peterz@infradead.org, mingo@kernel.org, koverstreet@google.com,
neilb@suse.de, nab@linux-iscsi.org, ying.huang@intel.com,
oleg@redhat.com, asias@redhat.com, shli@kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] llist: Don't reinvent the wheel but use existing llist API
Date: Mon, 13 Feb 2017 05:43:26 +0000 [thread overview]
Message-ID: <20170213054326.GR13195@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1486959013-26105-1-git-send-email-byungchul.park@lge.com>
On Mon, Feb 13, 2017 at 01:10:13PM +0900, Byungchul Park wrote:
> Although llist provides proper APIs, they are not used. Make them used.
> @@ -231,12 +231,10 @@ static void __fput(struct file *file)
> static void delayed_fput(struct work_struct *unused)
> {
> struct llist_node *node = llist_del_all(&delayed_fput_list);
> - struct llist_node *next;
> + struct file *f;
>
> - for (; node; node = next) {
> - next = llist_next(node);
> - __fput(llist_entry(node, struct file, f_u.fu_llist));
> - }
> + llist_for_each_entry(f, node, f_u.fu_llist)
> + __fput(f);
> }
#define llist_for_each_entry(pos, node, member) \
for ((pos) = llist_entry((node), typeof(*(pos)), member); \
&(pos)->member != NULL; \
(pos) = llist_entry((pos)->member.next, typeof(*(pos)), member))
Now, think what happens after __fput() frees the damn thing. In the
step of that loop, that is.
That kind of pattern (find next, do something with the current, proceed to
the next we'd found before) is a strong hint that this "do something"
might remove the thing from the list, or outright destroy it. Both
file_table.c and namespace.c chunks are breaking exactly that kind of
places.
Please, don't do this kind of conversions blindly. There _is_ another
iterating primitive for such places, but figuring out which one is right
is not something you can do without understanding what the code is doing.
And no, blind replacement of all such loops with llist_for_each_entry_safe,
just in case, is not a good idea either.
next prev parent reply other threads:[~2017-02-13 5:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-13 4:10 [PATCH] llist: Don't reinvent the wheel but use existing llist API Byungchul Park
2017-02-13 4:56 ` NeilBrown
2017-02-13 5:14 ` Byungchul Park
2017-02-13 5:38 ` Huang, Ying
2017-02-13 5:55 ` Byungchul Park
2017-02-13 5:43 ` Al Viro [this message]
2017-02-13 6:00 ` Byungchul Park
2017-02-24 1:20 ` [lkp-robot] [llist] bc1a405b00: Kernel_panic-not_syncing:No_working_init_found kernel test robot
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=20170213054326.GR13195@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=asias@redhat.com \
--cc=byungchul.park@lge.com \
--cc=koverstreet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=nab@linux-iscsi.org \
--cc=neilb@suse.de \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=shli@kernel.org \
--cc=ying.huang@intel.com \
/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