Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp509791iog; Wed, 15 Jun 2022 06:52:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s1rU31ErRBfNjR24rHCmA3RSRlz/b9az9FqRnopH5RaqFNtyJEu2DtNb8xROtdzdmZmtSE X-Received: by 2002:a17:90b:4b48:b0:1e8:7df8:1e25 with SMTP id mi8-20020a17090b4b4800b001e87df81e25mr10398883pjb.186.1655301173982; Wed, 15 Jun 2022 06:52:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655301173; cv=none; d=google.com; s=arc-20160816; b=FjfcUl13eIWligncIR/UpssY6psy1VmnRucjXFMdDWlZSaVdhY0gj8b14zR7em35W9 7YTRQJBQZ4KRR7feM0QP7znYeA56B9KE64ZjGEOf4exLZsUcRTzrC3de+tuB7QEzmBSd t8HheRflzvBkYaLXoem1iSVgokHtLm0L5pnzbFk/+11unW7eH59qwmSXicXk3aAXw6ze VqGVCBRH+JZXkiglVAjfu6vgwf8IsYnM2nITFR+fFB7JeTDMDHXuDgv5uBhwBFOSJn9v +8aEXD/sB6LjUm1ZYOwBAd4X04EIhWg+Ty4yU13D+MqmsfXNsrTEwJJnvL5iEXGb+MZA zk2g== 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; bh=B2uGtqdyTyve2A4HjKnERqrT+Xadprbqi+LBFQJ2wQY=; b=Ct4FO0VKsI0tHVSU6QzDd5IYGsgALD0/q83zw6Esoyv80DZD6+sBIDkz7zzmpaTqWH XX4fLgzszs5sguslH1JmWxzavCtbVeVMb4oTZLxK4fdu2zA2PAU0n42SLJ8WzVBs/Uhi xZapuc85sD3XKCgNjQ8SyvVSCyNeZyNaOvxxcZUWrZXhqkXrLYJ9EB5xw1N73YMH5oKM EC1TS0oXyiKHafClNYEHE9wTpI6BpKA5RMfH0SHmtWTOWCWCnc/T3A88lyRp0/VkCGvI mQ/Ta3MkO6IQNFO7hitfp36UYW3W1+xYUQ8Gxnw36W+vdN1h68xqvgi6Fv9pQXmQFcsO BGrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ufIki4At; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jh1-20020a170903328100b00161872d6f01si15741060plb.98.2022.06.15.06.52.33; Wed, 15 Jun 2022 06:52:53 -0700 (PDT) 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=@infradead.org header.s=casper.20170209 header.b=ufIki4At; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349241AbiFONoe (ORCPT + 99 others); Wed, 15 Jun 2022 09:44:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354405AbiFONob (ORCPT ); Wed, 15 Jun 2022 09:44:31 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B3413054A; Wed, 15 Jun 2022 06:44:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=B2uGtqdyTyve2A4HjKnERqrT+Xadprbqi+LBFQJ2wQY=; b=ufIki4AtSH5dq2SbjSMl8CPEFM v/EXBmPrriTKKf+lAr+zfVp5vQPC/WHGO384N0tyCGrmaWBPwMlw/6FQ3XPGYw8e6R4o/v8qnMUvp eTJQNBqMMkZcXw1dRJIqRgWEosXToBf2elNWVgrs4ARibwFgQPM/KhZL7gJWXEmEp+A2ctlGP1HpZ con0jb9tA2OCEhX9gVlKcS2bP5G9PMSuEEJsh3DYCnbwqaJg2QS7Ox95e8kQgp2l9SSJx7rCViRXb irBpdVoNMVr6dVuECOeDM3StQWjEVGlLZLRqFIpZk01yqzHG6iHr+c3Gd4wUlU/yLNyLiQs/9F7Ay WJEdjx0A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1o1TJr-0015gS-QI; Wed, 15 Jun 2022 13:44:27 +0000 Date: Wed, 15 Jun 2022 14:44:27 +0100 From: Matthew Wilcox To: Brian Foster Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, ikent@redhat.com, onestero@redhat.com Subject: Re: [PATCH 3/3] proc: use idr tgid tag hint to iterate pids in readdir Message-ID: References: <20220614180949.102914-1-bfoster@redhat.com> <20220614180949.102914-4-bfoster@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220614180949.102914-4-bfoster@redhat.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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 Tue, Jun 14, 2022 at 02:09:49PM -0400, Brian Foster wrote: > +++ b/include/linux/idr.h > @@ -185,6 +185,20 @@ static inline bool idr_is_group_lead(struct idr *idr, unsigned long id) > return radix_tree_tag_get(&idr->idr_rt, id, IDR_TGID); > } > > +/* > + * Find the next id with a potentially associated TGID task using the internal > + * tag. Task association is not guaranteed and must be checked explicitly. > + */ > +static inline struct pid *find_tgid_pid(struct idr *idr, unsigned long id) > +{ > + struct pid *pid; > + > + if (radix_tree_gang_lookup_tag(&idr->idr_rt, (void **) &pid, id, 1, > + IDR_TGID) != 1) > + return NULL; > + return pid; > +} The IDR is a generic data structure, and shouldn't know anything about PIDs, TGIDs or tasks.