Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754476AbdHYCUw (ORCPT ); Thu, 24 Aug 2017 22:20:52 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:33210 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754446AbdHYCUu (ORCPT ); Thu, 24 Aug 2017 22:20:50 -0400 Date: Fri, 25 Aug 2017 11:21:06 +0900 From: Sergey Senozhatsky To: Nick Terrell Cc: Sergey Senozhatsky , Joonsoo Kim , "linux-kernel@vger.kernel.org" , "minchan@kernel.org" , Yann Collet Subject: Re: [PATCH] zram: add zstd to the supported algorithms list Message-ID: <20170825022106.GC743@jagdpanzerIV.localdomain> References: <20170824014936.4738-1-sergey.senozhatsky@gmail.com> <20170825004947.GE29701@js1304-P5Q-DELUXE> <27EDD68A-61DC-42F1-8422-16B9AB9F0EB3@fb.com> <20170825015301.GB743@jagdpanzerIV.localdomain> <08620C31-AD6A-4DDB-ACA6-22243920AE1E@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <08620C31-AD6A-4DDB-ACA6-22243920AE1E@fb.com> User-Agent: Mutt/1.8.3 (2017-05-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1384 Lines: 28 On (08/25/17 02:09), Nick Terrell wrote: [..] > > > I think using dictionaries in zram could be very interesting. We could for > > > example, take a random sample of the RAM and use that as the dictionary > > > for compression. E.g. take 32 512B samples from RAM and build a 16 KB > > > dictionary (sizes may vary). > > > > > > I'm not sure how you would pass a dictionary into the crypto compression > > > API, but I'm sure we can make something work if dictionary compression > > > proves to be beneficial enough. > > > > a dictionaty pointer can be in `struct zstd_ctx'. > > Sorry I'm not super familiar with the crypto API. How would the user > initialize the dictionary in the `struct zstd_ctx'? I guess you could > either expose the struct in some header, or provide a function that > initializes it, but that isn't generic. Does the crypto library already > have a standard way to provide extra information? not really familiar either... I was thinking about having "zstd" and "zstd_dict" crypto_alg structs - one would be !dict, the other one would allocate dict and pass it to compress/decompress zstd callbacks. "zstd" vecrsion would invoke zstd_params() passing zeros as compress and dict sizes to ZSTD_getParams(), while "zstd_dict" would invoke, lets say, zstd_params_dict() passing PAGE_SIZE-s. hm... (0, PAGE_SIZE)? to ZSTD_getParams(). just a rough idea... -ss