Received: by 10.213.65.68 with SMTP id h4csp299436imn; Mon, 12 Mar 2018 14:19:25 -0700 (PDT) X-Google-Smtp-Source: AG47ELu1ixHuPBw9OIAPXhWwKVpBDco/naH1T+igc8gIbL1Um/94wbUEtUO89kWB3NQPe6afECWH X-Received: by 2002:a17:902:7008:: with SMTP id y8-v6mr9789694plk.395.1520889565414; Mon, 12 Mar 2018 14:19:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520889565; cv=none; d=google.com; s=arc-20160816; b=k8/KY9DWgTE6PJZ8768IS2MVm/8Q47kkeX8aTNxudNKiiZ8vFaNUT/xO7QMtAsyFvS WvNJf/jan4X59ULRFwQ+yx9vGm6PD8hEacfqHMQPmv1ZL5z0HQBnlOLRZ4cclFIIpPo0 PCRkJbwmxQ57e9YEi9C373qOi1zMtF99tKzQttbWkngWXEGihMuJP8GW+2UBzNH2KJ5t sAVqEpeP/EA3ZuhXgmeDgBGRkFwt1u7i4mATnR+ht0XTs4TcJIK/UhMePTt3YJvTaL3r NkawKPxqiuYYXstysOYQtpO1NtwGjURaH4BnVD0CLxjK5N2C7AfZL4QzZrXspKP8djc5 88/Q== 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:arc-authentication-results; bh=9s00sMRCT699hpQXPnCeT83G5F2gVLaIWCDcuyNOVxA=; b=vPhUoErhjCC08FKDizMgpADuoyf8hHIfh0ikraqofi9gLWRE6mPupRuXWZMQ7kCMp7 p+xuDqSTztDbQ0NFSbqylPgcZKKfi69EmMpuAeyj+dxTDRtwEtWlnjl+Vq2qq33eQD3j xBd91i8BF5qtt+qcE7iLoBPMYAmZD8rPhnN4YJm4TlmUCg/L8AXNkTY48LtGWiu0v+CC emKG/PCNauIQs/PjfbNxAyOpzJrSKiJdpE1vTZgPaWNH+S7GJ6lGD21m+EjPKrTXvpvm LMPB3r0CwTXdqX9MN1ZlbczTbGrZVX6jSG3tILUdO6ahthkLjSAltVgsfU+bM2709iGU POfg== 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 q67si6450418pfj.146.2018.03.12.14.19.08; Mon, 12 Mar 2018 14:19:25 -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 S932408AbeCLVRu (ORCPT + 99 others); Mon, 12 Mar 2018 17:17:50 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:55508 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932242AbeCLVRt (ORCPT ); Mon, 12 Mar 2018 17:17:49 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1evUpC-0007JS-Ds; Mon, 12 Mar 2018 21:17:42 +0000 Date: Mon, 12 Mar 2018 21:17:42 +0000 From: Al Viro To: Roman Gushchin Cc: linux-mm@kvack.org, Andrew Morton , Michal Hocko , Johannes Weiner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH 3/3] dcache: account external names as indirectly reclaimable memory Message-ID: <20180312211742.GR30522@ZenIV.linux.org.uk> References: <20180305133743.12746-1-guro@fb.com> <20180305133743.12746-5-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180305133743.12746-5-guro@fb.com> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 05, 2018 at 01:37:43PM +0000, Roman Gushchin wrote: > diff --git a/fs/dcache.c b/fs/dcache.c > index 5c7df1df81ff..a0312d73f575 100644 > --- a/fs/dcache.c > +++ b/fs/dcache.c > @@ -273,8 +273,16 @@ static void __d_free(struct rcu_head *head) > static void __d_free_external(struct rcu_head *head) > { > struct dentry *dentry = container_of(head, struct dentry, d_u.d_rcu); > - kfree(external_name(dentry)); > - kmem_cache_free(dentry_cache, dentry); > + struct external_name *name = external_name(dentry); > + unsigned long bytes; > + > + bytes = dentry->d_name.len + offsetof(struct external_name, name[1]); > + mod_node_page_state(page_pgdat(virt_to_page(name)), > + NR_INDIRECTLY_RECLAIMABLE_BYTES, > + -kmalloc_size(kmalloc_index(bytes))); > + > + kfree(name); > + kmem_cache_free(dentry_cache, dentry); > } That can't be right - external names can be freed in release_dentry_name_snapshot() and copy_name() as well. When do you want kfree_rcu() paths accounted for, BTW? At the point where we are freeing them, or where we are scheduling their freeing?