public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Eric Nelson <eric@nelint.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V3 1/3] drivers: block: add block device cache
Date: Fri, 1 Apr 2016 16:16:42 -0700	[thread overview]
Message-ID: <56FF015A.2010304@nelint.com> (raw)
In-Reply-To: <56FEFCD1.50507@wwwdotorg.org>

Hi Stephen,

On 04/01/2016 03:57 PM, Stephen Warren wrote:
> On 03/31/2016 02:24 PM, Eric Nelson wrote:
>> On 03/30/2016 02:57 PM, Stephen Warren wrote:
>>> On 03/30/2016 11:34 AM, Eric Nelson wrote:
>>>> On 03/30/2016 07:36 AM, Stephen Warren wrote:
>>>>> On 03/28/2016 11:05 AM, Eric Nelson wrote:

<snip>

>>>
>>> We could allocate the data storage for the block cache at the top of RAM
>>> before relocation, like many other things are allocated, and hence not
>>> use malloc() for that.
>>
>> Hmmm. We seem to have gone from a discussion about data structures to
>> type of allocation.
>>
>> I'm interested in seeing how that works. Can you provide hints about
>> what's doing this now?
> 
> Something like common/board_f.c:reserve_mmu() and many other functions
> there. relocaddr starts at approximately the top of RAM, continually
> gets adjusted down as many static allocations are reserved, and
> eventually becomes the address that U-Boot is relocated to. Simply
> adding another entry into init_sequence_f[] for the disk cache might work.
> 

Thanks for the pointer. I'll review that when time permits.

This would remove the opportunity to re-configure the cache though, right?

I'm not sure whether how important this feature is, and I think
only time and use will tell.

I'd prefer to keep that ability at least for a cycle or two so that
I and others can test.

>>>> While re-working the code, I also thought more about using an array and
>>>> still don't see how the implementation doesn't get more complex.
>>>>
>>>> The key bit is that the list is implemented in MRU order so
>>>> invalidating the oldest is trivial.
>>>
>>> Yes, the MRU logic would make it more complex. Is that particularly
>>> useful, i.e. is it an intrinsic part of the speedup?
>>
>> It's not a question of speed with small numbers of entries. The code
>> to handle eviction would just be more complex.
> 
> My thought was that if the eviction algorithm wasn't important (i.e.
> most of the speedup comes from have some (any) kind of cache, but the
> eviction algorithm makes little difference to the gain from having the
> cache), we could just drop MRU completely. If that's not possible, then
> indeed a list would make implementing MRU easier.
> 

How would we decide which block to discard? I haven't traced enough
to know what algorithm(s) might be best, but I can say that there's
a preponderance of repeated accesses to the last-accessed block,
especially in ext4.

> You could still do a list with a statically allocated set of list nodes,
> especially since the length of the list is bounded.
> 

Sure. A pooled allocator (pool of free nodes) works well with
array-based allocation.

Having a fixed upper limit on the number of blocks would require
additional checking unless we just sized it for (max entries * max
blocks/entry).

>> Given that the command "blkcache configure 0 0" will discard all
>> cache and since both dfu and ums should properly have the cache
>> disabled, I'd like to proceed as-is with the list and heap approach.
>
> I don't understand "since both dfu and ums should properly have the
> cache disabled"; I didn't see anything that did that. Perhaps you're
> referring to the fact that writes invalidate the cache?
> 

Yes, but also that the host will cache blocks in the ums case, so
having the cache enabled will only slow things down slightly by
lots of memcpy's to cached blocks that won't be helpful.

I think I was a bit flippant by including dfu in this statement,
since I haven't used it to access anything except SPI-NOR.

> Eventually it seems better to keep the cache enabled for at least DFU to
> a filesystem (rather than raw block device) since presumably parsing the
> directory structure to write to a file for DFU would benefit from the
> cache just like anything else.

I'm not in a position to comment about dfu.

Regards,


Eric

  reply	other threads:[~2016-04-01 23:16 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-21  1:45 [U-Boot] [RFC V2 PATCH 0/3] Add cache for block devices Eric Nelson
2016-03-21  1:45 ` [U-Boot] [RFC V2 PATCH 1/3] drivers: block: add block device cache Eric Nelson
2016-03-21 17:59   ` Eric Nelson
2016-03-23 17:22   ` Stephen Warren
2016-03-23 17:43     ` Eric Nelson
2016-03-21  1:45 ` [U-Boot] [RFC V2 PATCH 2/3] block: add Kconfig options for [CMD_]BLOCK_CACHE Eric Nelson
2016-03-23 17:24   ` Stephen Warren
2016-03-23 17:45     ` Eric Nelson
2016-03-21  1:45 ` [U-Boot] [RFC V2 PATCH 3/3] mmc: add support for block device cache Eric Nelson
2016-03-23 17:27   ` Stephen Warren
2016-03-23 17:46     ` Eric Nelson
2016-03-21  1:59 ` [U-Boot] [RFC V2 PATCH 0/3] Add cache for block devices Marek Vasut
2016-03-21 13:48   ` Eric Nelson
2016-03-21 16:49     ` Marek Vasut
2016-03-21 17:56       ` Eric Nelson
2016-03-21 18:54         ` Marek Vasut
2016-03-27 19:00 ` [U-Boot] [PATCH " Eric Nelson
2016-03-27 19:00   ` [U-Boot] [PATCH 1/3] drivers: block: add block device cache Eric Nelson
2016-03-28 14:16     ` Tom Rini
2016-03-28 14:33       ` Eric Nelson
2016-03-28 16:24         ` [U-Boot] [PATCH V2 " Eric Nelson
2016-03-28 17:05           ` [U-Boot] [PATCH V3 " Eric Nelson
2016-03-30 14:36             ` Stephen Warren
2016-03-30 15:19               ` Tom Rini
2016-03-30 15:21                 ` Stephen Warren
2016-03-30 17:37                 ` Eric Nelson
2016-03-30 17:34               ` Eric Nelson
2016-03-30 21:57                 ` Stephen Warren
2016-03-31 20:24                   ` Eric Nelson
2016-04-01 22:57                     ` Stephen Warren
2016-04-01 23:16                       ` Eric Nelson [this message]
2016-04-01 23:41                         ` Tom Rini
2016-04-02 14:17                           ` Eric Nelson
2016-04-02  2:07                         ` Stephen Warren
2016-04-02 14:24                           ` Eric Nelson
2016-04-02  1:59             ` [U-Boot] [U-Boot, V3, " Tom Rini
2016-04-02 14:19               ` Eric Nelson
2016-04-02 14:37                 ` [U-Boot] [PATCH 0/3] minor blkcache updates Eric Nelson
2016-04-02 14:37                   ` [U-Boot] [PATCH 1/3] cmd: blkcache: remove indentation from output of 'show' Eric Nelson
2016-04-12  2:28                     ` [U-Boot] [U-Boot, " Tom Rini
2016-04-02 14:37                   ` [U-Boot] [PATCH 2/3] cmd: blkcache: simplify sub-command handling Eric Nelson
2016-04-04 17:39                     ` Stephen Warren
2016-04-12  2:28                     ` [U-Boot] [U-Boot, " Tom Rini
2016-04-02 14:37                   ` [U-Boot] [PATCH 3/3] drivers: block: fix placement of parameters Eric Nelson
2016-04-12  2:29                     ` [U-Boot] [U-Boot, " Tom Rini
2016-03-27 19:00   ` [U-Boot] [PATCH 2/3] mmc: use block layer in mmc command Eric Nelson
2016-03-28 14:16     ` Tom Rini
2016-04-02  1:58     ` [U-Boot] [U-Boot,2/3] " Tom Rini
2016-03-27 19:00   ` [U-Boot] [PATCH 3/3] sata: use block layer for sata command Eric Nelson
2016-03-28 14:16     ` Tom Rini
2016-04-02  1:59     ` [U-Boot] [U-Boot,3/3] " Tom Rini

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=56FF015A.2010304@nelint.com \
    --to=eric@nelint.com \
    --cc=u-boot@lists.denx.de \
    /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