Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1725588iog; Sat, 18 Jun 2022 18:49:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1si4KHZ1F7gpk7gLB7NgmL+hSI87Ij1IioQAdBv4paF9R6CmNJKOMxXLqmMH5Fksf9vnRUv X-Received: by 2002:aa7:d29a:0:b0:435:705f:1319 with SMTP id w26-20020aa7d29a000000b00435705f1319mr5662204edq.54.1655603348311; Sat, 18 Jun 2022 18:49:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655603348; cv=none; d=google.com; s=arc-20160816; b=relk88O0bqLfzosp1PrC+CF41BSQAAx+mcU54li7KtyuBtqmLMLbYL6Hu3OH0lded2 pN7dZHYJi4AdmVTUTGntjbYjBK3+F6Uscw5uYEy9pCE7x8Si+j5NHQliz/zvNask57ZE MoggFGHeqfqYQ8bvs/6zLNhYo8HKKbA6wScc3xEY0tmeuoi6iwd0zaZj7Gsf9v304ZfB N2QCbDjGmH2fMCLRnQjRZZ0lq1Z/ypkpkhhW5qn7h2VnHb4YnEVOSZirrjZxqGrvliBy NFunFZuMX9VLaXk1QshmdQVU2dCrk04aBi2xXcod+h0Z5ha0AB5NZk+ZqxSK85uKiN71 8Ggw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=wJvLT1c8CzvaCbjAqSrrU8ZMfJVjFlEKkFEGB+jSVpA=; b=b2GthBfbiNyYDbsylOfJBuR47kYzYTWfnOEuOLEus336HP3TZFyoMARz7K35+/qj50 vMv71GawtBsFCpWxLu2bX3VNbw1ikxL6XGlGLHugbIJo33QVAa3HcUGgaDjdR5zd+8dR lIxWi4APxL8EoAWSIZMie983KtYaNUmtxVEg6c/0bX16VTgVrsooIebQ4sk13z4A6bH0 Y1yQlFOs1xv8DtM3LqEaX64BKPesllUTe8MIcglISwVAq5SEXzJPkbaKJBDwZsO+s/T9 l+X4nPJh8xe98e5vnDsC+JxiVGQbcm6gtxPw8Iu1tLMyWEzKHtqT81cORzVZXvcjAZF2 VD9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=NspeGK5d; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f20-20020a170906739400b006f3969d2189si7360527ejl.576.2022.06.18.18.48.42; Sat, 18 Jun 2022 18:49:08 -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=@infradead.org header.s=desiato.20200630 header.b=NspeGK5d; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233593AbiFSB3c (ORCPT + 99 others); Sat, 18 Jun 2022 21:29:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbiFSB3b (ORCPT ); Sat, 18 Jun 2022 21:29:31 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B4C2BF68 for ; Sat, 18 Jun 2022 18:29:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID: Sender:Reply-To:Content-ID:Content-Description; bh=wJvLT1c8CzvaCbjAqSrrU8ZMfJVjFlEKkFEGB+jSVpA=; b=NspeGK5dueUIwd4z2ejduabl/v v0f9FSbrGqdt6x1vMdJq4YkaQexvMJz/9aZ7XVZ7PgfAMpe0K8Nr6Qq8y3t1y9bW2sd7MiRpZ4Xgf YItaK/P952nj6pufKSeyAO0GH4DN7eGXFcqOFjteJX0moip2Rptqbfxtjtt0Z2ghCUt0V+77rRRaG DHcodaMaXOL9AdL5jqLnSrO3Vc3WV3CqLlo/7gig5bLgbz69GB5mhBMk5s5Sg2ceYXQgHbPom1vMD sdzi5wsnDdppqi8Nt+l6xCEdO0jnMKyyuEavWm8/zRtjVDy2jurebOwTpXtS230lzgP8idNfXy+G9 uBiwNt2A==; Received: from [2601:1c0:6280:3f0::aa0b] by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1o2jki-00956s-Dz; Sun, 19 Jun 2022 01:29:24 +0000 Message-ID: Date: Sat, 18 Jun 2022 18:29:18 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v2 4/5] rslib: Improve the performance of encode_rs.c Content-Language: en-US To: Zhang Boyang , linux-kernel@vger.kernel.org Cc: Ferdinand Blomqvist , Thomas Gleixner , Kees Cook , Ivan Djelic , Boris Brezillon , Miquel Raynal References: <20220617144624.158973-1-zhangboyang.id@gmail.com> <20220617144624.158973-5-zhangboyang.id@gmail.com> From: Randy Dunlap In-Reply-To: <20220617144624.158973-5-zhangboyang.id@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,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 Hi-- On 6/17/22 07:46, Zhang Boyang wrote: > Signed-off-by: Zhang Boyang > --- > include/linux/rslib.h | 14 +++++++++++++- > lib/reed_solomon/encode_rs.c | 21 ++++++++++----------- > 2 files changed, 23 insertions(+), 12 deletions(-) > > diff --git a/include/linux/rslib.h b/include/linux/rslib.h > index cd0b5a7a5698..44ec7c6f24b2 100644 > --- a/include/linux/rslib.h > +++ b/include/linux/rslib.h > @@ -110,7 +110,7 @@ void free_rs(struct rs_control *rs); > /** modulo replacement for galois field arithmetics > * > * @rs: Pointer to the RS codec > - * @x: the value to reduce > + * @x: x >= 0 ; the value to reduce > * > * where > * rs->mm = number of bits per symbol > @@ -127,4 +127,16 @@ static inline int rs_modnn(struct rs_codec *rs, int x) > return x; > } > > +/** modulo replacement for galois field arithmetics /** * rs_modnn_fast() - modulo replacement for galois field arithmetics > + * > + * @rs: Pointer to the RS codec > + * @x: 0 <= x < 2*nn ; the value to reduce > + * > + * Same as rs_modnn(x), but faster, at the cost of limited value range of @x > +*/ > +static inline int rs_modnn_fast(struct rs_codec *rs, int x) > +{ > + return x - rs->nn < 0 ? x : x - rs->nn; > +} > + > #endif -- ~Randy