Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5408878yba; Wed, 10 Apr 2019 19:34:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVDWsMMYY9OFfeu/nJUm/01+GubAdWX3CnSi6B/JQkXwx5rOwtYkfkHbVcPjLVp8+K+HQA X-Received: by 2002:a63:b811:: with SMTP id p17mr44560614pge.219.1554950090421; Wed, 10 Apr 2019 19:34:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554950090; cv=none; d=google.com; s=arc-20160816; b=XsXtAMDN0E0CkhbpuC2mklejHycNEx4V4k73BHpMX+tpIo93FRiM8JSj7bwO0VLgy4 RqXNUoz3KgRqj4EAfByeGWCt04oDxgRgFGy+THMH+73XLPt9Nl9Iv8XFel/nVbEOoTG9 jFEvO8Qh8DsJGT2Piz7kFtQwNn8LQcpf0HRH5d333CIDHqRkQ4+offtGEW+Vspmfh0LP edQoXVN/tnmTKJv4DoNsqWIW/FzFKu6HVKuVgqjEWfjxyJaL6DFxt0bT2jjRK2kzSFwg jSmMP27MvB4PDZRTA94qi4n1g9TjSFZGnqfvsg4wEV3WhWIG7gfvC6wWega4K482Hqw4 wptQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=CPhlCb1xiC+aF9i/+wHcC5N2VlUxpHJ03lW18xSoMSI=; b=mRX95TAiq5Jpc3cyowp0i9meomrC4bqeiVTXSql39yK82CIp5oWID4AxSg1fKzRfzG 6D5HrPceKgHdEsphQ269gthMIYiKMMOPXuhQQh21aqUddNIxQq8D8n3nVyYrYj5rs9kZ ZST1M3fILanCWf08aNO2BGPM3vwKQGpJ0f8Tnbo0lelwEWMibQ0AakRGVlJTmS9T9eb3 P5M0TB2HQAiE0V7tI7Grqytvks4IUL+MkIB+Q3oiEks8M6dtBeIjjQ7hFSwFGCuYmoyL Ku7YzQS7sgCvkrU5bgCzQLKM0uph5+SFYvg6RWfZ9Z1gS55Glot2qYf+EqFT1h7zxQWj eV+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v16si2374474plo.36.2019.04.10.19.34.34; Wed, 10 Apr 2019 19:34:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726686AbfDKCd6 (ORCPT + 99 others); Wed, 10 Apr 2019 22:33:58 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:47368 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726181AbfDKCd5 (ORCPT ); Wed, 10 Apr 2019 22:33:57 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1hEPWk-0002SB-Qp; Thu, 11 Apr 2019 02:33:22 +0000 Date: Thu, 11 Apr 2019 03:33:22 +0100 From: Al Viro To: "Tobin C. Harding" Cc: Andrew Morton , Roman Gushchin , Alexander Viro , Christoph Hellwig , Pekka Enberg , David Rientjes , Joonsoo Kim , Christopher Lameter , Matthew Wilcox , Miklos Szeredi , Andreas Dilger , Waiman Long , Tycho Andersen , Theodore Ts'o , Andi Kleen , David Chinner , Nick Piggin , Rik van Riel , Hugh Dickins , Jonathan Corbet , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v3 14/15] dcache: Implement partial shrink via Slab Movable Objects Message-ID: <20190411023322.GD2217@ZenIV.linux.org.uk> References: <20190411013441.5415-1-tobin@kernel.org> <20190411013441.5415-15-tobin@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190411013441.5415-15-tobin@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 11, 2019 at 11:34:40AM +1000, Tobin C. Harding wrote: > +/* > + * d_isolate() - Dentry isolation callback function. > + * @s: The dentry cache. > + * @v: Vector of pointers to the objects to isolate. > + * @nr: Number of objects in @v. > + * > + * The slab allocator is holding off frees. We can safely examine > + * the object without the danger of it vanishing from under us. > + */ > +static void *d_isolate(struct kmem_cache *s, void **v, int nr) > +{ > + struct dentry *dentry; > + int i; > + > + for (i = 0; i < nr; i++) { > + dentry = v[i]; > + __dget(dentry); > + } > + > + return NULL; /* No need for private data */ > +} Huh? This is compeletely wrong; what you need is collecting the ones with zero refcount (and not on shrink lists) into a private list. *NOT* bumping the refcounts at all. And do it in your isolate thing. > +static void d_partial_shrink(struct kmem_cache *s, void **v, int nr, > + int node, void *_unused) > +{ > + struct dentry *dentry; > + LIST_HEAD(dispose); > + int i; > + > + for (i = 0; i < nr; i++) { > + dentry = v[i]; > + spin_lock(&dentry->d_lock); > + dentry->d_lockref.count--; > + > + if (dentry->d_lockref.count > 0 || > + dentry->d_flags & DCACHE_SHRINK_LIST) { > + spin_unlock(&dentry->d_lock); > + continue; > + } > + > + if (dentry->d_flags & DCACHE_LRU_LIST) > + d_lru_del(dentry); > + > + d_shrink_add(dentry, &dispose); > + > + spin_unlock(&dentry->d_lock); > + } Basically, that loop (sans jerking the refcount up and down) should get moved into d_isolate(). > + > + if (!list_empty(&dispose)) > + shrink_dentry_list(&dispose); > +} ... with this left in d_partial_shrink(). And you obviously need some way to pass the list from the former to the latter...