Re: [PATCH vfs 2/2] {block|char}_dev: remove inode->i_devices
From: Tejun Heo
Date: Thu Nov 20 2014 - 06:51:05 EST
Hello, Boaz.
On Thu, Nov 20, 2014 at 12:42:53PM +0200, Boaz Harrosh wrote:
> if I understand correctly the motivation here is that the allocation
> of the internal element is done GFP_KERNEL at this call
>
> Then the add() below can be under the spin_lock.
>
> So why don't you just return an element here to caller and give it to
> add below. No Preemption-disable, no percpu variable, simple. Like:
Hmmm... mostly because preloading is more convenient and but also
because it provides better separation from internal implementation
details. e.g. This may be implemented using a different data
structure (e.g. bonsai tree) which may require differing number of new
elements even on success. With the scheme you're describing, the
operation would be constantly allocating and freeing memory areas
(which may be multiple) unnecessarily.
One thing which is debatable is how to handle preloading errors. We
can have the preload fail and then assume that the later insertion
won't fail with -ENOMEM (often through BUG/WARN_ON()); however, it
often, but not always, is that those insertion operations may fail
with different error codes too and requires error handling anyway, so
overall it seems better to defer the allocation error to the actual
insertion point. It also makes conceptual sense. The preloading
simply upgrades the allocation mask the insertion operation uses.
Thanks.
--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/