Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp792931ybm; Wed, 22 May 2019 11:35:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpb+YJSLxeufxNiRUU0KaYcLyRzr8KFrk8bjv+ztGi6FVukJxV9KHJRKLpxjVr3bRrquw9 X-Received: by 2002:a62:e10f:: with SMTP id q15mr4382431pfh.56.1558550143209; Wed, 22 May 2019 11:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558550143; cv=none; d=google.com; s=arc-20160816; b=R+BkjuEFv73yHsW9UaeP0ZPPpT2fn06W08k8Y5qnO0+rL+YAnfnaky5i3kTzpflUVl NdCFqFnoJ3henGEvYBQ4HXzrSxonyvjarl7AqXj4K7S6iykmJ7y+MQcYRZNlrPNa5BZZ PkZ8c7X0AuHmHQ/voLsKGogHxoF/7OlALbXuAFppBBkQbULhxbFZqzqyz1ydEFAUivKP K9VZWetK7mvcI0H6JyM3JqzePc66rYZ2wIXPPJYyuxv/HTRop0UzHjrO12gj9cjudSJb nKn43tItpDhdgCzQesQrpRzK9716Crgh20DHujYzz6T6Scn+yxxyx7v3BZmFuSGYaO1b ptrQ== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=LbC9HGQtKcrOcOo4rgtJhfCO5KfXW1Px5+9xAUBkktU=; b=mf+SW2A3hhH8IvUJadhhPI8DJZ/ZQjCO+2e3l5R4VlsJzzPwXMWIy6I/gCOn6xNoTd thU5Hop4qXGnYXJdX/66x1AntAtRHQHS2v8lmzayYRp/RMFvxHqrurPDvek85vgM0Gc2 O3P9D0m//5VFDGQ/txyiGB9B1DHyZySjTV9X5X7y89aUyGQw2A41XFA1tzvc1MfewSPo Lk4IYrb+9BpP50tH+1hOblj700QcJQMJiJoxxv1Zu+u0dCeFofMXKgtn1qmXvYV6Ha5X jce8NT99fJddoPnKdhSAX1mkPIiPcs1kSCHEt6cuNNKihl8K+hubvktDa1iErGnRf21L mOuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qc6ooJJq; 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 61si28208970plf.355.2019.05.22.11.35.27; Wed, 22 May 2019 11:35:43 -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=@kernel.org header.s=default header.b=qc6ooJJq; 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 S1729018AbfEVSdR (ORCPT + 99 others); Wed, 22 May 2019 14:33:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:52014 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728272AbfEVSdR (ORCPT ); Wed, 22 May 2019 14:33:17 -0400 Received: from localhost.localdomain (c-73-223-200-170.hsd1.ca.comcast.net [73.223.200.170]) (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 DACD221473; Wed, 22 May 2019 18:33:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558549996; bh=/z7Nk3RKquTaLh7LGUcYRr+01LS+V0BVfOEfOJekipI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qc6ooJJqMW/TOTEEJs0mgLGcq/MVsfm/8GvlWWs9LT4wUO4b6UKknAx2oboANj7+q 6voZxPnNM595lMZPazAL9Ajnf53Oan1CXvtxHbpHSMnjiJ0sZ5bM/iZ8YyNuMp3jfr q17Z5wbd05wBVP8yO2kqntJwVR+63yQtjvjNtGIo= Date: Wed, 22 May 2019 11:33:15 -0700 From: Andrew Morton To: Boris Brezillon Cc: linux-kernel@vger.kernel.org, George Spelvin , Rasmus Villemoes , Andy Shevchenko , Andrey Abramov , kernel@collabora.com Subject: Re: [PATCH] lib/sort: Add the sort_r() variant Message-Id: <20190522113315.08484a3942ec07793b7d6112@linux-foundation.org> In-Reply-To: <20190522112550.31814-1-boris.brezillon@collabora.com> References: <20190522112550.31814-1-boris.brezillon@collabora.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 22 May 2019 13:25:50 +0200 Boris Brezillon wrote: > Some users might need extra context to compare 2 elements. This patch > adds the sort_r() which is similar to the qsort_r() variant of qsort(). > > Signed-off-by: Boris Brezillon > --- > Hello, > > A few more details about this patch. > > Even though I post it as a standalone patch, I do intend to use it in > a real driver (v4l2 driver), just didn't want to have it burried in a > huge patch series. > > Note that sort() and sort_r() are now implemented as wrappers around > do_sort() so that most of the code can be shared. I initially went for > a solution that implemented sort() as a wrapper around sort_r() (which > basically contained the do_sort() logic without the cmp_func arg) > but realized this was adding one extra indirect call (the compare func > wrapper), which I know are being chased. Please move the above text into the changelog. It's probably useful and we can afford the disk space ;) > There's another option, but I'm pretty sure other people already > considered it and thought it was not a good idea as it would make > the code size grow: move the code to sort.h as inline funcs/macros so > that the compiler can optimize things out and replace the indirect > cmp_func() calls by direct ones. I just tried it, and it makes my .o > file grow by 576 bytes, given that we currently have 122 users of > this function, that makes the kernel code grow by ~70k (that's kind > of a max estimate since not all users will be compiled in). eep, let's not do that. > --- a/include/linux/sort.h > +++ b/include/linux/sort.h Patch otherwise looks OK. Please include it with the patch series which uses it. Feel free to add Acked-by: Andrew Morton