All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boaz Harrosh <boaz@plexistor.com>
To: Tejun Heo <tj@kernel.org>, Boaz Harrosh <boaz@plexistor.com>
Cc: Jens Axboe <axboe@kernel.dk>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Christoph Hellwig <hch@infradead.org>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH vfs 2/2] {block|char}_dev: remove inode->i_devices
Date: Thu, 20 Nov 2014 14:36:53 +0200	[thread overview]
Message-ID: <546DE065.3090502@plexistor.com> (raw)
In-Reply-To: <20141120115052.GA32237@htj.dyndns.org>

On 11/20/2014 01:50 PM, Tejun Heo wrote:
> 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) 

Two things:
1. This can be easily hidden by returning a none defined type
   which internals are only known to the implementation so
   even if you change the implementation users need not change.
   Like just a (void *) but it is better to be type-full
   like:
   struct pset_new;
   struct pset_new *pset_preload()

   And the internals of struct pset_new is only known to implementation
2. Obfuscation: Currently this is the proposed implementation if jugging
   by the previous imp it is good for 15 years.
   Else since when are we afraid to change two users?

> 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.

  Actually with my proposed change to "the code you submitted here"
  there are *less* unnecessary allocations. In both our imp we have a
  waste when element already exist in the tree, and your imp already
  waists an allocation in every pset_preload()

  And again you are talking about a future undefined "what if", let
  us look at the very sound imp you proposed here with rbtree and
  do the best we can with that one.

> 
> 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, 

  Again Theoretical. With your current code the only failing I see
  from add() is allocation, so with my imp it will never fail. One
  thing good with embedded list_heads is the void returning add.
  And so with my proposition: void returning add.

  When some new imp will be needed we can cross the bridge then.

  For now you have convinced me that an rbtree is good, and I want to
  solve the preemption-disable, none interrupt ugliness, per-cpu vars,
  as well as the double alloc in the normal lots-of-free-memory case.

> so
> overall it seems better to defer the allocation error to the actual
> insertion point.  

That one I did not understand.

> It also makes conceptual sense.  The preloading
> simply upgrades the allocation mask the insertion operation uses.
> 

How is "upgrades", better then "always have the best mask"

> Thanks.
> 

Thanks
Boaz

  reply	other threads:[~2014-11-20 12:36 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-13 22:09 [PATCH vfs 1/2] lib: implement ptrset Tejun Heo
2014-11-13 22:11 ` [PATCH vfs 2/2] {block|char}_dev: remove inode->i_devices Tejun Heo
2014-11-18 12:10   ` Boaz Harrosh
2014-11-18 12:30     ` Tejun Heo
2014-11-20 10:42   ` Boaz Harrosh
2014-11-20 11:50     ` Tejun Heo
2014-11-20 12:36       ` Boaz Harrosh [this message]
2014-11-20 13:11         ` Tejun Heo
2014-11-20 13:39           ` Tejun Heo
2014-11-20 14:14           ` Boaz Harrosh
2014-11-20 14:19             ` Tejun Heo
2014-11-13 22:23 ` [PATCH vfs 1/2] lib: implement ptrset Andrew Morton
2014-11-13 22:27   ` Tejun Heo
2014-11-13 22:40     ` Andrew Morton
2014-11-14 13:12       ` Tejun Heo
2014-11-18 20:46         ` Andrew Morton
2014-11-18  9:19 ` Lai Jiangshan
2014-11-18 11:55   ` Tejun Heo
2014-11-19  1:41     ` Lai Jiangshan
2014-11-18 15:56 ` Azat Khuzhin
2014-11-18 17:16   ` Tejun Heo
2014-11-18 17:49 ` [PATCH vfs v2 " Tejun Heo
2014-11-25 16:37 ` [PATCH vfs " Jan Kara
2014-12-02 18:15   ` Tejun Heo

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=546DE065.3090502@plexistor.com \
    --to=boaz@plexistor.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.