Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp632277pxf; Thu, 8 Apr 2021 09:47:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdmiaWVDPa63T+HCYiqxmqXb/HVjkmGvmYAiJdQwiI2yFsd4y6ARHtrPnDn2Dtg2YIUtSI X-Received: by 2002:a17:907:628a:: with SMTP id nd10mr11578688ejc.326.1617900432045; Thu, 08 Apr 2021 09:47:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617900432; cv=none; d=google.com; s=arc-20160816; b=Ow2Rif7i1qmR+YYiGpxYPb2ICyqenQ1W82NNw22hDA1kMSqGopl9FRTjevHsiYqVi8 u4tQPiYhsiW2jCG7tq4ZGaAW4l2Hs/GB6a2gMSh1rmqPs2kEULSHv1lI+wVkbN/rUF/k cB+GYwfzyV0ax6VfjOGsT5HThc9Va9NH6h829ZIXeenp9/0XAYCqRxtnndhmyjIZpiPS WR0TKEq4wk3dWBv+/a/+ozbn+51uUmmJyxWsInxxrBxZSd9XL8UVcvzXQLD9JdTXNHYN 3E9gKA2ChplsroLVCFGRKNdVWJ39XS4Xv72hXrRUqPgvAzkClzU1nFq+sqpZW/yS3ymG /N0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=Jk0PqcUpIYOYoY1YOtMAJ7dGmSavOo1AaOLiDqR1DyY=; b=jiYK8ST6T+rKif8WVlMn6uoK4Qddwkhq41jIYYt7lUkpnTOu7Gq9YysVB9K6L8auPX +iCzubGkfu8W82EQx3xx2zqwfnqG6aHm8Kvhh8bhN+cpE+rm6X2Rup8wgJ/qkoX9pmVj RwEPl6yP72zdyzmqecqaKeejI58OnsVewrfiSx8Dvy/rNkpSijHTIeIk7ll3Qr80yv3q bIriIvILexFYjQ0/iENKD/u3Pw4TzgpzuXVbIVAKXYyiqDi0qf76+7TroI5lq18w1nOp FI8GLHojgsFkwrMQ82BLSM/H8bcfFAdInr+0SqsmwdpbTWXiwGcU5fbgkpchtVHdL1wi zI+g== ARC-Authentication-Results: i=1; mx.google.com; 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 o6si1975474edi.226.2021.04.08.09.46.48; Thu, 08 Apr 2021 09:47:12 -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; 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 S232355AbhDHQpx (ORCPT + 99 others); Thu, 8 Apr 2021 12:45:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231918AbhDHQpv (ORCPT ); Thu, 8 Apr 2021 12:45:51 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F186EC061760; Thu, 8 Apr 2021 09:45:39 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94 #2 (Red Hat Linux)) id 1lUXmj-003kcY-LV; Thu, 08 Apr 2021 16:45:37 +0000 Date: Thu, 8 Apr 2021 16:45:37 +0000 From: Al Viro To: Daniel Xu 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: References: <22bededbd502e0df45326a54b3056941de65a101.1617831474.git.dxu@dxuuu.xyz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <22bededbd502e0df45326a54b3056941de65a101.1617831474.git.dxu@dxuuu.xyz> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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...? 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.