From patchwork Tue Jul 31 09:06:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 10550487 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 94B9E13BF for ; Tue, 31 Jul 2018 09:07:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82E7629FB4 for ; Tue, 31 Jul 2018 09:07:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 76F362A206; Tue, 31 Jul 2018 09:07:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0504C29FB4 for ; Tue, 31 Jul 2018 09:07:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 93C3D6B026D; Tue, 31 Jul 2018 05:07:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 83E186B000E; Tue, 31 Jul 2018 05:07:03 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E0546B026B; Tue, 31 Jul 2018 05:07:03 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 153A56B000E for ; Tue, 31 Jul 2018 05:07:03 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id a23-v6so4442203pfo.23 for ; Tue, 31 Jul 2018 02:07:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=mago/OtTdc+yTn/7CKAknhNyQz4OFjN/yAQZ5QW50oM=; b=TDRd8L3KuKuZ+bAWnJ1tWjJoJZYtUO+bvNmcsqMiYYJVuTkRfXILsOjGNPFSNdfp/g w1J8sMm1I5dIsQaHOkipFAKR4MDMt052gs8m5JJ6fM5GiIwDyFeMmzp3uXaDCWRPp0P+ D7lGqRXi6KGdIsbrwEHKdn80KH8I9yJT+DyUA7/2NAVqb2JCR0osoPmItxtAuSKh2jXO cnJ8i/yC8LOrKCPMlpVAlNZhrLrcwK4q15S4NRw0nvCXpS9ZNLKlcv6rk5zNB71LZmu3 EKaOMzmNqR4R50dxyA0HF76d6XgByFpKmbROcjRG7cjB6jk0tbaXlia4D45BjGaWpK99 Btlg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Gm-Message-State: AOUpUlEe0AxtszuxfqigJxo1gvo1y6ARINtRg58M0BkwHq7vK1QRLDAE FlEvYVPnIsptGiA1iW6AAh/hB0FGY4o7Jognip+fpRPvXu0/3PfKbgDhQrOVcP4ZOA0KD90AMXi T0IEBJhOJ6I/JFXl5hUoSWTFhD3i6uePXMLzhsURiHLLJoEzauJqcGnBRdXB/DyYWEw== X-Received: by 2002:a17:902:da4:: with SMTP id 33-v6mr19406661plv.193.1533028022743; Tue, 31 Jul 2018 02:07:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfGBiLixYRXm2P0YFXV0ybNIOJLvmD3fATPNAeBoXzxHj8roCDnxKbo8iHzSI3Qs6/U0tT/ X-Received: by 2002:a17:902:da4:: with SMTP id 33-v6mr19406622plv.193.1533028021799; Tue, 31 Jul 2018 02:07:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533028021; cv=none; d=google.com; s=arc-20160816; b=vJsVwRwRtWQ6lXAZt3sURwjco25Sb89MhnYAg16QmaNYpOd792NbAuP96aFAGHx5vw m0EVih/uBTEknO6OEpsRvnT8TUXn9aLbNTct+N48HgEDXFOzbseAuknz7u1cXaQNhJpi ZvEvKm6HopO0X7j/kMPh0Rmctq2z49m4unfQl4TQbu06WbawKRF9QfiP1GtZHzHPY4jE KPN1lWak6PSQzFwIRzuumB4WPVYV7j44E11WJ7RBvDDzOtAj11OjEhxgbRE4Too6a21V UdwEP7jBcsjo3cWjzAjwtQZNkE8SI6fnoAdDkVDkcUDC6rBbY8VscDjhUFtkHXI7PeN8 4EIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=mago/OtTdc+yTn/7CKAknhNyQz4OFjN/yAQZ5QW50oM=; b=TCysoIFpIUxn5B5oLM9A6QhC3/4xU7QjmgOI5CuWisqFGKORYwzL0CFnAAYettkz4s O1GoBNZpsNcxX+ABQXj4pO0s/tjf7+56TZUihmrsPPuwvdaiNMSinb9GQBNcBweqsakZ drINJ6Tff3TJDLYjQ2ICdsYLLw0EpNVdROoHJc0igA1AnoY7Da8IyRKmLSdu8PBeuTeh xo10uICqy9+xVQyNPYg9UK2kLzPWLF/pKPi6M020RLCxNYPHkgOoNbwE6Eabbdhboh3T f97Jj8M8lf9ymmrVyct4N5EjZSG+BXxOoevJZdoleuWHcuTpexZwPlDZqCOGUaCM8L8R k+1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=vbabka@suse.cz Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id q3-v6si13459834pgf.40.2018.07.31.02.07.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Jul 2018 02:07:01 -0700 (PDT) Received-SPF: pass (google.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) client-ip=195.135.220.15; Authentication-Results: mx.google.com; spf=pass (google.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 8C4ECADBB; Tue, 31 Jul 2018 09:06:58 +0000 (UTC) From: Vlastimil Babka To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Roman Gushchin , Michal Hocko , Johannes Weiner , Christoph Lameter , David Rientjes , Joonsoo Kim , Mel Gorman , Matthew Wilcox , Vlastimil Babka Subject: [PATCH v4 3/6] dcache: allocate external names from reclaimable kmalloc caches Date: Tue, 31 Jul 2018 11:06:46 +0200 Message-Id: <20180731090649.16028-4-vbabka@suse.cz> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180731090649.16028-1-vbabka@suse.cz> References: <20180731090649.16028-1-vbabka@suse.cz> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP We can use the newly introduced kmalloc-reclaimable-X caches, to allocate external names in dcache, which will take care of the proper accounting automatically, and also improve anti-fragmentation page grouping. This effectively reverts commit f1782c9bc547 ("dcache: account external names as indirectly reclaimable memory") and instead passes __GFP_RECLAIMABLE to kmalloc(). The accounting thus moves from NR_INDIRECTLY_RECLAIMABLE_BYTES to NR_SLAB_RECLAIMABLE, which is also considered in MemAvailable calculation and overcommit decisions. Signed-off-by: Vlastimil Babka Acked-by: Mel Gorman Acked-by: Roman Gushchin --- fs/dcache.c | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 0e8e5de3c48a..518c9ed8db8c 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -257,24 +257,10 @@ static void __d_free(struct rcu_head *head) kmem_cache_free(dentry_cache, dentry); } -static void __d_free_external_name(struct rcu_head *head) -{ - struct external_name *name = container_of(head, struct external_name, - u.head); - - mod_node_page_state(page_pgdat(virt_to_page(name)), - NR_INDIRECTLY_RECLAIMABLE_BYTES, - -ksize(name)); - - kfree(name); -} - static void __d_free_external(struct rcu_head *head) { struct dentry *dentry = container_of(head, struct dentry, d_u.d_rcu); - - __d_free_external_name(&external_name(dentry)->u.head); - + kfree(external_name(dentry)); kmem_cache_free(dentry_cache, dentry); } @@ -305,7 +291,7 @@ void release_dentry_name_snapshot(struct name_snapshot *name) struct external_name *p; p = container_of(name->name, struct external_name, name[0]); if (unlikely(atomic_dec_and_test(&p->u.count))) - call_rcu(&p->u.head, __d_free_external_name); + kfree_rcu(p, u.head); } } EXPORT_SYMBOL(release_dentry_name_snapshot); @@ -1608,7 +1594,6 @@ EXPORT_SYMBOL(d_invalidate); struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name) { - struct external_name *ext = NULL; struct dentry *dentry; char *dname; int err; @@ -1629,14 +1614,15 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name) dname = dentry->d_iname; } else if (name->len > DNAME_INLINE_LEN-1) { size_t size = offsetof(struct external_name, name[1]); - - ext = kmalloc(size + name->len, GFP_KERNEL_ACCOUNT); - if (!ext) { + struct external_name *p = kmalloc(size + name->len, + GFP_KERNEL_ACCOUNT | + __GFP_RECLAIMABLE); + if (!p) { kmem_cache_free(dentry_cache, dentry); return NULL; } - atomic_set(&ext->u.count, 1); - dname = ext->name; + atomic_set(&p->u.count, 1); + dname = p->name; } else { dname = dentry->d_iname; } @@ -1675,12 +1661,6 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name) } } - if (unlikely(ext)) { - pg_data_t *pgdat = page_pgdat(virt_to_page(ext)); - mod_node_page_state(pgdat, NR_INDIRECTLY_RECLAIMABLE_BYTES, - ksize(ext)); - } - this_cpu_inc(nr_dentry); return dentry; @@ -2761,7 +2741,7 @@ static void copy_name(struct dentry *dentry, struct dentry *target) dentry->d_name.hash_len = target->d_name.hash_len; } if (old_name && likely(atomic_dec_and_test(&old_name->u.count))) - call_rcu(&old_name->u.head, __d_free_external_name); + kfree_rcu(old_name, u.head); } /*