Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6038137pxb; Mon, 14 Feb 2022 13:45:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/k4cWusbEFBW3g4sgqJf1XDEscvH5Rl2TlkVHScT8JOIssdYKUPuaB+/qYcqI2SGa4CFx X-Received: by 2002:a17:90b:2516:: with SMTP id ns22mr745967pjb.242.1644875143029; Mon, 14 Feb 2022 13:45:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644875143; cv=none; d=google.com; s=arc-20160816; b=JnPQuprAcdOmegHejVoXuF783UHp0Ke6W4rGz60jxB1IDCRY/Nlf3UpH526LNqaSXL mrgms2P1Sx3pBoIkRtGVuZdlgDsceWIBzqkslGtVVZADf/rZvnLMUPeR/AAJno1+OZz5 Pyc4OeI7M5wUFsrogepSoGlKKoY/7RmIUjOp5gOUoLVlRqeyqGD+hAdC4BwP4u56/+o2 pxfGSM+gRCxCulsgKeGWO6GFMlE/iN+rCMFkwayFMwDcTlE+e70zsg/Y7xE1X27uCbkz i2AV9olZYs5CIyZUjVhfLZ6GtPx1GmKrBNheNhrguFAQLFJt0LlyyJQ+XqrIa96ePHB1 sbmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=JOBfV7L+PZlUyiXZTGr3E52i0R85bq+GW0KUZJMEQh4=; b=mcpPkHElWgSXwl/phqVXWiAaUe/gybVzwYUd6nFAo74P8KcHQHYwypBNF7NsiWBSiE JrFSRNbLClBBCJfqI+2IzdVyg/OIiJtpD+4t0X0a11rhkrokl3RT6WHTR/edo5mKer1p 9a9pV+VpD/HNe2xKi5hMdXEd4K2tzybP+NiUkFztpsdBNU5xBGnTufPZMfcS3IUHa99i Pdf4UPU3V4dkom91CQsXxzCWQqSugGVAOkCzxoSxPhClygjZz2onMjYs0oeZK9fLOXN9 rZd7u/BXTv8uvTLcV6EtCvBU8dVMDA/EUrhFNE19GCgrxdGiS7MMShS93QPTjXSzTslP i67w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="f/q76W49"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t1si35165057pfg.249.2022.02.14.13.45.26; Mon, 14 Feb 2022 13:45:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="f/q76W49"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231560AbiBNVlg (ORCPT + 99 others); Mon, 14 Feb 2022 16:41:36 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231510AbiBNVla (ORCPT ); Mon, 14 Feb 2022 16:41:30 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C2431AF2A; Mon, 14 Feb 2022 13:41:21 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BA2BA614AB; Mon, 14 Feb 2022 21:41:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BD9EC340F0; Mon, 14 Feb 2022 21:41:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644874880; bh=PIdf2fTE/JbbJZPbCMEI4xkJ/6UtHxaqNLp2TxjzPVQ=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=f/q76W49+5AYJc/EBJA1jdPq2br+g+tNRm2EOEfVGRLl9WPp5Dy+0eL87BHctxrre w8cAyno4f/oXQlUd3ts/9c9DjDCNoPgpeToRdo5YQ0qzd1OadZ1sAPRZVOWq5sKEJN iv61aUPZ6ZZ7blt3wcWQ7JNtU2Y3i7nUOK45vXar3KViAqE4tL7iegO18fgLGBR2XE ffLc2RRveFCWT5XLIJtOxwsQ4uiOq9M1gF4Plr+fq8k7O0gJNKLBHXG9n+9bBBprmb e1yfNYZOvCi8Hlv6sildSpBmg0DTxTa70s+6Kzj+FyCDplmMsFIH1cwsmZh5xMAWbS w5JqQCd3x9Y/A== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id DFF345C0388; Mon, 14 Feb 2022 13:41:19 -0800 (PST) Date: Mon, 14 Feb 2022 13:41:19 -0800 From: "Paul E. McKenney" To: Rik van Riel Cc: Chris Mason , Giuseppe Scrivano , "viro@zeniv.linux.org.uk" , "linux-kernel@vger.kernel.org" , linux-fsdevel , Kernel Team Subject: Re: [PATCH RFC fs/namespace] Make kern_unmount() use synchronize_rcu_expedited() Message-ID: <20220214214119.GD4285@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20220214190549.GA2815154@paulmck-ThinkPad-P17-Gen-1> <20220214194440.GZ4285@paulmck-ThinkPad-P17-Gen-1> <20220214155536.1e0da8b6@imladris.surriel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220214155536.1e0da8b6@imladris.surriel.com> X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 14, 2022 at 03:55:36PM -0500, Rik van Riel wrote: > On Mon, 14 Feb 2022 11:44:40 -0800 > "Paul E. McKenney" wrote: > > On Mon, Feb 14, 2022 at 07:26:49PM +0000, Chris Mason wrote: > > > Moving from synchronize_rcu() to synchronize_rcu_expedited() does buy > > you at least an order of magnitude. But yes, it should be possible to > > get rid of all but one call per batch, which would be better. Maybe > > a bit more complicated, but probably not that much. > > It doesn't look too bad, except for the include of ../fs/mount.h. > > I'm hoping somebody has a better idea on how to deal with that. > Do we need a kern_unmount() variant that doesn't do the RCU wait, > or should it get a parameter, or something else? > > Is there an ordering requirement between the synchronize_rcu call > and zeroing out n->mq_mnt->mnt_ls? > > What other changes do we need to make everything right? > > The change below also fixes the issue that to-be-freed items that > are queued up while the free_ipc work function runs do not result > in the work item being enqueued again. > > This patch is still totally untested because the 4 year old is > at home today :) I agree that this should decrease grace-period latency quite a bit more than does my patch, so here is hoping that it does work. ;-) Thanx, Paul > diff --git a/ipc/namespace.c b/ipc/namespace.c > index 7bd0766ddc3b..321cbda17cfb 100644 > --- a/ipc/namespace.c > +++ b/ipc/namespace.c > @@ -17,6 +17,7 @@ > #include > #include > > +#include "../fs/mount.h" > #include "util.h" > > static struct ucounts *inc_ipc_namespaces(struct user_namespace *ns) > @@ -117,10 +118,7 @@ void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids, > > static void free_ipc_ns(struct ipc_namespace *ns) > { > - /* mq_put_mnt() waits for a grace period as kern_unmount() > - * uses synchronize_rcu(). > - */ > - mq_put_mnt(ns); > + mntput(ns->mq_mnt); > sem_exit_ns(ns); > msg_exit_ns(ns); > shm_exit_ns(ns); > @@ -134,11 +132,19 @@ static void free_ipc_ns(struct ipc_namespace *ns) > static LLIST_HEAD(free_ipc_list); > static void free_ipc(struct work_struct *unused) > { > - struct llist_node *node = llist_del_all(&free_ipc_list); > + struct llist_node *node; > struct ipc_namespace *n, *t; > > - llist_for_each_entry_safe(n, t, node, mnt_llist) > - free_ipc_ns(n); > + while ((node = llist_del_all(&free_ipc_list))) { > + llist_for_each_entry(n, node, mnt_llist) > + real_mount(n->mq_mnt)->mnt_ns = NULL; > + > + /* Wait for the last users to have gone away. */ > + synchronize_rcu(); > + > + llist_for_each_entry_safe(n, t, node, mnt_llist) > + free_ipc_ns(n); > + } > } > > /* >