Re: [PATCH 04/26] xfs: Improve metadata buffer reclaim accountability

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Oct 13, 2019 at 02:14:50PM +1100, Dave Chinner wrote:
> On Sat, Oct 12, 2019 at 08:05:58AM -0400, Brian Foster wrote:
> > On Sat, Oct 12, 2019 at 10:13:23AM +1100, Dave Chinner wrote:
> > > On Fri, Oct 11, 2019 at 08:39:39AM -0400, Brian Foster wrote:
> > > > On Wed, Oct 09, 2019 at 02:21:02PM +1100, Dave Chinner wrote:
> > > > > From: Dave Chinner <dchinner@xxxxxxxxxx>
> > > > > 
> > > > > The buffer cache shrinker frees more than just the xfs_buf slab
> > > > > objects - it also frees the pages attached to the buffers. Make sure
> > > > > the memory reclaim code accounts for this memory being freed
> > > > > correctly, similar to how the inode shrinker accounts for pages
> > > > > freed from the page cache due to mapping invalidation.
> > > > > 
> > > > > We also need to make sure that the mm subsystem knows these are
> > > > > reclaimable objects. We provide the memory reclaim subsystem with a
> > > > > a shrinker to reclaim xfs_bufs, so we should really mark the slab
> > > > > that way.
> > > > > 
> > > > > We also have a lot of xfs_bufs in a busy system, spread them around
> > > > > like we do inodes.
> > > > > 
> > > > > Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
> > > > > ---
> > > > 
> > > > Seems reasonable, but for inodes we also spread the ili zone. Should we
> > > > not be consistent with bli's as well?
> > > 
> > > bli's are reclaimed when the buffer is cleaned. ili's live for the
> > > live of the inode in cache. Hence bli's are short term allocations
> > > (much shorter than xfs_bufs they attach to) and are reclaimed much
> > > faster than inodes and their ilis. There's also a lot less blis than
> > > ili's, so the spread of their footprint across memory nodes doesn't
> > > matter that much. Local access for the memcpy during formatting is
> > > probably more important than spreading the memory usage of them
> > > these days, anyway.
> > > 
> > 
> > Yes, the buffer/inode lifecycle difference is why why I presume bli
> > zones are not ZONE_RECLAIM like ili zones.
> 
> No, that is not the case. IO completion cleaning the buffer is what
> frees the bli. The ili can only be freed by reclaiming the inode, so
> it's memory that can only be returned to the free pool by running a
> shrinker. Hence ilis are ZONE_RECLAIM to account them as memory that
> can be reclaimed through shrinker invocation, while BLIs are not
> because memory reclaim can't directly cause them to be freed.
> 

That is pretty much what I said. I think we're in agreement.

> > This doesn't tell me anything about why buffers should be spread
> > around as such and buffer log items not, though..
> 
> xfs_bufs are long lived, are global structures, and can accumulate
> in the millions if the workload requires it. IOWs, we should spread
> xfs_bufs for exactly the same reasons inodes are spread.
> 
> As for BLIs, they are short term structures - a single xfs_buf might
> have thousands of different blis attached to it over it's life in
> the cache because the BLI is freed when the buffer is cleaned.
> 

Short term relative to the ILI perhaps, but these are still memory
allocations that outlive the allocating task returning to userspace, are
reused (across tasks) commonly enough and have an I/O bound life cycle.
That's also not considering page/slab buildup in the kmem cache beyond
the lifetime of individual allocations..

> We don't need to spread small short term structures around NUMA
> memory nodes because they don't present a long term memory imbalance
> vector. In general it is better to have them allocated local to the
> process that is using them where the memory access latency is
> lowest, knowing that they will be freed shortly and not contribute
> to long term memory usage.
> 

Hmm.. doesn't this all depend on enablement of a cgroup knob in the
first place? It looks to me that this behavior is tied to a per-task
state (not a per-mount or zone setting, which just allows such behavior
on the zone) where the controller has explicitly requested us to not
perform sustained allocations in the local node if possible. Instead,
spread slab allocations around at the cost of bypassing this local
allocation heuristic, presumably because $application wants prioritized
access to that memory. What am I missing?

BTW, it also looks like this is only relevant for slab. I don't see any
references in slub (or slob), but I haven't dug too deeply..

Brian

> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@xxxxxxxxxxxxx




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux