Re: [PATCH 03/19] fs: Convert nr_inodes and nr_unused to per-cpu counters

Eric Dumazet
2010-10-16T10:34:10Z

Le samedi 16 octobre 2010 à 21:04 +1100, Dave Chinner a écrit :

> get_nr_inodes_unused() is called on every single shrinker call. i.e.
> for every 128 inodes we attempt to reclaim. Given that I'm seeing
> inode reclaim rate in the order of a million per second on a 8p box,
> that meets your criteria for using the generic percpu counter
> infrastructure.
>
> Also, get_nr_inodes() is also called by get_nr_dirty_inodes(), which is
> called by the high level inode writeback code, so will typically be
> called in the order of tens of times per second, and the number of
> calls increased depending on the number of filesystems that are
> active. It's still much higher frequency than your "cat
> /proc/sys/fs/inode-nr" example indicates it might be called.
>
> So I'd say that by your reasoning, the choice of using the generic
> percpu counters is the right one to make.

You missed one thing :

In cases you mention, you want a precise count (aka
percpu_counter_sum_positive()), not the approximate one (aka
percpu_counter_read_positive()).

The only difference is then the possible/online cpu loop difference.

I am saying :

No need to maintain an approximate counter if we dont _read_ it, ever.

Andrew answer : Eric, cant you implement this generically ?