OSDN Git Service

mbcache2: Speed up cache entry creation
authorSultan Alsawaf <sultan@kerneltoast.com>
Wed, 3 Jul 2019 21:09:01 +0000 (14:09 -0700)
committer0ranko0P <ranko0p@outlook.com>
Sat, 7 Dec 2019 10:22:17 +0000 (18:22 +0800)
commit55c7b7b2e39bf8291125f607bf3000e7606d75b1
treed5b76efe9e0723a14de6bd3f052595e66c373117
parent79c300b5fc0f380cb3f696eb736f4ccc87208842
mbcache2: Speed up cache entry creation

In order to prevent redundant entry creation by racing against itself,
mb2_cache_entry_create scans through a large hash-list of all current
entries in order to see if another allocation for the requested new
entry has been made. Furthermore, it allocates memory for a new entry
before scanning through this hash-list, which results in that allocated
memory being discarded when the requested new entry is already present.
This happens more than half the time.

Speed up cache entry creation by keeping a small linked list of
requested new entries in progress, and scanning through that first
instead of the large hash-list. Additionally, don't bother allocating
memory for a new entry until it's known that the allocated memory will
be used.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
fs/mbcache2.c