Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp644965imm; Fri, 27 Jul 2018 03:40:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfS1aYhDGWG1FJzM2vl6a1X1+Q1cTb1aRgGfosq3FZ1IH4oloP7YSF56oxv/gH2R3JfuAdI X-Received: by 2002:a63:db05:: with SMTP id e5-v6mr5550599pgg.152.1532688032955; Fri, 27 Jul 2018 03:40:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532688032; cv=none; d=google.com; s=arc-20160816; b=EEsanl8zXrrYbYJKRmHJVOKnEfhBQ2zD/Fj++p4A/9byrjBy7QGTJ53dUr0TYxfj1S 8gltjWK69aOiKK5Q0DRZT8IgPWExG1MLuIk7PfvKlCMdVNkfDX03uGLAlUDfTBeL/nIh eGl81nixVdZl2jqNSj2ZxqlK0f0CtvJIu+YOHATpLi/98lTZxVb5hLlDDhPLWDSAku9k kgZwo1g0331fSPWMAUyb2z0Q+Mken6i5A1M6tNPdXG0XDdIaTqFcL8d99h73qhVvxWky IA79EjJssWK76HDAl17CjhPWKDsOhxgV3QS4Zf5DNXMz5GPtFaTzNGdLx2Loi2Pg3pzd ZvWg== 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:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=GNpiQh7ABwX5CzZaDSFk4r46vvFK7pNN6hDEEKpsaq0=; b=QKokmk16IjBpURFrJwoTmkkuOja0uZn9imaBSum/c7PnMv4jyMAdqFOQZWMgpqaYZc Vwyzpj/va4AL5GARN/PlwWsYZGHYyCklBvzUW4vqRcN7u9YjTl0NZHbBhgYDtQFT0KLT x1Ajzd31uZJfRHqzb7cLfitdKHC+RiTDenSUpkMXSkMBX/PgMP0/HM3WPnPfruv8lbqn nY1jVDoaDZWArmvKuUELe4PBfMde/6WV4Hr9FZO9zcSknsaa/SZt0uL7ABtCN0ghawcD WPS0sTPugvh2G5Od8Vjk4fgRXc1+OE9mdqmw0V4z5U5P9xMZRuuKGQDDZYItYt282foP Q3RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BSJ2xz6y; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x25-v6si3885310pfi.138.2018.07.27.03.40.17; Fri, 27 Jul 2018 03:40:32 -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=@gmail.com header.s=20161025 header.b=BSJ2xz6y; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730654AbeG0MAn (ORCPT + 99 others); Fri, 27 Jul 2018 08:00:43 -0400 Received: from mail-ua0-f194.google.com ([209.85.217.194]:37348 "EHLO mail-ua0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730026AbeG0MAn (ORCPT ); Fri, 27 Jul 2018 08:00:43 -0400 Received: by mail-ua0-f194.google.com with SMTP id y10-v6so3038867uao.4 for ; Fri, 27 Jul 2018 03:39:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=GNpiQh7ABwX5CzZaDSFk4r46vvFK7pNN6hDEEKpsaq0=; b=BSJ2xz6yFRhH+LpqtO9EL31GMQbBsZsA/L3u4/Va1E/Gjdz3e+c/RCRJwtvRLX3+pL ATkum5z/7PbSUZMoGn8kbaey1OLOn7cwUDJC7VpL3irwD0IDl4VL6NDTDB+uk5lu/HqG fh9Y5Ou78rKes3Y3GxYtdyYdqIMpsydzlzmoDaXq2BFg/6qul0e8/RDUpG4lIDRW/Lno 0Y55Y4mqZRM6Kpgy0oJ36ZJCTIOAYy3YcnMuq1lQoggV2SEVZ+yP74HFWqdRbgtLW3t2 p9TAQbGZwHhPkczd9i3ACkFvEmabNVUbNi7LiMu3AqqOAqO/xmJZ9gKhiVVvINPxFCmI 30AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=GNpiQh7ABwX5CzZaDSFk4r46vvFK7pNN6hDEEKpsaq0=; b=VyodCY5k72X0/ws+5f9BN/jgz+TvWuP+WBbLix/vMqMQxFB4wfwRnLlzNU/8WA3RsA bGQ5wY61SSgU8wvegRskwr4+oUP/yXBAyb0OQZ/wPReMygoaHKD6/alUnfv9ME1vQJxp hqoa14lK/KPbZSE6ulEzpgVcn36bCjFhysMKj51kx2yrxsXvpo++mKuDLjJGYN95NNJ1 HpruF1C46cbMb5H3tu8RMe7y8qy03nA6WUU62fzow04/sF+lyV2uYQCZrvTz9ARbZG0x xfkpvgVV4S+/dDqP1+RFBElzCpe97tJMofaV5KmZaxzY1Z/1QYp/UgVWNvhzOiF2XatC jbXQ== X-Gm-Message-State: AOUpUlFbhQX5fzNM6/skxXx5CEWtrBhGytbsJsA7Xp+5lvNKbawBmtL6 /L6N0fXG4fKTcLAZwzODaceKQZu6odWMJUY/6w0= X-Received: by 2002:ab0:6037:: with SMTP id n23-v6mr4085827ual.28.1532687962582; Fri, 27 Jul 2018 03:39:22 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a67:2149:0:0:0:0:0 with HTTP; Fri, 27 Jul 2018 03:39:22 -0700 (PDT) In-Reply-To: <6dc928cd-adbb-0304-1308-fb556d48698d@163.com> References: <20180722173715.25327-1-zengzhaoxiu@163.com> <20180722183706.GA7979@kroah.com> <9b18802b-a451-eb81-3317-1de406f03118@163.com> <6dc928cd-adbb-0304-1308-fb556d48698d@163.com> From: Andy Shevchenko Date: Fri, 27 Jul 2018 13:39:22 +0300 Message-ID: Subject: Re: [PATCH 1/1] lib: use sunday algorithm to do strstr() and strnstr() To: Zhaoxiu Zeng Cc: Greg Kroah-Hartman , Andrew Morton , Matthew Wilcox , Dan Carpenter , Geert Uytterhoeven , Thomas Gleixner , Andrey Ryabinin , Linux Kernel Mailing List , Zhaoxiu Zeng Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 27, 2018 at 8:48 AM, Zhaoxiu Zeng wrote: > =E5=9C=A8 2018/7/27 1:17, Zhaoxiu Zeng =E5=86=99=E9=81=93: >> =E5=9C=A8 2018/7/23 2:37, Greg Kroah-Hartman =E5=86=99=E9=81=93: >>> On Mon, Jul 23, 2018 at 01:37:15AM +0800, Zhaoxiu Zeng wrote: >>>> The Sunday algorithm is a variation of Boyer-Moore algorithm, it is ea= sy and fast. >>>> For the Sunday algorithm, to see >>>> http://www.inf.fh-flensburg.de/lang/algorithmen/pattern/sundayen.h= tm >>> >>> So you say, but what does this really buy us? Why make this change? >>> How was it tested? What is the downside of not taking this? >> I use the following program to test on fc28. >> Compile with O2, the new version is almost 2X faster than the original. >> The code size of the original is 0x80, the newer is 0xB0. So, output of bloat-o-meter would be good to have in commit message. >> The test result: Compact performance statistics as well. >> Thanks! > The original strnstr might has a bug too! > For example, assume s1 is "123\0abc...." and s2 is "abc\0", > call strnstr(s1, s2, 7) will return &s1[4], but the correct result is NUL= L. If there is a bug, send another patch to fix the bug first. --=20 With Best Regards, Andy Shevchenko