Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp834380pxf; Thu, 8 Apr 2021 13:50:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZCEMoRJikZDB1uLvqpoJWbx/ZR6sngKq6Du0X1UszBEagcnz38VD2hy138WSZlCQ/loJm X-Received: by 2002:a17:902:8bc3:b029:e9:9639:be21 with SMTP id r3-20020a1709028bc3b02900e99639be21mr4063663plo.59.1617915032183; Thu, 08 Apr 2021 13:50:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617915032; cv=none; d=google.com; s=arc-20160816; b=E1Z6jq03j2P9RlAbaQGB3AKZAXtTvLjJbxQQrImRCAf9bFewKib3inSccBN4HTmXyS ZO4rMf/24yy7no10OpPNWpTX6NNOsa7Din08hYhV2ijY7dFXk1J9rG3lIAWZow6kZPgR godCSWL1y7Iev9mx2i6kgokjtdrZt1RW0kfufPNVlZ6SJvS4pXGanZbPlCxSW8AGEWNG lHsC6jR0zRlBnkWn4ArO8Md2UT/ySyOuOEa4fLUubNdkbF/PVGb3zJnWXkmCT1SXwb31 d4tzD7IX6TfS2z84KO7OJx28Hko1/lXvfJjmdd4xnlsSrgDRJa5gk7JDQauFZgH+/7HI vzmw== 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:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=MQtSHPJqtnoPnzsLmLnzXyuX+LYDZOGWduO0MWZnQ4w=; b=gjyR6xkAINA++xLMJbtoC6vUHyMgEHVWvRB0HFpd8agB/3GefFnqEajPQ5L1MFYyxk 4b5LjLjhXK40G1G4G/7+fz73d8znI2RPTgW3VGphqSfV1wL/hV//7moZBsv0sZfBNlom dyM6PK7q1N+GDnBOQBYmN+DbRmxByitqpA06h8R2w3NFfW08Uj73NMn/T7eMe1v2zTIk Wjy95LZ6eXGsw9OCVnqAEOLGFS/8GmtyyzvNvny7KYbwDJwdwGzirPdHgwxE4m7mmmsJ z/10fhmSUizO0OOm4wIdpbCL87cdgCzwQFYE3C96HZw3W+RM5yW8xwBjTGgKXiCsft5h CQAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b="V0/BROVa"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=BL1kxNiY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h9si539726pju.51.2021.04.08.13.50.19; Thu, 08 Apr 2021 13:50:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b="V0/BROVa"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=BL1kxNiY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232351AbhDHUtw (ORCPT + 99 others); Thu, 8 Apr 2021 16:49:52 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:37427 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231897AbhDHUtw (ORCPT ); Thu, 8 Apr 2021 16:49:52 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id CEA125C011A; Thu, 8 Apr 2021 16:49:39 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 08 Apr 2021 16:49:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dxuuu.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=MQtSHPJqtnoPnzsLmLnzXyuX+LY DZOGWduO0MWZnQ4w=; b=V0/BROVaZviWOXWayii4M2rCj+aWENTi/HG+cw32BK6 JwhVkZg2PDP75XW8rAo4GS1xZQZ2ILRd2l4ZimrvbLdGYbv7IBIqsn/+paoScYUG QwhDVizRXDtp0qp8MNmLjSmqdq8BgOwXeHbrM5ZARicn8lvD2Mr1pUkvlH1eI/p8 WQLiLuzD66Crf5G/8F2h86YpLZ3KDJi7uZyldlvPb754gQozWoKp8a1ihrPC5qYS KpqpSoFUTxkxY5sPylqoIMRnordMt8jczn6Ci9kFJbwMOpMp+Blh+UzjvOlVCkZP vMERXaRuzac1ndSim1CPUVvwG1btvbTxGq4GXHR0g7g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=MQtSHP JqtnoPnzsLmLnzXyuX+LYDZOGWduO0MWZnQ4w=; b=BL1kxNiYfljceJuJ5rR2GA 21qCSxk5t0DAhehulEWmXzDETz/h5OX//HNTnOdDXwsvTacRu49pWW53U6vLPyx+ kdm15sbFdteNVvZnUzlp/YlauBg8pDZ2+WSfxQmFdOVK/0Ne/LOm1BY8zjw6kFIF XJF/+2vF0ZQLSeKW1T9a0VizAP/RmVqAJ7cXdx+RSOlKQnzNirp/1rNGIJgE9ZWR t77Ehod/E5YrDajk2Sxe+jvEJWnqZRAvXj8s6/N28UEyuEc246JuL6ELoyCMiRO+ h7sxP2a/X2dJLPQdumIhEaIX6KfAcsWrQ8bbCziVGQ7aSOuYH08TdSvQ4XbUUxKA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudejledgudehhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enfghrlhcuvffnffculdejtddmnecujfgurhepfffhvffukfhfgggtuggjsehttdertddt tddvnecuhfhrohhmpeffrghnihgvlhcuighuuceougiguhesugiguhhuuhdrgiihiieqne cuggftrfgrthhtvghrnhepueduvdejfefflefgueevheefgeefteefteeuudduhfduhfeh veelteevudelheejnecukfhppeduieefrdduudegrddufedvrddunecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepugiguhesugiguhhuuhdrgiih ii X-ME-Proxy: Received: from dlxu-fedora-R90QNFJV (unknown [163.114.132.1]) by mail.messagingengine.com (Postfix) with ESMTPA id 0BD031080063; Thu, 8 Apr 2021 16:49:36 -0400 (EDT) Date: Thu, 8 Apr 2021 13:49:35 -0700 From: Daniel Xu To: Al Viro Cc: bpf@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, jolsa@kernel.org, hannes@cmpxchg.org, yhs@fb.com Subject: Re: [RFC bpf-next 1/1] bpf: Introduce iter_pagecache Message-ID: <20210408204935.4itnxm4ekdv7zlrw@dlxu-fedora-R90QNFJV> References: <22bededbd502e0df45326a54b3056941de65a101.1617831474.git.dxu@dxuuu.xyz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 08, 2021 at 04:45:37PM +0000, Al Viro wrote: > On Wed, Apr 07, 2021 at 02:46:11PM -0700, Daniel Xu wrote: > > > +static void fini_seq_pagecache(void *priv_data) > > +{ > > + struct bpf_iter_seq_pagecache_info *info = priv_data; > > + struct radix_tree_iter iter; > > + struct super_block *sb; > > + void **slot; > > + > > + radix_tree_for_each_slot(slot, &info->superblocks, &iter, 0) { > > + sb = (struct super_block *)iter.index; > > + atomic_dec(&sb->s_active); > > + radix_tree_delete(&info->superblocks, iter.index); > > + } > > ... and if in the meanwhile all other contributors to ->s_active have > gone away, that will result in...? Ah right, sorry. Nobody will clean up the super_block. > IOW, NAK. The objects you are playing with have non-trivial lifecycle > and poking into the guts of data structures without bothering to > understand it is not a good idea. > > Rule of the thumb: if your code ends up using fields that are otherwise > handled by a small part of codebase, the odds are that you need to be > bloody careful. In particular, ->ns_lock has 3 users - all in > fs/namespace.c. ->list/->mnt_list: all users in fs/namespace.c and > fs/pnode.c. ->s_active: majority in fs/super.c, with several outliers > in filesystems and safety of those is not trivial. > > Any time you see that kind of pattern, you are risking to reprise > a scene from The Modern Times - the one with Charlie taking a trip > through the guts of machinery. I'll take a closer look at the lifetime semantics. Hopefully the overall goal of the patch is ok. Happy to iterate on the implementation details until it's correct. Thanks, Daniel