Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8492755ybi; Thu, 6 Jun 2019 13:19:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNQz8jiik4iMOHWPU0aWpCAG2NCpnd8GDXm1NBH3jlwSeuwLpd9rGleDKHSS97dfcvIaEz X-Received: by 2002:a65:5206:: with SMTP id o6mr342561pgp.248.1559852380350; Thu, 06 Jun 2019 13:19:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559852380; cv=none; d=google.com; s=arc-20160816; b=Ol19Zxeov+1y+KQoE0iN90dUy2EtFji/Q29OvFrf8NHm7tLuQZ/KEQmWKIL9fk4REN rLVgjWdRal3CgYRG47O1s3mz1hbMSfscGBmC3evRZeWT9yJbc9HaG4ireexeBU3pV9jB eOI/MJvGFUDLYsNlHLy604PlzYH2xayaunHa8hLMuDtOK1uxG8Mi/7rI0yrVGNDYi0l3 OCkLMBIZx+7kM4OTn3FMgbWEF6qEatflCTVHBzK3yrkJgYS5nNLn3bg7C6IgB1YkMs8y QFRzk/rC46lt4M7oLQ14oTSylAYYQU6PGiAlndJHkc1Q6RUmgQGu2fRaGKQLgHE/1kqd QSqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature:dkim-signature; bh=0hlzEy69btagHvz167Ug/ihAFb/NDX9JrZFUPX3rIG0=; b=CMNhFqZcT3QL78cIQYZ6JTXAJ2kPnkKdiZ1HN68TdD1TWsSqFr24peUIbOmnA1ewz5 cA6CaF+Zt8isd1qFXisJdqcwTFTOHWpZT2hFKekwwD7ID7+0WeAF+4zDAPLjvaETQoxq PH/d/SL1idNe2wE6QMepe1FtHF6O4WW1is091QVOf6ZrVvEF0zkbGTUy0pCM7fuSGJew CXubL3Gp0iZ3PkCMuh5ytYleU4glGU98gNBQUkztD9g5IENQ73GD0Z7TAYMMxw2SOHOg L64+ti1V3AyOndE3apQeVNfRzXblEfqsf/STYmZgFVNGXzIql59mpcLd/F6SAhFba37w XHSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=npw6XvvL; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-onmicrosoft-com header.b=ZZtTROhQ; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s5si11964pjp.29.2019.06.06.13.19.20; Thu, 06 Jun 2019 13:19:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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=@fb.com header.s=facebook header.b=npw6XvvL; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-onmicrosoft-com header.b=ZZtTROhQ; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728332AbfFFUJw (ORCPT + 99 others); Thu, 6 Jun 2019 16:09:52 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:50552 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727082AbfFFUJv (ORCPT ); Thu, 6 Jun 2019 16:09:51 -0400 Received: from pps.filterd (m0109332.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x56K4Jes005445; Thu, 6 Jun 2019 13:09:30 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=facebook; bh=0hlzEy69btagHvz167Ug/ihAFb/NDX9JrZFUPX3rIG0=; b=npw6XvvLWPsV7xeuw8SPcRtpAMHfJ2f4q+wEr7KXDpkZPhoZuTdWb7tc9ieeRjs9LKOx IG4M4FS4cIWfD6xtMJQRpBnrQTMI2Y8g5vfxemqkvuJx6Xn4FNA+9nrgipoxxUjJksdF v8/uM5ZEo3EH7ucs9dBiTKE5dEavJoBdn/Q= Received: from mail.thefacebook.com (mailout.thefacebook.com [199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2sy1quhwg6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 06 Jun 2019 13:09:30 -0700 Received: from prn-hub04.TheFacebook.com (2620:10d:c081:35::128) by prn-hub06.TheFacebook.com (2620:10d:c081:35::130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1713.5; Thu, 6 Jun 2019 13:09:29 -0700 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1713.5 via Frontend Transport; Thu, 6 Jun 2019 13:09:29 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0hlzEy69btagHvz167Ug/ihAFb/NDX9JrZFUPX3rIG0=; b=ZZtTROhQ25v9xoqB0DfwGiAKMFGyYu+cdpHFrlbhSIraf1slTKC4U26hBkH5IxJ4HakN8vWu5wYG7jNKqeQNBA9KblxahI7vxSZDq2DDmkLjj1Jg8F0iOPRSutqQVjuN8HpLnW8X36oaXSk7rxrht4JpCflxYqLy9MZhwd6Wc1M= Received: from MW2PR1501MB1993.namprd15.prod.outlook.com (52.132.149.157) by MW2PR1501MB2169.namprd15.prod.outlook.com (52.132.150.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1965.14; Thu, 6 Jun 2019 20:09:22 +0000 Received: from MW2PR1501MB1993.namprd15.prod.outlook.com ([fe80::ede1:f275:2869:8156]) by MW2PR1501MB1993.namprd15.prod.outlook.com ([fe80::ede1:f275:2869:8156%7]) with mapi id 15.20.1965.011; Thu, 6 Jun 2019 20:09:22 +0000 From: Nick Terrell To: Maninder Singh CC: Herbert Xu , "davem@davemloft.net" , "keescook@chromium.org" , "gustavo@embeddedor.com" , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "a.sahrawat@samsung.com" , "pankaj.m@samsung.com" , Vaneet Narang Subject: Re: [PATCH 2/2] zstd: use U16 data type for rankPos Thread-Topic: [PATCH 2/2] zstd: use U16 data type for rankPos Thread-Index: AQHVBwEYf0+ujrSaGEy2U/daRipAjqaPOXKA Date: Thu, 6 Jun 2019 20:09:22 +0000 Message-ID: <31A71209-48C0-464D-9578-DBEEF5D16567@fb.com> References: <1557468839-3388-1-git-send-email-maninder1.s@samsung.com> In-Reply-To: <1557468839-3388-1-git-send-email-maninder1.s@samsung.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2620:10d:c090:200::2:d31d] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f75e8b7c-6279-41a7-5ad9-08d6eabaddaa x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:MW2PR1501MB2169; x-ms-traffictypediagnostic: MW2PR1501MB2169: x-ms-exchange-purlcount: 1 x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; x-forefront-prvs: 00603B7EEF x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(366004)(136003)(376002)(346002)(39860400002)(199004)(189003)(99286004)(68736007)(6436002)(476003)(2616005)(229853002)(486006)(46003)(6306002)(6486002)(11346002)(446003)(14444005)(76176011)(6246003)(256004)(53546011)(6506007)(33656002)(7416002)(7736002)(86362001)(5660300002)(53936002)(316002)(478600001)(14454004)(6512007)(54906003)(6916009)(71190400001)(83716004)(71200400001)(966005)(82746002)(8936002)(81156014)(81166006)(66476007)(66556008)(73956011)(66446008)(76116006)(64756008)(66946007)(305945005)(36756003)(6116002)(102836004)(4326008)(8676002)(186003)(2906002)(25786009);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2PR1501MB2169;H:MW2PR1501MB1993.namprd15.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: fb.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: qwXE2Xt7E66ZsyPkLwqBrR5v1rG5AIDLrrOIlXU+6rqClnI734d6CkUM9/u7lsN+r6WqtcdM3XsuTzBJHS712rqi+aTq2iK33agYr+zhkJmRpF250WDwuZ/A8g04NML/z4UVh6V2AgoWn5mV7VH/g70bSVdywrzWtJOki3p3+x1JoVzQeLlaOzlhMHV98S0sW2qm6ehTNzpsFSCcTEcTzIJDSeKEKvh4cnbAQxP4pKMpBhvqWB5sKd6vbZs9CtbtUQf5qBN/kNCuMZlda+ndOgeKcLzUAMEe7aQshgUtlM78OxaPZ5QWcB1hem7FsaY+CubQFWmJ45y9DnB3QLQ9EOZfzeeObmGo6CLk+soqPzJIexyTA6Qpq9Xu60LoafgtRa+nIVhbtIVFqEU7/IvYG0z8Xzm8sLmSxfgpOASsNu0= Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: f75e8b7c-6279-41a7-5ad9-08d6eabaddaa X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jun 2019 20:09:22.1450 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: terrelln@fb.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR1501MB2169 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-06_14:,, signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906060135 X-FB-Internal: deliver Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org > On May 9, 2019, at 11:13 PM, Maninder Singh wro= te: >=20 > rankPos structure variables value can not be more than 512. > So it can easily be declared as U16 rather than U32. >=20 > It will reduce stack usage of HUF_sort from 256 bytes to 128 bytes >=20 > original: > e92ddbf0 push {r4, r5, r6, r7, r8, r9, fp, ip, lr, pc} > e24cb004 sub fp, ip, #4 > e24ddc01 sub sp, sp, #256 ; 0x100 >=20 > changed: > e92ddbf0 push {r4, r5, r6, r7, r8, r9, fp, ip, lr, pc} > e24cb004 sub fp, ip, #4 > e24dd080 sub sp, sp, #128 ; 0x80 >=20 >=20 > Signed-off-by: Maninder Singh > Signed-off-by: Vaneet Narang > --- > lib/zstd/huf_compress.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/lib/zstd/huf_compress.c b/lib/zstd/huf_compress.c > index e727812..2203124 100644 > --- a/lib/zstd/huf_compress.c > +++ b/lib/zstd/huf_compress.c > @@ -382,8 +382,8 @@ static U32 HUF_setMaxHeight(nodeElt *huffNode, U32 la= stNonNull, U32 maxNbBits) > } >=20 > typedef struct { > - U32 base; > - U32 curr; > + U16 base; > + U16 curr; > } rankPos; This seems fine to me. I measured zstd's performance in userspace with this= change, and there is a ~1% speed regression for level 1. We wouldn't take this patc= h there, but in the kernel it makes sense to me. This function is called by HUF_buildCTable_wksp() which takes a workspace p= arameter. We could put this table into the workspace instead to reduce the stack usag= e by the whole 256 bytes. We'd just have to make sure that the workspace is large enough. Eventually I will update the zstd in the kernel to the latest upstream vers= ion. I've opened up https://github.com/facebook/zstd/issues/1636 to make sure we get this op= timization in before porting. > static void HUF_sort(nodeElt *huffNode, const U32 *count, U32 maxSymbolVa= lue) > --=20 > 2.7.4 >=20