LWN: Comments on "Negative dentries, 20 years later" https://lwn.net/Articles/890025/ This is a special feed containing comments posted to the individual LWN article titled "Negative dentries, 20 years later". en-us Tue, 04 Nov 2025 01:43:36 +0000 Tue, 04 Nov 2025 01:43:36 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Intuitive ways to exit text editors https://lwn.net/Articles/891749/ https://lwn.net/Articles/891749/ Jandar <div class="FormattedComment"> <font class="QuotedText">&gt; CTRL+Z</font><br> <font class="QuotedText">&gt; $ killall emacs vi</font><br> <p> Neither vi in insert-mode nor emacs in x11 mode stops with CTRL-Z ;-)<br> <p> vi inserts the CTRL-Z and emacs executes suspend-frame.<br> </div> Mon, 18 Apr 2022 20:41:24 +0000 Intuitive ways to exit text editors https://lwn.net/Articles/891678/ https://lwn.net/Articles/891678/ Spack <div class="FormattedComment"> CTRL+Z<br> $ killall emacs vi<br> </div> Sun, 17 Apr 2022 22:59:52 +0000 Negative dentries, 20 years later https://lwn.net/Articles/891323/ https://lwn.net/Articles/891323/ nix <div class="FormattedComment"> <font class="QuotedText">&gt; You don&#x27;t really want to make things exhaustive... Imagine having users creating single directories with millions of files.</font><br> <p> Maildirs do this routinely. It&#x27;s amazing how much trouble it causes (to backup programs in particular, since they have to enumerate every inode in the directory to figure out which ones changed). (INN news tradspools do it too, but they&#x27;re not per-user and they&#x27;re relatively rarely backed up at all.)<br> </div> Thu, 14 Apr 2022 11:44:42 +0000 Intuitive ways to exit text editors https://lwn.net/Articles/891301/ https://lwn.net/Articles/891301/ SiB <div class="FormattedComment"> My way of starting emacs is `emacsclient -c -d &quot;$DISPLAY&quot; --alternate-editor=&#x27;&#x27; &quot;$1&quot;`<br> <p> That has the same effect on how to kill the emacs process. Ctrl-X Ctrl-C just closes the frame.<br> <p> </div> Thu, 14 Apr 2022 07:40:03 +0000 Intuitive ways to exit text editors https://lwn.net/Articles/891275/ https://lwn.net/Articles/891275/ neilbrown <div class="FormattedComment"> <font class="QuotedText">&gt; emacs: Ctrl-G Ctrl-G Ctrl-G Ctrl-X Ctrl-C</font><br> <p> This actually doesn&#x27;t work for me ..... because I deliberately disabled it as I was somehow typing it accidentally.<br> Now I use : alt-x k i l l - e m a c s enter<br> I haven&#x27;t yet typed that by mistake.<br> <p> </div> Wed, 13 Apr 2022 23:50:38 +0000 Negative dentries, 20 years later https://lwn.net/Articles/891111/ https://lwn.net/Articles/891111/ NYKevin <div class="FormattedComment"> If every bucket is occupied, then there are no empty buckets to cache.<br> </div> Wed, 13 Apr 2022 03:00:06 +0000 Negative dentries, 20 years later https://lwn.net/Articles/891102/ https://lwn.net/Articles/891102/ Wol <div class="FormattedComment"> <font class="QuotedText">&gt; You have entirely missed the point. We&#x27;re not trying to figure out whether the bucket is occupied, we&#x27;re trying to find its nearest occupied neighbors so that we can find an empty range of buckets. That requires a linear scan over neighboring buckets.</font><br> <p> Except you completely missed the point I was responding to. cesarb was talking about a hashed directory, and not a cache.<br> <p> And in that case, there are NO empty buckets (if you want to use that particular variant of hashing). The variant I&#x27;m used to sticks multiple entries per bucket, but there&#x27;s a variant that has exactly as many buckets as entries, and one entry per bucket.<br> <p> And just as it&#x27;s very quick and easy to grow the table, it&#x27;s just as easy to shrink it - the entire bucket you&#x27;re getting rid of just tags on the end of the bucket the (now invalid) old hash hashes to.<br> <p> Cheers,<br> Wol<br> </div> Tue, 12 Apr 2022 21:42:39 +0000 Negative dentries, 20 years later https://lwn.net/Articles/891099/ https://lwn.net/Articles/891099/ NYKevin <div class="FormattedComment"> Yes, you can do that, but it buys you less than you think:<br> <p> * Under open addressing (linear/quadratic probing, cuckoo hashing, etc.), the number of buckets must be greater than the number of dentries, and for performance reasons, it should be significantly greater.<br> * Under closed addressing (separate chaining), the number of dentries cannot be much more than a small (constant) multiple of the number of buckets, or performance suffers.<br> <p> In both cases: Assuming the hash function is a quasi-random oracle, the probability of a hash collision should be quite low, and should become lower as the hash table grows (so that the average number of collisions that each dentry suffers remains bounded above). A cached negative dentry range consisting of a single hash bucket will only help you for other dentries that would have collided with that bucket, which should not be very many in practice, or else the hash function is bad.<br> </div> Tue, 12 Apr 2022 21:09:23 +0000 Negative dentries, 20 years later https://lwn.net/Articles/891098/ https://lwn.net/Articles/891098/ cesarb <div class="FormattedComment"> <font class="QuotedText">&gt; We&#x27;re not trying to figure out whether the bucket is occupied, we&#x27;re trying to find its nearest occupied neighbors so that we can find an empty range of buckets.</font><br> <p> Actually, now that I thought about it better, not even that might be necessary. A hash bucket itself is already a &quot;range&quot; of directory entries, since it being empty means that none of the entries hashing to that bucket are present. Since the number of hash buckets is limited, that could be enough to limit the number of negative &quot;ranges&quot;.<br> </div> Tue, 12 Apr 2022 20:54:26 +0000 Negative dentries, 20 years later https://lwn.net/Articles/891092/ https://lwn.net/Articles/891092/ NYKevin <div class="FormattedComment"> <font class="QuotedText">&gt; And being a hash table, you can return a definitive yes/no just by scanning the one bucket.</font><br> <p> You have entirely missed the point. We&#x27;re not trying to figure out whether the bucket is occupied, we&#x27;re trying to find its nearest occupied neighbors so that we can find an empty range of buckets. That requires a linear scan over neighboring buckets.<br> <p> Furthermore, if you allow deletions, then a linearly-growing hash table does not help, because you can grow the hash table to be huge, and then depopulate it (e.g. by making lots of entries in a directory, then removing them).<br> </div> Tue, 12 Apr 2022 19:26:06 +0000 Negative dentries, 20 years later https://lwn.net/Articles/891080/ https://lwn.net/Articles/891080/ vgoyal <div class="FormattedComment"> We indeed raise open file limit to 1M by default. But that requires CAP_SYS_RESOURCE. We also have been looking at running virtiofsd unprivileged and don&#x27;t have CAP_SYS_RESOURCE and hence can&#x27;t raise the limit.<br> </div> Tue, 12 Apr 2022 16:06:30 +0000 Intuitive ways to exit text editors https://lwn.net/Articles/891078/ https://lwn.net/Articles/891078/ dskoll <p>It can be hard to get out of emacs too, sometimes. The emergency cheat-sheet: <p>vi: <tt>Esc Esc Esc :q!</tt> <p>emacs: <tt>Ctrl-G Ctrl-G Ctrl-G Ctrl-X Ctrl-C</tt> Tue, 12 Apr 2022 15:50:02 +0000 Negative dentries, 20 years later https://lwn.net/Articles/891059/ https://lwn.net/Articles/891059/ Wol <div class="FormattedComment"> <font class="QuotedText">&gt; Typically, when we characterize the performance of a hash table, we assume that it has some maximum fullness. That is, if there are N buckets, then we assume that there are at most kN elements in the hash table (for some k with, in most cases, 0 &lt; k &lt; 1); if the hash table grows larger than that, it gets rebuilt with more buckets.</font><br> <p> Or you use a modern hash algorithm like, dare I say it, Pick has used for the last 40 years ... I believe it&#x27;s the same one as used by Python and Sleepycat/Berkeley amongst others.<br> <p> <a href="https://en.wikipedia.org/wiki/Linear_hashing">https://en.wikipedia.org/wiki/Linear_hashing</a><br> <p> tldr;<br> Given 2^(n-1) &lt; N &lt;= 2^n, if mod(2^n) gives a valid bucket use that otherwise use mod(2^(n-1)). When creating a new bucket N+1, all the records that belong in the new bucket will currently be in bucket (N+1)mod(2^(n-1)), so the cost of growing the hash table by one bucket at a time is constant. So the hash table can be kept at optimal fullness with minimal cost.<br> <p> And being a hash table, you can return a definitive yes/no just by scanning the one bucket.<br> <p> Cheers,<br> Wol<br> </div> Tue, 12 Apr 2022 12:42:55 +0000 Negative dentries, 20 years later https://lwn.net/Articles/891058/ https://lwn.net/Articles/891058/ aaronmdjones <div class="FormattedComment"> <font class="QuotedText">&gt; As it happens, repeated attempts to look up a nonexistent file are also common; an example would be the shell&#x27;s process of working through the search path every time a user types &quot;vi&quot; (Emacs users start the editor once and never leave its cozy confines thereafter, so they don&#x27;t benefit in the same way).</font><br> <p> It could also be argued that vi users don&#x27;t benefit either, because they can&#x27;t figure out how to close it.<br> </div> Tue, 12 Apr 2022 12:04:32 +0000 Negative dentries, 20 years later https://lwn.net/Articles/891057/ https://lwn.net/Articles/891057/ grawity <blockquote><p>some filesystems may not be able to provide this information within acceptable performance parameters. For example, consider a FUSE filesystem like &lt;https://pypi.org/project/simple-httpfs/&gt;</p></blockquote> <p>I think you would have the same problem with ordinary network filesystems like NFS/SMB when accessing a directory where you have +x but not +r. The server knows the nearest two files in that directory, but the client doesn't have the permissions to know that.</p> Tue, 12 Apr 2022 11:37:58 +0000 Negative dentries, 20 years later https://lwn.net/Articles/891014/ https://lwn.net/Articles/891014/ pomac <div class="FormattedComment"> You don&#x27;t really want to make things exhaustive... Imagine having users creating single directories with millions of files.<br> <p> It&#x27;s already a DoS in terms of memory due to how Linux works but enumerating them all with caches... Nah.. ;)<br> </div> Tue, 12 Apr 2022 09:16:27 +0000 Negative dentries, 20 years later https://lwn.net/Articles/891011/ https://lwn.net/Articles/891011/ josh <div class="FormattedComment"> <font class="QuotedText">&gt; Is there a way to track the amount of time it took to generate the dentry, and then trash the cheaper ones and keep the more expensive ones?</font><br> <p> That seems like a useful heuristic to weight entries, if you also take into account the number of lookups.<br> </div> Tue, 12 Apr 2022 07:45:54 +0000 Negative dentries, 20 years later https://lwn.net/Articles/891012/ https://lwn.net/Articles/891012/ geert <div class="FormattedComment"> Why not a power of two? ;-)<br> </div> Tue, 12 Apr 2022 07:44:51 +0000 Negative dentries, 20 years later https://lwn.net/Articles/891010/ https://lwn.net/Articles/891010/ dgc <div class="FormattedComment"> Hi Jon,<br> <p> More discussion of the periodic reclaim concept for controlling cache explosions can be found under this thread:<br> <p> <a href="https://lwn.net/ml/linux-mm/20220402072103.5140-1-hdanton%40sina.com/">https://lwn.net/ml/linux-mm/20220402072103.5140-1-hdanton...</a><br> <p> -Dave.<br> </div> Tue, 12 Apr 2022 07:26:19 +0000 Negative dentries, 20 years later https://lwn.net/Articles/891005/ https://lwn.net/Articles/891005/ benjamir <div class="FormattedComment"> Isn&#x27;t the number of open files (sometimes) user defined?<br> Why not depend on that (in fractions or multiples)?<br> </div> Tue, 12 Apr 2022 04:39:02 +0000 Negative dentries, 20 years later https://lwn.net/Articles/891000/ https://lwn.net/Articles/891000/ NYKevin <div class="FormattedComment"> <font class="QuotedText">&gt; (where N is the number of buckets, which is proportional to the actual number of dentries)</font><br> <p> Correction: Where N is proportional to *the largest number of dentries that the directory has ever had, or the largest number since the last time the filesystem shrank the hash table, if the filesystem does that at all.* This makes things significantly worse, because it means you really can get N - 1 for large N in a non-pathological case (i.e. removing most or all of the contents of a directory, but not rmdir&#x27;ing the directory itself).<br> </div> Tue, 12 Apr 2022 00:24:35 +0000 Negative dentries, 20 years later https://lwn.net/Articles/890999/ https://lwn.net/Articles/890999/ NYKevin <div class="FormattedComment"> <font class="QuotedText">&gt; For unsorted directories, you already have to scan the whole directory linearly on a cache miss; the only change would be to keep track of the nearest preceding and following names.</font><br> <p> That is probably acceptable.<br> <p> <font class="QuotedText">&gt; For a sorted structure, the lookup code would have to be modified to return the neighbor entries when the entry is not found. There&#x27;s an extra complication in that the range lookup would have to use the filesystem&#x27;s native concept of order, which could differ from filesystem to filesystem (for instance, the order might be based on a hash of the filename).</font><br> <p> This might require more complicated tree traversal logic, in the case where one of the neighbor leaves is in a different subtree to the other neighbor leaf. At worst, that probably adds an extra O(log n) root-to-leaf traversal, which is likely acceptable in practice.<br> <p> <font class="QuotedText">&gt; I don&#x27;t have a good solution for filesystems which use a hash table directly, though an approach using directly the low-level details of the hash table might be possible (that is, a negative entry would map to a range of hash buckets).</font><br> <p> Typically, when we characterize the performance of a hash table, we assume that it has some maximum fullness. That is, if there are N buckets, then we assume that there are at most kN elements in the hash table (for some k with, in most cases, 0 &lt; k &lt; 1); if the hash table grows larger than that, it gets rebuilt with more buckets. This periodic rebuilding is necessary if you want a hash table to have O(1) performance on its standard operations - else it will eventually degrade to linear scans (regardless of whether you use open hashing or closed hashing). But this also means that it&#x27;s possible for the hash table to be much, much sparser than k, if it has just been rebuilt (or if you&#x27;ve only added a small number of elements in the first place). As a result, in the worst case you could potentially scan N-1 consecutive buckets to find the boundaries (when there&#x27;s only one occupied bucket). In cases where the hash table was just rebuilt, you could observe up to N - kn consecutive empty buckets, where n is the previous size (n depends on your growth algorithm, but it&#x27;s probably some constant fraction of N, e.g. n = N/2). In both cases, this means our worst case performance has degraded from O(1) to O(N) (where N is the number of buckets, which is proportional to the actual number of dentries). That is likely to be unacceptable, for systems where we decided to use a hash table in the first place, because it defeats the main selling point of a hash table.<br> <p> <font class="QuotedText">&gt; The worst case would be remote filesystems (which also includes things like FUSE), since not only their API would have no concept of a negative dentry range, but also a range could become invalid without warning.</font><br> <p> That also applies to individual negative dentries. The only way negative dentry caching can possibly work is if it takes place on the server side, and not the client side. Which is rather unfortunate, seeing as the network roundtrip is by far the more expensive operation than the disk lookup (at least in high-latency deployments, anyway).<br> </div> Tue, 12 Apr 2022 00:17:07 +0000 Negative dentries, 20 years later https://lwn.net/Articles/890997/ https://lwn.net/Articles/890997/ vgoyal <div class="FormattedComment"> Controlling the size of dentry cache without memory pressure can help us in one of the problems we face with virtiofs. As dentry cache is growing, it keeps inodes around, that means it keeps corresponding data structures around in virtiofs daemon. And it keeps O_PATH fd per inode on server. And soon we run out of number of open fd a process can have. If guest has good amount of RAM, it can cache lot of dentries/inodes without memory pressure and create problems for virtiofs daemon. Some notion/knob of controlling the size of dentry cache without memory pressure can possibly.<br> </div> Mon, 11 Apr 2022 23:54:43 +0000 Negative dentries, 20 years later https://lwn.net/Articles/890994/ https://lwn.net/Articles/890994/ cesarb <div class="FormattedComment"> <font class="QuotedText">&gt; By all means try to implement this, but I think it&#x27;ll be vastly inferior to the current dcache.</font><br> <p> I don&#x27;t doubt that it would be inferior; still, it&#x27;s an interesting thought experiment.<br> <p> <font class="QuotedText">&gt; Lookup is currently hash(directory pointer, component) and search the global hash table. What you&#x27;re proposing would be a per-directory data structure to search, so a massive change.</font><br> <p> Actually, it could be a per-filesystem data structure, if the concept of range is extended to include the parent directory; but it would have to be something like hash(directory pointer) || key(component), with the definition of key() depending on the filesystem&#x27;s native on-disk order (if it has one; naïve filesystems with simple unsorted directories could use hash(component) for the key). I agree that it would be a massive change, with potential gains only on an unlikely case (a large amount of lookups to non-existing entries, which could be hits on a negative range cache but would be misses on a negative entry cache).<br> <p> <font class="QuotedText">&gt; Also, you&#x27;d need to be able to query the filesystem for the &quot;previous&quot; and &quot;next&quot; entries ... for whatever sort you think needs to be used (filesystem directories are not necessarily sorted in any way you think they are).</font><br> <p> Yes, the sort would have to be filesystem-specific; I went into more detail on another comment above.<br> </div> Mon, 11 Apr 2022 23:30:51 +0000 Negative dentries, 20 years later https://lwn.net/Articles/890993/ https://lwn.net/Articles/890993/ cesarb <div class="FormattedComment"> <font class="QuotedText">&gt; I&#x27;m not clear on how you would go about creating negative dentry ranges in a non-exhaustive cache.</font><br> <p> It would need help from each filesystem. I can think of three main ways of storing directory entries on a filesystem: they can be an unsorted list of filenames (as you mentioned, FAT and ext2 are good examples), or they can be a more complicated sorted structure (either a linear ordered list or something like a b-tree), or they can be an unsorted hash table.<br> <p> For unsorted directories, you already have to scan the whole directory linearly on a cache miss; the only change would be to keep track of the nearest preceding and following names.<br> <p> For a sorted structure, the lookup code would have to be modified to return the neighbor entries when the entry is not found. There&#x27;s an extra complication in that the range lookup would have to use the filesystem&#x27;s native concept of order, which could differ from filesystem to filesystem (for instance, the order might be based on a hash of the filename).<br> <p> I don&#x27;t have a good solution for filesystems which use a hash table directly, though an approach using directly the low-level details of the hash table might be possible (that is, a negative entry would map to a range of hash buckets).<br> <p> The worst case would be remote filesystems (which also includes things like FUSE), since not only their API would have no concept of a negative dentry range, but also a range could become invalid without warning.<br> </div> Mon, 11 Apr 2022 23:10:59 +0000 Negative dentries, 20 years later https://lwn.net/Articles/890992/ https://lwn.net/Articles/890992/ MattBBaker <div class="FormattedComment"> It seems like there is also a question of how valuable each dentry, negative or not, really is. A lookup on a local SSD is going to be a lot easier on the system if you get the policy wrong than will a bad decision on a NFS filesystem. Is there a way to track the amount of time it took to generate the dentry, and then trash the cheaper ones and keep the more expensive ones?<br> </div> Mon, 11 Apr 2022 22:26:36 +0000 Negative dentries, 20 years later https://lwn.net/Articles/890991/ https://lwn.net/Articles/890991/ willy <div class="FormattedComment"> By all means try to implement this, but I think it&#x27;ll be vastly inferior to the current dcache.<br> <p> Lookup is currently hash(directory pointer, component) and search the global hash table. What you&#x27;re proposing would be a per-directory data structure to search, so a massive change.<br> <p> Also, you&#x27;d need to be able to query the filesystem for the &quot;previous&quot; and &quot;next&quot; entries ... for whatever sort you think needs to be used (filesystem directories are not necessarily sorted in any way you think they are).<br> </div> Mon, 11 Apr 2022 22:13:58 +0000 Negative dentries, 20 years later https://lwn.net/Articles/890986/ https://lwn.net/Articles/890986/ NYKevin <div class="FormattedComment"> It is my understanding that the dentry cache is currently non-exhaustive, that is, it does not contain every dentry in a given directory, but only those that have been recently accessed. I&#x27;m not clear on how you would go about creating negative dentry ranges in a non-exhaustive cache. I can think of a few ways to do it, but they all seem obviously terrible to me:<br> <p> 1. Make the dentry cache exhaustive; scan and pre-cache the entire directory when you want to cache any individual dentry. On ext4 and other modern FS&#x27;s, this will result in hilariously large caches in some cases, because directories are allowed to have a very large number of entries. Also, the scan will take a long time to complete.<br> 2. Scan the directory once every time a failed lookup occurs, and make a negative dentry for the range surrounding that failed lookup. This slows down failed lookups by potentially quite a lot, especially on filesystems where dentries are not sorted in any convenient way (e.g. most if not all versions of FAT, ext2).<br> 3. Scan the directory once every time a successful lookup occurs, and make negative dentries for the two ranges adjacent to the successful lookup. This is subject to most of the same problems as (2), except that it slows down successful lookups instead of failed lookups.<br> 4. Periodically identify directories that have a lot of cached negative dentries, scan them, and coalesce their negative dentries into ranges. But it would be far simpler to just expire the negative dentries which have not been recently used; a negative dentry does not correspond to anything on disk, and so negative dentries are always clean and can be unceremoniously discarded without disk access (i.e. discarding is very fast compared to scanning).<br> </div> Mon, 11 Apr 2022 21:49:10 +0000 Negative dentries, 20 years later https://lwn.net/Articles/890985/ https://lwn.net/Articles/890985/ nybble41 <div class="FormattedComment"> <font class="QuotedText">&gt; a solution could be to, instead of storing the name of the nonexistent file, storing the name of the existent files preceding and following the existent file</font><br> <p> I like this. Automatically bounded, and you can potentially answer many queries with a single negative range. You could even reuse the positive dentries for the preceding and following files, so long as you can ensure they won&#x27;t be freed prematurely, further reducing RAM requirements.<br> <p> The main drawback seems to me to be that the current filesystem APIs don&#x27;t provide the preceding and following files in response to failed lookups—which could be changed—and, more importantly, that some filesystems may not be able to provide this information within acceptable performance parameters. For example, consider a FUSE filesystem like &lt;<a href="https://pypi.org/project/simple-httpfs/">https://pypi.org/project/simple-httpfs/</a>&gt; which only responds to requests for specific paths and can&#x27;t be enumerated to find the preceding and following positive entries. (And even if it could, that information could be obsolete before the query finishes; this can even affect simple non-range negative dentries but storing ranges, including names not directly queried, would make it worse.)<br> <p> One can imagine using a mix of ranges where filesystem support exists and simple negative entries where it doesn&#x27;t, but then we still need to solve the original problem. Or we could just not cache negative lookups from filesystems that can&#x27;t provide ranges, but that has its own drawbacks.<br> </div> Mon, 11 Apr 2022 21:48:32 +0000 Negative dentries, 20 years later https://lwn.net/Articles/890983/ https://lwn.net/Articles/890983/ cesarb <div class="FormattedComment"> <font class="QuotedText">&gt; While normal dentries are limited by the number of files that actually exist, there are few limits to the number of nonexistent files.</font><br> <p> But there is a limit to the number of _ranges_ of nonexistent files: they are limited by the number of files that actually exist plus one. So a solution could be to, instead of storing the name of the nonexistent file, storing the name of the existent files preceding and following the existent file. There is precedent in the NSEC family of DNS entry types (NSEC and NSEC3), which prove the absence of a record on a DNS zone by signing a record containing both the preceding and following names.<br> <p> (You could also make the ranges circular to remove the &quot;plus one&quot; and avoid a couple of special cases.)<br> </div> Mon, 11 Apr 2022 20:35:38 +0000 Negative dentries, 20 years later https://lwn.net/Articles/890981/ https://lwn.net/Articles/890981/ willy <div class="FormattedComment"> The idea I&#x27;m currently advocating (a little busy with other projects to work on myself) is that after allocating 100 entries, we scan 110 entries at the tail of the list and either return them to the head of the list with their &#x27;referenced&#x27; flag cleared, or free them. That allows the cache to both shrink (if &lt;100 have been referenced) and grow (if &gt;100 have been referenced)<br> <p> Obviously those numbers are a bit magic. Why not 150? Or 200? Needs some experimentation.<br> </div> Mon, 11 Apr 2022 19:31:34 +0000 Negative dentries, 20 years later https://lwn.net/Articles/890977/ https://lwn.net/Articles/890977/ dskoll <p>Right. I guess limiting the size of the dentry cache so we start evicting before we have general memory pressure is the main idea, but allowing it to expand if by some miracle all entries have been hit so that it scales up if memory is available. Mon, 11 Apr 2022 19:03:48 +0000 Negative dentries, 20 years later https://lwn.net/Articles/890975/ https://lwn.net/Articles/890975/ willy <div class="FormattedComment"> You&#x27;re absolutely correct that never-accessed negative dentries have no value. And we even have a single bit that says whether the dentry has been accessed since the last time it got to the end of the LRU list. The problem is, as Dave says, that we don&#x27;t try to turn the list over to find which ones are and aren&#x27;t used until were under general memory pressure.<br> </div> Mon, 11 Apr 2022 18:56:21 +0000 Negative dentries, 20 years later https://lwn.net/Articles/890973/ https://lwn.net/Articles/890973/ dskoll <p>It seems to me that a negative dentry is useful only to the extent that it's hit. So what if the total number of negative dentries was limited to some small number and if that number is exceeded, then either (1) we evict an entry that has never been hit yet (or hit fewer than N times), or (2) we increase the negative dentry cache size by some amount if all negative dentries have been hit at least once (or at least N times). <p>This means keeping track of how many times a negative dentry is hit. <p>Caveat: I'm not a kernel programmer and have no idea how this would work in practice with the existing data structures. Mon, 11 Apr 2022 18:19:30 +0000