Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3428387imw; Mon, 11 Jul 2022 08:28:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tV1Ld6NGdgxsK0Coo4Zpmzlugp5cTz6YfsQHW0Wz5XD/ysz8U5vw6h193bI9rTHz+SALcj X-Received: by 2002:a17:902:9348:b0:167:8e92:272f with SMTP id g8-20020a170902934800b001678e92272fmr18917282plp.77.1657553303374; Mon, 11 Jul 2022 08:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657553303; cv=none; d=google.com; s=arc-20160816; b=F5rD4owgs3s1oPxKSaZbAWsTbZ4HedMsam7BkOuu1G5Ef/GxfwBrteJ1AkJVtts2xU c70hGz+Wcp9CmM5hZZ3HqlB2eWfm7p4hDNA7VcTmUoE3yx6nrNg7U8TltQQJ7TR6gAej wsP4lBmVWl7I5VJJzJw5PEUEgszjkV1mLKFJC768lPzBmDIPpD+xSECtlJS2RW7KQ9ke 7uj9DVSoBS0sSAE6R7SXDmLlssgEzfBr+5w5amJV7oqbfatMc41qOxIYzFQCDGgSO4wC E9um7w5JIWZKjwU8R/dD7eDXPnug8G/54YmpH0uxwLy4De9tA/PM5aLe1CgRLChGGLgg o9/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=YErQAJTNBsroUwBWXYZSk0t8HBKJD/pgmYdR3arRfh0=; b=IzUhAh0Qn+fZgO/z43rgSdX0o5PP9YZNeyj6jJ8fatokiwmHPImAirrkF+t3jecPd+ BqVHInIei0FXBxcHpcukzHXUvBx+fNcz4l6jYvEYG+ptdDWGhfRfuMbgBLLCzCY6h3uE GzhsULov6nNg5dcDkoIlJ/VOQ8kQ7SOZsur66za1FdxdtsxEyb54LNdZXiD3+izJRC0W cpAKGaTxjTzBsRfA4DX6q0ohVaxQTnErVam6LjUH4cL/5N5JtkK3nfxs7lw/Vy7ut5Zz Zm0j6akwXNuABnTkSGmrZo809AqL4pJTEVkJonrVYZkvKgqk/3dcTkveNVNoODQaW9fC ZHww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qO08D9a7; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o14-20020a056a0015ce00b00519099107ddsi11714583pfu.234.2022.07.11.08.28.10; Mon, 11 Jul 2022 08:28:23 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qO08D9a7; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231862AbiGKPDv (ORCPT + 99 others); Mon, 11 Jul 2022 11:03:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229670AbiGKPDr (ORCPT ); Mon, 11 Jul 2022 11:03:47 -0400 Received: from mail-yb1-xb33.google.com (mail-yb1-xb33.google.com [IPv6:2607:f8b0:4864:20::b33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60CDC13F6D for ; Mon, 11 Jul 2022 08:03:46 -0700 (PDT) Received: by mail-yb1-xb33.google.com with SMTP id 6so9166544ybc.8 for ; Mon, 11 Jul 2022 08:03:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YErQAJTNBsroUwBWXYZSk0t8HBKJD/pgmYdR3arRfh0=; b=qO08D9a7Ul7Z5pIUVipX8dvxICNRcJuNNXaX1wo2nbgYlSzbFEzRmKDZ4suiQmK5QE 5O79C7VcQ4c1jAxkV+3LXFwCi7gdMd5yVzCrtB6FA8FKeflTC6ZxyNbgU3MrGUZvvaMQ uOeqcFGWeKUfWB0H5vNUdXkamNdMSfx9kTcmTnMMDupUr3wEfmS03f5C01EYjMMjF182 RdH2CeywyRnTbfmCvQFwnratwesgRsH/pohx8RjZQQqPArZw8+o96ZLtXYtlxw8QQMth 1xqtItUDFMbBfNREqfFtChLx+Hv8S4zoee203d/yqQi9NCAZZijzI+X8VEn5MkiG5MRu 3RbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YErQAJTNBsroUwBWXYZSk0t8HBKJD/pgmYdR3arRfh0=; b=r52Hg3TziRCaU4kOq2sl6z67PnNwhlSvubLZkPll0nWwkjwushsetPeqOGNFqI7mrj uDbgAleVi5ooBES/MYaWSDO0SDzf1JD0ljPhgHMC3kz6oMa7/+tvPkWwf5T20f6AUfYX YFErhs259OyBKO+PBiXfPpo+FRdmfEjYivbGQmYvhsc6V1+rkokFmPhAzHYtpBFSmty3 xQVLihTJIDI+Kfxi+xiOTciHF8UqKemRLVUTHLSaGkmfLnH53hYvlRNm7CMloJMtFeVk dLBLhijd15UWJI1sKuqoTcsZjc0tSdOsIVOjaevxdrv0P6BZUMCiWu47MF7FdX+gMBMz kyyA== X-Gm-Message-State: AJIora9kiUKXTyt0soKlTdugTpIjcyqcDRo1E+ZtXLld9uWltE/BHGGq nPT+Hy/3VrMsBsbhdkV9yl2GdvhRP4PIhAmYZUlp8MtFR4ehQw== X-Received: by 2002:a05:6902:10c9:b0:668:e27c:8f7 with SMTP id w9-20020a05690210c900b00668e27c08f7mr17544509ybu.128.1657551825513; Mon, 11 Jul 2022 08:03:45 -0700 (PDT) MIME-Version: 1.0 References: <20220710142822.52539-1-arthurchang09@gmail.com> <20220710142822.52539-3-arthurchang09@gmail.com> <3a1b50d2-a7aa-3e89-56fe-5d14ef9da22f@gmail.com> <48db247e-f6fd-cb4b-7cc5-455bf26bb153@gmail.com> In-Reply-To: <48db247e-f6fd-cb4b-7cc5-455bf26bb153@gmail.com> From: Andy Shevchenko Date: Mon, 11 Jul 2022 17:03:09 +0200 Message-ID: Subject: Re: [PATCH 2/2] lib/string.c: Optimize memchr() To: Andrey Semashev Cc: Yu-Jen Chang , Andy Shevchenko , Akinobu Mita , Ching-Chun Huang , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 On Mon, Jul 11, 2022 at 5:00 PM Andrey Semashev wrote: > On 7/11/22 17:52, Yu-Jen Chang wrote: ... > I think you're missing the point. Loads at unaligned addresses may not > be allowed by hardware using conventional load instructions or may be > inefficient. Given that this memchr implementation is used as a fallback > when no hardware-specific version is available, you should be > conservative wrt. hardware capabilities and behavior. You should > probably have a pre-alignment loop. Exactly! The initial code is broken, NAK. P.S. At least you may look into strscpy() implementation to get a clue. -- With Best Regards, Andy Shevchenko