From patchwork Thu May 24 11:00:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 10424145 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B964B60327 for ; Thu, 24 May 2018 11:00:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEF0B29376 for ; Thu, 24 May 2018 11:00:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B40A329379; Thu, 24 May 2018 11:00:31 +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 46E3829376 for ; Thu, 24 May 2018 11:00:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF3466B0010; Thu, 24 May 2018 07:00:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C12306B026D; Thu, 24 May 2018 07:00:25 -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 AD3EC6B026A; Thu, 24 May 2018 07:00:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr0-f198.google.com (mail-wr0-f198.google.com [209.85.128.198]) by kanga.kvack.org (Postfix) with ESMTP id 522556B0269 for ; Thu, 24 May 2018 07:00:25 -0400 (EDT) Received: by mail-wr0-f198.google.com with SMTP id y9-v6so1027727wrg.22 for ; Thu, 24 May 2018 04:00:25 -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=zlAmjVXQE8abjefcztdTzwMySB8e441f0ahvwbrNUBE=; b=S0v36N5bnnuHunxliCLeNGAP0KGfLiUfhDg9YmU62Emzv6QC+WLms6SyrFSL5YPURd FTY6f7D3YJnnVl7I9WkSZIP2VmlssBbYQIQ23/2qoelqhKbxyXiNVdOkuIXLXLpu8cfc Gb44nqmHEl85v0VdszeNH2xMxUpsL/fNYIyVYv6v8KUOxY+yCUmC20GWtlrD0P+fMxwr Q74SxV29r2rQ/53fLWHkofwtos+b4yHF9XAv0cqy0oc52l2GOAanhHNofc4IPyGkpAfW V+FyXfiB7/0Bcz6bkuX6pL/+HFXMbAZcUV/n/gBkrSlbT0ZJKokIn5fWsb+L/QsaizZi Zcnw== 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: ALKqPwdiQnCzVbs6mdxWt6Ho9DxmEWVcqrrormHVOO7qUOSBeHSRAxPc X3wuGTPfE9xOgpkuNU6MMRdSb6yOPjz/JT+N0wc5Px6ALsHWomGf/Nv+ls3tYBkwDQCryiX9yQs 3rAHdC57YjwdljiLHmgtmFmTBYxnLVUQF1i5GdIqk2Tvy18SACEczZ6jTxc//hMxTaA== X-Received: by 2002:a50:a3e5:: with SMTP id t34-v6mr11384899edb.227.1527159624883; Thu, 24 May 2018 04:00:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqOf1In2xyjChDeRuhToRljjgNaSykPEBkshNEvwWv9FwDkaeOucmiQ+t8MUBQTPlUbGFu5 X-Received: by 2002:a50:a3e5:: with SMTP id t34-v6mr11384834edb.227.1527159624046; Thu, 24 May 2018 04:00:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527159624; cv=none; d=google.com; s=arc-20160816; b=ppCDiYmT3hvXsdJ/OTF3nxLH94jMSWmvcmiuB3d+YpCwCqbkTxnq0HWpTNBAqTfO6s efNqYhGCrxbABBBhA7UTs7QthqQ6bk0HtQc9Z4ss3kZQpvDnC7dflELjVzGwYY7bv7nY VQ51RIi6GypHhEJMUX3iu7H4OhfuElMt4RH6TS52x/yX//ECWj16ZfHw7HT5RFMtUtOc vkbnJL2xP67e0j+DMpeFgeOZ0VwtQUdKffKWfnqgbV9BE8rhobS1BpgPkyOv+cWn+I4h U8M8UspZ9scXpmzUI8sTIf+3TpeA8Y1Rx7VFiK/6ORTISAsfTEJ4vPOuFDFZkj45pzgG YeDw== 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=zlAmjVXQE8abjefcztdTzwMySB8e441f0ahvwbrNUBE=; b=03mGmJZSEa5Z0hL5c3I0TqCDPHVzWtAnl2yJyXpOHHcO6PaK7obYqbzkXZVv4tJEy6 MAa0YDsyUu8erfvPRwX4OzUeiatB57nAzBfuspMrlpxUW+IjLX+zxkqHG5O+xm1vv1S6 +WBsLm1G7LbyHvuVz7IwfusqC6Ov4xI+Hr9/Q2tpvSSwHllW46fPflan8t3yOWQ25xKm rCKGDmX2NeK/WQY8KgNqAuybyBhlOqq83HuXyjm0v8lLaQhuY+MbMFyuDacHhYPIeS9G FRLCghR2lIHITVNd31hET4nMDjHoDM8Zp/ElhvXp89/OL5rwhfokoPlhn0vrALBouOzT 1fZw== 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 mx2.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id b10-v6si4308222edf.239.2018.05.24.04.00.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 24 May 2018 04:00:24 -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 (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CFBF5AF3E; Thu, 24 May 2018 11:00:22 +0000 (UTC) From: Vlastimil Babka To: linux-mm@kvack.org Cc: Roman Gushchin , Michal Hocko , Johannes Weiner , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Mel Gorman , Vijayanand Jitta , Vlastimil Babka Subject: [RFC PATCH 3/5] dcache: allocate external names from reclaimable kmalloc caches Date: Thu, 24 May 2018 13:00:09 +0200 Message-Id: <20180524110011.1940-4-vbabka@suse.cz> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524110011.1940-1-vbabka@suse.cz> References: <20180524110011.1940-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. This reverts commit f1782c9bc547754f4bd3043fe8cfda53db85f13f. --- fs/dcache.c | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index c30a8ae46096..3346034d4520 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -257,25 +257,11 @@ 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); - - kmem_cache_free(dentry_cache, dentry); + kfree(external_name(dentry)); + kmem_cache_free(dentry_cache, dentry); } static inline int dname_external(const struct dentry *dentry) @@ -306,7 +292,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); @@ -1609,7 +1595,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; @@ -1630,14 +1615,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; } @@ -1676,12 +1662,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; @@ -2762,7 +2742,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); } /*