Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp581559imc; Sun, 10 Mar 2019 14:57:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8z72fbexoFMES4cFS/yvZtqdwqv6q3IKbxoVcWliw40oRUcyfWcXzXTLAg6coESREfz/L X-Received: by 2002:a17:902:4181:: with SMTP id f1mr31058092pld.280.1552255024757; Sun, 10 Mar 2019 14:57:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552255024; cv=none; d=google.com; s=arc-20160816; b=pw+0dXjj6bCYm8joYP2TcSJM0vuro5+Drj7TksPVEfWmaJn2EQ/VgQwwvHOz7Br57q hx/JE+3Vg1QI4Uk5xN/NsZoGp88yL8nSB/9JX9Epzs3kJc8Bm/aVrVvgjheF8Wf5owIn Ju7l5VpNg+F3Ifvq5PhFAFalKfQqdrVGSCgae5ClxyhLHD+KSH7sEacE/2Ol7gRmlVaE t667KcOJ2RdrrB5ShGLTMxeIviWBL2PmacD2WZaR3tiUpBIdnvNivQQH4Sj0BCsETNQl +TJqikeg7qtD7Z/cWAv99afEeWtCcF5/vfZ1C2cTVmN3JyehP3FZTCA45sfZ3QBoyOVw qB9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=3n3zLsxeTrvdNVHWG+lNbUiLZmUjtMGJ41LijBUri6Y=; b=mJp8MrG5klXzZCSI0Le08Mn5ncQq/M/C0CgXXDn46CWnBln5Gtoxaw/cHETG/OrxAL jX728oVfVd8+lIsey/Y4lFw0u5Wbu08VlpuCuavYGqa0ojGwHU+OWeAhf5fl66Pp6S9q hEEWYS2MnWPxWq3m2IG63fzh30c51V2olhvnqeMiWUVeIbe58C6l96dC5OESqQsTh3Rz zyM0VNVsrFFPLSVLzjtjYfD47OMiMjlliJ74qGAucvArLAfgAV5I7GqX9JgD9n+pNlHj 2s+SREy8gk3p7R5zgZoOwqciT2DEorUcXK8jzh9lCFl6koFK7k/UM0sapX1BsffCAsYO spdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=Xxpj7Di3; 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 u69si3522052pgd.161.2019.03.10.14.56.48; Sun, 10 Mar 2019 14:57:04 -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; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=Xxpj7Di3; 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 S1726942AbfCJVyp (ORCPT + 99 others); Sun, 10 Mar 2019 17:54:45 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:35600 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726505AbfCJVyp (ORCPT ); Sun, 10 Mar 2019 17:54:45 -0400 Received: by mail-ed1-f65.google.com with SMTP id g19so2420204edp.2 for ; Sun, 10 Mar 2019 14:54:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=3n3zLsxeTrvdNVHWG+lNbUiLZmUjtMGJ41LijBUri6Y=; b=Xxpj7Di375QxQ2ys4+Zi2/3fzc0AGWgGY2icT3ohKpNqkSzAApi1l5/4JuFlfGDIzg SWvwJtf5v09I/RTTz836ShVL40FswuhU12gvEc6Emcz4n/SujWbCtsKyAGT9gePWz7cb UZOiif5cmQ0tAEyFRLALnIxhXDPCt3OafCxVw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=3n3zLsxeTrvdNVHWG+lNbUiLZmUjtMGJ41LijBUri6Y=; b=fTQJMWYZtJIkslbE603HomD8bFQX6jHKK8eawcAkQgLmaZKnOuZgR82zO2FyZxp/h5 I0UJXyUMxlDODBKZjTWwsoY4YyUgpEPRbvgMtbQIjRa9WlidKN/RYwMjvKQIk0h+iPZx ODhC41iTazjkhmP+OWj9B2zmNIwdtc0UwCl+38Sm+2KYcBDBqaMlyohpR88IMEhIrmmA SU5a7NB4C8oXMwGLIvgJSQAq+NiQqa71ZJna/809BA85+HBL7+gSi7saXtI9GJsLCIHb yHgdKpNklByQJCV9HSImvQrka+9q53MouEBpZpj4fYbrOoSz6ks0SuhbZ6ErSLBGx345 Z4jg== X-Gm-Message-State: APjAAAVP6SHrqRwzhMju8e723u8gLBD6lJlr4uSeMUUt5zCKCN+BVaom rex3uWwZCsFhk5Ntp3LOR2A6Fg== X-Received: by 2002:a17:906:7fcc:: with SMTP id r12mr19719808ejs.100.1552254883454; Sun, 10 Mar 2019 14:54:43 -0700 (PDT) Received: from [192.168.1.149] (ip-5-186-117-145.cgn.fibianet.dk. [5.186.117.145]) by smtp.gmail.com with ESMTPSA id g11sm4230390edf.44.2019.03.10.14.54.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Mar 2019 14:54:42 -0700 (PDT) Subject: Re: [PATCH 4/5] lib/list_sort: Simplify and remove MAX_LIST_LENGTH_BITS To: George Spelvin , linux-kernel@vger.kernel.org Cc: Andrew Morton , Andrey Abramov , Geert Uytterhoeven , Daniel Wagner , Rasmus Villemoes , Don Mullis , Dave Chinner , Andy Shevchenko References: From: Rasmus Villemoes Message-ID: <3194949c-6e04-da01-68df-60ae344db099@rasmusvillemoes.dk> Date: Sun, 10 Mar 2019 22:54:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/03/2019 04.06, George Spelvin wrote: > * The comparison function @cmp must return a negative value if @a > * should sort before @b, and a positive value if @a should sort after > * @b. If @a and @b are equivalent, and their original relative > * ordering is to be preserved, @cmp must return 0. > + * > + * (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. So I agree that it is worth documenting this feature, both for users of list_sort, but even more so for future refactorers of it - but you probably want to change the wording somewhat. 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. Rasmus