From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 464E8C2BB85 for ; Thu, 9 Apr 2020 16:50:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C8F720753 for ; Thu, 9 Apr 2020 16:50:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727121AbgDIQuy (ORCPT ); Thu, 9 Apr 2020 12:50:54 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:51126 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726574AbgDIQuy (ORCPT ); Thu, 9 Apr 2020 12:50:54 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jMaO8-00FIjH-H4; Thu, 09 Apr 2020 16:50:48 +0000 Date: Thu, 9 Apr 2020 17:50:48 +0100 From: Al Viro To: Miklos Szeredi Cc: Karel Zak , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v2] proc/mounts: add cursor Message-ID: <20200409165048.GE23230@ZenIV.linux.org.uk> References: <20200409141619.GF28467@miu.piliscsaba.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200409141619.GF28467@miu.piliscsaba.redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Thu, Apr 09, 2020 at 04:16:19PM +0200, Miklos Szeredi wrote: > Solve this by adding a cursor entry for each open instance. Taking the > global namespace_sem for write seems excessive, since we are only dealing > with a per-namespace list. Instead add a per-namespace spinlock and use > that together with namespace_sem taken for read to protect against > concurrent modification of the mount list. This may reduce parallelism of > is_local_mountpoint(), but it's hardly a big contention point. We could > also use RCU freeing of cursors to make traversal not need additional > locks, if that turns out to be neceesary. Umm... That can do more than reduction of parallelism - longer lists take longer to scan and moving cursors dirties cachelines in a bunch of struct mount instances. And I'm not convinced that your locking in m_next() is correct. What's to stop umount_tree() from removing the next entry from the list just as your m_next() tries to move the cursor? I don't see any common locks for those two...