Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6419705ybv; Wed, 12 Feb 2020 11:52:03 -0800 (PST) X-Google-Smtp-Source: APXvYqwY4+JuTgtQ5fDbm1ScPjp7wjNGsCLaAIiu2aXsWFEH1YQr3i33FGFv5lZWdQEwPQB2gcld X-Received: by 2002:a05:6808:aba:: with SMTP id r26mr504196oij.4.1581537123137; Wed, 12 Feb 2020 11:52:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581537123; cv=none; d=google.com; s=arc-20160816; b=0CvZZO/qVTPNWYehTo/vqxb5a+NRomLHHRLlHKINm3Mw+eN61ViiCUHdnGzXSyxk2p uvIKjy7YfeZIL+feaDBXR+RiMa6uS30/PRuBPOtQKrDtBU8td5S/gNMV723Wh/gLyNMn 5lt9zZ/dxtWVbUetZ+7nTww4qOJdcxOynBeCqSc3BvT9VRu8bKhtDnjjSTTWjx7K2sbb Xae85jQo6v2SkRLbDwNvRg1O8xR2KnujpOCfzHRrtFWgeSpxZKnO6NuyTmxvCYvqpVej ijc6QgpFsbl/mOwhaKoMgQANgyeBrqwYnOQJQlKXJuFpH1AhauJdQ8iQvHQ7efdjJv4z QyIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=CHXH6o1ncLcAF0HeWBgC/IvihmP9toR2+/NwDUguxaw=; b=Jc9g3ckrcg4C36DDRMAoyAze0jEPKHvZdNk1MOGyZZf84w0MkIidUp4eGqYMvLWwfD QkjD28RmZTIsADzreO0ggf0oCOh8A04YbMVkijTXMyBvwqBjInlRHHPLYVgQNx6Ve87W agnXnaxNOfEq+GT4MK/qEJI8QPEv7gB+ujpvP0KwONYha1H0VfCVSli8Q4oOrCoghWhi uDWn4DfT+LaQjvieI68ueQxTWqzSgpirN1AnyXdblgiXf7gQsFK7CHTPGHxjMZ0HRoIL kVXzXf0JcdsCDE+ospfCDif+rnO+S2jQ+XpLLMGDsKhnSeMP90QbIGpUj+IXQaPTCCp5 WEFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=F1RTR2Mk; 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 n2si648315otk.177.2020.02.12.11.51.51; Wed, 12 Feb 2020 11:52:03 -0800 (PST) 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; dkim=pass header.i=@linux-foundation.org header.s=google header.b=F1RTR2Mk; 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 S1729058AbgBLTuW (ORCPT + 99 others); Wed, 12 Feb 2020 14:50:22 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:46878 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728866AbgBLTuV (ORCPT ); Wed, 12 Feb 2020 14:50:21 -0500 Received: by mail-lj1-f194.google.com with SMTP id x14so3721946ljd.13 for ; Wed, 12 Feb 2020 11:50:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CHXH6o1ncLcAF0HeWBgC/IvihmP9toR2+/NwDUguxaw=; b=F1RTR2Mk3atysxi94JEv4Vc5seMqqx02k5CmzRHPSL9IrjapbyqOHw2Fl4dXiCvUEV ncTWbgP69pZD/8vVK6OQciM9WRN9WfMjKk6TsKRj9cuZUdWmWVaikWPX14ZlXYji3kdw CWzsabp8eT8r94ZjWLxWvcikM9+qEZil4HvcY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CHXH6o1ncLcAF0HeWBgC/IvihmP9toR2+/NwDUguxaw=; b=bG/rYnd8LkmTFoYBRun486aMp+qLgHy8vlZcJZE76g3MABWKGN4lHHPZeUjfk4kGrC OIkSwJu6Q3U3NYkd3Ur1lUMTdbhU9RYbvkA2NzeiRZf+mQt3G/YFhKO1+jFKR37s3LVz RkSloFCJ27YhxU3iwYs4U6s7WXhjmenanUw2vr5xkvMfViQzdFi4u9Q2+QDLik1OZz/M b2+Mm4UO1BRNW7QYq6ZDJA9Y1z9kE+CBk5/tpDvKLX/dDITu4tnR5sqBcSK/qQax7g1e yJl4g8XuqMku0r/zMRljA0CgzY79vjlijiOIQSOq//YEg9CMb3aAE2xLSJ1aiBUVBCr3 lMHA== X-Gm-Message-State: APjAAAVVZUpSU6D97vFLCu95Xwmhd/BU0/tlIkWQCixRI0phZnAidgsQ 3f96XV5pKWvL5i2br7RAyHDF56rxoY8= X-Received: by 2002:a2e:8944:: with SMTP id b4mr8826107ljk.90.1581537016606; Wed, 12 Feb 2020 11:50:16 -0800 (PST) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com. [209.85.167.47]) by smtp.gmail.com with ESMTPSA id w8sm75040ljj.75.2020.02.12.11.50.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Feb 2020 11:50:15 -0800 (PST) Received: by mail-lf1-f47.google.com with SMTP id f24so2488863lfh.3 for ; Wed, 12 Feb 2020 11:50:15 -0800 (PST) X-Received: by 2002:a19:c82:: with SMTP id 124mr7333707lfm.152.1581537014849; Wed, 12 Feb 2020 11:50:14 -0800 (PST) MIME-Version: 1.0 References: <20200210150519.538333-1-gladkov.alexey@gmail.com> <20200210150519.538333-8-gladkov.alexey@gmail.com> <87v9odlxbr.fsf@x220.int.ebiederm.org> <20200212144921.sykucj4mekcziicz@comp-core-i7-2640m-0182e6> <87tv3vkg1a.fsf@x220.int.ebiederm.org> <87v9obipk9.fsf@x220.int.ebiederm.org> In-Reply-To: <87v9obipk9.fsf@x220.int.ebiederm.org> From: Linus Torvalds Date: Wed, 12 Feb 2020 11:49:58 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v8 07/11] proc: flush task dcache entries from all procfs instances To: "Eric W. Biederman" Cc: LKML , Kernel Hardening , Linux API , Linux FS Devel , Linux Security Module , Akinobu Mita , Alexander Viro , Alexey Dobriyan , Andrew Morton , Andy Lutomirski , Daniel Micay , Djalal Harouni , "Dmitry V . Levin" , Greg Kroah-Hartman , Ingo Molnar , "J . Bruce Fields" , Jeff Layton , Jonathan Corbet , Kees Cook , Oleg Nesterov , Solar Designer Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 12, 2020 at 11:18 AM Eric W. Biederman wrote: > > > So it's just fs_info that needs to be rcu-delayed because it contains > > that list. Or is there something else? > > The fundamental dcache thing we are playing with is: > > dentry = d_hash_and_lookup(proc_root, &name); > if (dentry) { > d_invalidate(dentry); > dput(dentry); > } Ahh. And we can't do that part under the RCU read lock. So it's not the freeing, it's the list traversal itself. Fair enough. Hmm. I wonder if we could split up d_invalidate(). It already ends up being two phases: first the unhashing under the d_lock, and then the recursive shrinking of parents and children. The recursive shrinking of the parent isn't actually interesting for the proc shrinking case: we just looked up one child, after all. So we only care about the d_walk of the children. So if we only did the first part under the RCU lock, and just collected the dentries (can we perhaps then re-use the hash list to collect them to another list?) and then did the child d_walk afterwards? Linus