Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1116898pxb; Sun, 21 Feb 2021 12:13:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/9bL0fOJToDAt+zM4kHrGk/jfaYlsn51CDkEO54cfkfDO2w700W+muAAUe6cj2pgvFr99 X-Received: by 2002:a17:906:17d7:: with SMTP id u23mr18124077eje.390.1613938406826; Sun, 21 Feb 2021 12:13:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613938406; cv=none; d=google.com; s=arc-20160816; b=VcANTNTLKUC+JnrNcOiM81+aNFtZTt4TCHhn7Lk8XMainkV1Ehn7WIC5v2X4ZGLA7G YN/aRFaoyP0UuWoaITLIed6ST8XYuCrepCbNBdYdFxSphyS6QF+MhDNge74UDHuaoGKH eiXSCRrpH0ZMiqqXuj8CSc6wfV7cQ6nfsHmQnxemDHyurWvPLjpe4pySu3D5p7ixLqM/ 9kRsx4Tpz5LXnK9TOrDqvC0guW4sV5NUJvtD6Lo5X/tCBVbR1qde9DE1pbST1fQyo3+K LAo1KiwSL1Cwia5g8HKcI019uX4mH9xDWyMcK4XhE6yzloZJUnEk18WnlII3KSnDl6e5 NYrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=7ZYHvlz2PyOH+1LBos+UH4lABWNPQ4hE/eJx23H2AVM=; b=ODQ3UmH3fkyk8nFjbIuyMT60L1i0PaaKewVGpOqNAzeYrBbxvuOZTo0rituhHdZZxC qBymkal5rg/U/jc61EM7iF513Dj0K1ATwhCCo5L/yorp8ZKcpG3EQ/klPiDOfp47S4Oq siib/bwMe+G+L814lkFqi3cgLkgTWmn3nWDP/f4J6j9o2WnxaSKkctB2o2wZX2ppyjmt h+HDFFdFM9UFDTn+qgrx5CtMfYwEYryQ/Ga44vioIdtW2Gyqa6KiDvVTdQQPF9yxRePK uNSr2oRNXKZyg4UIB6iSdF1zA1UsLrXI/zr1hTmN3cUitb3wwZ69vNpUeyX48LcvcVDD s0WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=kdABrIaG; 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 o18si7278159ejx.455.2021.02.21.12.13.02; Sun, 21 Feb 2021 12:13:26 -0800 (PST) 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=@fieldses.org header.s=default header.b=kdABrIaG; 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 S230455AbhBUULI (ORCPT + 99 others); Sun, 21 Feb 2021 15:11:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230296AbhBUULF (ORCPT ); Sun, 21 Feb 2021 15:11:05 -0500 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64EFEC06178B; Sun, 21 Feb 2021 12:10:25 -0800 (PST) Received: by fieldses.org (Postfix, from userid 2815) id 07C0028E5; Sun, 21 Feb 2021 15:10:24 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 07C0028E5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1613938224; bh=7ZYHvlz2PyOH+1LBos+UH4lABWNPQ4hE/eJx23H2AVM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kdABrIaGwL/eI3jBD++XWajauPoawwiH8JbrZft3T7k7FePF3rPxit/zoYPW4uf2h YuMiE/3N0vVZ8FPaSCS8oeetn9bXRnhBEMjIXkzteBypIY/tCbsG6nT9guQeyZ1/08 m987d5kdmNjfkDNQmrWTE6pBJmPrPkZP+RGSrQpQ= Date: Sun, 21 Feb 2021 15:10:24 -0500 From: "J. Bruce Fields" To: Jeff Layton Cc: Al Viro , Luo Longjun , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, sangyan@huawei.com, luchunhua@huawei.com Subject: Re: [PATCH] fs/locks: print full locks information Message-ID: <20210221201024.GB15975@fieldses.org> References: <20210220063250.742164-1-luolongjun@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Feb 21, 2021 at 01:43:03PM -0500, Jeff Layton wrote: > On Sun, 2021-02-21 at 16:52 +0000, Al Viro wrote: > > On Sat, Feb 20, 2021 at 01:32:50AM -0500, Luo Longjun wrote: > > > + list_for_each_entry(bfl, &fl->fl_blocked_requests, fl_blocked_member) > > > + __locks_show(f, bfl, level + 1); > > > > Er... What's the maximal depth, again? Kernel stack is very much finite... > > Ooof, good point. I don't think there is a maximal depth on the tree > itself. If you do want to do something like this, then you'd need to > impose a hard limit on the recursion somehow. I think all you need to do is something like: follow the first entry of fl_blocked_requests, printing as you go, until you get down to lock with empty fl_blocked_requests (a leaf of the tree). When you get to a leaf, print, then follow fl_blocker back up and look for your parent's next sibling on its fl_blocked_requests list. If there are no more siblings, continue up to your grandparent, etc. It's the traverse-a-maze-by-always-turning-left algorithm applied to a tree. I think we do it elsewhere in the VFS. You also need an integer that keeps track of your current indent depth. But you don't need a stack. ? --b.