Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp598981imc; Sun, 10 Mar 2019 15:31:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwyXQ+Nd8xJwtyLYbxme+wJq9tro+pKn8zdoh5XCWuQSH67fCzkYtVMzQFeGtICpn35KVD4 X-Received: by 2002:a17:902:6a4:: with SMTP id 33mr30946930plh.140.1552257092531; Sun, 10 Mar 2019 15:31:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552257092; cv=none; d=google.com; s=arc-20160816; b=Mt8YatCGPnal9ffyNMrIPc+cxXYoITyNaGbp5bnn5Spw9Aa9UquHAr4PwIFTUv56xH 6Z7ZXjnOAzhUxYEP4zplLIL/aOvlM3BtHrIvvW7goxj5PBqUKGqv9AGvKhcIszTg2vEy T8A0qsSUzyQuj8SgNQ0RgAa+wP10siEtSqVcl55GilnbbUdBQPnc+Nr9HeASqaXLcsMS cTkRr7Ldhk+K5RyWGYDTEigGdgvgbxLSUslgrkalsPTwEp09xoixRrKUd6MSyczVhRYj satngiqTd+r6KHmiVmhKtZUykESNFnJuLK41WgCKKhdFzdmJzPEowfhcZIvyTLVkxwKT KMGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:cc:subject:to :message-id:from:date; bh=FYCwUHa7hYpF8FznzR9dPYW9OufHi8IHQuldifRevGI=; b=ZK0ZpR0XkPV7glZdOd+3QJf+FJmzc4pbPR5WhAfPJezrUzjnmxGqovlZKJGi1HZYbc 6ipPGeLbSB5MBTCn/czDayc48Cud8YrBzcSwlZYJVrsrfYuo5HD7stb4NaPomwfhApNr IPGFO92fKg761WKmSXnuoV7ukshNOMkOFF/DrLLSooJyQByosdKxUVmtDsf68BD0pg2O nsBGN9TvJNu0Kq9dYJNyGTVepkZC1Sl6FQ1D3cpW80xbrw80/oK671amcr7NEM+CwnDW Wjth7WnL7NxjLK5OIV85MHmq1EzZv9pI8b+CSpg6LfKQ3W1zt7HwUCC1HI3l1A2pc83d T2bw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si4019935plw.207.2019.03.10.15.31.17; Sun, 10 Mar 2019 15:31:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727265AbfCJWap (ORCPT + 99 others); Sun, 10 Mar 2019 18:30:45 -0400 Received: from mx.sdf.org ([205.166.94.20]:56997 "EHLO mx.sdf.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727192AbfCJWam (ORCPT ); Sun, 10 Mar 2019 18:30:42 -0400 Received: from sdf.org (IDENT:lkml@sdf.lonestar.org [205.166.94.16]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id x2AMTP6K001770 (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits) verified NO); Sun, 10 Mar 2019 22:29:25 GMT Received: (from lkml@localhost) by sdf.org (8.15.2/8.12.8/Submit) id x2AMTOoU009609; Sun, 10 Mar 2019 22:29:24 GMT Date: Sun, 10 Mar 2019 22:29:24 GMT From: George Spelvin Message-Id: <201903102229.x2AMTOoU009609@sdf.org> To: linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk, lkml@sdf.org Subject: Re: [PATCH 4/5] lib/list_sort: Simplify and remove MAX_LIST_LENGTH_BITS Cc: akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, daniel.wagner@siemens.com, dchinner@redhat.com, don.mullis@gmail.com, geert@linux-m68k.org, st5pub@yandex.ru In-Reply-To: <3194949c-6e04-da01-68df-60ae344db099@rasmusvillemoes.dk> References: , , <3194949c-6e04-da01-68df-60ae344db099@rasmusvillemoes.dk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rasmus Villemoes wrote: > On 05/03/2019 04.06, George Spelvin wrote: >> + * (Actually, it is always called with @a being the element which was >> + * originally first, so it is not necessary to to distinguish the @a < @b >> + * and @a == @b cases; the return value may be a simple boolean. But if >> + * you ever *use* this freedom, be sure to update this comment to document >> + * that code now depends on preserving this property!) > > This was and still is used at least by the block layer, and likely > others as well. While 3110fc79606fb introduced a bunch of if() return -1 > else if () ... stuff, it still ends with a 0/1 result. Before > 3110fc79606fb, it was even more obvious that this property was used. Ah, thank you! I actually read through every list_sort caller in the kernel to see if I could find anywhere that used it and couldn't, but I didn't study this code carefully enough to see that it does in the last step. Since someone *does* use this, I'll change the comment signiicantly. > Grepping around shows that this could probably be used in more places, > gaining a cycle or two per cmp callback, e.g. xfs_buf_cmp. But that's of > course outside the scope of this series. The one that misled me at first was _xfs_buf_obj_cmp, which returns 0/1, but that's not used by list_sort(). xfs_buf_cmp returns -1/0/+1. As you might see from the comment around the cmp_func typedef, there are other things that could be cleaned up if we did a pass over all the call sites. (I'm almost tempted to tell the compiler than cmp_func is const, since it's supposed to be independent of the pointer frobbing that list_sort does, but then I remember Henry Spencer's maxim about lying to the compiler.)