Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3343857imw; Mon, 11 Jul 2022 06:58:55 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vTJnrXBhT/5OyqsxsB9wu8y0zXVUwsEoX5rbpq3xQdgN/2hxKuk1+W4nMh9RFy41giUdkW X-Received: by 2002:a17:902:778c:b0:16a:6cd5:469f with SMTP id o12-20020a170902778c00b0016a6cd5469fmr19110780pll.102.1657547935379; Mon, 11 Jul 2022 06:58:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657547935; cv=none; d=google.com; s=arc-20160816; b=WgEBJZQbUcjIgylzW69+Mm4OENXfKxk+Yl0Mj/N77k5Dw97c/JurJWVIEoMVCZOjFK EZqLc5I4zFIuLknQ910ElJJTm6zYrrxmgxydmg2EYy1Ro2atNy9PuqEGHWzuSpXJi+jJ L3Lds/u2swwi/jZsm6CoP0gcKsntLT5xpCoTyJAG1YcGrzeM8B1Z+Vd5G0RVyvaN8j2p wICVezAZ5tsMObOdG4Jv2qdUxC99TlEuZnrfZHcwODLUtbyKlQCD3CVBG8MUEuN3vm7g cp6nVVDxpjRLzHuyeN3GT/6y2nMfgnmCBqCYcI/tR0CLg45/WkmOoM+S/VPr1cetg0Cg 9tbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2mSjA/SPr5DLrqocTMOuQhkZ+1jjuTVoS1exRVSQKa4=; b=WTUiS9L7RrG/4nhSRaJzjSA+gDDljwNcmbGjRpCJrWbocX0zI6knZVzPQ/J8XSYOq7 UH5n6TZB6sD8GzT8eolWHkSDw3vXIPelo8zF3hIdhRnj43BOHIoizK55sOP+uIqej/Lr chPO+FnUeV2ojllV9spfMXh5iVrcPmdG5AN/8pmgRvroMyn2VJO4DnqiDuBSzvkC/aiK FvPWMXtKSQmkkXBbylSHEEwDQk1ARCMVMeEESF+sC1BpLM0zLAIsCd5n/x37Cn4UbaIH I/4gVdfWY/8CxezSzzBgTm4OD6G67wbz/Y4SYWStBNgnuBLbcMugmDNPEthwl8TlQ6rS R3Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Jfp31RWP; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k6-20020a63d846000000b003fc51453576si10468006pgj.545.2022.07.11.06.58.41; Mon, 11 Jul 2022 06:58:55 -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=@redhat.com header.s=mimecast20190719 header.b=Jfp31RWP; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230448AbiGKNwv (ORCPT + 99 others); Mon, 11 Jul 2022 09:52:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230386AbiGKNwp (ORCPT ); Mon, 11 Jul 2022 09:52:45 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6035B61D66 for ; Mon, 11 Jul 2022 06:52:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657547563; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2mSjA/SPr5DLrqocTMOuQhkZ+1jjuTVoS1exRVSQKa4=; b=Jfp31RWPkKPtHfAhFL+xpXPethNuV7KhWEptfghsfq129KxYJMMG0qDwLTOdlzI33Eg2Q2 +5YdiNEwkMZesfnz2Na5oSRx+I/6JDdwhBPu+WCdG0WtTTHcDee1m2p83DTBQF+pjBNoue 05g2kzNKCukuS7lhkODbUEKWkREg05A= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-661-xZrsl3tlPeSeCLwvcwrYmA-1; Mon, 11 Jul 2022 09:52:38 -0400 X-MC-Unique: xZrsl3tlPeSeCLwvcwrYmA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1627685A584; Mon, 11 Jul 2022 13:52:38 +0000 (UTC) Received: from bfoster.redhat.com (unknown [10.22.32.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5EB418EA8; Mon, 11 Jul 2022 13:52:37 +0000 (UTC) From: Brian Foster To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: ikent@redhat.com, onestero@redhat.com, willy@infradead.org Subject: [PATCH v2 1/4] radix-tree: propagate all tags in idr tree Date: Mon, 11 Jul 2022 09:52:34 -0400 Message-Id: <20220711135237.173667-2-bfoster@redhat.com> In-Reply-To: <20220711135237.173667-1-bfoster@redhat.com> References: <20220711135237.173667-1-bfoster@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 The IDR tree has hardcoded tag propagation logic to handle the internal IDR_FREE tag and ignore all others. Fix up the hardcoded logic to support additional tags. This is specifically to support a new internal IDR_TGID radix tree tag used to improve search efficiency of pids with associated PIDTYPE_TGID tasks within a pid namespace. Signed-off-by: Brian Foster --- lib/radix-tree.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/radix-tree.c b/lib/radix-tree.c index b3afafe46fff..08eef33e7820 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c @@ -431,12 +431,14 @@ static int radix_tree_extend(struct radix_tree_root *root, gfp_t gfp, tag_clear(node, IDR_FREE, 0); root_tag_set(root, IDR_FREE); } - } else { - /* Propagate the aggregated tag info to the new child */ - for (tag = 0; tag < RADIX_TREE_MAX_TAGS; tag++) { - if (root_tag_get(root, tag)) - tag_set(node, tag, 0); - } + } + + /* Propagate the aggregated tag info to the new child */ + for (tag = 0; tag < RADIX_TREE_MAX_TAGS; tag++) { + if (is_idr(root) && tag == IDR_FREE) + continue; + if (root_tag_get(root, tag)) + tag_set(node, tag, 0); } BUG_ON(shift > BITS_PER_LONG); @@ -1368,11 +1370,13 @@ static bool __radix_tree_delete(struct radix_tree_root *root, unsigned offset = get_slot_offset(node, slot); int tag; - if (is_idr(root)) - node_tag_set(root, node, IDR_FREE, offset); - else - for (tag = 0; tag < RADIX_TREE_MAX_TAGS; tag++) - node_tag_clear(root, node, tag, offset); + for (tag = 0; tag < RADIX_TREE_MAX_TAGS; tag++) { + if (is_idr(root) && tag == IDR_FREE) { + node_tag_set(root, node, tag, offset); + continue; + } + node_tag_clear(root, node, tag, offset); + } replace_slot(slot, NULL, node, -1, values); return node && delete_node(root, node); -- 2.35.3