Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp273489pxv; Wed, 21 Jul 2021 22:56:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeRELkC3PlSfh5NjmNwYQ09Wem4ckIvIb19lfggPSM52NSPe/YvzHWMvJ1l1Kst0wUk1wP X-Received: by 2002:a05:6602:342a:: with SMTP id n42mr20144557ioz.126.1626933374538; Wed, 21 Jul 2021 22:56:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626933374; cv=none; d=google.com; s=arc-20160816; b=FoMSqpLfJ0qf/gFpOy8h432RQa83fIvgeXoBtvhRDtA3m60cj8Am2hAUOqllJZ0cUk w/C+kSXb+sGsb/m3fhDWmgi88Y8qaqt1kfifOQeErx2l3+coup8q7hxXdULDeK/9tfYy POxuM2jzsH9c22X5ThgSaOmFvYR4OgLHtm+1qPVjg2DFYFvD5abpvdR+ZudC3Lw+X19e W3AJlJmhjQ693O00o6569nlFOSBhbQQ617Yf+ZIC3hQqPIYQXZ+7VSTiJcz3VoctiIH5 lOs4UnJS8tPapIaBRob2N0T+GY5EjxCxKprBdNmk2YB2W0ho5y8tSh/9JpZnXWwCoSF+ uZcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:dkim-signature; bh=nEQOsUBhG7WuceEdafdVcMY/cqYyTJYTe4BOBvgIZgM=; b=0MxrDE1UwXT52b9+zKS62AHQz8XOLibJpETPoACEehY5eN2rEBmw6Pc6E3RzPfg9bT u3oZw9wYETBB3egOl3dxBclEmDcYtcY3Hv8JeO6T4tQtbFw7FoBqCtxenj32tR6Ot0jf F6MV6OKuctdUlzoAMkFIGZWMTRtRrEZ6lAJCp3BztyXLqr+DUcSLLkZxmnV3MDe5LayJ YHlXINf3eqVtoi/pmMJnhipmfrP32LgBvenWVrwgXDS3wdq6DTcf3tAQ4RauXbtoW+89 PajbJtwvlRCPz3Y4jTu2ufsdIdA38i+FLOX8gXCIpPpUs37CnX3oRPfCl/9I7yBY2uZz YJpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=FzsAUuKT; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c19si18603149ild.65.2021.07.21.22.56.03; Wed, 21 Jul 2021 22:56:14 -0700 (PDT) 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=@suse.com header.s=susede1 header.b=FzsAUuKT; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230137AbhGVFNl (ORCPT + 99 others); Thu, 22 Jul 2021 01:13:41 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:36414 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229971AbhGVFNk (ORCPT ); Thu, 22 Jul 2021 01:13:40 -0400 Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 434F91FEEF; Thu, 22 Jul 2021 05:54:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1626933255; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nEQOsUBhG7WuceEdafdVcMY/cqYyTJYTe4BOBvgIZgM=; b=FzsAUuKT9FbQwXQ3KEtoHkP8PVj0LRaZb5nqfoPxY3v5XjScaLtY3LhudrgyZU2GbiAwgf CocoqrB672lsxB8PS2NDLR7blctdZlwgyuie4K+bWvT2nxPYmoQb5wEta7gn1mgsyLs0Ze 1thGT4zbJ4gVye4yLA8Kw5OaR7/VCsQ= Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id DFDFA13299; Thu, 22 Jul 2021 05:54:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id pPCSMwYI+WB6aQAAGKfGzw (envelope-from ); Thu, 22 Jul 2021 05:54:14 +0000 Subject: Re: [PATCH] lib/string: Bring optimized memcmp from glibc To: Linus Torvalds , David Sterba , Linux Kernel Mailing List , Nick Desaulniers , linux-fsdevel , Dave Chinner References: <20210721135926.602840-1-nborisov@suse.com> <20210721201029.GQ19710@twin.jikos.cz> From: Nikolay Borisov Message-ID: <792949a2-d987-f6a0-a153-8c5fe1e3a073@suse.com> Date: Thu, 22 Jul 2021 08:54:14 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21.07.21 г. 23:27, Linus Torvalds wrote: > On Wed, Jul 21, 2021 at 1:13 PM David Sterba wrote: >> >> adding a memcmp_large that compares by native words or u64 could be >> the best option. > > Yeah, we could just special-case that one place. This who thread started because I first implemented a special case just for dedupe and Dave Chinner suggested instead of playing whack-a-mole to get something decent for the generic memcmp so that we get an improvement across the whole of the kernel. > > But see the patches I sent out - I think we can get the best of both worlds. > > A small and simple memcmp() that is good enough and not the > _completely_ stupid thing we have now. > > The second patch I sent out even gets the mutually aligned case right. > > Of course, the glibc code also ended up unrolling things a bit, but > honestly, the way it did it was too disgusting for words. > > And if it really turns out that the unrolling makes a big difference - > although I doubt it's meaningful with any modern core - I can add a > couple of lines to that simple patch I sent out to do that too. > Without getting the monster that is that glibc code. > > Of course, my patch depends on the fact that "get_unaligned()" is > cheap on all CPU's that really matter, and that caches aren't > direct-mapped any more. The glibc code seems to be written for a world > where registers are cheap, unaligned accesses are prohibitively > expensive, and unrolling helps because L1 caches are direct-mapped and > you really want to do chunking to not get silly way conflicts. > > If old-style Sparc or MIPS was our primary target, that would be one > thing. But it really isn't. > > Linus >