From patchwork Wed Jul 18 13:36:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 10532485 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 0C0766053F for ; Wed, 18 Jul 2018 13:36:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2AF4292E3 for ; Wed, 18 Jul 2018 13:36:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6CAA293F2; Wed, 18 Jul 2018 13:36:46 +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=unavailable 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 863ED292E3 for ; Wed, 18 Jul 2018 13:36:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D2DB46B000A; Wed, 18 Jul 2018 09:36:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C99776B0266; Wed, 18 Jul 2018 09:36:32 -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 870856B000A; Wed, 18 Jul 2018 09:36:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 021D46B000E for ; Wed, 18 Jul 2018 09:36:32 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id l1-v6so1933098edi.11 for ; Wed, 18 Jul 2018 06:36:31 -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=iQsCBqgyaJkmflVm6iM8glkpyucyqxs8sE7IzxpqSj4=; b=cZ9iVL8lQpLGWT9n5LJzY90L/t8+MQNoN3zbMvbwmrCmpug9/7XOKfDOs5HlZ71beH 7u7Lh3pD6w1zL8AROd5Pb4VOE2CJajWkQkMR2vU6rjKyhgvMSKJLPNQQrXL1kGBCrsJp XA+hA/TPW54nuxCCf1Cp2+6ZNSGOaUmE6+zlz/QbQWHSqQdVnaph3mWwsOE/yMuvmjjC 0Vth38dM9hAa8ueCxY/2C3jmYKw9nDg0quhSSFnK1GIMn2aeAkCYJgmfdNk0Ugj9UnHE 8LLWYuHC9dXdO07/zP3xwbsYwhMu/VJcUDauT8N9Ag0IfubETkHLyoquhAoehkrQHQHQ +CSw== 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: AOUpUlGQccH+Wtvx+aXAIuU/Ku1PnnmXBNFK6aCbh6DLgkj8t4k0Dz93 TbC/t2GuUC9xBuJV/puw6phJng7Dr7tG9UlMhRI5mY2/Eqt86ljuJ1kiDTIdMahDrPX4TiLJTyf tuyiokm+QYsa0JqB9nUosfvHFg8VVXLUnHx2tlSywVGHjKV2RnkXE/VQfeyMkAbsQFw== X-Received: by 2002:aa7:d742:: with SMTP id a2-v6mr7370797eds.100.1531920991453; Wed, 18 Jul 2018 06:36:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeLv/gw1yoNmxk3DhHUibqUMrvozUnGZ5mL7xK+r0PsQWqUYJDq/eQjimqrB8bZHb7ccqtX X-Received: by 2002:aa7:d742:: with SMTP id a2-v6mr7370715eds.100.1531920990382; Wed, 18 Jul 2018 06:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531920990; cv=none; d=google.com; s=arc-20160816; b=UjhCVDQJqcdN1dIDJU9XJgq6QOFe3Un+gV45O3PECpgxGOz1awOdX7UGTEgXajEKOw 4OrJB+6blPKn6QfZ/eGGgMY3J8qirUm2Ewfashh+xk+s4Od0hHGftOiXmbZ6NCgopDFT /KIbZ7abqilZoKqXrs3xgi2a9bqssiFZu2o3gKd8SyiJ29t1hO1mr0PtL1aSpWACxqSN ZF9Um/qF2f5Sc1GkugLeb2uTvuzAErKjq/yJeU1Hs3/tM0bDWPOjxboyNNvdu/FYYaZP qgv1EUPaAgH1wkunfqRBIkLZ3Ea7F3vrIUU3ksrJvrAz2BlRajKrpX1QKO+IHgt8AaIg LSbA== 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=iQsCBqgyaJkmflVm6iM8glkpyucyqxs8sE7IzxpqSj4=; b=DqEYmOYawd/tWsSJKafRpKe6OkFxnd8w2938b6T8WKVTDVbMlfJslrV2NCI82Xji9I Ru63GUXxHJ++mgsucRA/FoWPAl8GdGUqy73uOeTcV9pOqBRxyyf224wUvAz4EJVteShA ItLN22/EoKT+utOwDY6ukD6xqwex2qcKSTpw7jeF6fkDDtNGP7ZAsNJKRGalYff3FhnQ lB7jQRlXg70y22fCeV7/sFoqPuxx3KO/7Jae6qmCrIrl+MM6raI5pPUgHrr8fDOBNw8G qjzd5JGx+r4Iz4Sfe9I79AEJn5mhhS7oHFghAI8EIf1/MciBYFiIPrjq3TCU4N+XNjsu V4OQ== 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 h29-v6si3074672edb.301.2018.07.18.06.36.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 06:36:30 -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 DF910ADC4; Wed, 18 Jul 2018 13:36:28 +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 v3 4/7] dcache: allocate external names from reclaimable kmalloc caches Date: Wed, 18 Jul 2018 15:36:17 +0200 Message-Id: <20180718133620.6205-5-vbabka@suse.cz> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180718133620.6205-1-vbabka@suse.cz> References: <20180718133620.6205-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 --- 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); } /*