fs/dcache: Track & limit # of negative dentries
Subsystems (5)
v5 cover fs/dcache: Track & limit # of negative dentries
v4->v5:
- Backed to the latest 4.18 kernel and modify the code accordingly. Patch 1 "Relocate dentry_kill() after lock_parent()" is now no longer necessary.
- Make tracking and limiting of negative dentries an user configurable option (CONFIG_DCACHE_TRACK_NEG_ENTRY) so that users can decide if they want to include this capability in the kernel.
- Make killing excess negative dentries an optional feature that can be enabled via a boot command line option or a sysctl parameter.
- Spread negative dentry pruning across multiple CPUs.
v4: https://lkml.org/lkml/2017/9/18/739
A rogue application can potentially create a large number of negative dentries in the system consuming most of the memory available if it is not under the direct control of a memory controller that enforce kernel memory limit.
This patchset introduces changes to the dcache subsystem to track and optionally limit the number of negative dentries allowed to be created by background pruning of excess negative dentries or even kill it after use. This capability will help to limit the amount of memory that can be consumed by negative dentries.
Patch 1 tracks the number of negative dentries present in the LRU lists and reports it in /proc/sys/fs/dentry-state.
Patch 2 makes negative dentry tracking a user configurable option (CONFIG_DCACHE_TRACK_NEG_ENTRY) as well as adding a "neg_dentry_pc=" boot command line option to specify a soft limit on the number of negative allowed as a percentage of total system memory. The default is 2%.
Patch 3 enables automatic pruning of least recently used negative dentries when the total number is close to the preset limit.
Patch 4 spreads the negative dentry pruning effort to multiple CPUs to make it more fair.
Patch 5 extends the "neg_dentry_pc=" boot command line option to optionally enable enforcing the limit by killing off excess negative dentries immediately after use.
Patch 6 makes the limit enforcing option a sysctl parameter so that it can be dynamically enabled at run time if the need arises, for example, when a rogue application generating a lot of negative dentries is detected.
Waiman Long (6):
fs/dcache: Track & report number of negative dentries fs/dcache: Make negative dentry tracking configurable fs/dcache: Enable automatic pruning of negative dentries fs/dcache: Spread negative dentry pruning across multiple CPUs fs/dcache: Allow optional enforcement of negative dentry limit fs/dcache: Make negative dentry limit enforcement sysctl parameter
Documentation/admin-guide/kernel-parameters.txt | 12 + Documentation/sysctl/fs.txt | 30 +- fs/Kconfig | 10 + fs/dcache.c | 452 +++++++++++++++++++++++- include/linux/dcache.h | 13 +- include/linux/list_lru.h | 1 + kernel/sysctl.c | 11 + mm/list_lru.c | 4 +- 8 files changed, 519 insertions(+), 14 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v5 1/6 fs/dcache: Track & report number of negative dentries
The current dentry number tracking code doesn't distinguish between positive & negative dentries. It just reports the total number of dentries in the LRU lists.
As excessive number of negative dentries can have an impact on system performance, it will be wise to track the number of positive and negative dentries separately.
This patch adds tracking for the total number of negative dentries in the system LRU lists and reports it in the /proc/sys/fs/dentry-state file. The number of positive dentries in the LRU lists can be found by subtracting the number of negative dentries from the total.
--- Documentation/sysctl/fs.txt | 19 +++++++++++++------ fs/dcache.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/dcache.h | 7 ++++--- 3 files changed, 62 insertions(+), 9 deletions(-)
Documentation/sysctl/fs.txt +13 -6
@@ -61,19 +61,26 @@ struct { int nr_unused; int age_limit; /* age in seconds */ int want_pages; /* pages requested by system */ - int dummy[2]; + int nr_negative; /* # of unused negative dentries */ + int dummy; } dentry_stat = {0, 0, 45, 0,}; --------------------------------------------------------------- +-------------------------------------------------------------- + +Dentries are dynamically allocated and deallocated. + +nr_dentry shows the total number of dentries allocated (active ++ unused). nr_unused shows the number of dentries that are not +actively used, but are saved in the LRU list for future reuse. -Dentries are dynamically allocated and deallocated, and -nr_dentry seems to be 0 all the time. Hence it's safe to -assume that only nr_unused, age_limit and want_pages are -used. Nr_unused seems to be exactly what its name says. Age_limit is the age in seconds after which dcache entries can be reclaimed when memory is short and want_pages is nonzero when shrink_dcache_pages() has been called and the dcache isn't pruned yet. +nr_negative shows the number of unused dentries that are also +negative dentries which do not mapped to actual files if negative +dentries tracking is enabled. + ============================================================== dquot-max & dquot-nr:
fs/dcache.c +45 -0
104 lines not on this page · raw message
include/linux/dcache.h +4 -3
@@ -62,9 +62,10 @@ struct qstr {struct dentry_stat_t {long nr_dentry;long nr_unused; -long age_limit;/* age in seconds */ -long want_pages;/* pages requested by system */ -long dummy[2 ]; +long age_limit;/* age in seconds */ +long want_pages;/* pages requested by system */ +long nr_negative;/* # of unused negative dentries */ +long dummy; };extern struct dentry_stat_t dentry_stat;
Signature · 1 line
1.8.3.1
PATCH v5 2/6 fs/dcache: Make negative dentry tracking configurable
In reply to Waiman LongThe negative dentry tracking is made a configurable option so that users who don't care about negative dentry tracking will have the option to disable it. The new config option DCACHE_TRACK_NEG_ENTRY is disabled by default.
If this option is enabled, a new kernel parameter "neg_dentry_pc=<%>" allows users to set the soft limit on how many negative dentries are allowed as a percentage of the total system memory. The default is 2% and this new parameter accept a range of 0-10% where 0% means there is no limit.
When the soft limit is reached, a warning message will be printed to the console to alert the system administrator.
--- Documentation/admin-guide/kernel-parameters.txt | 9 ++ fs/Kconfig | 10 ++ fs/dcache.c | 170 +++++++++++++++++++++++- 3 files changed, 184 insertions(+), 5 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +9 -0
@@ -2462,6 +2462,15 @@ n2= [NET] SDL Inc. RISCom/N2 synchronous serial card + neg_dentry_pc= + With "CONFIG_DCACHE_TRACK_NEG_ENTRY=y", specify + the limit for the number negative dentries + allowable in a system as a percentage of the + total system memory. The default is 2% and the + valid range is 0-10 where 0 means no limit. + + Format: <pc> + netdev= [NET] Network devices parameters Format: <irq>,<io>,<mem_start>,<mem_end>,<name> Note that mem_start is often overloaded to mean
fs/Kconfig +10 -0
@@ -113,6 +113,16 @@ source "fs/autofs/Kconfig" source "fs/fuse/Kconfig" source "fs/overlayfs/Kconfig" +# +# Track and limit the number of negative dentries allowed in the system. +# +config DCACHE_TRACK_NEG_ENTRY + bool "Track & limit negative dcache entries" + default n + help + This option enables the tracking and limiting of the total + number of negative dcache entries in the filesystem. + menu "Caches" source "fs/fscache/Kconfig"
fs/dcache.c +165 -5
230 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Andrew Morton
maintainerRe: [PATCH v5 2/6] fs/dcache: Make negative dentry tracking configurable
Quoted 5 lines · On Mon, 2 Jul 2018 13:51:59 +0800 Waiman Long <[email protected]> wrote:
The negative dentry tracking is made a configurable option so that users who don't care about negative dentry tracking will have the option to disable it. The new config option
DCACHE_TRACK_NEG_ENTRYis disabled by default.
Quoted 8 lines
If this option is enabled, a new kernel parameter "neg_dentry_pc=<%>" allows users to set the soft limit on how many negative dentries are allowed as a percentage of the total system memory. The default is 2% and this new parameter accept a range of 0-10% where 0% means there is no limit.
When the soft limit is reached, a warning message will be printed to the console to alert the system administrator.
It would be much more convenient if this was tunable at runtime via yet another /proc knob. Is there any particular reason why we can't do this?
Re: [PATCH v5 2/6] fs/dcache: Make negative dentry tracking configurable
Quoted 13 lines · Andrew Morton
Quoted 11 lines · On Mon, 2 Jul 2018 13:51:59 +0800 Waiman Long <[email protected]> wrote:
The negative dentry tracking is made a configurable option so that users who don't care about negative dentry tracking will have the option to disable it. The new config option
DCACHE_TRACK_NEG_ENTRYis disabled by default.If this option is enabled, a new kernel parameter "neg_dentry_pc=<%>" allows users to set the soft limit on how many negative dentries are allowed as a percentage of the total system memory. The default is 2% and this new parameter accept a range of 0-10% where 0% means there is no limit.
Quoted 5 lines
Quoted 2 lines
When the soft limit is reached, a warning message will be printed to the console to alert the system administrator.
It would be much more convenient if this was tunable at runtime via yet another /proc knob. Is there any particular reason why we can't do this?
The percpu accounting of negative dentries cannot be dynamically turn on and off or the count won't be accurate. Fortunately that part shouldn't introduce any noticeable overhead. Everything else can be dynamically turn on or off, if desired. I will look into making this patchset more dynamic in the next version.
Cheers,
Longman
PATCH v5 3/6 fs/dcache: Enable automatic pruning of negative dentries
In reply to Waiman LongIt is not good enough to have a soft limit for the number of negative dentries in the system and print a warning if that limit is exceeded. We need to do something about it when this happens.
This patch enables automatic pruning of negative dentries when the soft limit is going to be exceeded. This is done by using the workqueue API to do the pruning gradually when a threshold is reached to minimize performance impact on other running tasks.
The current threshold is 1/4 of the initial value of the free pool count. Once the threshold is reached, the automatic pruning process will be kicked in to replenish the free pool. Each pruning run will scan 64 dentries per LRU list and can remove up to 256 negative dentries to minimize the LRU locks hold time. The pruning rate will be 50 Hz if the free pool count is less than 1/8 of the original and 10 Hz otherwise.
The dentry pruning operation may also free some least recently used positive dentries.
In the unlikely event that a superblock is being umount'ed while in negative dentry pruning mode, the umount may face an additional delay of up to 0.1s.
--- fs/dcache.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/list_lru.h | 1 + mm/list_lru.c | 4 +- 3 files changed, 162 insertions(+), 1 deletion(-)
fs/dcache.c +158 -0
@@ -136,6 +136,11 @@ struct dentry_stat_t dentry_stat = {*/ #define NEG_DENTRY_PC_DEFAULT 2#define NEG_DENTRY_BATCH (1 << 8) +#define NEG_PRUNING_SIZE (1 << 6) +#define NEG_PRUNING_SLOW_RATE (HZ/10) +#define NEG_PRUNING_FAST_RATE (HZ/50) +#define NEG_IS_SB_UMOUNTING (sb) \ + unlikely(!(sb)->s_root || !((sb)->s_flags & MS_ACTIVE))#ifdef CONFIG_DCACHE_TRACK_NEG_ENTRY static int neg_dentry_pc__read_mostly =NEG_DENTRY_PC_DEFAULT ;
@@ -143,8 +148,17 @@ struct dentry_stat_t dentry_stat = {static long neg_dentry_nfree_init__read_mostly ;/* Free pool initial value */ static struct {raw_spinlock_t nfree_lock; +int niter;/* Pruning iteration count */ +int lru_count;/* Per-LRU pruning count */ +long n_neg;/* # of negative dentries pruned */ +long n_pos;/* # of positive dentries pruned */ long nfree;/* Negative dentry free pool */ +struct super_block *prune_sb;/* Super_block for pruning */ } ndblk____cacheline_aligned_in_smp ; + +static void prune_negative_dentry (struct work_struct *work); +static DECLARE_DELAYED_WORK(prune_neg_dentry_work, prune_negative_dentry); + static DEFINE_PER_CPU(long, nr_dentry_neg);#endif
@@ -330,6 +344,25 @@ static void __neg_dentry_inc(struct dentry *dentry)*/ if (!cnt)pr_warn_once ("Too many negative dentries." ); + +/* +* Initiate negative dentry pruning if free pool has less than +* 1/4 of its initial value. +*/ +if ((READ_ONCE (ndblk.nfree) <READ_ONCE (neg_dentry_nfree_init)/4 ) && + !READ_ONCE (ndblk.prune_sb) && + !cmpxchg (&ndblk.prune_sb,NULL , dentry->d_sb)) { +/* +* Abort if umounting is in progress, otherwise take a +* reference and move on. +*/ +if (NEG_IS_SB_UMOUNTING (ndblk.prune_sb)) { +WRITE_ONCE (ndblk.prune_sb,NULL ); + }else { +atomic_inc (&ndblk.prune_sb->s_active); +schedule_delayed_work (&prune_neg_dentry_work,1 ); + } + } }static inline void neg_dentry_inc (struct dentry *dentry)
@@ -1368,6 +1401,131 @@ void shrink_dcache_sb(struct super_block *sb) }EXPORT_SYMBOL (shrink_dcache_sb); +#ifdef CONFIG_DCACHE_TRACK_NEG_ENTRY +/* +* A modified version that attempts to remove a limited number of negative +* dentries as well as some other non-negative dentries at the front. +*/ +static enum lru_status dentry_negative_lru_isolate (struct list_head *item, +struct list_lru_one *lru,spinlock_t *lru_lock,void *arg) +{ +struct list_head *freeable = arg; + struct dentry *dentry = container_of(item, struct dentry, d_lru); +enum lru_status status =LRU_SKIP ; + +/* +* Limit amount of dentry walking in each LRU list. +*/ +if (ndblk.lru_count >=NEG_PRUNING_SIZE ) { + ndblk.lru_count =0 ; +return LRU_STOP ; + } + ndblk.lru_count++; + +/* +* we are inverting the lru lock/dentry->d_lock here, +* so use a trylock. If we fail to get the lock, just skip +* it +*/ +if (!spin_trylock (&dentry->d_lock)) +return LRU_SKIP ; + +/* +* Referenced dentries are still in use. If they have active +* counts, just remove them from the LRU. Otherwise give them +* another pass through the LRU. +*/ +if (dentry->d_lockref.count) { +d_lru_isolate (lru, dentry); + status =LRU_REMOVED ; + goto out; + } + +/* +* Dentries with reference bit on are moved back to the tail. +*/ +if (dentry->d_flags &DCACHE_REFERENCED ) { + dentry->d_flags &= ~DCACHE_REFERENCED ; + status =LRU_ROTATE ; + goto out; + } + + status =LRU_REMOVED ; +d_lru_shrink_move (lru, dentry, freeable); +if (d_is_negative (dentry)) + ndblk.n_neg++; +out: +spin_unlock (&dentry->d_lock); +return status; +} + +/* +* A workqueue function to prune negative dentry. +* +* The pruning is done gradually over time so as to have as little +* performance impact as possible. +*/ +static void prune_negative_dentry (struct work_struct *work) +{ +int freed, last_n_neg; +long nfree; +struct super_block *sb =READ_ONCE (ndblk.prune_sb); +LIST_HEAD (dispose); + +if (!sb) +return ; +if (NEG_IS_SB_UMOUNTING (sb)) + goto stop_pruning; + + ndblk.niter++; + ndblk.lru_count =0 ; + last_n_neg = ndblk.n_neg; + freed =list_lru_walk (&sb->s_dentry_lru, dentry_negative_lru_isolate, + &dispose,NEG_DENTRY_BATCH ); + +if (freed) +shrink_dentry_list (&dispose); + ndblk.n_pos += freed - (ndblk.n_neg - last_n_neg); + +/* +* Continue delayed pruning until negative dentry free pool is at +* least 1/2 of the initial value, the super_block has no more +* negative dentries left at the front, or unmounting is in +* progress. +* +* The pruning rate depends on the size of the free pool. The +* faster rate is used when there is less than 1/8 left. +* Otherwise, the slower rate will be used. +*/ + nfree =READ_ONCE (ndblk.nfree); +if ((ndblk.n_neg == last_n_neg) || + (nfree >= neg_dentry_nfree_init/2 ) ||NEG_IS_SB_UMOUNTING (sb)) + goto stop_pruning; + +schedule_delayed_work (&prune_neg_dentry_work, + (nfree < neg_dentry_nfree_init/8 ) + ?NEG_PRUNING_FAST_RATE :NEG_PRUNING_SLOW_RATE ); +return ; + +stop_pruning: +#ifdef CONFIG_DEBUG_KERNEL +/* +* Report large negative dentry pruning event. +*/ +if (ndblk.n_neg >NEG_PRUNING_SIZE ) { +pr_info ("Negative dentry pruning (SB=%s):\n\t" +"%d iterations, %ld/%ld neg/pos dentries freed.\n" , + ndblk.prune_sb->s_id, ndblk.niter, ndblk.n_neg, + ndblk.n_pos); + } +#endif + ndblk.niter =0 ; + ndblk.n_neg = ndblk.n_pos =0 ; +deactivate_super (sb); +WRITE_ONCE (ndblk.prune_sb,NULL ); +} +#endif /* CONFIG_DCACHE_TRACK_NEG_ENTRY */ +/** * enum d_walk_ret - action to talke during tree walk * @D_WALK_CONTINUE: contrinue walk
include/linux/list_lru.h +1 -0
@@ -23,6 +23,7 @@ enum lru_status {LRU_SKIP ,/* item cannot be locked, skip */ LRU_RETRY ,/* item not freeable. May drop the lock internally, but has to return locked. */ + LRU_STOP, /* stop walking the list */ }; struct list_lru_one {
mm/list_lru.c +3 -1
@@ -246,11 +246,13 @@ unsigned long list_lru_count_node(struct list_lru *lru, int nid)*/ assert_spin_locked (&nlru->lock); goto restart; +case LRU_STOP : + goto out;default :BUG (); } } - +out:spin_unlock (&nlru->lock);return isolated; }
Signature · 1 line
1.8.3.1
PATCH v5 4/6 fs/dcache: Spread negative dentry pruning across multiple CPUs
In reply to Waiman LongDoing negative dentry pruning using schedule_delayed_work() will typically concentrate the pruning effort on one particular CPU. That is not fair to the tasks running on that CPU. In addition, it is possible that one CPU can have all its negative dentries pruned away while the others can still have more negative dentries than the percpu limit.
To be fair, negative dentries pruning is now done across all the online CPUs, if they all have close to the percpu limit of negative dentries.
--- fs/dcache.c | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-)
fs/dcache.c +38 -5
@@ -360,7 +360,8 @@ static void __neg_dentry_inc(struct dentry *dentry)WRITE_ONCE (ndblk.prune_sb,NULL ); }else {atomic_inc (&ndblk.prune_sb->s_active); -schedule_delayed_work (&prune_neg_dentry_work,1 ); +schedule_delayed_work_on (smp_processor_id (), + &prune_neg_dentry_work,1 ); } } }
@@ -1467,8 +1468,9 @@ static enum lru_status dentry_negative_lru_isolate(struct list_head *item,*/ static void prune_negative_dentry (struct work_struct *work) { +int cpu =smp_processor_id ();int freed, last_n_neg; -long nfree; +long nfree, excess;struct super_block *sb =READ_ONCE (ndblk.prune_sb);LIST_HEAD (dispose);
@@ -1502,9 +1504,40 @@ static void prune_negative_dentry(struct work_struct *work) (nfree >= neg_dentry_nfree_init/2) || NEG_IS_SB_UMOUNTING(sb)) goto stop_pruning; -schedule_delayed_work (&prune_neg_dentry_work, - (nfree < neg_dentry_nfree_init/8 ) - ?NEG_PRUNING_FAST_RATE :NEG_PRUNING_SLOW_RATE ); +/* +* If the negative dentry count in the current cpu is less than the +* per_cpu limit, schedule the pruning in the next cpu if it has +* more negative dentries. This will make the negative dentry count +* reduction spread more evenly across multiple per-cpu counters. +*/ + excess = neg_dentry_percpu_limit -__this_cpu_read (nr_dentry_neg); +if (excess >0 ) { +int next_cpu =cpumask_next (cpu, cpu_online_mask); + +if (next_cpu >= nr_cpu_ids) + next_cpu =cpumask_first (cpu_online_mask); +if (per_cpu (nr_dentry_neg, next_cpu) > +__this_cpu_read (nr_dentry_neg)) { + cpu = next_cpu; + +/* +* Transfer some of the excess negative dentry count +* to the free pool if the current percpu pool is less +* than 3/4 of the limit. +*/ +if ((excess > neg_dentry_percpu_limit/4 ) && +raw_spin_trylock (&ndblk.nfree_lock)) { +WRITE_ONCE (ndblk.nfree, + ndblk.nfree +NEG_DENTRY_BATCH ); +__this_cpu_add (nr_dentry_neg,NEG_DENTRY_BATCH ); +raw_spin_unlock (&ndblk.nfree_lock); + } + } + } + +schedule_delayed_work_on (cpu, &prune_neg_dentry_work, + (nfree < neg_dentry_nfree_init/8 ) + ?NEG_PRUNING_FAST_RATE :NEG_PRUNING_SLOW_RATE );return ; stop_pruning:
Signature · 1 line
1.8.3.1
PATCH v5 5/6 fs/dcache: Allow optional enforcement of negative dentry limit
In reply to Waiman LongIf a rogue application that generates a large number of negative dentries is running, the automatic negative dentries pruning process may not be fast enough to clear up the negative dentries in time. In this case, it is possible that negative dentries will use up most of the available memory in the system when that application is not under the control of a memory cgroup that limit kernel memory.
The lack of available memory may significantly affect the operation of other applications running in the system. It may even lead to OOM kill of useful applications.
To allow system administrators the option to prevent this extreme situation from happening, the "enforce" option can now be added to the "neg_dentry_pc" kernel parameter to enforce the negative dentry limit. When the limit is enforced, extra negative dentries that exceed the limit will be killed after use instead of leaving them in the LRU.
--- Documentation/admin-guide/kernel-parameters.txt | 5 +- fs/dcache.c | 94 +++++++++++++++++++------ include/linux/dcache.h | 2 +- 3 files changed, 76 insertions(+), 25 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +4 -1
@@ -2468,8 +2468,11 @@ allowable in a system as a percentage of the total system memory. The default is 2% and the valid range is 0-10 where 0 means no limit. + The optional "enforce" option can be added to + enforce the limit by killing excessive negative + dentries. - Format: <pc> + Format: <pc>[,enforce] netdev= [NET] Network devices parameters Format: <irq>,<io>,<mem_start>,<mem_end>,<name>
fs/dcache.c +71 -23
181 lines not on this page · raw message
include/linux/dcache.h +1 -1
@@ -215,7 +215,7 @@ struct dentry_operations {#define DCACHE_FALLTHRU 0x01000000/* Fall through to lower layer */ #define DCACHE_ENCRYPTED_WITH_KEY 0x02000000/* dir is encrypted with a valid key */ #define DCACHE_OP_REAL 0x04000000 - +#define DCACHE_KILL_NEGATIVE 0x08000000/* Kill negative dentry */ #define DCACHE_PAR_LOOKUP 0x10000000/* being looked up (with parent locked shared) */ #define DCACHE_DENTRY_CURSOR 0x20000000
Signature · 1 line
1.8.3.1
PATCH v5 6/6 fs/dcache: Make negative dentry limit enforcement sysctl parameter
In reply to Waiman LongIt can be useful to make negative dentry limit enformcement a runtime tuning parameter instead of just a boot time option. This allows system administrator to disable limit enforcement in normal use, but turn it on under certain circumstances.
A new /proc/sys/fs/enforce-neg-dentry-limit sysctl parameter is now added. This is a boolean flag that accept a value of either 0 or 1 for disabling and enabling enforcement of negative dentry limit respectively.
--- Documentation/sysctl/fs.txt | 11 +++++++++++ fs/dcache.c | 4 +++- include/linux/dcache.h | 4 ++++ kernel/sysctl.c | 11 +++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-)
Documentation/sysctl/fs.txt +11 -0
@@ -24,6 +24,7 @@ Currently, these files are in /proc/sys/fs: - dentry-state - dquot-max - dquot-nr +- enforce-neg-dentry-limit - file-max - file-nr - inode-max
@@ -97,6 +98,16 @@ you might want to raise the limit. ============================================================== +enforce-neg-dentry-limit: + +The file enforce-neg-dentry-limit, if present, contains a boolean +flag (0 or 1) indicating if the negative dentries limit set by +the "neg_dentry_pc" kernel parameter should be enforced or not. +If enforced, excess negative dentries over the limit will be killed +immediately after use. + +============================================================== + file-max & file-nr: The value in file-max denotes the maximum number of file-
fs/dcache.c +3 -1
@@ -146,7 +146,9 @@ struct dentry_stat_t dentry_stat = { unlikely(!(sb)->s_root || !((sb)->s_flags & MS_ACTIVE))#ifdef CONFIG_DCACHE_TRACK_NEG_ENTRY -static int enforce_neg_dentry_limit__read_mostly ; +int enforce_neg_dentry_limit__read_mostly ; +EXPORT_SYMBOL_GPL (enforce_neg_dentry_limit); +static int neg_dentry_pc__read_mostly =NEG_DENTRY_PC_DEFAULT ;static long neg_dentry_percpu_limit__read_mostly ;static long neg_dentry_nfree_init__read_mostly ;/* Free pool initial value */
include/linux/dcache.h +4 -0
@@ -610,4 +610,8 @@ struct name_snapshot {void take_dentry_name_snapshot (struct name_snapshot *,struct dentry *);void release_dentry_name_snapshot (struct name_snapshot *); +#ifdef CONFIG_DCACHE_TRACK_NEG_ENTRY +extern int enforce_neg_dentry_limit; +#endif +#endif /* __LINUX_DCACHE_H */
kernel/sysctl.c +11 -0
@@ -1849,6 +1849,17 @@ static int sysrq_sysctl_handler(struct ctl_table *table, int write, .proc_handler = proc_dointvec_minmax, .extra1 = &one, }, +#ifdef CONFIG_DCACHE_TRACK_NEG_ENTRY + { + .procname = "enforce-neg-dentry-limit", + .data = &enforce_neg_dentry_limit, + .maxlen = sizeof(enforce_neg_dentry_limit), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = &zero, + .extra2 = &one, + }, +#endif { } };
Signature · 1 line
1.8.3.1
Quoted 5 lines · Waiman Long
A rogue application can potentially create a large number of negative dentries in the system consuming most of the memory available if it is not under the direct control of a memory controller that enforce kernel memory limit.
I certainly don't mind the patch series, but I would like it to be accompanied with some actual example numbers, just to make it all a bit more concrete.
Maybe even performance numbers showing "look, I've filled the dentry lists with nasty negative dentries, now it's all slower because we walk those less interesting entries".
Linus
Andrew Morton
maintainerQuoted 7 lines · On Mon, 2 Jul 2018 12:34:00 -0700 Linus Torvalds…
Quoted 5 lines · Waiman Long
A rogue application can potentially create a large number of negative dentries in the system consuming most of the memory available if it is not under the direct control of a memory controller that enforce kernel memory limit.
Quoted 8 lines
I certainly don't mind the patch series, but I would like it to be accompanied with some actual example numbers, just to make it all a bit more concrete.
Maybe even performance numbers showing "look, I've filled the dentry lists with nasty negative dentries, now it's all slower because we walk those less interesting entries".
(Please cc [email protected] on this work)
Yup. The description of the user-visible impact of current behavior is far too vague.
In the [5/6] changelog it is mentioned that a large number of -ve dentries can lead to oom-killings. This sounds bad - -ve dentries should be trivially reclaimable and we shouldn't be oom-killing in such a situation.
Dumb question: do we know that negative dentries are actually worthwhile? Has anyone checked in the past couple of decades? Perhaps our lookups are so whizzy nowadays that we don't need them?
Quoted 8 lines · Andrew Morton
In the [5/6] changelog it is mentioned that a large number of -ve dentries can lead to oom-killings. This sounds bad - -ve dentries should be trivially reclaimable and we shouldn't be oom-killing in such a situation.
Dumb question: do we know that negative dentries are actually worthwhile? Has anyone checked in the past couple of decades? Perhaps our lookups are so whizzy nowadays that we don't need them?
I can't believe that's true. Have you looked at strace of a typical program startup recently?
$ strace -o ls.out ls $ grep -c ENOENT ls.out 10
There's a few duplicates in there (6 accesses to /etc/ld.so.nohwcap), so we definitely want those negative entries.
Quoted 8 lines · Matthew Wilcox
Quoted 4 lines · Andrew Morton
Dumb question: do we know that negative dentries are actually worthwhile? Has anyone checked in the past couple of decades? Perhaps our lookups are so whizzy nowadays that we don't need them?
I can't believe that's true.
Yeah, I'm with Matthew.
Negative dentries are absolutely *critical*. We have a shit-ton of stuff that walks various PATH-like things, trying to open a file in one directory after another.
They also happen to be really fundamental to how the dentry cache itself works, with operations like "rename()" fundamentally depending on negative dentries.
Sure, that "fundamental to rename()" could still be something that isn't actually ever *cached*, but the thing about many filesystems is that it's actually much more expensive to look up a file that doesn't exist than it is to look up one that does.
That can be true even with things like hashed lookups, although it's more obviously true with legacy filesystems.
Calling down to the filesystem every time you wonder "do I have a /usr/local/bin/cat" binary would be absolutely horrid.
Also, honestly, I think the oom-killing thing says more about the issues we've had with the memory freeing code than about negative dentries. But the one problem with negative dentries is that it's fairly easy to create a shit-ton of them, so while we absolutely don't want to get rid of the concept, I do agree that having a limiter is a fine fine idea.
Linus
Quoted 26 lines · Andrew Morton
Quoted 11 lines · On Mon, 2 Jul 2018 12:34:00 -0700 Linus Torvalds <torvalds@linux-foun…
Quoted 8 lines · Waiman Long
A rogue application can potentially create a large number of negative
dentries in the system consuming most of the memory available if it
is not under the direct control of a memory controller that enforce
kernel memory limit.Quoted 9 lines
I certainly don't mind the patch series, but I would like it to be accompanied with some actual example numbers, just to make it all a bit more concrete.
Maybe even performance numbers showing "look, I've filled the dentry
lists with nasty negative dentries, now it's all slower because we walk those less interesting entries".(Please cc [email protected] on this work)
Quoted 7 lines
Yup. The description of the user-visible impact of current behavior is far too vague.
In the [5/6] changelog it is mentioned that a large number of -ve dentries can lead to oom-killings. This sounds bad - -ve dentries should be trivially reclaimable and we shouldn't be oom-killing in such a situation.
If you're old enough, it's déjà vu; Andrea went on a negative dentry rampage about 15 years ago:
https://lkml.org/lkml/2002/5/24/71
I think the summary of the thread is that it's not worth it because dentries are a clean cache, so they're immediately shrinkable.
Quoted 4 lines
Dumb question: do we know that negative dentries are actually worthwhile? Has anyone checked in the past couple of decades? Perhaps our lookups are so whizzy nowadays that we don't need them?
There are still a lot of applications that keep looking up non-existent files, so I think it's still beneficial to keep them. Apparently apache still looks for a .htaccess file in every directory it traverses, for instance. Round tripping every one of these to disk instead of caching it as a negative dentry would seem to be a performance loser here.
However, actually measuring this again might be useful.
James
Quoted 5 lines · James Bottomley
There are still a lot of applications that keep looking up non-existent files, so I think it's still beneficial to keep them. Apparently apache still looks for a .htaccess file in every directory it traverses, for instance.
.. or git looking for ".gitignore" files in every directory, or any number of similar things.
Lookie here, for example:
[torvalds@i7 linux]$ strace -e trace=%file -c git status On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
73.23 0.009066 2 4056 6 open
23.33 0.002888 2 1294 1189 openat
1.60 0.000198 13 15 8 access
0.80 0.000099 2 36 31 lstat
0.53 0.000066 1 40 6 stat
0.27 0.000033 8 4 getcwd
0.11 0.000014 14 1 execve
0.11 0.000014 14 1 chdir
0.02 0.000003 3 1 1 readlink
0.00 0.000000 0 1 unlink ------ ----------- ----------- --------- --------- ----------------
100.00 0.012381 5449 1241 total
so almost a quarter (1241 of 5449) of the file accesses resulted in errors (and I think they are all ENOENT).
Negative lookups are *not* some unusual thing.
Linus
Quoted 4 lines · Linus Torvalds
Lookie here, for example:
[torvalds@i7 linux]$ strace -e trace=%file -c git status
So in the name of honestly, that's slightly misleading.
"git" will happily thread the actual index file up-to-date testing.
And that's hidden in the above numbers (because I didn't use "-f" to follow threads), and they are all successful (because git will go an 'lstat()' on every single entry in the index file, and the index file obviously is all valid filenames).
So the numbers quoted are closer to the
git ls-files -o --exclude-standard
command (which doesn't check the index state, it only checks "what non-tracked files do I have that aren't the ones I explicitly exclude").
Linus
Andrew Morton
maintainerQuoted 35 lines · On Mon, 02 Jul 2018 15:34:40 -0700 James Bottomley…
Quoted 26 lines · Andrew Morton
Quoted 11 lines · On Mon, 2 Jul 2018 12:34:00 -0700 Linus Torvalds <torvalds@linux-foun…
Quoted 8 lines · Waiman Long
A rogue application can potentially create a large number of negative
dentries in the system consuming most of the memory available if it
is not under the direct control of a memory controller that enforce
kernel memory limit.Quoted 9 lines
I certainly don't mind the patch series, but I would like it to be accompanied with some actual example numbers, just to make it all a bit more concrete.
Maybe even performance numbers showing "look, I've filled the dentry
lists with nasty negative dentries, now it's all slower because we walk those less interesting entries".(Please cc [email protected] on this work)
Quoted 7 lines
Yup. The description of the user-visible impact of current behavior is far too vague.
In the [5/6] changelog it is mentioned that a large number of -ve dentries can lead to oom-killings. This sounds bad - -ve dentries should be trivially reclaimable and we shouldn't be oom-killing in such a situation.
Quoted 4 lines
If you're old enough, it's déjà vu; Andrea went on a negative dentry rampage about 15 years ago:
That's kinda funny.
Quoted 2 lines
I think the summary of the thread is that it's not worth it because dentries are a clean cache, so they're immediately shrinkable.
Yes, "should be". I could understand that the presence of huge nunmbers of -ve dentries could result in undesirable reclaim of pagecache, etc. Triggering oom-killings is very bad, and presumably has the same cause.
Before we go and add a large amount of code to do the shrinker's job for it, we should get a full understanding of what's going wrong. Is it because the dentry_lru had a mixture of +ve and -ve dentries? Should we have a separate LRU for -ve dentries? Are we appropriately aging the various dentries? etc.
It could be that tuning/fixing the current code will fix whatever problems inspired this patchset.
Quoted 5 lines
Quoted 4 lines
Dumb question: do we know that negative dentries are actually worthwhile? Has anyone checked in the past couple of decades? Perhaps our lookups are so whizzy nowadays that we don't need them?
Quoted 8 lines
There are still a lot of applications that keep looking up non-existent files, so I think it's still beneficial to keep them. Apparently apache still looks for a .htaccess file in every directory it traverses, for instance. Round tripping every one of these to disk instead of caching it as a negative dentry would seem to be a performance loser here.
However, actually measuring this again might be useful.
Yup. I don't know how hard it would be to disable the -ve dentries (the rename thing makes it sounds harder than I expected) but having real numbers to justify continuing presence might be a fun project for someone.
Quoted 9 lines · Andrew Morton
Before we go and add a large amount of code to do the shrinker's job for it, we should get a full understanding of what's going wrong. Is it because the
dentry_lruhad a mixture of +ve and -ve dentries? Should we have a separate LRU for -ve dentries? Are we appropriately aging the various dentries? etc.It could be that tuning/fixing the current code will fix whatever problems inspired this patchset.
So I do think that the shrinker is likely the culprit behind the oom issues. I think it's likely worse when you try to do some kind of containerization, and dentries are shared.
That said, I think there are likely good reasons to limit excessive negative dentries even outside the oom issue. Even if we did a perfect job at shrinking them and took no time at all doing so, the fact that you can generate an effecitvely infinite amount of negative dentries and then polluting the dentry hash chains with them _could_ be a performance problem.
No sane application does that, and we handle the "obvious" cases
already: ie if you create a lot of files in a deep subdirectory and then do "rm -rf dir", we *will* throw the negative dentries away as we remove the directories they are in. So it is unlikely to be much of a problem in practice. But at least in theory you can generate many millions of negative dentries just to mess with the system, and slow down good people.
Probably not even remotely to the point of a DoS attack, but certainly to the point of "we're wasting time".
So I do think that restricting negative dentries is a fine concept. They are useful, but that doesn't mean that it makes sense to fill memory with them.
Linus
Quoted 46 lines · Andrew Morton
Quoted 27 lines · On Mon, 02 Jul 2018 15:34:40 -0700 James Bottomley…
Quoted 26 lines · Andrew Morton
Quoted 9 lines · On Mon, 2 Jul 2018 12:34:00 -0700 Linus Torvalds <torvalds@linux-foun…
Quoted 7 lines · Waiman Long
A rogue application can potentially create a large number of negative
dentries in the system consuming most of the memory available if it
is not under the direct control of a memory controller that enforce
kernel memory limit.Quoted 9 lines
I certainly don't mind the patch series, but I would like it to be accompanied with some actual example numbers, just to make it all a bit more concrete.
Maybe even performance numbers showing "look, I've filled the dentry
lists with nasty negative dentries, now it's all slower because we walk those less interesting entries".(Please cc [email protected] on this work)
Yup. The description of the user-visible impact of current behavior is far too vague.
Quoted 8 lines
Quoted 4 lines
In the [5/6] changelog it is mentioned that a large number of -ve dentries can lead to oom-killings. This sounds bad - -ve dentries should be trivially reclaimable and we shouldn't be oom-killing in such a situation.
If you're old enough, it's déjà vu; Andrea went on a negative dentry rampage about 15 years ago:
That's kinda funny.
Quoted 2 lines
I think the summary of the thread is that it's not worth it because dentries are a clean cache, so they're immediately shrinkable.
Yes, "should be". I could understand that the presence of huge nunmbers of -ve dentries could result in undesirable reclaim of pagecache, etc. Triggering oom-killings is very bad, and presumably has the same cause.
Quoted 5 lines
Before we go and add a large amount of code to do the shrinker's job for it, we should get a full understanding of what's going wrong. Is it because the
dentry_lruhad a mixture of +ve and -ve dentries? Should we have a separate LRU for -ve dentries? Are we appropriately aging the various dentries? etc.
I have actually investigated having a separate LRU for negative dentries. That will result in a far more invasive patch that will be more disruptive.
Another change that was suggested by a colleague is to put a newly created -ve dentry to the tail (LRU end) of the LRU and move it to the head only if it is accessed a second time. That will put most of the negative dentries at the tail that will be more easily trimmed away.
Cheers,
Longman
Jan Kara
reviewerQuoted 52 lines · Andrew Morton
Quoted 35 lines · On Mon, 02 Jul 2018 15:34:40 -0700 James Bottomley…
Quoted 26 lines · Andrew Morton
Quoted 11 lines · On Mon, 2 Jul 2018 12:34:00 -0700 Linus Torvalds <torvalds@linux-foun…
Quoted 8 lines · Waiman Long
A rogue application can potentially create a large number of negative
dentries in the system consuming most of the memory available if it
is not under the direct control of a memory controller that enforce
kernel memory limit.Quoted 9 lines
I certainly don't mind the patch series, but I would like it to be accompanied with some actual example numbers, just to make it all a bit more concrete.
Maybe even performance numbers showing "look, I've filled the dentry
lists with nasty negative dentries, now it's all slower because we walk those less interesting entries".(Please cc [email protected] on this work)
Quoted 7 lines
Yup.��The description of the user-visible impact of current behavior is far too vague.
In the [5/6] changelog it is mentioned that a large number of -ve dentries can lead to oom-killings.��This sounds bad - -ve dentries should be trivially reclaimable and we shouldn't be oom-killing in such a situation.
Quoted 4 lines
If you're old enough, it's d�j� vu; Andrea went on a negative dentry rampage about 15 years ago:
That's kinda funny.
Quoted 2 lines
I think the summary of the thread is that it's not worth it because dentries are a clean cache, so they're immediately shrinkable.
Yes, "should be". I could understand that the presence of huge nunmbers of -ve dentries could result in undesirable reclaim of pagecache, etc. Triggering oom-killings is very bad, and presumably has the same cause.
Quoted 8 lines
Before we go and add a large amount of code to do the shrinker's job for it, we should get a full understanding of what's going wrong. Is it because the
dentry_lruhad a mixture of +ve and -ve dentries? Should we have a separate LRU for -ve dentries? Are we appropriately aging the various dentries? etc.It could be that tuning/fixing the current code will fix whatever problems inspired this patchset.
What I think is contributing to the problems and could lead to reclaim oddities is the internal fragmentation of dentry slab cache. Dentries are relatively small, you get 21 per page on my system, so if trivial to reclaim negative dentries get mixed with a small amount of unreclaimable positive dentries, you can get a lot of pages in dentry slab cache that are unreclaimable.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 14 lines
Quoted 5 lines
Yes, "should be". I could understand that the presence of huge nunmbers of -ve dentries could result in undesirable reclaim of pagecache, etc. Triggering oom-killings is very bad, and presumably has the same cause.
Quoted 8 lines
Before we go and add a large amount of code to do the shrinker's job for it, we should get a full understanding of what's going wrong. Is it because the
dentry_lruhad a mixture of +ve and -ve dentries? Should we have a separate LRU for -ve dentries? Are we appropriately aging the various dentries? etc.It could be that tuning/fixing the current code will fix whatever problems inspired this patchset.
Quoted 6 lines
What I think is contributing to the problems and could lead to reclaim oddities is the internal fragmentation of dentry slab cache. Dentries are relatively small, you get 21 per page on my system, so if trivial to reclaim negative dentries get mixed with a small amount of unreclaimable positive dentries, you can get a lot of pages in dentry slab cache that are unreclaimable.
Could we allocate -ve entries from separate slab?
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 2 lines · Pavel Machek
Could we allocate -ve entries from separate slab?
No, because negative dentrires don't stay negative.
Every single positive dentry starts out as a negative dentry that is passed in to "lookup()" to maybe be made positive.
And most of the time they <i>do</i> turn positive, because most of the time people actually open files that exist.
But then occasionally you don't, because you're just blindly opening a filename whether it exists or not (to _check_ whether it's there).
Linus
Al Viro
maintainerQuoted 6 lines · Linus Torvalds
Quoted 2 lines · Pavel Machek
Could we allocate -ve entries from separate slab?
No, because negative dentrires don't stay negative.
Quoted 8 lines
Every single positive dentry starts out as a negative dentry that is passed in to "
lookup()" to maybe be made positive.And most of the time they <i>do</i> turn positive, because most of the time people actually open files that exist.
But then occasionally you don't, because you're just blindly opening a filename whether it exists or not (to _check_ whether it's there).
BTW, one point that might not be realized by everyone: negative dentries are *not* the hard case.
mount -t tmpfs none /mnt
touch /mnt/a
for i in seq 100000; do ln /mnt/a /mnt/$i; done
and you've got 100000 *unevictable* dentries, with the time per iteration being not all that high (especially if you just call link(2) in a loop). They are all positive and all pinned. And you've got only one inode there and no persistently opened files, so rlimit and quota won't help any.
Al Viro
maintainerQuoted 22 lines · Al Viro
Quoted 6 lines · Linus Torvalds
Quoted 2 lines · Pavel Machek
Could we allocate -ve entries from separate slab?
No, because negative dentrires don't stay negative.
Quoted 8 lines
Every single positive dentry starts out as a negative dentry that is passed in to "
lookup()" to maybe be made positive.And most of the time they <i>do</i> turn positive, because most of the time people actually open files that exist.
But then occasionally you don't, because you're just blindly opening a filename whether it exists or not (to _check_ whether it's there).
BTW, one point that might not be realized by everyone: negative dentries are *not* the hard case.
mount -t tmpfs none /mnt
touch/mnt/a
for i inseq 100000; do ln/mnt/a/mnt/$i; done
Quoted 5 lines
and you've got 100000 *unevictable* dentries, with the time per iteration being not all that high (especially if you just call link(2) in a loop). They are all positive and all pinned. And you've got only one inode there and no persistently opened files, so rlimit and quota won't help any.
OK, this
/*
* No ordinary (disk based) filesystem counts links as inodes;
* but each new link needs a new dentry, pinning lowmem, and
* tmpfs dentries cannot be pruned until they are unlinked.
*/
ret = shmem_reserve_inode(inode->i_sb);
if (ret)
goto out;will probably help (on ramfs it won't, though).
Quoted 11 lines · Al Viro
OK, this
/* * No ordinary (disk based) filesystem counts links as inodes; * but each new link needs a new dentry, pinning lowmem, and * tmpfs dentries cannot be pruned until they are unlinked. */ ret = shmem_reserve_inode(inode->i_sb); if (ret) goto out;will probably help (on ramfs it won't, though).
Nobody who cares about memory use would use ramfs and then allow random users on it.
I think you can exhaust memory more easily on ramfs by just writing a huge file. Do we have any limits at all?
ramfs is fine for things like initramfs, but I think the comment says it all:
* NOTE! This filesystem is probably most useful
* not as a real filesystem, but as an example of
* how virtual filesystems can be written.
and even that comment may have been more correct back in 2000 than it is today.
Linus
Quoted 19 lines · Al Viro
Quoted 4 lines · Linus Torvalds
Quoted 1 line · Pavel Machek
Could we allocate -ve entries from separate slab?
No, because negative dentrires don't stay negative.
Quoted 8 lines
Every single positive dentry starts out as a negative dentry that is passed in to "
lookup()" to maybe be made positive.And most of the time they <i>do</i> turn positive, because most of the time people actually open files that exist.
But then occasionally you don't, because you're just blindly opening a filename whether it exists or not (to _check_ whether it's there).
BTW, one point that might not be realized by everyone: negative dentries are *not* the hard case.
mount -t tmpfs none /mnt
touch/mnt/a
for i inseq 100000; do ln/mnt/a/mnt/$i; done
Quoted 5 lines
and you've got 100000 *unevictable* dentries, with the time per iteration being not all that high (especially if you just call link(2) in a loop). They are all positive and all pinned. And you've got only one inode there and no persistently opened files, so rlimit and quota won't help any.
Normally you need to be root or have privileges to mount a filesystem. Right?
I am aware there is effort going on to allow non-privilege user mount in container. That can open a can of worms if it is not done properly.
With privileges, there is a lot of ways one can screw up the system. So I am not less concern about this particular issue.
Cheers,
Longman
Quoted 17 lines · Andrew Morton
Quoted 5 lines · On Mon, 2 Jul 2018 12:34:00 -0700 Linus Torvalds…
Quoted 4 lines · Waiman Long
A rogue application can potentially create a large number of negative dentries in the system consuming most of the memory available if it is not under the direct control of a memory controller that enforce kernel memory limit.
Quoted 8 lines
I certainly don't mind the patch series, but I would like it to be accompanied with some actual example numbers, just to make it all a bit more concrete.
Maybe even performance numbers showing "look, I've filled the dentry lists with nasty negative dentries, now it's all slower because we walk those less interesting entries".
(Please cc [email protected] on this work)
Quoted 7 lines
Yup. The description of the user-visible impact of current behavior is far too vague.
In the [5/6] changelog it is mentioned that a large number of -ve dentries can lead to oom-killings. This sounds bad - -ve dentries should be trivially reclaimable and we shouldn't be oom-killing in such a situation.
The OOM situation was observed in an older distro kernel. It may not be the case with the upstream kernel. I will double check that.
Cheers,
Longman
Quoted 21 lines · Waiman Long
Quoted 20 lines · Andrew Morton
Quoted 5 lines · On Mon, 2 Jul 2018 12:34:00 -0700 Linus Torvalds…
Quoted 4 lines · Waiman Long
A rogue application can potentially create a large number of negative dentries in the system consuming most of the memory available if it is not under the direct control of a memory controller that enforce kernel memory limit.
Quoted 8 lines
I certainly don't mind the patch series, but I would like it to be accompanied with some actual example numbers, just to make it all a bit more concrete.
Maybe even performance numbers showing "look, I've filled the dentry lists with nasty negative dentries, now it's all slower because we walk those less interesting entries".
(Please cc [email protected] on this work)
Yup. The description of the user-visible impact of current behavior is far too vague.
Quoted 7 lines
Quoted 4 lines
In the [5/6] changelog it is mentioned that a large number of -ve dentries can lead to oom-killings. This sounds bad - -ve dentries should be trivially reclaimable and we shouldn't be oom-killing in such a situation.
The OOM situation was observed in an older distro kernel. It may not be the case with the upstream kernel. I will double check that.
Note that dentries with externally allocated (long) names might have been the factor here, until recent commits f1782c9bc547 ("dcache:
account external names as indirectly reclaimable memory") and d79f7aa496fc ("mm: treat indirectly reclaimable memory as free in overcommit logic").
Vlastimil
Quoted 3 lines
Cheers,
Longman
Quoted 9 lines · Linus Torvalds
Quoted 4 lines · Waiman Long
A rogue application can potentially create a large number of negative dentries in the system consuming most of the memory available if it is not under the direct control of a memory controller that enforce kernel memory limit.
I certainly don't mind the patch series, but I would like it to be accompanied with some actual example numbers, just to make it all a bit more concrete.
Quoted 5 lines
Maybe even performance numbers showing "look, I've filled the dentry lists with nasty negative dentries, now it's all slower because we walk those less interesting entries".
Linus
I did have performance numbers in the previous version of the patchset. I will rerun the performance test and post the numbers later on.
Cheers,
Longman