Received: by 10.192.165.156 with SMTP id m28csp1227587imm; Wed, 11 Apr 2018 15:02:30 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/VrNpWWK2z4eqJ48iPap0j0udnyZJWUCHl69VzUgt51lJxBN80P6bGOTLoBRiMUXjMkhSP X-Received: by 2002:a17:902:bd03:: with SMTP id p3-v6mr7047202pls.236.1523484149953; Wed, 11 Apr 2018 15:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523484149; cv=none; d=google.com; s=arc-20160816; b=KQWIM2aPTBbvG1RFJmGRjCrvw88pe1LNo8FNj0uyMl+bOuCSTPuvKIN2ul+OtcZCe4 7MoaEoHGMRYNMtPuXhTqIVBRtMdVL7EciOjvySW+0A9JcGDZCfvAQytgH+BxYA9FBzYk lzEr3hJdko/T1DoZbXsBnf9OQTDZgwxM4NfCwvxpEQIMDNsCf0TRNurw/p90XUjIV4pq hh8CyFNlxt1ClaeGC1usZ1BHlaXGLjWSTwNRVQ9xKAyhh+Q+1TCHKHoOFQ4LNr1SJ1DK 9++rPsTHdyPHObx4ae05xVcmr+RMNcs2ThpawFoFlUUvavCjVdAqGOXjOxFztjf8TBan X7Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:cc:subject:date:to :from:arc-authentication-results; bh=9OySyEUnCnwqkzD1UKzw1UjKx0dRpYMs1dolz2RG4M4=; b=XtsmMY/YACTjsZNO+lzj2nGUF6OImAc5tn9lYOGVGFd3u4gZxOfPmgkKzmGKoeuk0Z wRRQarfxjQ+uGoTLRfsUyP4H6XjWlzPrKQukFDhfx++XA1xeC4l6/2vDBzXqipTzjtGa O9QgMFZD/W8pEj7zcf9vdZqgz3ygdRpGD3UxxyEOy459imdbzw5bFVvb683USZ8MLB3J AlMRqIkqiIqFXb5P4t58ZqOG7PUJ/opQoL+IqeQpykpFtyLyAZlvwae/5pWcCrlQ00Ps aJKVcXG5hSCCFEEQOCfNOKZFVilK2C6ilgmspS/FWZDdwQzW3Fw1ZxIbe3H0SL8RFGdJ YJKw== 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 q87si1523461pfj.323.2018.04.11.15.01.52; Wed, 11 Apr 2018 15:02:29 -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 S1754342AbeDKV51 (ORCPT + 99 others); Wed, 11 Apr 2018 17:57:27 -0400 Received: from mx2.suse.de ([195.135.220.15]:46086 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754315AbeDKV5Z (ORCPT ); Wed, 11 Apr 2018 17:57:25 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 56FFEAFB0; Wed, 11 Apr 2018 21:57:24 +0000 (UTC) From: NeilBrown To: Oleg Drokin , Greg Kroah-Hartman , James Simmons , Andreas Dilger Date: Thu, 12 Apr 2018 07:54:49 +1000 Subject: [PATCH 17/20] staging: lustre: use call_rcu() to free lu_object_headers Cc: Linux Kernel Mailing List , Lustre Development List Message-ID: <152348368912.12394.12204341677623060724.stgit@noble> In-Reply-To: <152348312863.12394.11915752362061083241.stgit@noble> References: <152348312863.12394.11915752362061083241.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Using call_rcu to free lu_object_headers will allow us to use rhashtable and get lockless lookup. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/lu_object.h | 6 +++++- drivers/staging/lustre/lustre/llite/vvp_object.c | 9 ++++++++- drivers/staging/lustre/lustre/lov/lovsub_object.c | 9 ++++++++- .../staging/lustre/lustre/obdecho/echo_client.c | 8 +++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index d23a78577fb5..85066ece44d6 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -535,8 +535,12 @@ struct lu_object_header { struct hlist_node loh_hash; /** * Linkage into per-site LRU list. Protected by lu_site::ls_guard. + * memory shared with lru_head for delayed freeing; */ - struct list_head loh_lru; + union { + struct list_head loh_lru; + struct rcu_head loh_rcu; + }; /** * Linkage into list of layers. Never modified once set (except lately * during object destruction). No locking is necessary. diff --git a/drivers/staging/lustre/lustre/llite/vvp_object.c b/drivers/staging/lustre/lustre/llite/vvp_object.c index 05ad3b322a29..48a999f8406b 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_object.c +++ b/drivers/staging/lustre/lustre/llite/vvp_object.c @@ -251,13 +251,20 @@ static int vvp_object_init(const struct lu_env *env, struct lu_object *obj, return result; } +static void __vvp_object_free(struct rcu_head *rcu) +{ + struct vvp_object *vob = container_of(rcu, struct vvp_object, vob_header.coh_lu.loh_rcu); + + kmem_cache_free(vvp_object_kmem, vob); +} + static void vvp_object_free(const struct lu_env *env, struct lu_object *obj) { struct vvp_object *vob = lu2vvp(obj); lu_object_fini(obj); lu_object_header_fini(obj->lo_header); - kmem_cache_free(vvp_object_kmem, vob); + call_rcu(&vob->vob_header.coh_lu.loh_rcu, __vvp_object_free); } static const struct lu_object_operations vvp_lu_obj_ops = { diff --git a/drivers/staging/lustre/lustre/lov/lovsub_object.c b/drivers/staging/lustre/lustre/lov/lovsub_object.c index 13d452086b61..3626c2500149 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_object.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_object.c @@ -70,6 +70,13 @@ int lovsub_object_init(const struct lu_env *env, struct lu_object *obj, return result; } +static void __lovsub_object_free(struct rcu_head *rcu) +{ + struct lovsub_object *los = container_of(rcu, struct lovsub_object, + lso_header.coh_lu.loh_rcu); + kmem_cache_free(lovsub_object_kmem, los); +} + static void lovsub_object_free(const struct lu_env *env, struct lu_object *obj) { struct lovsub_object *los = lu2lovsub(obj); @@ -88,7 +95,7 @@ static void lovsub_object_free(const struct lu_env *env, struct lu_object *obj) lu_object_fini(obj); lu_object_header_fini(&los->lso_header.coh_lu); - kmem_cache_free(lovsub_object_kmem, los); + call_rcu(&los->lso_header.coh_lu.loh_rcu, __lovsub_object_free); } static int lovsub_object_print(const struct lu_env *env, void *cookie, diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 767067b61109..16bf3b5a74e4 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -431,6 +431,12 @@ static int echo_object_init(const struct lu_env *env, struct lu_object *obj, return 0; } +static void __echo_object_free(struct rcu_head *rcu) +{ + struct echo_object *eco = container_of(rcu, struct echo_object, eo_hdr.coh_lu.loh_rcu); + kmem_cache_free(echo_object_kmem, eco); +} + static void echo_object_free(const struct lu_env *env, struct lu_object *obj) { struct echo_object *eco = cl2echo_obj(lu2cl(obj)); @@ -446,7 +452,7 @@ static void echo_object_free(const struct lu_env *env, struct lu_object *obj) lu_object_header_fini(obj->lo_header); kfree(eco->eo_oinfo); - kmem_cache_free(echo_object_kmem, eco); + call_rcu(&eco->eo_hdr.coh_lu.loh_rcu, __echo_object_free); } static int echo_object_print(const struct lu_env *env, void *cookie,