From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5A6FC4BA10 for ; Wed, 26 Feb 2020 13:57:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AE96E24680 for ; Wed, 26 Feb 2020 13:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582725472; bh=XgwNi2pGTQGnshv0k0m5gJ0yXUmSyZYqwZHo0xuQ4uU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=iYRcomd9e9PoVIrbZrutr54b5V4/K+fJIXIevsdzdAxQTkBjktw5XWmWzMQPBMr2s GePsxWP1VQYi8Dfrw/wYzSVCCDhy8xGW1vHW5nD2BfqGHG3dVeSwoEnTK63zoebGNG zq5oADkls3amarWGSWYeYUQaJ3kx7AVIVIHzIUhI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727198AbgBZN5w (ORCPT ); Wed, 26 Feb 2020 08:57:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:55454 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726388AbgBZN5w (ORCPT ); Wed, 26 Feb 2020 08:57:52 -0500 Received: from localhost (unknown [213.57.247.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A09042467B; Wed, 26 Feb 2020 13:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582725471; bh=XgwNi2pGTQGnshv0k0m5gJ0yXUmSyZYqwZHo0xuQ4uU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=i5L3AARifoVUQDV9ECdqShhAsL1TlFDwh88e6oLVaObX6EdyG/xMISnfBDVxH9M1a r3VEKlfbBeZBpHQ4BnxtnuyJnCih/MR0ndAt0yJUv3/BQzPye0D/14dgfa4rNGWe4V jAFcTisLgPVxkThYwhsA1jnTkSwL5nGFIr5B01zA= Date: Wed, 26 Feb 2020 15:57:49 +0200 From: Leon Romanovsky To: Jason Gunthorpe Cc: Haim Boozaglo , linux-rdma@vger.kernel.org Subject: Re: "ibstat -l" displays CA device list in an unsorted order Message-ID: <20200226135749.GE12414@unreal> References: <2b43584f-f56a-6466-a2da-43d02fad6b64@mellanox.com> <20200224194131.GV31668@ziepe.ca> <20200226134310.GX31668@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200226134310.GX31668@ziepe.ca> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org On Wed, Feb 26, 2020 at 09:43:10AM -0400, Jason Gunthorpe wrote: > On Tue, Feb 25, 2020 at 10:25:49AM +0200, Haim Boozaglo wrote: > > > > > > On 2/24/2020 9:41 PM, Jason Gunthorpe wrote: > > > On Mon, Feb 24, 2020 at 08:06:56PM +0200, Haim Boozaglo wrote: > > > > Hi all, > > > > > > > > When running "ibstat" or "ibstat -l", the output of CA device list > > > > is displayed in an unsorted order. > > > > > > > > Before pull request #561, ibstat displayed the CA device list sorted in > > > > alphabetical order. > > > > > > > > The problem is that users expect to have the output sorted in alphabetical > > > > order and now they get it not as expected (in an unsorted order). > > > > > > Really? Why? That doesn't look like it should happen, the list is > > > constructed out of readdir() which should be sorted? > > > > > > Do you know where this comes from? > > > > > > Jason > > > > > > > readdir() gives us struct by struct and doesn't keep on alphabetical order. > > Before pull request #561 ibstat have used this API of libibumad: > > int umad_get_cas_names(char cas[][UMAD_CA_NAME_LEN], int max) > > > > This API used this function: > > n = scandir(SYS_INFINIBAND, &namelist, NULL, alphasort); > > > > scandir() can return a sorted CA device list in alphabetical order. > > Oh what a weird unintended side effect. > > Resolving it would require adding a sorting pass on a linked > list.. Will you try? Please be aware that once ibstat will be converted to netlink, the order will change again. Thanks > > Jason