Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2403597ioo; Sat, 28 May 2022 12:32:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUrLiZHuWG3Jgt6hpfEUWrITc4ElKuPkqwFdJpGIQl2MMLEGlJ+iWaa+qqQ5tO0Z3qWkgN X-Received: by 2002:a17:903:32c9:b0:163:6bf9:aeb7 with SMTP id i9-20020a17090332c900b001636bf9aeb7mr16351886plr.108.1653766325576; Sat, 28 May 2022 12:32:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653766325; cv=none; d=google.com; s=arc-20160816; b=W6zOv+bjte8h716sok+GLrixQRZrzmcW33sxzPTzsJjgbRFUm9JUXOevet6u+EXPmw KsaknQ+pA06IXwf47/P4Lr4fYBmq1rISiFw/amA0B2nm4rcxlsNqIow+UjxzAmIkwYjW mr3+dg0xk8NkRA9A0VRFm9+3xrqfJP3uiypJ4zdQOubr7rmBeKhDSwIBqf4hg/FiaouT C02+ysRPFaSqk7Y2u5L4MeAoGZygVy61CX8NNijDwkoCT3u4flWxFump73rihzArkU7/ JivTs1HGOHUNS25ebJaAtW31Bjqv6WYuQ40hl6Rp3yt0FeaHWkcuJghkXKF851ccDQ8T f3uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=m0Jp11ciNAmXB/3Pf8JdDNa95fWKHhwkSmYD7UsUFGA=; b=zx9e4IYWPC0zJtvKMx4K2IqWQ/O9+gt1XMXHrGXqCMcO2fxswnbfZgi5VPMA4sKQTh iaUk4+m/nI3Fflii5bYLG/NLa4+qROQMz21Ic8bu5AzPuITqUM0MFmPoldz0cR2O/2ZI XSmqHVZxyqqgCMoAdRHuzK9dqZNeQgkL9Gd+fGYFT7io18D6cLhPgYsXKrqjw63Lbnxe eYvq6CXrZsWiKhBrGRkxa2iknq4S3nctlGdbhn3J9uYTFdstQMBJHYm0LuTsdtOz4UM3 GnfsS3Hrd8uAzRYXbuThUzPlNcXiQDeHt/uJ3Ibf7XFBkh34hARFvG2guT7EoYkpyeaP Zj6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PSY5MRuM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id nv6-20020a17090b1b4600b001e26ef28512si6843184pjb.189.2022.05.28.12.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 12:32:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PSY5MRuM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D833057B04; Sat, 28 May 2022 11:59:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231504AbiE1IN7 (ORCPT + 99 others); Sat, 28 May 2022 04:13:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231189AbiE1IN5 (ORCPT ); Sat, 28 May 2022 04:13:57 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FF63298; Sat, 28 May 2022 01:13:56 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id c10-20020a17090a4d0a00b001e283823a00so2838840pjg.0; Sat, 28 May 2022 01:13:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=m0Jp11ciNAmXB/3Pf8JdDNa95fWKHhwkSmYD7UsUFGA=; b=PSY5MRuM+7vQLSUanhYSON0qmE76h2jQpxL5Waq+Jr0uf9JrdvzdhDzbwkeKpGpC2u v9PGcKg9O6bm+vBOd910pX+NISgKSnJyyh8spAztkp5whbey7LgRU9QsS/qYS0HjAb9b +DlPCyyM9HEwNosEpG+nKwTEG5dQ0j394k7WRYcK5+Mi6np5dX6Dd3vnVyDQPd4JygAl HM2zsNlrZD3eEljk1PAZn2C1r4IlnnC2vXL8YBVYj09rHQ8c1uzz9/Pr7SctzdhSuYLH qJ2Rh2qmOM5nuE4ZyzGQ9b6PSWKzaw8Ff6Yx9N20RVaku0FHEgueyRz+OLc7bmOxIe9/ xvpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=m0Jp11ciNAmXB/3Pf8JdDNa95fWKHhwkSmYD7UsUFGA=; b=4isribNPRDDfQL/PBkIO5SwvYeDrjpj4p3aMSYro6gLU+EGmIfA3L3dLU7t7eD9Lxd ppBRRGDD2Kb/FXzWFL9mXcHh/XSTZxC2rGM6E+fDdaPJP37+DdbHAkBtTbwGc8/LM7nE G8oEjI/9LBkUbC94LdECAywKoUdtMWO54KMscT2jZCpXKTlLWmQKYuwmGSRdy+AWR+s9 QRUdPIohJuqXk4lUH2aR/vRxrZo5Zy8uJANBPW72mkoyIMP0tFVdsm4LCsuGyA3GDfwd eZd1ghRurmxc/bGOLdfqT1vUm7vgmwavpTRLThmcVINr4BW6jDkTH/Sf9pcziUIBv54Z HNkQ== X-Gm-Message-State: AOAM533ck+sujQkIUz7hp0ICvD33ohGcys7j0eNi6wu3fWEjjwDkhqMa 1d/+Fe8MphdS8lvO6xZWuMZeHgQ6Re5jxA== X-Received: by 2002:a17:903:32d2:b0:161:d485:613f with SMTP id i18-20020a17090332d200b00161d485613fmr46749255plr.173.1653725635716; Sat, 28 May 2022 01:13:55 -0700 (PDT) Received: from localhost.localdomain ([140.116.104.153]) by smtp.gmail.com with ESMTPSA id i12-20020a17090ad34c00b001e0c5da6a51sm2774347pjx.50.2022.05.28.01.13.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 01:13:55 -0700 (PDT) From: Yu-Jen Chang To: ak@linux.intel.com, jdike@linux.intel.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, keescook@chromium.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, richard@nod.at, anton.ivanov@cambridgegreys.com, johannes@sipsolutions.net, linux-um@lists.infradead.org, jserv@ccns.ncku.edu.tw, Yu-Jen Chang Subject: [PATCH 0/2] x86: Optimize memchr() for x86-64 Date: Sat, 28 May 2022 16:12:34 +0800 Message-Id: <20220528081236.3020-1-arthurchang09@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org *** BLURB HERE *** These patch series add an optimized "memchr()" for x86-64 and USER-MODE LINUX (UML). There exists an assemebly implementation for x86-32. However, for x86-64, there isn't any optimized version. We implement word-wise comparison so that 8 characters can be compared at the same time on x86-64 CPU. The optimized “memchr()” is nearly 4x faster than the orginal implementation for long strings. We test the optimized “memchr()” in UML and also recompile the 5.18 Kernel with the optimized “memchr()”. They run correctly. In this patch we add a new file "string_64.c", which only contains "memchr()". We can add more optimized string functions in it in the future. Yu-Jen Chang (2): x86/lib: Optimize memchr() x86/um: Use x86_64-optimized memchr arch/x86/include/asm/string_64.h | 3 ++ arch/x86/lib/Makefile | 1 + arch/x86/lib/string_64.c | 78 ++++++++++++++++++++++++++++++++ arch/x86/um/Makefile | 2 +- 4 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 arch/x86/lib/string_64.c -- 2.25.1