Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2352405rwb; Mon, 15 Aug 2022 04:03:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR6iNCcNZymAF0NZ0LL5o/cpnDwZGw5qFV3keRfoUSvzfetUDt6rEhL9eRrebs5afO1aTVZ0 X-Received: by 2002:a05:6402:248a:b0:440:9709:df09 with SMTP id q10-20020a056402248a00b004409709df09mr14044241eda.42.1660561418512; Mon, 15 Aug 2022 04:03:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660561418; cv=none; d=google.com; s=arc-20160816; b=KWb8Dw8+JZ34yyEbqFj5/FM/YB7DfxeFoSY2GfSDRVSCjRmil/zAutGlKZPXHmfcsl 9nLA9EQNDuosyoLOVnfWJ3oTS6wpzWNz0BNbYF1+uAtSAxCuT6w9TlNhMW2aL7sBZMwR qQj/kGAsdmVyqjNAK/tTJjwrjtnCU3UjnMSoHyDo6wIIklFGCCuhYRLzfzzxd2NCjFJG NtVsUampXgUhtXRnL49hr+xEKsV5FqbT8hwiKN8E5g1maDpW0RhSxmPNA75LAXunDF7w q8rZ8P06Ds9NVFns2cRxgvw1/ZBM3WuNjjqdadaswsKZpeiJzxCpAtiD0PG1xlviwiIX 7Atw== 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 :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=RhaoMLkWLvESZ/DVxbL9zmbNeuXsW3BU/Ivunx6PebE=; b=dKgrpBNbza4vEih9VK1LoZ81f987XqCJwYPnZtwQACXUCdh63RPyPp2WO0c4cXfE7e Y/8DRSMPG1E0V/gJBwBaaCIL+qlTv+jVyMLSSmT1OWpyz8SBCMMa0p4eCR/Ya3CmeLyL HP4TRDEhb43zSqTW17EflRgkmo9WCTjf7SnuY8/+j5NOXF3h2Fa7uHBpDJv2eLboKyuG 6FwaRPC0t672COi/P/BJuYn7gzGiuLgrnSe2zKyoc5kIPjZcJKcVH0n4xtzebHYwoj2O T5Y9kPj8FlEt+WLBe7DypeXWha7k73V18cdF8+olQAVjQCSqUDoSRkEe17POmBtLY0ay NvXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz11-20020a1709077d8b00b00730a65e581asi7517149ejc.750.2022.08.15.04.03.12; Mon, 15 Aug 2022 04:03:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233321AbiHOK7l convert rfc822-to-8bit (ORCPT + 99 others); Mon, 15 Aug 2022 06:59:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231511AbiHOK7b (ORCPT ); Mon, 15 Aug 2022 06:59:31 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B0ECE21260 for ; Mon, 15 Aug 2022 03:59:29 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-67-rcu_PtKqP8eoCWaPzqMOGA-1; Mon, 15 Aug 2022 11:59:26 +0100 X-MC-Unique: rcu_PtKqP8eoCWaPzqMOGA-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Mon, 15 Aug 2022 11:59:26 +0100 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.040; Mon, 15 Aug 2022 11:59:26 +0100 From: David Laight To: 'Pavel Machek' , Yu-Jen Chang CC: "andy@kernel.org" , "akinobu.mita@gmail.com" , "jserv@ccns.ncku.edu.tw" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH 0/2] Optimize memchr() Thread-Topic: [PATCH 0/2] Optimize memchr() Thread-Index: AQHYrn6nxbqvf/0XNUiVCIKBvUkbVq2vzrlA Date: Mon, 15 Aug 2022 10:59:26 +0000 Message-ID: References: <20220710142822.52539-1-arthurchang09@gmail.com> <20220812190631.GA1347@bug> In-Reply-To: <20220812190631.GA1347@bug> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: Pavel Machek > Sent: 12 August 2022 20:07 > > Hi! > > > This patche series optimized "memchr()" and add a macro for > > "memchr_inv()" so that both funtions can use it to generate bit mask. > > > > The original implementaion of "memchr()" is based on byte-wise comparison, > > which do not fully use 64-bit or 32-bit register in CPU. We implement a > > word-wise comparison so that at least 4 bytes can be compared at the same > > time. The optimized "memchr()" is nearly 4x faster than the original one > > for long strings. In Linux Kernel, we find that the length of the string > > Well... how much slower is it for short strings? And cold cache?? David > > searched by "memchr()" is up to 512 bytes in drivers/misc/lkdtm/heap.c. > > In our test, the optimized version is about 20% faster if the target > > character is at the end of the string when going through a 512-byte > > string. > > "What is the average length passed to memchr" would be more useful question. > > Best regards, > Pavel - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)